]>
Commit | Line | Data |
---|---|---|
db5b3679 GKH |
1 | From 3e10e716abf3c71bdb5d86b8f507f9e72236c9cd Mon Sep 17 00:00:00 2001 |
2 | From: Jiri Slaby <jslaby@suse.cz> | |
3 | Date: Thu, 19 Nov 2009 17:16:37 +0100 | |
4 | Subject: resource: add helpers for fetching rlimits | |
5 | ||
6 | From: Jiri Slaby <jslaby@suse.cz> | |
7 | ||
8 | commit 3e10e716abf3c71bdb5d86b8f507f9e72236c9cd upstream. | |
9 | ||
10 | We want to be sure that compiler fetches the limit variable only | |
11 | once, so add helpers for fetching current and maximal resource | |
12 | limits which do that. | |
13 | ||
14 | Add them to sched.h (instead of resource.h) due to circular dependency | |
15 | sched.h->resource.h->task_struct | |
16 | Alternative would be to create a separate res_access.h or similar. | |
17 | ||
18 | Signed-off-by: Jiri Slaby <jslaby@suse.cz> | |
19 | Cc: James Morris <jmorris@namei.org> | |
20 | Cc: Heiko Carstens <heiko.carstens@de.ibm.com> | |
21 | Cc: Andrew Morton <akpm@linux-foundation.org> | |
22 | Cc: Ingo Molnar <mingo@elte.hu> | |
23 | Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> | |
24 | ||
25 | --- | |
26 | include/linux/sched.h | 22 ++++++++++++++++++++++ | |
27 | 1 file changed, 22 insertions(+) | |
28 | ||
29 | --- a/include/linux/sched.h | |
30 | +++ b/include/linux/sched.h | |
31 | @@ -2232,6 +2232,28 @@ static inline void mm_init_owner(struct | |
32 | ||
33 | #define TASK_STATE_TO_CHAR_STR "RSDTtZX" | |
34 | ||
35 | +static inline unsigned long task_rlimit(const struct task_struct *tsk, | |
36 | + unsigned int limit) | |
37 | +{ | |
38 | + return ACCESS_ONCE(tsk->signal->rlim[limit].rlim_cur); | |
39 | +} | |
40 | + | |
41 | +static inline unsigned long task_rlimit_max(const struct task_struct *tsk, | |
42 | + unsigned int limit) | |
43 | +{ | |
44 | + return ACCESS_ONCE(tsk->signal->rlim[limit].rlim_max); | |
45 | +} | |
46 | + | |
47 | +static inline unsigned long rlimit(unsigned int limit) | |
48 | +{ | |
49 | + return task_rlimit(current, limit); | |
50 | +} | |
51 | + | |
52 | +static inline unsigned long rlimit_max(unsigned int limit) | |
53 | +{ | |
54 | + return task_rlimit_max(current, limit); | |
55 | +} | |
56 | + | |
57 | #endif /* __KERNEL__ */ | |
58 | ||
59 | #endif |