mirror of
				https://github.com/torvalds/linux.git
				synced 2025-10-31 16:48:26 +02:00 
			
		
		
		
	resource: add helpers for fetching rlimits
We want to be sure that compiler fetches the limit variable only once, so add helpers for fetching current and maximal resource limits which do that. Add them to sched.h (instead of resource.h) due to circular dependency sched.h->resource.h->task_struct Alternative would be to create a separate res_access.h or similar. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: James Morris <jmorris@namei.org> Cc: Heiko Carstens <heiko.carstens@de.ibm.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Ingo Molnar <mingo@elte.hu>
This commit is contained in:
		
							parent
							
								
									96d07d2117
								
							
						
					
					
						commit
						3e10e716ab
					
				
					 1 changed files with 22 additions and 0 deletions
				
			
		|  | @ -2601,6 +2601,28 @@ static inline void mm_init_owner(struct mm_struct *mm, struct task_struct *p) | ||||||
| } | } | ||||||
| #endif /* CONFIG_MM_OWNER */ | #endif /* CONFIG_MM_OWNER */ | ||||||
| 
 | 
 | ||||||
|  | static inline unsigned long task_rlimit(const struct task_struct *tsk, | ||||||
|  | 		unsigned int limit) | ||||||
|  | { | ||||||
|  | 	return ACCESS_ONCE(tsk->signal->rlim[limit].rlim_cur); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static inline unsigned long task_rlimit_max(const struct task_struct *tsk, | ||||||
|  | 		unsigned int limit) | ||||||
|  | { | ||||||
|  | 	return ACCESS_ONCE(tsk->signal->rlim[limit].rlim_max); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static inline unsigned long rlimit(unsigned int limit) | ||||||
|  | { | ||||||
|  | 	return task_rlimit(current, limit); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | static inline unsigned long rlimit_max(unsigned int limit) | ||||||
|  | { | ||||||
|  | 	return task_rlimit_max(current, limit); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| #endif /* __KERNEL__ */ | #endif /* __KERNEL__ */ | ||||||
| 
 | 
 | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Jiri Slaby
						Jiri Slaby