diff options
author | Zefan Li <lizefan@huawei.com> | 2014-09-24 21:40:40 -0400 |
---|---|---|
committer | Tejun Heo <tj@kernel.org> | 2014-09-24 22:16:06 -0400 |
commit | e0e5070b20e01f0321f97db4e4e174f3f6b49e50 (patch) | |
tree | 4135aa645ae2bc041d72fcfd5e64f6544a0791f4 /include/linux/sched.h | |
parent | a2b86f772227bcaf962c8b134f8d187046ac5f0e (diff) |
sched: add macros to define bitops for task atomic flags
This will simplify code when we add new flags.
v3:
- Kees pointed out that no_new_privs should never be cleared, so we
shouldn't define task_clear_no_new_privs(). we define 3 macros instead
of a single one.
v2:
- updated scripts/tags.sh, suggested by Peter
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Miao Xie <miaox@cn.fujitsu.com>
Cc: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Zefan Li <lizefan@huawei.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'include/linux/sched.h')
-rw-r--r-- | include/linux/sched.h | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/include/linux/sched.h b/include/linux/sched.h index 45577650f629..5630763956d9 100644 --- a/include/linux/sched.h +++ b/include/linux/sched.h | |||
@@ -1959,15 +1959,18 @@ static inline void memalloc_noio_restore(unsigned int flags) | |||
1959 | /* Per-process atomic flags. */ | 1959 | /* Per-process atomic flags. */ |
1960 | #define PFA_NO_NEW_PRIVS 0 /* May not gain new privileges. */ | 1960 | #define PFA_NO_NEW_PRIVS 0 /* May not gain new privileges. */ |
1961 | 1961 | ||
1962 | static inline bool task_no_new_privs(struct task_struct *p) | 1962 | #define TASK_PFA_TEST(name, func) \ |
1963 | { | 1963 | static inline bool task_##func(struct task_struct *p) \ |
1964 | return test_bit(PFA_NO_NEW_PRIVS, &p->atomic_flags); | 1964 | { return test_bit(PFA_##name, &p->atomic_flags); } |
1965 | } | 1965 | #define TASK_PFA_SET(name, func) \ |
1966 | 1966 | static inline void task_set_##func(struct task_struct *p) \ | |
1967 | static inline void task_set_no_new_privs(struct task_struct *p) | 1967 | { set_bit(PFA_##name, &p->atomic_flags); } |
1968 | { | 1968 | #define TASK_PFA_CLEAR(name, func) \ |
1969 | set_bit(PFA_NO_NEW_PRIVS, &p->atomic_flags); | 1969 | static inline void task_clear_##func(struct task_struct *p) \ |
1970 | } | 1970 | { clear_bit(PFA_##name, &p->atomic_flags); } |
1971 | |||
1972 | TASK_PFA_TEST(NO_NEW_PRIVS, no_new_privs) | ||
1973 | TASK_PFA_SET(NO_NEW_PRIVS, no_new_privs) | ||
1971 | 1974 | ||
1972 | /* | 1975 | /* |
1973 | * task->jobctl flags | 1976 | * task->jobctl flags |