]> Git Repo - linux.git/commitdiff
resource: add helpers for fetching rlimits
authorJiri Slaby <[email protected]>
Thu, 19 Nov 2009 16:16:37 +0000 (17:16 +0100)
committerJiri Slaby <[email protected]>
Mon, 4 Jan 2010 10:35:18 +0000 (11:35 +0100)
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 <[email protected]>
Cc: James Morris <[email protected]>
Cc: Heiko Carstens <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: Ingo Molnar <[email protected]>
include/linux/sched.h

index f2f842db03cea4e1d082f6d45596ba3c3c52e1a1..8d4991be9d53800a8c3cfd4a67cf0879d9ea62e7 100644 (file)
@@ -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
This page took 0.061619 seconds and 4 git commands to generate.