Skip to contentSkip to conversation

Add MAX_NICE, MIN_NICE and NICE_WIDTH macros in prio.h.

PATCH Applied Dongsheng Yang 8 participants 44 messages Feb 11, 2014 – Feb 27, 2014

Subsystems (5)
Tracing Scheduler RCU Workqueue +1 more subsystems
lore
Share & tools
lore
#0 lore raw

cover Add MAX_NICE, MIN_NICE and NICE_WIDTH macros in prio.h.

Hi Peter,
There are lots of hardcoding of -20 and 19 in kernel to represent
minimum and maximum of nice value currently. This patch set define three macros in prio.h and replace some of the hardcoding with them.

Please help to take a look at it, thanx :)

Dongsheng Yang (9):
sched: Prio: Use DEFAULT_PRIO to define NICE_TO_PRIO and PRIO_TO_NICE.
sched: prio: Add 3 macros of MAX_NICE, MIN_NICE and NICE_WIDTH in

    prio.h.

sched: prio: Use NICE_WIDTH macro to avoid using of hard coding of 40
and 20 in prio.h.
sched: prio: Add spaces before and after operator of '-'.
rcu: Use MAX_NICE to replace hard coding of 19.
sched: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE.
sys: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE.
workqueue: Replace hardcoding of -20 and 19 with MIN_NICE and
MAX_NICE.
trace: Replace hardcoding of 19 with MAX_NICE.

 include/linux/sched/prio.h           | 14 +++++++++-----
 kernel/rcu/torture.c                 |  8 ++++----
 kernel/sched/auto_group.c            |  2 +-
 kernel/sched/core.c                  | 12 ++++++------
 kernel/sys.c                         |  8 ++++----
 kernel/trace/ring_buffer_benchmark.c |  6 +++---
 kernel/workqueue.c                   |  2 +-
 7 files changed, 28 insertions(+), 24 deletions(-)
Signature · 1 line
1.8.2.1
#1 lore raw

PATCH 1/9 sched: Prio: Use DEFAULT_PRIO to define NICE_TO_PRIO and PRIO_TO_NICE.

There is already a macro named DEFAULT_PRIO in prio.h, we can use it to define NICE_TO_PRIO and PRIO_TO_NICE rather than use hard coding of (MAX_RT_PRIO + 20).

cc Peter Zijlstra <[email protected]>
cc Ingo Molnar <[email protected]>
---
 include/linux/sched/prio.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/sched/prio.h +2 -2
index 410ccb7..1ceaaa1 100644
@@ -25,8 +25,8 @@
  * to static priority [ MAX_RT_PRIO..MAX_PRIO-1 ],
  * and back.
  */
-#define NICE_TO_PRIO(nice)	(MAX_RT_PRIO + (nice) + 20)
-#define PRIO_TO_NICE(prio)	((prio) - MAX_RT_PRIO - 20)
+#define NICE_TO_PRIO(nice)	((nice) + DEFAULT_PRIO)
+#define PRIO_TO_NICE(prio)	((prio) - DEFAULT_PRIO)
 
 /*
  * 'User priority' is the nice value converted to something we
Signature · 1 line
1.8.2.1
#2 lore raw

[tip:sched/core] sched: Prio: Use DEFAULT_PRIO to define NICE_TO_PRIO and PRIO_TO_NICE.

sched: Prio: Use DEFAULT_PRIO to define NICE_TO_PRIO and PRIO_TO_NICE.
Commit-ID:  103fc73128e3c55773d7f60998f9296c256df3a5
Gitweb:     http://git.kernel.org/tip/103fc73128e3c55773d7f60998f9296c256df3a5
Author:     Dongsheng Yang <[email protected]>
AuthorDate: Tue, 11 Feb 2014 15:34:45 +0800
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Fri, 21 Feb 2014 21:43:20 +0100

sched: Prio: Use DEFAULT_PRIO to define NICE_TO_PRIO and PRIO_TO_NICE.

There is already a macro named DEFAULT_PRIO in prio.h, we can use it to define NICE_TO_PRIO and PRIO_TO_NICE rather than use hard coding of (MAX_RT_PRIO + 20).

---
 include/linux/sched/prio.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/sched/prio.h +2 -2
index 410ccb7..1ceaaa1 100644
@@ -25,8 +25,8 @@
  * to static priority [ MAX_RT_PRIO..MAX_PRIO-1 ],
  * and back.
  */
-#define NICE_TO_PRIO(nice)	(MAX_RT_PRIO + (nice) + 20)
-#define PRIO_TO_NICE(prio)	((prio) - MAX_RT_PRIO - 20)
+#define NICE_TO_PRIO(nice)	((nice) + DEFAULT_PRIO)
+#define PRIO_TO_NICE(prio)	((prio) - DEFAULT_PRIO)
 
 /*
  * 'User priority' is the nice value converted to something we
#3 lore raw

[tip:sched/core] sched/prio: Use DEFAULT_PRIO to define NICE_TO_PRIO() and PRIO_TO_NICE()

In reply to Dongsheng Yang
sched/prio: Use DEFAULT_PRIO to define NICE_TO_PRIO() and PRIO_TO_NICE()
Commit-ID:  7e298d60f717257dc8365c975f45ff9c37165362
Gitweb:     http://git.kernel.org/tip/7e298d60f717257dc8365c975f45ff9c37165362
Author:     Dongsheng Yang <[email protected]>
AuthorDate: Tue, 11 Feb 2014 15:34:45 +0800
Committer:  Ingo Molnar <[email protected]>
CommitDate: Sat, 22 Feb 2014 18:11:29 +0100

sched/prio: Use DEFAULT_PRIO to define NICE_TO_PRIO() and PRIO_TO_NICE()

There is already a macro named DEFAULT_PRIO in prio.h, we can use it to define NICE_TO_PRIO and PRIO_TO_NICE rather than use hard coding of (MAX_RT_PRIO + 20).

---
 include/linux/sched/prio.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/sched/prio.h +2 -2
index 410ccb7..1ceaaa1 100644
@@ -25,8 +25,8 @@
  * to static priority [ MAX_RT_PRIO..MAX_PRIO-1 ],
  * and back.
  */
