]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/2.6.27.46/resource-add-helpers-for-fetching-rlimits.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 2.6.27.46 / resource-add-helpers-for-fetching-rlimits.patch
CommitLineData
db5b3679
GKH
1From 3e10e716abf3c71bdb5d86b8f507f9e72236c9cd Mon Sep 17 00:00:00 2001
2From: Jiri Slaby <jslaby@suse.cz>
3Date: Thu, 19 Nov 2009 17:16:37 +0100
4Subject: resource: add helpers for fetching rlimits
5
6From: Jiri Slaby <jslaby@suse.cz>
7
8commit 3e10e716abf3c71bdb5d86b8f507f9e72236c9cd upstream.
9
10We want to be sure that compiler fetches the limit variable only
11once, so add helpers for fetching current and maximal resource
12limits which do that.
13
14Add them to sched.h (instead of resource.h) due to circular dependency
15 sched.h->resource.h->task_struct
16Alternative would be to create a separate res_access.h or similar.
17
18Signed-off-by: Jiri Slaby <jslaby@suse.cz>
19Cc: James Morris <jmorris@namei.org>
20Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
21Cc: Andrew Morton <akpm@linux-foundation.org>
22Cc: Ingo Molnar <mingo@elte.hu>
23Signed-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