Skip to contentSkip to conversation

sched: fix confusing PFA_NO_NEW_PRIVS constant

PATCH Superseded Zefan Li 4 participants 10 messages Sep 23, 2014 – Sep 24, 2014

Subsystems (3)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Zefan Li

author
#0 lore raw

PATCH v2 1/3 sched: fix confusing PFA_NO_NEW_PRIVS constant

From: Tetsuo Handa <[email protected]>

Commit 1d4457f99928 ("sched: move no_new_privs into new atomic flags") defined PFA_NO_NEW_PRIVS as hexadecimal value, but it is confusing because it is used as bit number. Redefine it as decimal bit number.

Note this changes the bit position of PFA_NOW_NEW_PRIVS from 1 to 0.

Cc Peter Zijlstra <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Miao Xie <[email protected]>
Cc Kees Cook <[email protected]>
[ lizf: slightly modified subject and changelog ]
---
 include/linux/sched.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/sched.h +1 -1
index 5c2c885..4557765 100644
@@ -1957,7 +1957,7 @@ static inline void memalloc_noio_restore(unsigned int flags)
 }
 
 /* Per-process atomic flags. */
-#define PFA_NO_NEW_PRIVS 0x00000001	/* May not gain new privileges. */
+#define PFA_NO_NEW_PRIVS 0	/* May not gain new privileges. */
 
 static inline bool task_no_new_privs(struct task_struct *p)
 {
Signature · 1 line
1.8.0.2
author
#1 lore raw

PATCH v2 2/3 sched: add a macro to define bitops for task atomic flags

This will simplify code when we add new flags.

v2:
- updated scripts/tags.sh, suggested by Peter

Cc Peter Zijlstra <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Miao Xie <[email protected]>
Cc Kees Cook <[email protected]>
Cc Tetsuo Handa <penguin-kernel-JPay3/[email protected]>
---
 include/linux/sched.h | 20 +++++++++++---------
 scripts/tags.sh       |  6 ++++++
 2 files changed, 17 insertions(+), 9 deletions(-)
include/linux/sched.h +11 -9
index 4557765..04a2ae2 100644
@@ -1959,15 +1959,17 @@ static inline void memalloc_noio_restore(unsigned int flags)
 /* Per-process atomic flags. */
 #define PFA_NO_NEW_PRIVS 0	/* May not gain new privileges. */
 
-static inline bool task_no_new_privs(struct task_struct *p)
-{
-	return test_bit(PFA_NO_NEW_PRIVS, &p->atomic_flags);
-}
-
-static inline void task_set_no_new_privs(struct task_struct *p)
-{
-	set_bit(PFA_NO_NEW_PRIVS, &p->atomic_flags);
-}
+#define TASK_PFA_BITOPS(name, func)				\
+static inline bool task_##func(struct task_struct *p)		\
+{ return test_bit(PFA_##name, &p->atomic_flags); }		\
+								\
+static inline void task_set_##func(struct task_struct *p)	\
+{ set_bit(PFA_##name, &p->atomic_flags); }			\
+								\
+static inline void task_clear_##func(struct task_struct *p)	\
+{ clear_bit(PFA_##name, &p->atomic_flags); }
+
+TASK_PFA_BITOPS(NO_NEW_PRIVS, no_new_privs)
 
 /*
  * task->jobctl flags
scripts/tags.sh +6 -0
index cbfd269..8591b57 100755
@@ -197,6 +197,9 @@ exuberant()
 	--regex-c++='/SETPCGFLAG\(([^,)]*).*/SetPageCgroup\1/'		\
 	--regex-c++='/CLEARPCGFLAG\(([^,)]*).*/ClearPageCgroup\1/'	\
 	--regex-c++='/TESTCLEARPCGFLAG\(([^,)]*).*/TestClearPageCgroup\1/' \
+	--regex-c++='/TASK_PFA_BITOPS\([^,]*,\s*([^)]*)\)/task_\1/'	\
+	--regex-c++='/TASK_PFA_BITOPS\([^,]*,\s*([^)]*)\)/task_set_\1/'	\
+	--regex-c++='/TASK_PFA_BITOPS\([^,]*,\s*([^)]*)\)/task_clear_\1/'  \
 	--regex-c='/PCI_OP_READ\((\w*).*[1-4]\)/pci_bus_read_config_\1/' \
 	--regex-c='/PCI_OP_WRITE\((\w*).*[1-4]\)/pci_bus_write_config_\1/' \
 	--regex-c='/DEFINE_(MUTEX|SEMAPHORE|SPINLOCK)\((\w*)/\2/v/'	\
@@ -260,6 +263,9 @@ emacs()
 	--regex='/SETPCGFLAG\(([^,)]*).*/SetPageCgroup\1/'	\
 	--regex='/CLEARPCGFLAG\(([^,)]*).*/ClearPageCgroup\1/'	\
 	--regex='/TESTCLEARPCGFLAG\(([^,)]*).*/TestClearPageCgroup\1/' \
+	--regex='/TASK_PFA_BITOPS\([^,]*,\s*([^)]*)\)/task_\1/'	\
+	--regex='/TASK_PFA_BITOPS\([^,]*,\s*([^)]*)\)/task_set_\1/'	\
+	--regex='/TASK_PFA_BITOPS\([^,]*,\s*([^)]*)\)/task_clear_\1/'	\
 	--regex='/_PE(\([^,)]*\).*/PEVENT_ERRNO__\1/'		\
 	--regex='/PCI_OP_READ(\([a-z]*[a-z]\).*[1-4])/pci_bus_read_config_\1/' \
 	--regex='/PCI_OP_WRITE(\([a-z]*[a-z]\).*[1-4])/pci_bus_write_config_\1/'\
Signature · 1 line
1.8.0.2
#2 lore raw

Re: [PATCH v2 2/3] sched: add a macro to define bitops for task atomic flags

Quoted 34 lines · Zefan Li

This will simplify code when we add new flags.

v2:
- updated scripts/tags.sh, suggested by Peter

Cc Peter Zijlstra <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Miao Xie <[email protected]>
Cc Kees Cook <[email protected]>
Cc Tetsuo Handa <penguin-kernel-JPay3/[email protected]>
---
 include/linux/sched.h | 20 +++++++++++---------
 scripts/tags.sh       |  6 ++++++
 2 files changed, 17 insertions(+), 9 deletions(-)
include/linux/sched.h +1 -9
index 4557765..04a2ae2 100644
@@ -1959,15 +1959,17 @@ static inline void memalloc_noio_restore(unsigned int flags)
 /* Per-process atomic flags. */
 #define PFA_NO_NEW_PRIVS 0     /* May not gain new privileges. */
 
-static inline bool task_no_new_privs(struct task_struct *p)
-{
-       return test_bit(PFA_NO_NEW_PRIVS, &p->atomic_flags);
-}
-
-static inline void task_set_no_new_privs(struct task_struct *p)
-{
-       set_bit(PFA_NO_NEW_PRIVS, &p->atomic_flags);
-}
+#define TASK_PFA_BITOPS(name, func)                            \

include/linux/sched.h static inline void memalloc_noio_restore(unsigned int flags) · line 1972

Quoted 10 lines
include/linux/sched.h +10 -0
+static inline bool task_##func(struct task_struct *p)          \
+{ return test_bit(PFA_##name, &p->atomic_flags); }             \
+                                                               \
+static inline void task_set_##func(struct task_struct *p)      \
+{ set_bit(PFA_##name, &p->atomic_flags); }                     \
+                                                               \
+static inline void task_clear_##func(struct task_struct *p)    \
+{ clear_bit(PFA_##name, &p->atomic_flags); }
+
+TASK_PFA_BITOPS(NO_NEW_PRIVS, no_new_privs)

One thing I don't like about this is that task_clear_no_new_privs() ends up getting defined, and it should absolutely never be used. NNP should never be cleared or there could be security issues. I realize this isn't a very useful nit-pick, but I'd rather the function wasn't even available for someone to accidentally use. Maybe break up the macro with some kind of "write only" version like:

#define TASK_PFA_BITOPS_WO(name, func) \

static inline bool task_##func(struct task_struct *p)          \
{ return test_bit(PFA_##name, &p->atomic_flags); }             \
static inline void task_set_##func(struct task_struct *p)      \

{ set_bit(PFA_##name, &p->atomic_flags); }

#define TASK_PFA_BITOPS(name, func) \
TASK_PFA_BITOPS_WO(name, func); \
static inline void task_clear_##func(struct task_struct *p) \
{ clear_bit(PFA_##name, &p->atomic_flags); }

TASK_PFA_BITOPS_WO(NO_NEW_PRIVS, no_new_privs)

And then all the new users can use TASK_PFA_BITOPS() normally since they expect to use "clear"?

-Kees

Quoted 30 lines
include/linux/sched.h +0 -0
 /*
  * task->jobctl flags
scripts/tags.sh +6 -1
index cbfd269..8591b57 100755
@@ -197,6 +197,9 @@ exuberant()
        --regex-c++='/SETPCGFLAG\(([^,)]*).*/SetPageCgroup\1/'          \
        --regex-c++='/CLEARPCGFLAG\(([^,)]*).*/ClearPageCgroup\1/'      \
        --regex-c++='/TESTCLEARPCGFLAG\(([^,)]*).*/TestClearPageCgroup\1/' \
+       --regex-c++='/TASK_PFA_BITOPS\([^,]*,\s*([^)]*)\)/task_\1/'     \
+       --regex-c++='/TASK_PFA_BITOPS\([^,]*,\s*([^)]*)\)/task_set_\1/' \
+       --regex-c++='/TASK_PFA_BITOPS\([^,]*,\s*([^)]*)\)/task_clear_\1/'  \
        --regex-c='/PCI_OP_READ\((\w*).*[1-4]\)/pci_bus_read_config_\1/' \
        --regex-c='/PCI_OP_WRITE\((\w*).*[1-4]\)/pci_bus_write_config_\1/' \
        --regex-c='/DEFINE_(MUTEX|SEMAPHORE|SPINLOCK)\((\w*)/\2/v/'     \
@@ -260,6 +263,9 @@ emacs()
        --regex='/SETPCGFLAG\(([^,)]*).*/SetPageCgroup\1/'      \
        --regex='/CLEARPCGFLAG\(([^,)]*).*/ClearPageCgroup\1/'  \
        --regex='/TESTCLEARPCGFLAG\(([^,)]*).*/TestClearPageCgroup\1/' \
+       --regex='/TASK_PFA_BITOPS\([^,]*,\s*([^)]*)\)/task_\1/' \
+       --regex='/TASK_PFA_BITOPS\([^,]*,\s*([^)]*)\)/task_set_\1/'     \
+       --regex='/TASK_PFA_BITOPS\([^,]*,\s*([^)]*)\)/task_clear_\1/'   \
        --regex='/_PE(\([^,)]*\).*/PEVENT_ERRNO__\1/'           \
        --regex='/PCI_OP_READ(\([a-z]*[a-z]\).*[1-4])/pci_bus_read_config_\1/' \
        --regex='/PCI_OP_WRITE(\([a-z]*[a-z]\).*[1-4])/pci_bus_write_config_\1/'\
--

1.8.0.2

Signature · 2 lines
Kees Cook
Chrome OS Security
author
#3 lore raw

Re: [PATCH v2 2/3] sched: add a macro to define bitops for task atomic flags

Quoted 39 lines
Quoted 10 lines
include/linux/sched.h +1 -9
-static inline bool task_no_new_privs(struct task_struct *p)
-{
-       return test_bit(PFA_NO_NEW_PRIVS, &p->atomic_flags);
-}
-
-static inline void task_set_no_new_privs(struct task_struct *p)
-{
-       set_bit(PFA_NO_NEW_PRIVS, &p->atomic_flags);
-}
+#define TASK_PFA_BITOPS(name, func)                            \

include/linux/sched.h static inline void memalloc_noio_restore(unsigned int flags) · line 1972

Quoted 10 lines
include/linux/sched.h +10 -0
+static inline bool task_##func(struct task_struct *p)          \
+{ return test_bit(PFA_##name, &p->atomic_flags); }             \
+                                                               \
+static inline void task_set_##func(struct task_struct *p)      \
+{ set_bit(PFA_##name, &p->atomic_flags); }                     \
+                                                               \
+static inline void task_clear_##func(struct task_struct *p)    \
+{ clear_bit(PFA_##name, &p->atomic_flags); }
+
+TASK_PFA_BITOPS(NO_NEW_PRIVS, no_new_privs)

One thing I don't like about this is that task_clear_no_new_privs() ends up getting defined, and it should absolutely never be used. NNP should never be cleared or there could be security issues. I realize this isn't a very useful nit-pick, but I'd rather the function wasn't even available for someone to accidentally use. Maybe break up the macro with some kind of "write only" version like:

#define TASK_PFA_BITOPS_WO(name, func) \

static inline bool task_##func(struct task_struct *p)          \
{ return test_bit(PFA_##name, &p->atomic_flags); }             \
static inline void task_set_##func(struct task_struct *p)      \

{ set_bit(PFA_##name, &p->atomic_flags); }

#define TASK_PFA_BITOPS(name, func) \
TASK_PFA_BITOPS_WO(name, func); \
static inline void task_clear_##func(struct task_struct *p) \
{ clear_bit(PFA_##name, &p->atomic_flags); }

Quoted 5 lines

TASK_PFA_BITOPS_WO(NO_NEW_PRIVS, no_new_privs)

And then all the new users can use TASK_PFA_BITOPS() normally since they expect to use "clear"?

Now I'm inclined to do this:

+#define TASK_PFA_TEST(name, func) \
+ static inline bool task_##func(struct task_struct *p) \
+ { return test_bit(PFA_##name, &p->atomic_flags); }
+#define TASK_PFA_SET(name, func) \
+ static inline void task_set_##func(struct task_struct *p) \
+ { set_bit(PFA_##name, &p->atomic_flags); }
+#define TASK_PFA_CLEAR(name, func) \
+ static inline void task_clear_##func(struct task_struct *p) \
+ { clear_bit(PFA_##name, &p->atomic_flags); }
+
+TASK_PFA_TEST(NO_NEW_PRIVS, no_new_privs)
+TASK_PFA_SET(NO_NEW_PRIVS, no_new_privs)

author
#4 lore raw

PATCH v2 3/3 cpuset: PF_SPREAD_PAGE and PF_SPREAD_SLAB should be atomic flags

In reply to Zefan Li

When we change cpuset.memory_spread_{page,slab}, cpuset will flip PF_SPREAD_{PAGE,SLAB} bit of tsk->flags for each task in that cpuset. This should be done using atomic bitops, but currently we don't, which is broken.

Tetsuo reported a hard-to-reproduce kernel crash on RHEL6, which happend when one thread tried to clear PF_USED_MATH while at the same time another thread tried to flip PF_SPREAD_PAGE/PF_SPREAD_SLAB. They both operate on the same task.

Here's the full report:
https://lkml.org/lkml/2014/9/19/230

To fix this, we make PF_SPREAD_PAGE and PF_SPARED_SLAB atomic flags.

Cc Peter Zijlstra <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Miao Xie <[email protected]>
Cc Kees Cook <[email protected]>
Fixes 950592f7b991 ("cpusets: update tasks' page/slab spread flags in time")
Cc <[email protected]> # 2.6.31+
---
 include/linux/cpuset.h | 4 ++--
 include/linux/sched.h  | 6 ++++--
 kernel/cpuset.c        | 9 +++++----
 3 files changed, 11 insertions(+), 8 deletions(-)
include/linux/cpuset.h +2 -2
index 0d4e067..2f073db 100644
@@ -94,12 +94,12 @@ extern int cpuset_slab_spread_node(void);
 
 static inline int cpuset_do_page_mem_spread(void)
 {
-	return current->flags & PF_SPREAD_PAGE;
+	return task_spread_page(current);
 }
 
 static inline int cpuset_do_slab_mem_spread(void)
 {
-	return current->flags & PF_SPREAD_SLAB;
+	return task_spread_slab(current);
 }
 
 extern int current_cpuset_is_being_rebound(void);
include/linux/sched.h +4 -2
index 04a2ae2..ee634d1 100644
@@ -1903,8 +1903,6 @@ extern void thread_group_cputime_adjusted(struct task_struct *p, cputime_t *ut,
 #define PF_KTHREAD	0x00200000	/* I am a kernel thread */
 #define PF_RANDOMIZE	0x00400000	/* randomize virtual address space */
 #define PF_SWAPWRITE	0x00800000	/* Allowed to write to swap */
-#define PF_SPREAD_PAGE	0x01000000	/* Spread page cache over cpuset */
-#define PF_SPREAD_SLAB	0x02000000	/* Spread some slab caches over cpuset */
 #define PF_NO_SETAFFINITY 0x04000000	/* Userland is not allowed to meddle with cpus_allowed */
 #define PF_MCE_EARLY    0x08000000      /* Early kill for mce process policy */
 #define PF_MUTEX_TESTER	0x20000000	/* Thread belongs to the rt mutex tester */
@@ -1958,6 +1956,8 @@ static inline void memalloc_noio_restore(unsigned int flags)
 
 /* Per-process atomic flags. */
 #define PFA_NO_NEW_PRIVS 0	/* May not gain new privileges. */
+#define PFA_SPREAD_PAGE  1      /* Spread page cache over cpuset */
+#define PFA_SPREAD_SLAB  2      /* Spread some slab caches over cpuset */
 
 #define TASK_PFA_BITOPS(name, func)				\
 static inline bool task_##func(struct task_struct *p)		\
@@ -1970,6 +1970,8 @@ static inline void task_clear_##func(struct task_struct *p)	\
 { clear_bit(PFA_##name, &p->atomic_flags); }
 
 TASK_PFA_BITOPS(NO_NEW_PRIVS, no_new_privs)
+TASK_PFA_BITOPS(SPREAD_PAGE, spread_page)
+TASK_PFA_BITOPS(SPREAD_SLAB, spread_slab)
 
 /*
  * task->jobctl flags
kernel/cpuset.c +5 -4
index a37f4ed..1f107c7 100644
@@ -365,13 +365,14 @@ static void cpuset_update_task_spread_flag(struct cpuset *cs,
 					struct task_struct *tsk)
 {
 	if (is_spread_page(cs))
-		tsk->flags |= PF_SPREAD_PAGE;
+		task_set_spread_page(tsk);
 	else
-		tsk->flags &= ~PF_SPREAD_PAGE;
+		task_clear_spread_page(tsk);
+
 	if (is_spread_slab(cs))
-		tsk->flags |= PF_SPREAD_SLAB;
+		task_set_spread_slab(tsk);
 	else
-		tsk->flags &= ~PF_SPREAD_SLAB;
+		task_clear_spread_slab(tsk);
 }
 
 /*
Signature · 1 line
1.8.0.2
#5 lore raw

Re: [PATCH v2 3/3] cpuset: PF_SPREAD_PAGE and PF_SPREAD_SLAB should beatomic flags

Quoted 1 line · Zefan Li

Tetsuo reported a hard-to-reproduce kernel crash on RHEL6, which happend

s/happend/happened/

Review static inline void memalloc_noio_restore(unsigned int flags) · line 1983

Quoted 12 lines
(quoted diff) +8 -0
@@ -1972,6 +1973,14 @@ static inline void memalloc_noio_restore(unsigned int flags)
 TASK_PFA_TEST(NO_NEW_PRIVS, no_new_privs)
 TASK_PFA_SET(NO_NEW_PRIVS, no_new_privs)
 
+TASK_PFA_TEST(SPREAD_PAGE, spread_page)
+TASK_PFA_SET(SPREAD_PAGE, spread_page)
+TASK_PFA_CLEAR(SPREAD_PAGE, spread_page)
+
+TASK_PFA_TEST(SPREAD_SLAB, spread_slab)
+TASK_PFA_SET(SPREAD_SLAB, spread_slab)
+TASK_PFA_CLEAR(SPREAD_SLAB, spread_slab)
+

I wonder how adding 3 macro lines differs from 3 inlined functions. Personally, from LXR (source code browser) point of view, inlined functions are more friendly than macros. Also, I wonder about the cost of extracting macros in a file which is likely included by every file but referenced by few files. Speak of SPREAD_PAGE and SPREAD_SLAB, they should be defined as inlined functions in include/linux/cpuset.h rather than as macros in include/linux/sched.h ?

maintainer
#6 lore raw

Re: [PATCH v2 3/3] cpuset: PF_SPREAD_PAGE and PF_SPREAD_SLAB should beatomic flags

Quoted 9 lines · Tetsuo Handa
Quoted 1 line · Zefan Li

Tetsuo reported a hard-to-reproduce kernel crash on RHEL6, which happend

s/happend/happened/

Quoted 4 lines
(quoted diff) +0 -0
@@ -1972,6 +1973,14 @@ static inline void memalloc_noio_restore(unsigned int flags)
 TASK_PFA_TEST(NO_NEW_PRIVS, no_new_privs)
 TASK_PFA_SET(NO_NEW_PRIVS, no_new_privs)
 
Quoted 16 lines

Review static inline void memalloc_noio_restore(unsigned int flags) · line 1983

Quoted 8 lines
(quoted diff) +8 -0
+TASK_PFA_TEST(SPREAD_PAGE, spread_page)
+TASK_PFA_SET(SPREAD_PAGE, spread_page)
+TASK_PFA_CLEAR(SPREAD_PAGE, spread_page)
+
+TASK_PFA_TEST(SPREAD_SLAB, spread_slab)
+TASK_PFA_SET(SPREAD_SLAB, spread_slab)
+TASK_PFA_CLEAR(SPREAD_SLAB, spread_slab)
+

I wonder how adding 3 macro lines differs from 3 inlined functions. Personally, from LXR (source code browser) point of view, inlined functions are more friendly than macros. Also, I wonder about the cost of extracting macros in a file which is likely included by every file but referenced by few files. Speak of SPREAD_PAGE and SPREAD_SLAB, they should be defined as inlined functions in include/linux/cpuset.h rather than as macros in include/linux/sched.h ?

I think sched.h is fine along w/ inlines for other flags but yeah we might be better off just open-coding them.

Thanks.

Signature · 1 line
tejun
author
#7 lore raw

Re: [PATCH v2 3/3] cpuset: PF_SPREAD_PAGE and PF_SPREAD_SLAB should beatomic flags

In reply to Tetsuo Handa
Quoted 18 lines · Tetsuo Handa
Quoted 1 line · Zefan Li

Tetsuo reported a hard-to-reproduce kernel crash on RHEL6, which happend

s/happend/happened/

Review static inline void memalloc_noio_restore(unsigned int flags) · line 1983

Quoted 12 lines
(quoted diff) +8 -0
@@ -1972,6 +1973,14 @@ static inline void memalloc_noio_restore(unsigned int flags)
 TASK_PFA_TEST(NO_NEW_PRIVS, no_new_privs)
 TASK_PFA_SET(NO_NEW_PRIVS, no_new_privs)
 
+TASK_PFA_TEST(SPREAD_PAGE, spread_page)
+TASK_PFA_SET(SPREAD_PAGE, spread_page)
+TASK_PFA_CLEAR(SPREAD_PAGE, spread_page)
+
+TASK_PFA_TEST(SPREAD_SLAB, spread_slab)
+TASK_PFA_SET(SPREAD_SLAB, spread_slab)
+TASK_PFA_CLEAR(SPREAD_SLAB, spread_slab)
+
Quoted 8 lines

I wonder how adding 3 macro lines differs from 3 inlined functions. Personally, from LXR (source code browser) point of view, inlined functions are more friendly than macros. Also, I wonder about the cost of extracting macros in a file which is likely included by every file but referenced by few files. Speak of SPREAD_PAGE and SPREAD_SLAB, they should be defined as inlined functions in include/linux/cpuset.h rather than as macros in include/linux/sched.h ?
.

Though tsk->atomic_flags were newly introduced in 3.17 merge window, we already have 3 flags, and we may see more flags added.

Those macros make the code easier to read, and emacs and cscope can also understand them.

I'd vote for this:

TASK_PFA_TEST(NO_NEW_PRIVS, no_new_privs)
TASK_PFA_SET(NO_NEW_PRIVS, no_new_privs)

TASK_PFA_TEST(SPREAD_PAGE, spread_page)
TASK_PFA_SET(SPREAD_PAGE, spread_page)
TASK_PFA_CLEAR(SPREAD_PAGE, spread_page)

TASK_PFA_TEST(SPREAD_SLAB, spread_slab)
TASK_PFA_SET(SPREAD_SLAB, spread_slab)
TASK_PFA_CLEAR(SPREAD_SLAB, spread_slab)

over this:

static inline bool task_no_new_privs(struct task_struct *p)

{
	return test_bit(PFA_NO_NEW_PRIVS, &p->atomic_flags);
}
static inline void task_set_new_privs(struct task_struct *p)
{
	set_bit(PFA_NO_NEW_PRIVS, &p->atomic_flags);
}

static inline bool task_spread_page(struct task_struct *p)

{
	return test_bit(PFA_SPREAD_PAGE, &p->atomic_flags);
}
static inline void task_set_spread_page(struct task_struct *p)
{
	set_bit(PFA_SPREAD_PAGE, &p->atomic_flags);
}
static inline void task_clear_spread_page(struct task_struct *p)
{
	clear_bit(PFA_SPREAD_PAGE, &p->atomic_flags);
}

static inline bool task_spread_slab(struct task_struct *p)

{
	return test_bit(PFA_SPREAD_SLAB, &p->atomic_flags);
}
static inline void task_set_spread_slab(struct task_struct *p)
{
	set_bit(PFA_SPREAD_SLAB, &p->atomic_flags);
}
static inline void task_clear_spread_slab(struct task_struct *p)
{
	clear_bit(PFA_SPREAD_SLAB, &p->atomic_flags);
}
#8 lore raw

Re: [PATCH v2 3/3] cpuset: PF_SPREAD_PAGE and PF_SPREAD_SLAB should be atomic flags

Quoted 2 lines · Zefan Li

Those macros make the code easier to read, and emacs and cscope can also understand them.

I'm using legacy LXR which cannot understand them. But

Quoted 9 lines

I'd vote for this:

TASK_PFA_TEST(NO_NEW_PRIVS, no_new_privs)
TASK_PFA_SET(NO_NEW_PRIVS, no_new_privs)

TASK_PFA_TEST(SPREAD_PAGE, spread_page)
TASK_PFA_SET(SPREAD_PAGE, spread_page)
TASK_PFA_CLEAR(SPREAD_PAGE, spread_page)

Quoted 5 lines

TASK_PFA_TEST(SPREAD_SLAB, spread_slab)
TASK_PFA_SET(SPREAD_SLAB, spread_slab)
TASK_PFA_CLEAR(SPREAD_SLAB, spread_slab)

over this:

you can go ahead. This difference is not a stopper.

Quoted 4 lines · Tejun Heo

All the patches look good to me. I can't say I'm a big fan of function defining macros but I don't have prettier alternatives either. Once Peter/Ingo acks the patches, I'll route them through cgroup/for-3.17-fixes.

Peter and Ingo, are these patches OK for you?

maintainer
#9 lore raw

Re: [PATCH v2 3/3] cpuset: PF_SPREAD_PAGE and PF_SPREAD_SLAB should be atomic flags

Quoted 7 lines · Tetsuo Handa
Quoted 4 lines · Tejun Heo

All the patches look good to me. I can't say I'm a big fan of function defining macros but I don't have prettier alternatives either. Once Peter/Ingo acks the patches, I'll route them through cgroup/for-3.17-fixes.

Peter and Ingo, are these patches OK for you?

Peter acked. I'll apply the patches to cgroup/for-3.17-fixes.

Thanks.

Signature · 1 line
tejun