GIT: unionfs2-2.6.27.y: resource: add helpers for fetching rlimits
Erez Zadok
ezk at fsl.cs.sunysb.edu
Thu Aug 12 23:15:05 EDT 2010
commit 1626749d7bbbc00b362b632d993289128651d075
Author: Jiri Slaby <jslaby at suse.cz>
Date: Thu Nov 19 17:16:37 2009 +0100
resource: add helpers for fetching rlimits
commit 3e10e716abf3c71bdb5d86b8f507f9e72236c9cd upstream.
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 at suse.cz>
Cc: James Morris <jmorris at namei.org>
Cc: Heiko Carstens <heiko.carstens at de.ibm.com>
Cc: Andrew Morton <akpm at linux-foundation.org>
Cc: Ingo Molnar <mingo at elte.hu>
Signed-off-by: Greg Kroah-Hartman <gregkh at suse.de>
diff --git a/include/linux/sched.h b/include/linux/sched.h
index ebe801e..20d6dd5 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -2232,6 +2232,28 @@ static inline void mm_init_owner(struct mm_struct *mm, struct task_struct *p)
#define TASK_STATE_TO_CHAR_STR "RSDTtZX"
+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
More information about the unionfs-cvs
mailing list