-#define NICE_TO_PRIO(nice)	(MAX_RT_PRIO + (nice) + 20)
-#define PRIO_TO_NICE(prio)	((prio) - MAX_RT_PRIO - 20)
+#define NICE_TO_PRIO(nice)	((nice) + DEFAULT_PRIO)
+#define PRIO_TO_NICE(prio)	((prio) - DEFAULT_PRIO)
 
 /*
  * 'User priority' is the nice value converted to something we
#4 lore raw

PATCH 2/9 sched: prio: Add 3 macros of MAX_NICE, MIN_NICE and NICE_WIDTH in prio.h.

In reply to Dongsheng Yang

Currently, there are lots of hard coding of 19 and -20 to represent maximum and minimum of nice value.

This patch add three macros in prio.h for maximum, minimum and width of nice value.

cc Peter Zijlstra <[email protected]>
cc Ingo Molnar <[email protected]>
---
 include/linux/sched/prio.h | 4 ++++
 1 file changed, 4 insertions(+)
include/linux/sched/prio.h +4 -0
index 1ceaaa1..c6974c4 100644
@@ -1,6 +1,10 @@
 #ifndef _SCHED_PRIO_H
 #define _SCHED_PRIO_H
 
+#define MAX_NICE	19
+#define MIN_NICE	-20
+#define NICE_WIDTH	(MAX_NICE - MIN_NICE + 1)
+
 /*
  * Priority of a process goes from 0..MAX_PRIO-1, valid RT
  * priority is 0..MAX_RT_PRIO-1, and SCHED_NORMAL/SCHED_BATCH
Signature · 1 line
1.8.2.1
#5 lore raw

[tip:sched/core] sched: prio: Add 3 macros of MAX_NICE, MIN_NICE and NICE_WIDTH in prio.h.

sched: prio: Add 3 macros of MAX_NICE, MIN_NICE and NICE_WIDTH in prio.h.
Commit-ID:  798fa741dd4e5a2d15e862367000a0ac63253978
Gitweb:     http://git.kernel.org/tip/798fa741dd4e5a2d15e862367000a0ac63253978
Author:     Dongsheng Yang <[email protected]>
AuthorDate: Tue, 11 Feb 2014 15:34:46 +0800
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Fri, 21 Feb 2014 21:43:20 +0100

sched: prio: Add 3 macros of MAX_NICE, MIN_NICE and NICE_WIDTH in prio.h.

Currently, there are lots of hard coding of 19 and -20 to represent maximum and minimum of nice value.

This patch add three macros in prio.h for maximum, minimum and width of nice value.

---
 include/linux/sched/prio.h | 4 ++++
 1 file changed, 4 insertions(+)
include/linux/sched/prio.h +4 -0
index 1ceaaa1..c6974c4 100644
@@ -1,6 +1,10 @@
 #ifndef _SCHED_PRIO_H
 #define _SCHED_PRIO_H
 
+#define MAX_NICE	19
+#define MIN_NICE	-20
+#define NICE_WIDTH	(MAX_NICE - MIN_NICE + 1)
+
 /*
  * Priority of a process goes from 0..MAX_PRIO-1, valid RT
  * priority is 0..MAX_RT_PRIO-1, and SCHED_NORMAL/SCHED_BATCH
#6 lore raw

[tip:sched/core] sched/prio: Add 3 macros of MAX_NICE, MIN_NICE and NICE_WIDTH in prio.h

In reply to Dongsheng Yang
sched/prio: Add 3 macros of MAX_NICE, MIN_NICE and NICE_WIDTH in prio.h
Commit-ID:  3ee237dddcd885d4e525791299d62de33b2ca117
Gitweb:     http://git.kernel.org/tip/3ee237dddcd885d4e525791299d62de33b2ca117
Author:     Dongsheng Yang <[email protected]>
AuthorDate: Tue, 11 Feb 2014 15:34:46 +0800
Committer:  Ingo Molnar <[email protected]>
CommitDate: Sat, 22 Feb 2014 18:14:13 +0100

sched/prio: Add 3 macros of MAX_NICE, MIN_NICE and NICE_WIDTH in prio.h

Currently there is lots of hard coding to 19 and -20, to represent maximum and minimum of nice values.

This patch add three macros in prio.h for maximum, minimum and width of nice value, and uses it to remove hardcoded values in prio.h.

---
 include/linux/sched/prio.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
include/linux/sched/prio.h +6 -2
index 1ceaaa1..ac32258 100644
@@ -1,6 +1,10 @@
 #ifndef _SCHED_PRIO_H
 #define _SCHED_PRIO_H
 
+#define MAX_NICE	19
+#define MIN_NICE	-20
+#define NICE_WIDTH	(MAX_NICE - MIN_NICE + 1)
+
 /*
  * Priority of a process goes from 0..MAX_PRIO-1, valid RT
  * priority is 0..MAX_RT_PRIO-1, and SCHED_NORMAL/SCHED_BATCH
@@ -17,8 +21,8 @@
 #define MAX_USER_RT_PRIO	100
 #define MAX_RT_PRIO		MAX_USER_RT_PRIO
 
-#define MAX_PRIO		(MAX_RT_PRIO + 40)
-#define DEFAULT_PRIO		(MAX_RT_PRIO + 20)
+#define MAX_PRIO		(MAX_RT_PRIO + NICE_WIDTH)
+#define DEFAULT_PRIO		(MAX_RT_PRIO + NICE_WIDTH / 2)
 
 /*
  * Convert user-nice values [ -20 ... 0 ... 19 ]
#7 lore raw

PATCH 3/9 sched: prio: Use NICE_WIDTH macro to avoid using of hard coding of 40 and 20 in prio.h.

In reply to Dongsheng Yang
cc Ingo Molnar <[email protected]>
cc Peter Zijlstra <[email protected]>
---
 include/linux/sched/prio.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/sched/prio.h +2 -2
index c6974c4..ac32258 100644
@@ -21,8 +21,8 @@
 #define MAX_USER_RT_PRIO	100
 #define MAX_RT_PRIO		MAX_USER_RT_PRIO
 
-#define MAX_PRIO		(MAX_RT_PRIO + 40)
-#define DEFAULT_PRIO		(MAX_RT_PRIO + 20)
+#define MAX_PRIO		(MAX_RT_PRIO + NICE_WIDTH)
+#define DEFAULT_PRIO		(MAX_RT_PRIO + NICE_WIDTH / 2)
 
 /*
  * Convert user-nice values [ -20 ... 0 ... 19 ]
Signature · 1 line
1.8.2.1
#8 lore raw

[tip:sched/core] sched: prio: Use NICE_WIDTH macro to avoid using of hard coding of 40 and 20 in prio.h.

sched: prio: Use NICE_WIDTH macro to avoid using of hard coding of 40 and 20 in prio.h.
Commit-ID:  eb2ae7dad9dad350b4444962465d7e09bcfc128a
Gitweb:     http://git.kernel.org/tip/eb2ae7dad9dad350b4444962465d7e09bcfc128a
Author:     Dongsheng Yang <[email protected]>
AuthorDate: Tue, 11 Feb 2014 15:34:47 +0800
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Fri, 21 Feb 2014 21:43:20 +0100

sched: prio: Use NICE_WIDTH macro to avoid using of hard coding of 40 and 20 in prio.h.

---
 include/linux/sched/prio.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
include/linux/sched/prio.h +2 -2
index c6974c4..ac32258 100644
@@ -21,8 +21,8 @@
 #define MAX_USER_RT_PRIO	100
 #define MAX_RT_PRIO		MAX_USER_RT_PRIO
 
-#define MAX_PRIO		(MAX_RT_PRIO + 40)
-#define DEFAULT_PRIO		(MAX_RT_PRIO + 20)
+#define MAX_PRIO		(MAX_RT_PRIO + NICE_WIDTH)
+#define DEFAULT_PRIO		(MAX_RT_PRIO + NICE_WIDTH / 2)
 
 /*
  * Convert user-nice values [ -20 ... 0 ... 19 ]
#9 lore raw

PATCH 4/9 sched: prio: Add spaces before and after operator of '-'.

In reply to Dongsheng Yang
cc Peter Zijlstra <[email protected]>
cc Ingo Molnar <[email protected]>
---
 include/linux/sched/prio.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/sched/prio.h +1 -1
index ac32258..1bf9935 100644
@@ -37,7 +37,7 @@
  * can work with better when scaling various scheduler parameters,
  * it's a [ 0 ... 39 ] range.
  */
-#define USER_PRIO(p)		((p)-MAX_RT_PRIO)
+#define USER_PRIO(p)		((p) - MAX_RT_PRIO)
 #define TASK_USER_PRIO(p)	USER_PRIO((p)->static_prio)
 #define MAX_USER_PRIO		(USER_PRIO(MAX_PRIO))
 
Signature · 1 line
1.8.2.1
#10 lore raw

[tip:sched/core] sched: prio: Add spaces before and after operator of '-'.

sched: prio: Add spaces before and after operator of '-'.
Commit-ID:  02228c930672ec5476cf8ef84e4f3f45ab01b597
Gitweb:     http://git.kernel.org/tip/02228c930672ec5476cf8ef84e4f3f45ab01b597
Author:     Dongsheng Yang <[email protected]>
AuthorDate: Tue, 11 Feb 2014 15:34:48 +0800
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Fri, 21 Feb 2014 21:43:20 +0100

sched: prio: Add spaces before and after operator of '-'.

---
 include/linux/sched/prio.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/sched/prio.h +1 -1
