diff options
author | Jiri Slaby <jslaby@suse.cz> | 2009-11-19 17:16:37 +0100 |
---|---|---|
committer | Jiri Slaby <jslaby@suse.cz> | 2010-01-04 11:35:18 +0100 |
commit | 3e10e716abf3c71bdb5d86b8f507f9e72236c9cd (patch) | |
tree | c0dee002666c9aaf9862f3ec1140c5946461ec54 | |
parent | 96d07d211739fd2450ac54e81d00fa40fcd4b1bd (diff) | |
download | linux-3.10-3e10e716abf3c71bdb5d86b8f507f9e72236c9cd.tar.gz linux-3.10-3e10e716abf3c71bdb5d86b8f507f9e72236c9cd.tar.bz2 linux-3.10-3e10e716abf3c71bdb5d86b8f507f9e72236c9cd.zip |
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>
-rw-r--r-- | include/linux/sched.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h index f2f842db03c..8d4991be9d5 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h @@ -2601,6 +2601,28 @@ static inline void mm_init_owner(struct mm_struct *mm, struct task_struct *p) } #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 |