index ac32258..1bf9935 100644
@@ -37,7 +37,7 @@
  * can work with better when scaling various scheduler parameters,
  * it's a [ 0 ... 39 ] range.
  */
-#define USER_PRIO(p)		((p)-MAX_RT_PRIO)
+#define USER_PRIO(p)		((p) - MAX_RT_PRIO)
 #define TASK_USER_PRIO(p)	USER_PRIO((p)->static_prio)
 #define MAX_USER_PRIO		(USER_PRIO(MAX_PRIO))
 
#11 lore raw

PATCH 5/9 rcu: Use MAX_NICE to replace hard coding of 19.

In reply to Dongsheng Yang
cc Josh Triplett <[email protected]>
cc "Paul E. McKenney" <[email protected]>
cc Peter Zijlstra <[email protected]>
cc Ingo Molnar <[email protected]>
---
 kernel/rcu/torture.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/rcu/torture.c +4 -4
index 732f8ae..219761d 100644
@@ -805,7 +805,7 @@ rcu_torture_writer(void *arg)
 	static DEFINE_RCU_RANDOM(rand);
 
 	VERBOSE_PRINTK_STRING("rcu_torture_writer task started");
-	set_user_nice(current, 19);
+	set_user_nice(current, MAX_NICE);
 
 	do {
 		schedule_timeout_uninterruptible(1);
@@ -871,7 +871,7 @@ rcu_torture_fakewriter(void *arg)
 	DEFINE_RCU_RANDOM(rand);
 
 	VERBOSE_PRINTK_STRING("rcu_torture_fakewriter task started");
-	set_user_nice(current, 19);
+	set_user_nice(current, MAX_NICE);
 
 	do {
 		schedule_timeout_uninterruptible(1 + rcu_random(&rand)%10);
@@ -987,7 +987,7 @@ rcu_torture_reader(void *arg)
 	unsigned long long ts;
 
 	VERBOSE_PRINTK_STRING("rcu_torture_reader task started");
-	set_user_nice(current, 19);
+	set_user_nice(current, MAX_NICE);
 	if (irqreader && cur_ops->irq_capable)
 		setup_timer_on_stack(&t, rcu_torture_timer, 0);
 
@@ -1584,7 +1584,7 @@ static int rcu_torture_barrier_cbs(void *arg)
 
 	init_rcu_head_on_stack(&rcu);
 	VERBOSE_PRINTK_STRING("rcu_torture_barrier_cbs task started");
-	set_user_nice(current, 19);
+	set_user_nice(current, MAX_NICE);
 	do {
 		wait_event(barrier_cbs_wq[myid],
 			   (newphase =
Signature · 1 line
1.8.2.1
Reviewed-by on v1 5/9
#12 lore raw

Re: [PATCH 5/9] rcu: Use MAX_NICE to replace hard coding of 19.

Quoted 5 lines · Dongsheng Yang
cc Josh Triplett <[email protected]>
cc "Paul E. McKenney" <[email protected]>
cc Peter Zijlstra <[email protected]>
cc Ingo Molnar <[email protected]>
Quoted 46 lines
 kernel/rcu/torture.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/rcu/torture.c +4 -4
index 732f8ae..219761d 100644
@@ -805,7 +805,7 @@ rcu_torture_writer(void *arg)
 	static DEFINE_RCU_RANDOM(rand);
 
 	VERBOSE_PRINTK_STRING("rcu_torture_writer task started");
-	set_user_nice(current, 19);
+	set_user_nice(current, MAX_NICE);
 
 	do {
 		schedule_timeout_uninterruptible(1);
@@ -871,7 +871,7 @@ rcu_torture_fakewriter(void *arg)
 	DEFINE_RCU_RANDOM(rand);
 
 	VERBOSE_PRINTK_STRING("rcu_torture_fakewriter task started");
-	set_user_nice(current, 19);
+	set_user_nice(current, MAX_NICE);
 
 	do {
 		schedule_timeout_uninterruptible(1 + rcu_random(&rand)%10);
@@ -987,7 +987,7 @@ rcu_torture_reader(void *arg)
 	unsigned long long ts;
 
 	VERBOSE_PRINTK_STRING("rcu_torture_reader task started");
-	set_user_nice(current, 19);
+	set_user_nice(current, MAX_NICE);
 	if (irqreader && cur_ops->irq_capable)
 		setup_timer_on_stack(&t, rcu_torture_timer, 0);
 
@@ -1584,7 +1584,7 @@ static int rcu_torture_barrier_cbs(void *arg)
 
 	init_rcu_head_on_stack(&rcu);
 	VERBOSE_PRINTK_STRING("rcu_torture_barrier_cbs task started");
-	set_user_nice(current, 19);
+	set_user_nice(current, MAX_NICE);
 	do {
 		wait_event(barrier_cbs_wq[myid],
 			   (newphase =
Signature · 1 line
1.8.2.1
#13 lore raw

Re: [PATCH 5/9] rcu: Use MAX_NICE to replace hard coding of 19.

Quoted 8 lines · Josh Triplett
Quoted 5 lines · Dongsheng Yang
cc Josh Triplett <[email protected]>
cc "Paul E. McKenney" <[email protected]>
cc Peter Zijlstra <[email protected]>
cc Ingo Molnar <[email protected]>

I get complaints about MAX_NICE being undefined, and I don't see any definition of MAX_NICE in sched.h as of 3.14-rc2. Am I looking in the wrong place, or is this symbol not yet quite in mainline?

Thanx, Paul

Quoted 47 lines
Quoted 46 lines
 kernel/rcu/torture.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/rcu/torture.c +4 -4
index 732f8ae..219761d 100644
@@ -805,7 +805,7 @@ rcu_torture_writer(void *arg)
 	static DEFINE_RCU_RANDOM(rand);
 
 	VERBOSE_PRINTK_STRING("rcu_torture_writer task started");
-	set_user_nice(current, 19);
+	set_user_nice(current, MAX_NICE);
 
 	do {
 		schedule_timeout_uninterruptible(1);
@@ -871,7 +871,7 @@ rcu_torture_fakewriter(void *arg)
 	DEFINE_RCU_RANDOM(rand);
 
 	VERBOSE_PRINTK_STRING("rcu_torture_fakewriter task started");
-	set_user_nice(current, 19);
+	set_user_nice(current, MAX_NICE);
 
 	do {
 		schedule_timeout_uninterruptible(1 + rcu_random(&rand)%10);
@@ -987,7 +987,7 @@ rcu_torture_reader(void *arg)
 	unsigned long long ts;
 
 	VERBOSE_PRINTK_STRING("rcu_torture_reader task started");
-	set_user_nice(current, 19);
+	set_user_nice(current, MAX_NICE);
 	if (irqreader && cur_ops->irq_capable)
 		setup_timer_on_stack(&t, rcu_torture_timer, 0);
 
@@ -1584,7 +1584,7 @@ static int rcu_torture_barrier_cbs(void *arg)
 
 	init_rcu_head_on_stack(&rcu);
 	VERBOSE_PRINTK_STRING("rcu_torture_barrier_cbs task started");
-	set_user_nice(current, 19);
+	set_user_nice(current, MAX_NICE);
 	do {
 		wait_event(barrier_cbs_wq[myid],
 			   (newphase =
Signature · 1 line
1.8.2.1
maintainer
#14 lore raw

Re: [PATCH 5/9] rcu: Use MAX_NICE to replace hard coding of 19.

Quoted 8 lines · Paul E. McKenney
Quoted 7 lines · Josh Triplett
Quoted 5 lines · Dongsheng Yang
cc Josh Triplett <[email protected]>
cc "Paul E. McKenney" <[email protected]>
cc Peter Zijlstra <[email protected]>
cc Ingo Molnar <[email protected]>
Quoted 5 lines
Quoted 1 line

I get complaints about MAX_NICE being undefined, and I don't see any definition of MAX_NICE in sched.h as of 3.14-rc2. Am I looking in the wrong place, or is this symbol not yet quite in mainline?

It is not.. its a proposed thingy. I'm still trying to make up my mind on it.

#15 lore raw

Re: [PATCH 5/9] rcu: Use MAX_NICE to replace hard coding of 19.

Quoted 9 lines · Peter Zijlstra
Quoted 8 lines · Paul E. McKenney
Quoted 7 lines · Josh Triplett
Quoted 5 lines · Dongsheng Yang
cc Josh Triplett <[email protected]>
cc "Paul E. McKenney" <[email protected]>
cc Peter Zijlstra <[email protected]>
cc Ingo Molnar <[email protected]>
Quoted 8 lines
Quoted 5 lines
Quoted 1 line

I get complaints about MAX_NICE being undefined, and I don't see any definition of MAX_NICE in sched.h as of 3.14-rc2. Am I looking in the wrong place, or is this symbol not yet quite in mainline?

It is not.. its a proposed thingy. I'm still trying to make up my mind on it.

OK, will hold off then.

Thanx, Paul

#16 lore raw

[tip:sched/core] rcu: Use MAX_NICE to replace hard coding of 19.

In reply to Dongsheng Yang
rcu: Use MAX_NICE to replace hard coding of 19.
Commit-ID:  c30f4ba1cb3f89cefba728f5289caf3c0fc7149d
Gitweb:     http://git.kernel.org/tip/c30f4ba1cb3f89cefba728f5289caf3c0fc7149d
Author:     Dongsheng Yang <[email protected]>
AuthorDate: Tue, 11 Feb 2014 15:34:49 +0800
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Fri, 21 Feb 2014 21:43:20 +0100

rcu: Use MAX_NICE to replace hard coding of 19.

---
 kernel/rcu/torture.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/rcu/torture.c +4 -4
index 732f8ae..219761d 100644
@@ -805,7 +805,7 @@ rcu_torture_writer(void *arg)
 	static DEFINE_RCU_RANDOM(rand);
 
 	VERBOSE_PRINTK_STRING("rcu_torture_writer task started");
-	set_user_nice(current, 19);
+	set_user_nice(current, MAX_NICE);
 
 	do {
 		schedule_timeout_uninterruptible(1);
@@ -871,7 +871,7 @@ rcu_torture_fakewriter(void *arg)
 	DEFINE_RCU_RANDOM(rand);
 
 	VERBOSE_PRINTK_STRING("rcu_torture_fakewriter task started");
-	set_user_nice(current, 19);
+	set_user_nice(current, MAX_NICE);
 
 	do {
 		schedule_timeout_uninterruptible(1 + rcu_random(&rand)%10);
@@ -987,7 +987,7 @@ rcu_torture_reader(void *arg)
 	unsigned long long ts;
 
 	VERBOSE_PRINTK_STRING("rcu_torture_reader task started");
-	set_user_nice(current, 19);
+	set_user_nice(current, MAX_NICE);
 	if (irqreader && cur_ops->irq_capable)
 		setup_timer_on_stack(&t, rcu_torture_timer, 0);
 
@@ -1584,7 +1584,7 @@ static int rcu_torture_barrier_cbs(void *arg)
 
 	init_rcu_head_on_stack(&rcu);
 	VERBOSE_PRINTK_STRING("rcu_torture_barrier_cbs task started");
-	set_user_nice(current, 19);
+	set_user_nice(current, MAX_NICE);
 	do {
 		wait_event(barrier_cbs_wq[myid],
 			   (newphase =
#17 lore raw

[tip:sched/core] rcu: Use MAX_NICE to replace hardcoding of 19

In reply to Dongsheng Yang
rcu: Use MAX_NICE to replace hardcoding of 19
Commit-ID:  d277d868dab6537a85f4757e39648b1d6afc60d5
Gitweb:     http://git.kernel.org/tip/d277d868dab6537a85f4757e39648b1d6afc60d5
Author:     Dongsheng Yang <[email protected]>
AuthorDate: Tue, 11 Feb 2014 15:34:49 +0800
Committer:  Ingo Molnar <[email protected]>
CommitDate: Sat, 22 Feb 2014 18:15:24 +0100

rcu: Use MAX_NICE to replace hardcoding of 19

---
 kernel/rcu/torture.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/rcu/torture.c +4 -4
index 732f8ae..219761d 100644
@@ -805,7 +805,7 @@ rcu_torture_writer(void *arg)
 	static DEFINE_RCU_RANDOM(rand);
 
 	VERBOSE_PRINTK_STRING("rcu_torture_writer task started");
-	set_user_nice(current, 19);
+	set_user_nice(current, MAX_NICE);
 
 	do {
 		schedule_timeout_uninterruptible(1);
@@ -871,7 +871,7 @@ rcu_torture_fakewriter(void *arg)
 	DEFINE_RCU_RANDOM(rand);
 
 	VERBOSE_PRINTK_STRING("rcu_torture_fakewriter task started");
-	set_user_nice(current, 19);
+	set_user_nice(current, MAX_NICE);
 
 	do {
 		schedule_timeout_uninterruptible(1 + rcu_random(&rand)%10);
@@ -987,7 +987,7 @@ rcu_torture_reader(void *arg)
 	unsigned long long ts;
 
 	VERBOSE_PRINTK_STRING("rcu_torture_reader task started");
-	set_user_nice(current, 19);
+	set_user_nice(current, MAX_NICE);
 	if (irqreader && cur_ops->irq_capable)
 		setup_timer_on_stack(&t, rcu_torture_timer, 0);
 
@@ -1584,7 +1584,7 @@ static int rcu_torture_barrier_cbs(void *arg)
 
 	init_rcu_head_on_stack(&rcu);
 	VERBOSE_PRINTK_STRING("rcu_torture_barrier_cbs task started");
-	set_user_nice(current, 19);
+	set_user_nice(current, MAX_NICE);
 	do {
 		wait_event(barrier_cbs_wq[myid],
 			   (newphase =
#18 lore raw

PATCH 6/9 sched: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE.

In reply to Dongsheng Yang
cc Ingo Molnar <[email protected]>
cc Peter Zijlstra <[email protected]>
---
 kernel/sched/auto_group.c |  2 +-
 kernel/sched/core.c       | 12 ++++++------
 2 files changed, 7 insertions(+), 7 deletions(-)
kernel/sched/auto_group.c +1 -1
index 4a07353..e73efba 100644
@@ -203,7 +203,7 @@ int proc_sched_autogroup_set_nice(struct task_struct *p, int nice)
 	struct autogroup *ag;
 	int err;
 
-	if (nice < -20 || nice > 19)
+	if (nice < MIN_NICE || nice > MAX_NICE)
 		return -EINVAL;
 
 	err = security_task_setnice(current, nice);
kernel/sched/core.c +6 -6
index 104c816..46cf585 100644
@@ -3000,7 +3000,7 @@ void set_user_nice(struct task_struct *p, long nice)
 	unsigned long flags;
 	struct rq *rq;
 
-	if (task_nice(p) == nice || nice < -20 || nice > 19)
+	if (task_nice(p) == nice || nice < MIN_NICE || nice > MAX_NICE)
 		return;
 	/*
 	 * We have to be careful, if called from sys_setpriority(),
@@ -3079,10 +3079,10 @@ SYSCALL_DEFINE1(nice, int, increment)
 		increment = 40;
 
 	nice = task_nice(current) + increment;
-	if (nice < -20)
-		nice = -20;
-	if (nice > 19)
-		nice = 19;
+	if (nice < MIN_NICE)
+		nice = MIN_NICE;
+	if (nice > MAX_NICE)
+		nice = MAX_NICE;
 
 	if (increment < 0 && !can_nice(current, nice))
 		return -EPERM;
@@ -3605,7 +3605,7 @@ static int sched_copy_attr(struct sched_attr __user *uattr,
 	 * XXX: do we want to be lenient like existing syscalls; or do we want
 	 * to be strict and return an error on out-of-bounds values?
 	 */
-	attr->sched_nice = clamp(attr->sched_nice, -20, 19);
+	attr->sched_nice = clamp(attr->sched_nice, MIN_NICE, MAX_NICE);
 
 out:
 	return ret;
Signature · 1 line
1.8.2.1
#19 lore raw

[tip:sched/core] sched: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE.

sched: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE.
Commit-ID:  82abc86e6bcd0ab6b2efad1d8201abb463422034
Gitweb:     http://git.kernel.org/tip/82abc86e6bcd0ab6b2efad1d8201abb463422034
Author:     Dongsheng Yang <[email protected]>
AuthorDate: Tue, 11 Feb 2014 15:34:50 +0800
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Fri, 21 Feb 2014 21:43:20 +0100

sched: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE.

---
 kernel/sched/auto_group.c |  2 +-
 kernel/sched/core.c       | 12 ++++++------
 2 files changed, 7 insertions(+), 7 deletions(-)
kernel/sched/auto_group.c +1 -1
index 4a07353..e73efba 100644
@@ -203,7 +203,7 @@ int proc_sched_autogroup_set_nice(struct task_struct *p, int nice)
 	struct autogroup *ag;
 	int err;
 
-	if (nice < -20 || nice > 19)
+	if (nice < MIN_NICE || nice > MAX_NICE)
 		return -EINVAL;
 
 	err = security_task_setnice(current, nice);
kernel/sched/core.c +6 -6
index 67a24fa..67fcadb 100644
@@ -3001,7 +3001,7 @@ void set_user_nice(struct task_struct *p, long nice)
 	unsigned long flags;
 	struct rq *rq;
 
-	if (task_nice(p) == nice || nice < -20 || nice > 19)
+	if (task_nice(p) == nice || nice < MIN_NICE || nice > MAX_NICE)
 		return;
 	/*
 	 * We have to be careful, if called from sys_setpriority(),
@@ -3080,10 +3080,10 @@ SYSCALL_DEFINE1(nice, int, increment)
 		increment = 40;
 
 	nice = task_nice(current) + increment;
-	if (nice < -20)
-		nice = -20;
-	if (nice > 19)
-		nice = 19;
+	if (nice < MIN_NICE)
+		nice = MIN_NICE;
+	if (nice > MAX_NICE)
+		nice = MAX_NICE;
 
 	if (increment < 0 && !can_nice(current, nice))
 		return -EPERM;
@@ -3631,7 +3631,7 @@ static int sched_copy_attr(struct sched_attr __user *uattr,
 	 * XXX: do we want to be lenient like existing syscalls; or do we want
 	 * to be strict and return an error on out-of-bounds values?
 	 */
-	attr->sched_nice = clamp(attr->sched_nice, -20, 19);
+	attr->sched_nice = clamp(attr->sched_nice, MIN_NICE, MAX_NICE);
 
 out:
 	return ret;
#20 lore raw

[tip:sched/core] sched: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE

In reply to Dongsheng Yang
sched: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE
Commit-ID:  75e45d512f257beedae0d8a67d053cde5537bd4c
Gitweb:     http://git.kernel.org/tip/75e45d512f257beedae0d8a67d053cde5537bd4c
Author:     Dongsheng Yang <[email protected]>
AuthorDate: Tue, 11 Feb 2014 15:34:50 +0800
Committer:  Ingo Molnar <[email protected]>
CommitDate: Sat, 22 Feb 2014 18:15:54 +0100

sched: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE

---
 kernel/sched/auto_group.c |  2 +-
 kernel/sched/core.c       | 12 ++++++------
 2 files changed, 7 insertions(+), 7 deletions(-)
kernel/sched/auto_group.c +1 -1
index 4a07353..e73efba 100644
@@ -203,7 +203,7 @@ int proc_sched_autogroup_set_nice(struct task_struct *p, int nice)
 	struct autogroup *ag;
 	int err;
 
-	if (nice < -20 || nice > 19)
+	if (nice < MIN_NICE || nice > MAX_NICE)
 		return -EINVAL;
 
 	err = security_task_setnice(current, nice);
kernel/sched/core.c +6 -6
index cc4965e..a8a73b8 100644
@@ -2993,7 +2993,7 @@ void set_user_nice(struct task_struct *p, long nice)
 	unsigned long flags;
 	struct rq *rq;
 
-	if (task_nice(p) == nice || nice < -20 || nice > 19)
+	if (task_nice(p) == nice || nice < MIN_NICE || nice > MAX_NICE)
 		return;
 	/*
 	 * We have to be careful, if called from sys_setpriority(),
@@ -3072,10 +3072,10 @@ SYSCALL_DEFINE1(nice, int, increment)
 		increment = 40;
 
 	nice = task_nice(current) + increment;
-	if (nice < -20)
-		nice = -20;
-	if (nice > 19)
-		nice = 19;
+	if (nice < MIN_NICE)
+		nice = MIN_NICE;
+	if (nice > MAX_NICE)
+		nice = MAX_NICE;
 
 	if (increment < 0 && !can_nice(current, nice))
 		return -EPERM;
@@ -3623,7 +3623,7 @@ static int sched_copy_attr(struct sched_attr __user *uattr,
 	 * XXX: do we want to be lenient like existing syscalls; or do we want
 	 * to be strict and return an error on out-of-bounds values?
 	 */
-	attr->sched_nice = clamp(attr->sched_nice, -20, 19);
+	attr->sched_nice = clamp(attr->sched_nice, MIN_NICE, MAX_NICE);
 
 out:
 	return ret;
#21 lore raw

PATCH 7/9 sys: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE.

In reply to Dongsheng Yang
cc Andrew Morton <[email protected]>
cc Oleg Nesterov <[email protected]>
cc Robin Holt <[email protected]>
cc Al Viro <[email protected]>
cc Kees Cook <[email protected]>
cc "Eric W. Biederman" <[email protected]>
cc Stephen Rothwell <[email protected]>
cc Peter Zijlstra <[email protected]>
cc Ingo Molnar <[email protected]>
---
 kernel/sys.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/sys.c +4 -4
index c0a58be..adaeab6 100644
@@ -174,10 +174,10 @@ SYSCALL_DEFINE3(setpriority, int, which, int, who, int, niceval)
 
 	/* normalize: avoid signed division (rounding problems) */
 	error = -ESRCH;
-	if (niceval < -20)
-		niceval = -20;
-	if (niceval > 19)
-		niceval = 19;
+	if (niceval < MIN_NICE)
+		niceval = MIN_NICE;
+	if (niceval > MAX_NICE)
+		niceval = MAX_NICE;
 
 	rcu_read_lock();
 	read_lock(&tasklist_lock);
Signature · 1 line
1.8.2.1
#22 lore raw

Re: [PATCH 7/9] sys: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE.

Quoted 20 lines · Dongsheng Yang
cc Andrew Morton <[email protected]>
cc Oleg Nesterov <[email protected]>
cc Robin Holt <[email protected]>
cc Al Viro <[email protected]>
cc Kees Cook <[email protected]>
cc "Eric W. Biederman" <[email protected]>
cc Stephen Rothwell <[email protected]>
cc Peter Zijlstra <[email protected]>
cc Ingo Molnar <[email protected]>
---
 kernel/sys.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/sys.c +0 -0
index c0a58be..adaeab6 100644
@@ -174,10 +174,10 @@ SYSCALL_DEFINE3(setpriority, int, which, int, who, int, niceval)
 

kernel/sys.c SYSCALL_DEFINE3(setpriority, int, which, int, who, int, niceval) · line 180

Quoted 10 lines
kernel/sys.c +4 -4
        /* normalize: avoid signed division (rounding problems) */
        error = -ESRCH;
-       if (niceval < -20)
-               niceval = -20;
-       if (niceval > 19)
-               niceval = 19;
+       if (niceval < MIN_NICE)
+               niceval = MIN_NICE;
+       if (niceval > MAX_NICE)
+               niceval = MAX_NICE;

Good catch! I'm all for using names instead of numeric values, however, I wonder if it'd be more readable to use "clamp" instead?

niceval = clamp(niceval, MIN_NICE, MAX_NICE);

-Kees

Quoted 6 lines
kernel/sys.c +0 -1
        rcu_read_lock();
        read_lock(&tasklist_lock);
--

1.8.2.1

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

Re: [PATCH 7/9] sys: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE.

Hi Kees,

Quoted 35 lines · Kees Cook
Quoted 20 lines · Dongsheng Yang
cc Andrew Morton <[email protected]>
cc Oleg Nesterov <[email protected]>
cc Robin Holt <[email protected]>
cc Al Viro <[email protected]>
cc Kees Cook <[email protected]>
cc "Eric W. Biederman" <[email protected]>
cc Stephen Rothwell <[email protected]>
cc Peter Zijlstra <[email protected]>
cc Ingo Molnar <[email protected]>
---
  kernel/sys.c | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)
kernel/sys.c +0 -0
index c0a58be..adaeab6 100644
@@ -174,10 +174,10 @@ SYSCALL_DEFINE3(setpriority, int, which, int, who, int, niceval)
 

kernel/sys.c SYSCALL_DEFINE3(setpriority, int, which, int, who, int, niceval) · line 180

Quoted 10 lines
kernel/sys.c +4 -4
         /* normalize: avoid signed division (rounding problems) */
         error = -ESRCH;
-       if (niceval < -20)
-               niceval = -20;
-       if (niceval > 19)
-               niceval = 19;
+       if (niceval < MIN_NICE)
+               niceval = MIN_NICE;
+       if (niceval > MAX_NICE)
+               niceval = MAX_NICE;

Good catch! I'm all for using names instead of numeric values, however, I wonder if it'd be more readable to use "clamp" instead?

Quoted 1 line

niceval = clamp(niceval, MIN_NICE, MAX_NICE);

Good suggestion! This patch here is just to replace the numeric values with a name defined in prio.h. So I will send another patch to make it more readable with clamp after the patch set here applied. Is this plan ok to you?

Thanx.

Quoted 10 lines

-Kees

Quoted 5 lines
kernel/sys.c +0 -1
         rcu_read_lock();
         read_lock(&tasklist_lock);
--

1.8.2.1

#24 lore raw

Re: [PATCH 7/9] sys: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE.

Quoted 43 lines · Dongsheng Yang

Hi Kees,

Quoted 39 lines · Kees Cook
Quoted 22 lines · Dongsheng Yang
cc Andrew Morton <[email protected]>
cc Oleg Nesterov <[email protected]>
cc Robin Holt <[email protected]>
cc Al Viro <[email protected]>
cc Kees Cook <[email protected]>
cc "Eric W. Biederman" <[email protected]>
cc Stephen Rothwell <[email protected]>
cc Peter Zijlstra <[email protected]>
cc Ingo Molnar <[email protected]>
---
  kernel/sys.c | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)
kernel/sys.c +0 -0
index c0a58be..adaeab6 100644
@@ -174,10 +174,10 @@ SYSCALL_DEFINE3(setpriority, int, which, int, who,
 int, niceval)
 

kernel/sys.c SYSCALL_DEFINE3(setpriority, int, which, int, who, · line 181

Quoted 10 lines
kernel/sys.c +4 -4
         /* normalize: avoid signed division (rounding problems) */
         error = -ESRCH;
-       if (niceval < -20)
-               niceval = -20;
-       if (niceval > 19)
-               niceval = 19;
+       if (niceval < MIN_NICE)
+               niceval = MIN_NICE;
+       if (niceval > MAX_NICE)
+               niceval = MAX_NICE;

Good catch! I'm all for using names instead of numeric values, however, I wonder if it'd be more readable to use "clamp" instead?

Quoted 7 lines
Quoted 1 line

niceval = clamp(niceval, MIN_NICE, MAX_NICE);

Good suggestion! This patch here is just to replace the numeric values with a name defined in prio.h. So I will send another patch to make it more readable
with clamp after the patch set here applied. Is this plan ok to you?

Sounds good to me. Thanks!

-Kees

Quoted 14 lines

Thanx.

Quoted 10 lines

-Kees

Quoted 5 lines
kernel/sys.c +0 -1
         rcu_read_lock();
         read_lock(&tasklist_lock);
--

1.8.2.1

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

[tip:sched/core] sys: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE.

In reply to Dongsheng Yang
sys: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE.
Commit-ID:  4870c6e5774424c994bfd606cd8adb8818e8a85c
Gitweb:     http://git.kernel.org/tip/4870c6e5774424c994bfd606cd8adb8818e8a85c
Author:     Dongsheng Yang <[email protected]>
AuthorDate: Tue, 11 Feb 2014 15:34:51 +0800
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Fri, 21 Feb 2014 21:43:21 +0100

sys: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE.

---
 kernel/sys.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/sys.c +4 -4
index c0a58be..adaeab6 100644
@@ -174,10 +174,10 @@ SYSCALL_DEFINE3(setpriority, int, which, int, who, int, niceval)
 
 	/* normalize: avoid signed division (rounding problems) */
 	error = -ESRCH;
-	if (niceval < -20)
-		niceval = -20;
-	if (niceval > 19)
-		niceval = 19;
+	if (niceval < MIN_NICE)
+		niceval = MIN_NICE;
+	if (niceval > MAX_NICE)
+		niceval = MAX_NICE;
 
 	rcu_read_lock();
 	read_lock(&tasklist_lock);
#26 lore raw

[tip:sched/core] sys: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE

In reply to Dongsheng Yang
sys: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE
Commit-ID:  c4a4d2f43177f6165132c6d36a4d46963018f726
Gitweb:     http://git.kernel.org/tip/c4a4d2f43177f6165132c6d36a4d46963018f726
Author:     Dongsheng Yang <[email protected]>
AuthorDate: Tue, 11 Feb 2014 15:34:51 +0800
Committer:  Ingo Molnar <[email protected]>
CommitDate: Sat, 22 Feb 2014 18:16:19 +0100

sys: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE

---
 kernel/sys.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
kernel/sys.c +4 -4
index c0a58be..adaeab6 100644
@@ -174,10 +174,10 @@ SYSCALL_DEFINE3(setpriority, int, which, int, who, int, niceval)
 
 	/* normalize: avoid signed division (rounding problems) */
 	error = -ESRCH;
-	if (niceval < -20)
-		niceval = -20;
-	if (niceval > 19)
-		niceval = 19;
+	if (niceval < MIN_NICE)
+		niceval = MIN_NICE;
+	if (niceval > MAX_NICE)
+		niceval = MAX_NICE;
 
 	rcu_read_lock();
 	read_lock(&tasklist_lock);
#27 lore raw

PATCH 8/9 workqueue: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE.

In reply to Dongsheng Yang
cc Tejun Heo <[email protected]>
cc Peter Zijlstra <[email protected]>
cc Ingo Molnar <[email protected]>
---
 kernel/workqueue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/workqueue.c +1 -1
index 82ef9f3..e4f5905 100644
@@ -3218,7 +3218,7 @@ static ssize_t wq_nice_store(struct device *dev, struct device_attribute *attr,
 		return -ENOMEM;
 
 	if (sscanf(buf, "%d", &attrs->nice) == 1 &&
-	    attrs->nice >= -20 && attrs->nice <= 19)
+	    attrs->nice >= MIN_NICE && attrs->nice <= MAX_NICE)
 		ret = apply_workqueue_attrs(wq, attrs);
 	else
 		ret = -EINVAL;
Signature · 1 line
1.8.2.1
maintainer Acked-by on v1 8/9
#28 lore raw

Re: [PATCH 8/9] workqueue: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE.

Quoted 13 lines · Dongsheng Yang
cc Tejun Heo <[email protected]>
cc Peter Zijlstra <[email protected]>
cc Ingo Molnar <[email protected]>
---
 kernel/workqueue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/workqueue.c +0 -0
index 82ef9f3..e4f5905 100644

kernel/workqueue.c static ssize_t wq_nice_store(struct device *dev, struct device_attribute *attr, · line 3221

Quoted 5 lines
kernel/workqueue.c +1 -1
@@ -3218,7 +3218,7 @@ static ssize_t wq_nice_store(struct device *dev, struct device_attribute *attr,
 		return -ENOMEM;
 
 	if (sscanf(buf, "%d", &attrs->nice) == 1 &&
-	    attrs->nice >= -20 && attrs->nice <= 19)
+	    attrs->nice >= MIN_NICE && attrs->nice <= MAX_NICE)

No objection. If this gets accepted, it will be routed through -tip, I suppose? Please feel free to add

Thanks.

Signature · 1 line
tejun
#29 lore raw

[tip:sched/core] workqueue: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE.

In reply to Dongsheng Yang
workqueue: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE.
Commit-ID:  dbebf7f826e1b3935f8bcd5d9681bf97708a7ddb
Gitweb:     http://git.kernel.org/tip/dbebf7f826e1b3935f8bcd5d9681bf97708a7ddb
Author:     Dongsheng Yang <[email protected]>
AuthorDate: Tue, 11 Feb 2014 15:34:52 +0800
Committer:  Thomas Gleixner <[email protected]>
CommitDate: Fri, 21 Feb 2014 21:43:21 +0100

workqueue: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE.

---
 kernel/workqueue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/workqueue.c +1 -1
index 193e977..3fa5b8f 100644
@@ -3225,7 +3225,7 @@ static ssize_t wq_nice_store(struct device *dev, struct device_attribute *attr,
 		return -ENOMEM;
 
 	if (sscanf(buf, "%d", &attrs->nice) == 1 &&
-	    attrs->nice >= -20 && attrs->nice <= 19)
+	    attrs->nice >= MIN_NICE && attrs->nice <= MAX_NICE)
 		ret = apply_workqueue_attrs(wq, attrs);
 	else
 		ret = -EINVAL;
#30 lore raw

[tip:sched/core] workqueue: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE

In reply to Dongsheng Yang
workqueue: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE
Commit-ID:  144818422bfa272531250473b888394c21e6fe19
Gitweb:     http://git.kernel.org/tip/144818422bfa272531250473b888394c21e6fe19
Author:     Dongsheng Yang <[email protected]>
AuthorDate: Tue, 11 Feb 2014 15:34:52 +0800
Committer:  Ingo Molnar <[email protected]>
CommitDate: Sat, 22 Feb 2014 18:16:41 +0100

workqueue: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE

---
 kernel/workqueue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/workqueue.c +1 -1
index 193e977..3fa5b8f 100644
@@ -3225,7 +3225,7 @@ static ssize_t wq_nice_store(struct device *dev, struct device_attribute *attr,
 		return -ENOMEM;
 
 	if (sscanf(buf, "%d", &attrs->nice) == 1 &&
-	    attrs->nice >= -20 && attrs->nice <= 19)
+	    attrs->nice >= MIN_NICE && attrs->nice <= MAX_NICE)
 		ret = apply_workqueue_attrs(wq, attrs);
 	else
 		ret = -EINVAL;
#31 lore raw

PATCH 9/9 trace: Replace hardcoding of 19 with MAX_NICE.

In reply to Dongsheng Yang
cc Steven Rostedt <[email protected]>
cc Frederic Weisbecker <[email protected]>
cc Ingo Molnar <[email protected]>
---
 kernel/trace/ring_buffer_benchmark.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/trace/ring_buffer_benchmark.c +3 -3
index a5457d5..0434ff1 100644
@@ -40,8 +40,8 @@ static int write_iteration = 50;
 module_param(write_iteration, uint, 0644);
 MODULE_PARM_DESC(write_iteration, "# of writes between timestamp readings");
 
-static int producer_nice = 19;
-static int consumer_nice = 19;
+static int producer_nice = MAX_NICE;
+static int consumer_nice = MAX_NICE;
 
 static int producer_fifo = -1;
 static int consumer_fifo = -1;
@@ -308,7 +308,7 @@ static void ring_buffer_producer(void)
 
 	/* Let the user know that the test is running at low priority */
 	if (producer_fifo < 0 && consumer_fifo < 0 &&
-	    producer_nice == 19 && consumer_nice == 19)
+	    producer_nice == MAX_NICE && consumer_nice == MAX_NICE)
 		trace_printk("WARNING!!! This test is running at lowest priority.\n");
 
 	trace_printk("Time:     %lld (usecs)\n", time);
Signature · 1 line
1.8.2.1
#32 lore raw

Re: [PATCH 9/9] trace: Replace hardcoding of 19 with MAX_NICE.

Hi Peter.
It seems the all other patches in this set were all applied to tip
except this one.
What is the problem with the [9/9]? Is there any thing I can do?

Thanx

Quoted 32 lines · Dongsheng Yang
cc Steven Rostedt <[email protected]>
cc Frederic Weisbecker <[email protected]>
cc Ingo Molnar <[email protected]>
---
  kernel/trace/ring_buffer_benchmark.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)
kernel/trace/ring_buffer_benchmark.c +3 -3
index a5457d5..0434ff1 100644
@@ -40,8 +40,8 @@ static int write_iteration = 50;
  module_param(write_iteration, uint, 0644);
  MODULE_PARM_DESC(write_iteration, "# of writes between timestamp readings");
 
-static int producer_nice = 19;
-static int consumer_nice = 19;
+static int producer_nice = MAX_NICE;
+static int consumer_nice = MAX_NICE;
 
  static int producer_fifo = -1;
  static int consumer_fifo = -1;
@@ -308,7 +308,7 @@ static void ring_buffer_producer(void)
 
  	/* Let the user know that the test is running at low priority */
  	if (producer_fifo < 0 && consumer_fifo < 0 &&
-	    producer_nice == 19 && consumer_nice == 19)
+	    producer_nice == MAX_NICE && consumer_nice == MAX_NICE)
  		trace_printk("WARNING!!! This test is running at lowest priority.\n");
 
  	trace_printk("Time:     %lld (usecs)\n", time);
maintainer
#33 lore raw

Re: [PATCH 9/9] trace: Replace hardcoding of 19 with MAX_NICE.

Quoted 4 lines · Dongsheng Yang

Hi Peter.
It seems the all other patches in this set were all applied to tip
except this one.
What is the problem with the [9/9]? Is there any thing I can do?

I might have just missed it; fail on my end. I'll try and sort it on monday.

maintainer
#34 lore raw

Re: [PATCH 9/9] trace: Replace hardcoding of 19 with MAX_NICE.

In reply to Dongsheng Yang
Quoted 4 lines · Dongsheng Yang

Hi Peter.
It seems the all other patches in this set were all applied to tip
except this one.
What is the problem with the [9/9]? Is there any thing I can do?

The problem is that it never actually made it to my inbox; could you verify that I was indeed on the recipient list? And if not resend it.

In case I was actually on the recipient list I need to go figure out where it went.

#35 lore raw

Re: [PATCH 9/9] trace: Replace hardcoding of 19 with MAX_NICE.

Quoted 7 lines · Peter Zijlstra
Quoted 4 lines · Dongsheng Yang

Hi Peter.
It seems the all other patches in this set were all applied to tip
except this one.
What is the problem with the [9/9]? Is there any thing I can do?

The problem is that it never actually made it to my inbox; could you verify that I was indeed on the recipient list? And if not resend it.

Oh, yes. Sorry for that. I will resend it soon with ccing you.

Quoted 9 lines

In case I was actually on the recipient list I need to go figure out where it went.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#36 lore raw

PATCH RESEND 1/1 trace: Replace hardcoding of 19 with MAX_NICE.

In reply to Dongsheng Yang
cc Steven Rostedt <[email protected]>
cc Frederic Weisbecker <[email protected]>
cc Ingo Molnar <[email protected]>
cc Peter Zijlstra <[email protected]>
---
 kernel/trace/ring_buffer_benchmark.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/trace/ring_buffer_benchmark.c +3 -3
index a5457d5..0434ff1 100644
@@ -40,8 +40,8 @@ static int write_iteration = 50;
 module_param(write_iteration, uint, 0644);
 MODULE_PARM_DESC(write_iteration, "# of writes between timestamp readings");
 
-static int producer_nice = 19;
-static int consumer_nice = 19;
+static int producer_nice = MAX_NICE;
+static int consumer_nice = MAX_NICE;
 
 static int producer_fifo = -1;
 static int consumer_fifo = -1;
@@ -308,7 +308,7 @@ static void ring_buffer_producer(void)
 
 	/* Let the user know that the test is running at low priority */
 	if (producer_fifo < 0 && consumer_fifo < 0 &&
-	    producer_nice == 19 && consumer_nice == 19)
+	    producer_nice == MAX_NICE && consumer_nice == MAX_NICE)
 		trace_printk("WARNING!!! This test is running at lowest priority.\n");
 
 	trace_printk("Time:     %lld (usecs)\n", time);
Signature · 1 line
1.8.2.1
maintainer
#38 lore raw

Re: [PATCH Resend] trace: Replace hardcoding of 19 with MAX_NICE.

In reply to Dongsheng Yang
Quoted 5 lines · On Mon, 24 Feb 2014 22:12:01 +0800 Dongsheng Yang <[email protected]>…
cc Steven Rostedt <[email protected]>
cc Frederic Weisbecker <[email protected]>
cc Ingo Molnar <[email protected]>
cc Peter Zijlstra <[email protected]>

Peter,

If you want to take this, you can add my Acked-by.

-- Steve

Quoted 28 lines
---
 kernel/trace/ring_buffer_benchmark.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/trace/ring_buffer_benchmark.c +3 -3
index a5457d5..0434ff1 100644
@@ -40,8 +40,8 @@ static int write_iteration = 50;
 module_param(write_iteration, uint, 0644);
 MODULE_PARM_DESC(write_iteration, "# of writes between timestamp readings");
 
-static int producer_nice = 19;
-static int consumer_nice = 19;
+static int producer_nice = MAX_NICE;
+static int consumer_nice = MAX_NICE;
 
 static int producer_fifo = -1;
 static int consumer_fifo = -1;
@@ -308,7 +308,7 @@ static void ring_buffer_producer(void)
 
 	/* Let the user know that the test is running at low priority */
 	if (producer_fifo < 0 && consumer_fifo < 0 &&
-	    producer_nice == 19 && consumer_nice == 19)
+	    producer_nice == MAX_NICE && consumer_nice == MAX_NICE)
 		trace_printk("WARNING!!! This test is running at lowest priority.\n");
 
 	trace_printk("Time:     %lld (usecs)\n", time);
maintainer
#39 lore raw

Re: [PATCH Resend] trace: Replace hardcoding of 19 with MAX_NICE.

Quoted 9 lines · Steven Rostedt
Quoted 5 lines · On Mon, 24 Feb 2014 22:12:01 +0800 Dongsheng Yang <[email protected]>…
cc Steven Rostedt <[email protected]>
cc Frederic Weisbecker <[email protected]>
cc Ingo Molnar <[email protected]>
cc Peter Zijlstra <[email protected]>
Quoted 3 lines

Peter,

If you want to take this, you can add my Acked-by.

Done, thanks!

#40 lore raw

[tip:sched/core] trace: Replace hardcoding of 19 with MAX_NICE

In reply to Dongsheng Yang
trace: Replace hardcoding of 19 with MAX_NICE
Commit-ID:  2b3942e4bb20ef8ef26515bd958c2df83d9a6210
Gitweb:     http://git.kernel.org/tip/2b3942e4bb20ef8ef26515bd958c2df83d9a6210
Author:     Dongsheng Yang <[email protected]>
AuthorDate: Mon, 24 Feb 2014 22:12:01 +0800
Committer:  Ingo Molnar <[email protected]>
CommitDate: Thu, 27 Feb 2014 12:41:03 +0100

trace: Replace hardcoding of 19 with MAX_NICE

Use MAX_NICE instead of the value 19 for ring_buffer_benchmark.

---
 kernel/trace/ring_buffer_benchmark.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
kernel/trace/ring_buffer_benchmark.c +3 -3
index a5457d5..0434ff1 100644
@@ -40,8 +40,8 @@ static int write_iteration = 50;
 module_param(write_iteration, uint, 0644);
 MODULE_PARM_DESC(write_iteration, "# of writes between timestamp readings");
 
-static int producer_nice = 19;
-static int consumer_nice = 19;
+static int producer_nice = MAX_NICE;
+static int consumer_nice = MAX_NICE;
 
 static int producer_fifo = -1;
 static int consumer_fifo = -1;
@@ -308,7 +308,7 @@ static void ring_buffer_producer(void)
 
 	/* Let the user know that the test is running at low priority */
 	if (producer_fifo < 0 && consumer_fifo < 0 &&
-	    producer_nice == 19 && consumer_nice == 19)
+	    producer_nice == MAX_NICE && consumer_nice == MAX_NICE)
 		trace_printk("WARNING!!! This test is running at lowest priority.\n");
 
 	trace_printk("Time:     %lld (usecs)\n", time);
#41 lore raw
In reply to Dongsheng Yang

Hi Ingo & Peter,
What's your opinion on this patchset?

Quoted 30 lines · Dongsheng Yang

Hi Peter,
There are lots of hardcoding of -20 and 19 in kernel to represent
minimum and maximum of nice value currently. This patch set define three macros in prio.h and replace some of the hardcoding with them.

Please help to take a look at it, thanx :)

Dongsheng Yang (9):
sched: Prio: Use DEFAULT_PRIO to define NICE_TO_PRIO and PRIO_TO_NICE.
sched: prio: Add 3 macros of MAX_NICE, MIN_NICE and NICE_WIDTH in

     prio.h.

sched: prio: Use NICE_WIDTH macro to avoid using of hard coding of 40
and 20 in prio.h.
sched: prio: Add spaces before and after operator of '-'.
rcu: Use MAX_NICE to replace hard coding of 19.
sched: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE.
sys: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE.
workqueue: Replace hardcoding of -20 and 19 with MIN_NICE and
MAX_NICE.
trace: Replace hardcoding of 19 with MAX_NICE.

  include/linux/sched/prio.h           | 14 +++++++++-----
  kernel/rcu/torture.c                 |  8 ++++----
  kernel/sched/auto_group.c            |  2 +-
  kernel/sched/core.c                  | 12 ++++++------
  kernel/sys.c                         |  8 ++++----
  kernel/trace/ring_buffer_benchmark.c |  6 +++---
  kernel/workqueue.c                   |  2 +-
  7 files changed, 28 insertions(+), 24 deletions(-)
maintainer Applied
#42 lore raw
Quoted 2 lines · Dongsheng Yang

Hi Ingo & Peter,
What's your opinion on this patchset?

I queued it; I wasn't convinced but people seem to like it, which is good enough.

#43 lore raw
Quoted 5 lines · Peter Zijlstra
Quoted 2 lines · Dongsheng Yang

Hi Ingo & Peter,
What's your opinion on this patchset?

I queued it; I wasn't convinced but people seem to like it, which is good enough.

Thank you :)

Quoted 6 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/