All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/9] Add MAX_NICE, MIN_NICE and NICE_WIDTH macros in prio.h.
@ 2014-02-11  7:34 Dongsheng Yang
  2014-02-11  7:34 ` [PATCH 1/9] sched: Prio: Use DEFAULT_PRIO to define NICE_TO_PRIO and PRIO_TO_NICE Dongsheng Yang
                   ` (9 more replies)
  0 siblings, 10 replies; 44+ messages in thread
From: Dongsheng Yang @ 2014-02-11  7:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: 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(-)

-- 
1.8.2.1


^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH 1/9] sched: Prio: Use DEFAULT_PRIO to define NICE_TO_PRIO and PRIO_TO_NICE.
  2014-02-11  7:34 [PATCH 0/9] Add MAX_NICE, MIN_NICE and NICE_WIDTH macros in prio.h Dongsheng Yang
@ 2014-02-11  7:34 ` Dongsheng Yang
  2014-02-21 21:32   ` [tip:sched/core] " tip-bot for Dongsheng Yang
  2014-02-22 18:03   ` [tip:sched/core] sched/prio: Use DEFAULT_PRIO to define NICE_TO_PRIO() and PRIO_TO_NICE() tip-bot for Dongsheng Yang
  2014-02-11  7:34 ` [PATCH 2/9] sched: prio: Add 3 macros of MAX_NICE, MIN_NICE and NICE_WIDTH in prio.h Dongsheng Yang
                   ` (8 subsequent siblings)
  9 siblings, 2 replies; 44+ messages in thread
From: Dongsheng Yang @ 2014-02-11  7:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: Dongsheng Yang, Peter Zijlstra, Ingo Molnar

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).

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
cc: Peter Zijlstra <peterz@infradead.org>
cc: Ingo Molnar <mingo@kernel.org>
---
 include/linux/sched/prio.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/sched/prio.h b/include/linux/sched/prio.h
index 410ccb7..1ceaaa1 100644
--- a/include/linux/sched/prio.h
+++ b/include/linux/sched/prio.h
@@ -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
-- 
1.8.2.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 2/9] sched: prio: Add 3 macros of MAX_NICE, MIN_NICE and NICE_WIDTH in prio.h.
  2014-02-11  7:34 [PATCH 0/9] Add MAX_NICE, MIN_NICE and NICE_WIDTH macros in prio.h Dongsheng Yang
  2014-02-11  7:34 ` [PATCH 1/9] sched: Prio: Use DEFAULT_PRIO to define NICE_TO_PRIO and PRIO_TO_NICE Dongsheng Yang
@ 2014-02-11  7:34 ` Dongsheng Yang
  2014-02-21 21:33   ` [tip:sched/core] " tip-bot for Dongsheng Yang
  2014-02-22 18:03   ` [tip:sched/core] sched/prio: " tip-bot for Dongsheng Yang
  2014-02-11  7:34 ` [PATCH 3/9] sched: prio: Use NICE_WIDTH macro to avoid using of hard coding of 40 and 20 " Dongsheng Yang
                   ` (7 subsequent siblings)
  9 siblings, 2 replies; 44+ messages in thread
From: Dongsheng Yang @ 2014-02-11  7:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: Dongsheng Yang, Peter Zijlstra, Ingo Molnar

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.

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
cc: Peter Zijlstra <peterz@infradead.org>
cc: Ingo Molnar <mingo@kernel.org>
---
 include/linux/sched/prio.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/include/linux/sched/prio.h b/include/linux/sched/prio.h
index 1ceaaa1..c6974c4 100644
--- a/include/linux/sched/prio.h
+++ b/include/linux/sched/prio.h
@@ -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
-- 
1.8.2.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 3/9] sched: prio: Use NICE_WIDTH macro to avoid using of hard coding of 40 and 20 in prio.h.
  2014-02-11  7:34 [PATCH 0/9] Add MAX_NICE, MIN_NICE and NICE_WIDTH macros in prio.h Dongsheng Yang
  2014-02-11  7:34 ` [PATCH 1/9] sched: Prio: Use DEFAULT_PRIO to define NICE_TO_PRIO and PRIO_TO_NICE Dongsheng Yang
  2014-02-11  7:34 ` [PATCH 2/9] sched: prio: Add 3 macros of MAX_NICE, MIN_NICE and NICE_WIDTH in prio.h Dongsheng Yang
@ 2014-02-11  7:34 ` Dongsheng Yang
  2014-02-21 21:33   ` [tip:sched/core] " tip-bot for Dongsheng Yang
  2014-02-11  7:34 ` [PATCH 4/9] sched: prio: Add spaces before and after operator of '-' Dongsheng Yang
                   ` (6 subsequent siblings)
  9 siblings, 1 reply; 44+ messages in thread
From: Dongsheng Yang @ 2014-02-11  7:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: Dongsheng Yang, Ingo Molnar, Peter Zijlstra

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
cc: Ingo Molnar <mingo@kernel.org>
cc: Peter Zijlstra <peterz@infradead.org>
---
 include/linux/sched/prio.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/sched/prio.h b/include/linux/sched/prio.h
index c6974c4..ac32258 100644
--- a/include/linux/sched/prio.h
+++ b/include/linux/sched/prio.h
@@ -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 ]
-- 
1.8.2.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 4/9] sched: prio: Add spaces before and after operator of '-'.
  2014-02-11  7:34 [PATCH 0/9] Add MAX_NICE, MIN_NICE and NICE_WIDTH macros in prio.h Dongsheng Yang
                   ` (2 preceding siblings ...)
  2014-02-11  7:34 ` [PATCH 3/9] sched: prio: Use NICE_WIDTH macro to avoid using of hard coding of 40 and 20 " Dongsheng Yang
@ 2014-02-11  7:34 ` Dongsheng Yang
  2014-02-21 21:33   ` [tip:sched/core] " tip-bot for Dongsheng Yang
  2014-02-11  7:34 ` [PATCH 5/9] rcu: Use MAX_NICE to replace hard coding of 19 Dongsheng Yang
                   ` (5 subsequent siblings)
  9 siblings, 1 reply; 44+ messages in thread
From: Dongsheng Yang @ 2014-02-11  7:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: Dongsheng Yang, Peter Zijlstra, Ingo Molnar

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
cc: Peter Zijlstra <peterz@infradead.org>
cc: Ingo Molnar <mingo@kernel.org>
---
 include/linux/sched/prio.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/sched/prio.h b/include/linux/sched/prio.h
index ac32258..1bf9935 100644
--- a/include/linux/sched/prio.h
+++ b/include/linux/sched/prio.h
@@ -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))
 
-- 
1.8.2.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 5/9] rcu: Use MAX_NICE to replace hard coding of 19.
  2014-02-11  7:34 [PATCH 0/9] Add MAX_NICE, MIN_NICE and NICE_WIDTH macros in prio.h Dongsheng Yang
                   ` (3 preceding siblings ...)
  2014-02-11  7:34 ` [PATCH 4/9] sched: prio: Add spaces before and after operator of '-' Dongsheng Yang
@ 2014-02-11  7:34 ` Dongsheng Yang
  2014-02-11 15:37   ` Josh Triplett
                     ` (2 more replies)
  2014-02-11  7:34 ` [PATCH 6/9] sched: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE Dongsheng Yang
                   ` (4 subsequent siblings)
  9 siblings, 3 replies; 44+ messages in thread
From: Dongsheng Yang @ 2014-02-11  7:34 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dongsheng Yang, Josh Triplett, Paul E. McKenney, Peter Zijlstra,
	Ingo Molnar

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
cc: Josh Triplett <josh@freedesktop.org>
cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
cc: Peter Zijlstra <peterz@infradead.org>
cc: Ingo Molnar <mingo@kernel.org>
---
 kernel/rcu/torture.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/rcu/torture.c b/kernel/rcu/torture.c
index 732f8ae..219761d 100644
--- a/kernel/rcu/torture.c
+++ b/kernel/rcu/torture.c
@@ -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 =
-- 
1.8.2.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 6/9] sched: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE.
  2014-02-11  7:34 [PATCH 0/9] Add MAX_NICE, MIN_NICE and NICE_WIDTH macros in prio.h Dongsheng Yang
                   ` (4 preceding siblings ...)
  2014-02-11  7:34 ` [PATCH 5/9] rcu: Use MAX_NICE to replace hard coding of 19 Dongsheng Yang
@ 2014-02-11  7:34 ` Dongsheng Yang
  2014-02-21 21:33   ` [tip:sched/core] " tip-bot for Dongsheng Yang
  2014-02-22 18:03   ` tip-bot for Dongsheng Yang
  2014-02-11  7:34 ` [PATCH 7/9] sys: " Dongsheng Yang
                   ` (3 subsequent siblings)
  9 siblings, 2 replies; 44+ messages in thread
From: Dongsheng Yang @ 2014-02-11  7:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: Dongsheng Yang, Ingo Molnar, Peter Zijlstra

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
cc: Ingo Molnar <mingo@redhat.com>
cc: Peter Zijlstra <peterz@infradead.org>
---
 kernel/sched/auto_group.c |  2 +-
 kernel/sched/core.c       | 12 ++++++------
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
index 4a07353..e73efba 100644
--- a/kernel/sched/auto_group.c
+++ b/kernel/sched/auto_group.c
@@ -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);
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 104c816..46cf585 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -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;
-- 
1.8.2.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 7/9] sys: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE.
  2014-02-11  7:34 [PATCH 0/9] Add MAX_NICE, MIN_NICE and NICE_WIDTH macros in prio.h Dongsheng Yang
                   ` (5 preceding siblings ...)
  2014-02-11  7:34 ` [PATCH 6/9] sched: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE Dongsheng Yang
@ 2014-02-11  7:34 ` Dongsheng Yang
  2014-02-11 18:27   ` Kees Cook
                     ` (2 more replies)
  2014-02-11  7:34 ` [PATCH 8/9] workqueue: " Dongsheng Yang
                   ` (2 subsequent siblings)
  9 siblings, 3 replies; 44+ messages in thread
From: Dongsheng Yang @ 2014-02-11  7:34 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dongsheng Yang, Andrew Morton, Oleg Nesterov, Robin Holt,
	Al Viro, Kees Cook, Eric W. Biederman, Stephen Rothwell,
	Peter Zijlstra, Ingo Molnar

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
cc: Andrew Morton <akpm@linux-foundation.org>
cc: Oleg Nesterov <oleg@redhat.com>
cc: Robin Holt <holt@sgi.com>
cc: Al Viro <viro@zeniv.linux.org.uk>
cc: Kees Cook <keescook@chromium.org>
cc: "Eric W. Biederman" <ebiederm@xmission.com>
cc: Stephen Rothwell <sfr@canb.auug.org.au>
cc: Peter Zijlstra <peterz@infradead.org>
cc: Ingo Molnar <mingo@kernel.org>
---
 kernel/sys.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/sys.c b/kernel/sys.c
index c0a58be..adaeab6 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -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);
-- 
1.8.2.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 8/9] workqueue: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE.
  2014-02-11  7:34 [PATCH 0/9] Add MAX_NICE, MIN_NICE and NICE_WIDTH macros in prio.h Dongsheng Yang
                   ` (6 preceding siblings ...)
  2014-02-11  7:34 ` [PATCH 7/9] sys: " Dongsheng Yang
@ 2014-02-11  7:34 ` Dongsheng Yang
  2014-02-11 17:50   ` Tejun Heo
                     ` (2 more replies)
  2014-02-11  7:34 ` [PATCH 9/9] trace: Replace hardcoding of 19 with MAX_NICE Dongsheng Yang
  2014-02-14  9:22 ` [PATCH 0/9] Add MAX_NICE, MIN_NICE and NICE_WIDTH macros in prio.h Dongsheng Yang
  9 siblings, 3 replies; 44+ messages in thread
From: Dongsheng Yang @ 2014-02-11  7:34 UTC (permalink / raw)
  To: linux-kernel; +Cc: Dongsheng Yang, Tejun Heo, Peter Zijlstra, Ingo Molnar

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
cc: Tejun Heo <tj@kernel.org>
cc: Peter Zijlstra <peterz@infradead.org>
cc: Ingo Molnar <mingo@kernel.org>
---
 kernel/workqueue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 82ef9f3..e4f5905 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -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;
-- 
1.8.2.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [PATCH 9/9] trace: Replace hardcoding of 19 with MAX_NICE.
  2014-02-11  7:34 [PATCH 0/9] Add MAX_NICE, MIN_NICE and NICE_WIDTH macros in prio.h Dongsheng Yang
                   ` (7 preceding siblings ...)
  2014-02-11  7:34 ` [PATCH 8/9] workqueue: " Dongsheng Yang
@ 2014-02-11  7:34 ` Dongsheng Yang
  2014-02-22  9:05   ` Dongsheng Yang
  2014-02-24 14:12   ` [PATCH Resend] " Dongsheng Yang
  2014-02-14  9:22 ` [PATCH 0/9] Add MAX_NICE, MIN_NICE and NICE_WIDTH macros in prio.h Dongsheng Yang
  9 siblings, 2 replies; 44+ messages in thread
From: Dongsheng Yang @ 2014-02-11  7:34 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dongsheng Yang, Steven Rostedt, Frederic Weisbecker, Ingo Molnar

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
cc: Steven Rostedt <rostedt@goodmis.org>
cc: Frederic Weisbecker <fweisbec@gmail.com>
cc: Ingo Molnar <mingo@redhat.com>
---
 kernel/trace/ring_buffer_benchmark.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/trace/ring_buffer_benchmark.c b/kernel/trace/ring_buffer_benchmark.c
index a5457d5..0434ff1 100644
--- a/kernel/trace/ring_buffer_benchmark.c
+++ b/kernel/trace/ring_buffer_benchmark.c
@@ -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);
-- 
1.8.2.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* Re: [PATCH 5/9] rcu: Use MAX_NICE to replace hard coding of 19.
  2014-02-11  7:34 ` [PATCH 5/9] rcu: Use MAX_NICE to replace hard coding of 19 Dongsheng Yang
@ 2014-02-11 15:37   ` Josh Triplett
  2014-02-11 16:13     ` Paul E. McKenney
  2014-02-21 21:33   ` [tip:sched/core] " tip-bot for Dongsheng Yang
  2014-02-22 18:03   ` [tip:sched/core] rcu: Use MAX_NICE to replace hardcoding " tip-bot for Dongsheng Yang
  2 siblings, 1 reply; 44+ messages in thread
From: Josh Triplett @ 2014-02-11 15:37 UTC (permalink / raw)
  To: Dongsheng Yang
  Cc: linux-kernel, Paul E. McKenney, Peter Zijlstra, Ingo Molnar

On Tue, Feb 11, 2014 at 03:34:49PM +0800, Dongsheng Yang wrote:
> Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
> cc: Josh Triplett <josh@freedesktop.org>
> cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
> cc: Peter Zijlstra <peterz@infradead.org>
> cc: Ingo Molnar <mingo@kernel.org>

Reviewed-by: Josh Triplett <josh@joshtriplett.org>

>  kernel/rcu/torture.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/kernel/rcu/torture.c b/kernel/rcu/torture.c
> index 732f8ae..219761d 100644
> --- a/kernel/rcu/torture.c
> +++ b/kernel/rcu/torture.c
> @@ -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 =
> -- 
> 1.8.2.1
> 

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 5/9] rcu: Use MAX_NICE to replace hard coding of 19.
  2014-02-11 15:37   ` Josh Triplett
@ 2014-02-11 16:13     ` Paul E. McKenney
  2014-02-11 16:42       ` Peter Zijlstra
  0 siblings, 1 reply; 44+ messages in thread
From: Paul E. McKenney @ 2014-02-11 16:13 UTC (permalink / raw)
  To: Josh Triplett; +Cc: Dongsheng Yang, linux-kernel, Peter Zijlstra, Ingo Molnar

On Tue, Feb 11, 2014 at 07:37:32AM -0800, Josh Triplett wrote:
> On Tue, Feb 11, 2014 at 03:34:49PM +0800, Dongsheng Yang wrote:
> > Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
> > cc: Josh Triplett <josh@freedesktop.org>
> > cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
> > cc: Peter Zijlstra <peterz@infradead.org>
> > cc: Ingo Molnar <mingo@kernel.org>
> 
> Reviewed-by: Josh Triplett <josh@joshtriplett.org>

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

> >  kernel/rcu/torture.c | 8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> > 
> > diff --git a/kernel/rcu/torture.c b/kernel/rcu/torture.c
> > index 732f8ae..219761d 100644
> > --- a/kernel/rcu/torture.c
> > +++ b/kernel/rcu/torture.c
> > @@ -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 =
> > -- 
> > 1.8.2.1
> > 
> 


^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 5/9] rcu: Use MAX_NICE to replace hard coding of 19.
  2014-02-11 16:13     ` Paul E. McKenney
@ 2014-02-11 16:42       ` Peter Zijlstra
  2014-02-11 17:42         ` Paul E. McKenney
  0 siblings, 1 reply; 44+ messages in thread
From: Peter Zijlstra @ 2014-02-11 16:42 UTC (permalink / raw)
  To: Paul E. McKenney; +Cc: Josh Triplett, Dongsheng Yang, linux-kernel, Ingo Molnar

On Tue, Feb 11, 2014 at 08:13:13AM -0800, Paul E. McKenney wrote:
> On Tue, Feb 11, 2014 at 07:37:32AM -0800, Josh Triplett wrote:
> > On Tue, Feb 11, 2014 at 03:34:49PM +0800, Dongsheng Yang wrote:
> > > Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
> > > cc: Josh Triplett <josh@freedesktop.org>
> > > cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
> > > cc: Peter Zijlstra <peterz@infradead.org>
> > > cc: Ingo Molnar <mingo@kernel.org>
> > 
> > Reviewed-by: Josh Triplett <josh@joshtriplett.org>
> 
> 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.

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 5/9] rcu: Use MAX_NICE to replace hard coding of 19.
  2014-02-11 16:42       ` Peter Zijlstra
@ 2014-02-11 17:42         ` Paul E. McKenney
  0 siblings, 0 replies; 44+ messages in thread
From: Paul E. McKenney @ 2014-02-11 17:42 UTC (permalink / raw)
  To: Peter Zijlstra; +Cc: Josh Triplett, Dongsheng Yang, linux-kernel, Ingo Molnar

On Tue, Feb 11, 2014 at 05:42:30PM +0100, Peter Zijlstra wrote:
> On Tue, Feb 11, 2014 at 08:13:13AM -0800, Paul E. McKenney wrote:
> > On Tue, Feb 11, 2014 at 07:37:32AM -0800, Josh Triplett wrote:
> > > On Tue, Feb 11, 2014 at 03:34:49PM +0800, Dongsheng Yang wrote:
> > > > Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
> > > > cc: Josh Triplett <josh@freedesktop.org>
> > > > cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
> > > > cc: Peter Zijlstra <peterz@infradead.org>
> > > > cc: Ingo Molnar <mingo@kernel.org>
> > > 
> > > Reviewed-by: Josh Triplett <josh@joshtriplett.org>
> > 
> > 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


^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 8/9] workqueue: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE.
  2014-02-11  7:34 ` [PATCH 8/9] workqueue: " Dongsheng Yang
@ 2014-02-11 17:50   ` Tejun Heo
  2014-02-21 21:34   ` [tip:sched/core] " tip-bot for Dongsheng Yang
  2014-02-22 18:04   ` tip-bot for Dongsheng Yang
  2 siblings, 0 replies; 44+ messages in thread
From: Tejun Heo @ 2014-02-11 17:50 UTC (permalink / raw)
  To: Dongsheng Yang; +Cc: linux-kernel, Peter Zijlstra, Ingo Molnar

On Tue, Feb 11, 2014 at 03:34:52PM +0800, Dongsheng Yang wrote:
> Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
> cc: Tejun Heo <tj@kernel.org>
> cc: Peter Zijlstra <peterz@infradead.org>
> cc: Ingo Molnar <mingo@kernel.org>
> ---
>  kernel/workqueue.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/workqueue.c b/kernel/workqueue.c
> index 82ef9f3..e4f5905 100644
> --- a/kernel/workqueue.c
> +++ b/kernel/workqueue.c
> @@ -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

 Acked-by: Tejun Heo <tj@kernel.org>

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 7/9] sys: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE.
  2014-02-11  7:34 ` [PATCH 7/9] sys: " Dongsheng Yang
@ 2014-02-11 18:27   ` Kees Cook
  2014-02-12  3:59     ` Dongsheng Yang
  2014-02-21 21:34   ` [tip:sched/core] " tip-bot for Dongsheng Yang
  2014-02-22 18:04   ` tip-bot for Dongsheng Yang
  2 siblings, 1 reply; 44+ messages in thread
From: Kees Cook @ 2014-02-11 18:27 UTC (permalink / raw)
  To: Dongsheng Yang
  Cc: LKML, Andrew Morton, Oleg Nesterov, Robin Holt, Al Viro,
	Eric W. Biederman, Stephen Rothwell, Peter Zijlstra, Ingo Molnar

On Mon, Feb 10, 2014 at 11:34 PM, Dongsheng Yang
<yangds.fnst@cn.fujitsu.com> wrote:
> Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
> cc: Andrew Morton <akpm@linux-foundation.org>
> cc: Oleg Nesterov <oleg@redhat.com>
> cc: Robin Holt <holt@sgi.com>
> cc: Al Viro <viro@zeniv.linux.org.uk>
> cc: Kees Cook <keescook@chromium.org>
> cc: "Eric W. Biederman" <ebiederm@xmission.com>
> cc: Stephen Rothwell <sfr@canb.auug.org.au>
> cc: Peter Zijlstra <peterz@infradead.org>
> cc: Ingo Molnar <mingo@kernel.org>
> ---
>  kernel/sys.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/kernel/sys.c b/kernel/sys.c
> index c0a58be..adaeab6 100644
> --- a/kernel/sys.c
> +++ b/kernel/sys.c
> @@ -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;

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

>
>         rcu_read_lock();
>         read_lock(&tasklist_lock);
> --
> 1.8.2.1
>



-- 
Kees Cook
Chrome OS Security

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 7/9] sys: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE.
  2014-02-11 18:27   ` Kees Cook
@ 2014-02-12  3:59     ` Dongsheng Yang
  2014-02-12  6:40       ` Kees Cook
  0 siblings, 1 reply; 44+ messages in thread
From: Dongsheng Yang @ 2014-02-12  3:59 UTC (permalink / raw)
  To: Kees Cook
  Cc: LKML, Andrew Morton, Oleg Nesterov, Robin Holt, Al Viro,
	Eric W. Biederman, Stephen Rothwell, Peter Zijlstra, Ingo Molnar

Hi Kees,

  On 02/12/2014 02:27 AM, Kees Cook wrote:
> On Mon, Feb 10, 2014 at 11:34 PM, Dongsheng Yang
> <yangds.fnst@cn.fujitsu.com> wrote:
>> Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
>> cc: Andrew Morton <akpm@linux-foundation.org>
>> cc: Oleg Nesterov <oleg@redhat.com>
>> cc: Robin Holt <holt@sgi.com>
>> cc: Al Viro <viro@zeniv.linux.org.uk>
>> cc: Kees Cook <keescook@chromium.org>
>> cc: "Eric W. Biederman" <ebiederm@xmission.com>
>> cc: Stephen Rothwell <sfr@canb.auug.org.au>
>> cc: Peter Zijlstra <peterz@infradead.org>
>> cc: Ingo Molnar <mingo@kernel.org>
>> ---
>>   kernel/sys.c | 8 ++++----
>>   1 file changed, 4 insertions(+), 4 deletions(-)
>>
>> diff --git a/kernel/sys.c b/kernel/sys.c
>> index c0a58be..adaeab6 100644
>> --- a/kernel/sys.c
>> +++ b/kernel/sys.c
>> @@ -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;
> 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);

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.
>
> -Kees
>
>>          rcu_read_lock();
>>          read_lock(&tasklist_lock);
>> --
>> 1.8.2.1
>>
>
>


^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 7/9] sys: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE.
  2014-02-12  3:59     ` Dongsheng Yang
@ 2014-02-12  6:40       ` Kees Cook
  0 siblings, 0 replies; 44+ messages in thread
From: Kees Cook @ 2014-02-12  6:40 UTC (permalink / raw)
  To: Dongsheng Yang
  Cc: LKML, Andrew Morton, Oleg Nesterov, Robin Holt, Al Viro,
	Eric W. Biederman, Stephen Rothwell, Peter Zijlstra, Ingo Molnar

On Tue, Feb 11, 2014 at 7:59 PM, Dongsheng Yang
<yangds.fnst@cn.fujitsu.com> wrote:
> Hi Kees,
>
>
>  On 02/12/2014 02:27 AM, Kees Cook wrote:
>>
>> On Mon, Feb 10, 2014 at 11:34 PM, Dongsheng Yang
>> <yangds.fnst@cn.fujitsu.com> wrote:
>>>
>>> Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
>>> cc: Andrew Morton <akpm@linux-foundation.org>
>>> cc: Oleg Nesterov <oleg@redhat.com>
>>> cc: Robin Holt <holt@sgi.com>
>>> cc: Al Viro <viro@zeniv.linux.org.uk>
>>> cc: Kees Cook <keescook@chromium.org>
>>> cc: "Eric W. Biederman" <ebiederm@xmission.com>
>>> cc: Stephen Rothwell <sfr@canb.auug.org.au>
>>> cc: Peter Zijlstra <peterz@infradead.org>
>>> cc: Ingo Molnar <mingo@kernel.org>
>>> ---
>>>   kernel/sys.c | 8 ++++----
>>>   1 file changed, 4 insertions(+), 4 deletions(-)
>>>
>>> diff --git a/kernel/sys.c b/kernel/sys.c
>>> index c0a58be..adaeab6 100644
>>> --- a/kernel/sys.c
>>> +++ b/kernel/sys.c
>>> @@ -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;
>>
>> 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);
>
>
> 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

>
> Thanx.
>
>>
>> -Kees
>>
>>>          rcu_read_lock();
>>>          read_lock(&tasklist_lock);
>>> --
>>> 1.8.2.1
>>>
>>
>>
>



-- 
Kees Cook
Chrome OS Security

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 0/9] Add MAX_NICE, MIN_NICE and NICE_WIDTH macros in prio.h.
  2014-02-11  7:34 [PATCH 0/9] Add MAX_NICE, MIN_NICE and NICE_WIDTH macros in prio.h Dongsheng Yang
                   ` (8 preceding siblings ...)
  2014-02-11  7:34 ` [PATCH 9/9] trace: Replace hardcoding of 19 with MAX_NICE Dongsheng Yang
@ 2014-02-14  9:22 ` Dongsheng Yang
  2014-02-14  9:51   ` Peter Zijlstra
  9 siblings, 1 reply; 44+ messages in thread
From: Dongsheng Yang @ 2014-02-14  9:22 UTC (permalink / raw)
  To: LKML; +Cc: Peter Zijlstra, Ingo Molnar

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

On 02/11/2014 03:34 PM, Dongsheng Yang wrote:
> 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(-)
>


^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 0/9] Add MAX_NICE, MIN_NICE and NICE_WIDTH macros in prio.h.
  2014-02-14  9:22 ` [PATCH 0/9] Add MAX_NICE, MIN_NICE and NICE_WIDTH macros in prio.h Dongsheng Yang
@ 2014-02-14  9:51   ` Peter Zijlstra
  2014-02-14  9:54     ` Dongsheng Yang
  0 siblings, 1 reply; 44+ messages in thread
From: Peter Zijlstra @ 2014-02-14  9:51 UTC (permalink / raw)
  To: Dongsheng Yang; +Cc: LKML, Ingo Molnar

On Fri, Feb 14, 2014 at 05:22:50PM +0800, Dongsheng Yang wrote:
> 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.

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 0/9] Add MAX_NICE, MIN_NICE and NICE_WIDTH macros in prio.h.
  2014-02-14  9:51   ` Peter Zijlstra
@ 2014-02-14  9:54     ` Dongsheng Yang
  0 siblings, 0 replies; 44+ messages in thread
From: Dongsheng Yang @ 2014-02-14  9:54 UTC (permalink / raw)
  To: Peter Zijlstra; +Cc: LKML, Ingo Molnar

On 02/14/2014 05:51 PM, Peter Zijlstra wrote:
> On Fri, Feb 14, 2014 at 05:22:50PM +0800, Dongsheng Yang wrote:
>> 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 :)
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>


^ permalink raw reply	[flat|nested] 44+ messages in thread

* [tip:sched/core] sched: Prio: Use DEFAULT_PRIO to define NICE_TO_PRIO and PRIO_TO_NICE.
  2014-02-11  7:34 ` [PATCH 1/9] sched: Prio: Use DEFAULT_PRIO to define NICE_TO_PRIO and PRIO_TO_NICE Dongsheng Yang
@ 2014-02-21 21:32   ` tip-bot for Dongsheng Yang
  2014-02-22 18:03   ` [tip:sched/core] sched/prio: Use DEFAULT_PRIO to define NICE_TO_PRIO() and PRIO_TO_NICE() tip-bot for Dongsheng Yang
  1 sibling, 0 replies; 44+ messages in thread
From: tip-bot for Dongsheng Yang @ 2014-02-21 21:32 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, peterz, tglx, yangds.fnst

Commit-ID:  103fc73128e3c55773d7f60998f9296c256df3a5
Gitweb:     http://git.kernel.org/tip/103fc73128e3c55773d7f60998f9296c256df3a5
Author:     Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
AuthorDate: Tue, 11 Feb 2014 15:34:45 +0800
Committer:  Thomas Gleixner <tglx@linutronix.de>
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).

cc: Peter Zijlstra <peterz@infradead.org>
cc: Ingo Molnar <mingo@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/4e28ec36fb49e8906027cbbdd900ab26a149905e.1392103744.git.yangds.fnst@cn.fujitsu.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 include/linux/sched/prio.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/sched/prio.h b/include/linux/sched/prio.h
index 410ccb7..1ceaaa1 100644
--- a/include/linux/sched/prio.h
+++ b/include/linux/sched/prio.h
@@ -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

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [tip:sched/core] sched: prio: Add 3 macros of MAX_NICE, MIN_NICE and NICE_WIDTH in prio.h.
  2014-02-11  7:34 ` [PATCH 2/9] sched: prio: Add 3 macros of MAX_NICE, MIN_NICE and NICE_WIDTH in prio.h Dongsheng Yang
@ 2014-02-21 21:33   ` tip-bot for Dongsheng Yang
  2014-02-22 18:03   ` [tip:sched/core] sched/prio: " tip-bot for Dongsheng Yang
  1 sibling, 0 replies; 44+ messages in thread
From: tip-bot for Dongsheng Yang @ 2014-02-21 21:33 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, peterz, tglx, yangds.fnst

Commit-ID:  798fa741dd4e5a2d15e862367000a0ac63253978
Gitweb:     http://git.kernel.org/tip/798fa741dd4e5a2d15e862367000a0ac63253978
Author:     Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
AuthorDate: Tue, 11 Feb 2014 15:34:46 +0800
Committer:  Thomas Gleixner <tglx@linutronix.de>
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.

cc: Peter Zijlstra <peterz@infradead.org>
cc: Ingo Molnar <mingo@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/3994e89327b2b15f992277cdf9f409c516f87d1b.1392103744.git.yangds.fnst@cn.fujitsu.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 include/linux/sched/prio.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/include/linux/sched/prio.h b/include/linux/sched/prio.h
index 1ceaaa1..c6974c4 100644
--- a/include/linux/sched/prio.h
+++ b/include/linux/sched/prio.h
@@ -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

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [tip:sched/core] sched: prio: Use NICE_WIDTH macro to avoid using of hard coding of 40 and 20 in prio.h.
  2014-02-11  7:34 ` [PATCH 3/9] sched: prio: Use NICE_WIDTH macro to avoid using of hard coding of 40 and 20 " Dongsheng Yang
@ 2014-02-21 21:33   ` tip-bot for Dongsheng Yang
  0 siblings, 0 replies; 44+ messages in thread
From: tip-bot for Dongsheng Yang @ 2014-02-21 21:33 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, peterz, tglx, yangds.fnst

Commit-ID:  eb2ae7dad9dad350b4444962465d7e09bcfc128a
Gitweb:     http://git.kernel.org/tip/eb2ae7dad9dad350b4444962465d7e09bcfc128a
Author:     Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
AuthorDate: Tue, 11 Feb 2014 15:34:47 +0800
Committer:  Thomas Gleixner <tglx@linutronix.de>
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.

cc: Ingo Molnar <mingo@kernel.org>
cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/72dc351df816a975e30b6320754fb52823d2aa3f.1392103744.git.yangds.fnst@cn.fujitsu.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 include/linux/sched/prio.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/sched/prio.h b/include/linux/sched/prio.h
index c6974c4..ac32258 100644
--- a/include/linux/sched/prio.h
+++ b/include/linux/sched/prio.h
@@ -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 ]

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [tip:sched/core] sched: prio: Add spaces before and after operator of '-'.
  2014-02-11  7:34 ` [PATCH 4/9] sched: prio: Add spaces before and after operator of '-' Dongsheng Yang
@ 2014-02-21 21:33   ` tip-bot for Dongsheng Yang
  0 siblings, 0 replies; 44+ messages in thread
From: tip-bot for Dongsheng Yang @ 2014-02-21 21:33 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, peterz, tglx, yangds.fnst

Commit-ID:  02228c930672ec5476cf8ef84e4f3f45ab01b597
Gitweb:     http://git.kernel.org/tip/02228c930672ec5476cf8ef84e4f3f45ab01b597
Author:     Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
AuthorDate: Tue, 11 Feb 2014 15:34:48 +0800
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 21 Feb 2014 21:43:20 +0100

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

cc: Peter Zijlstra <peterz@infradead.org>
cc: Ingo Molnar <mingo@kernel.org>
Cc: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/bcbf88bb25b5423e8d33b3aa0c2e829a23d56c76.1392103744.git.yangds.fnst@cn.fujitsu.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 include/linux/sched/prio.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/sched/prio.h b/include/linux/sched/prio.h
index ac32258..1bf9935 100644
--- a/include/linux/sched/prio.h
+++ b/include/linux/sched/prio.h
@@ -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))
 

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [tip:sched/core] rcu: Use MAX_NICE to replace hard coding of 19.
  2014-02-11  7:34 ` [PATCH 5/9] rcu: Use MAX_NICE to replace hard coding of 19 Dongsheng Yang
  2014-02-11 15:37   ` Josh Triplett
@ 2014-02-21 21:33   ` tip-bot for Dongsheng Yang
  2014-02-22 18:03   ` [tip:sched/core] rcu: Use MAX_NICE to replace hardcoding " tip-bot for Dongsheng Yang
  2 siblings, 0 replies; 44+ messages in thread
From: tip-bot for Dongsheng Yang @ 2014-02-21 21:33 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, peterz, paulmck, tglx, josh, yangds.fnst

Commit-ID:  c30f4ba1cb3f89cefba728f5289caf3c0fc7149d
Gitweb:     http://git.kernel.org/tip/c30f4ba1cb3f89cefba728f5289caf3c0fc7149d
Author:     Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
AuthorDate: Tue, 11 Feb 2014 15:34:49 +0800
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 21 Feb 2014 21:43:20 +0100

rcu: Use MAX_NICE to replace hard coding of 19.

Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Cc: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/5b3bf232f41b33ab703a1595e94671b303e2d1fc.1392103744.git.yangds.fnst@cn.fujitsu.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 kernel/rcu/torture.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/rcu/torture.c b/kernel/rcu/torture.c
index 732f8ae..219761d 100644
--- a/kernel/rcu/torture.c
+++ b/kernel/rcu/torture.c
@@ -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 =

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [tip:sched/core] sched: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE.
  2014-02-11  7:34 ` [PATCH 6/9] sched: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE Dongsheng Yang
@ 2014-02-21 21:33   ` tip-bot for Dongsheng Yang
  2014-02-22 18:03   ` tip-bot for Dongsheng Yang
  1 sibling, 0 replies; 44+ messages in thread
From: tip-bot for Dongsheng Yang @ 2014-02-21 21:33 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, mingo, hpa, mingo, peterz, tglx, yangds.fnst

Commit-ID:  82abc86e6bcd0ab6b2efad1d8201abb463422034
Gitweb:     http://git.kernel.org/tip/82abc86e6bcd0ab6b2efad1d8201abb463422034
Author:     Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
AuthorDate: Tue, 11 Feb 2014 15:34:50 +0800
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 21 Feb 2014 21:43:20 +0100

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

Cc: Ingo Molnar <mingo@redhat.com>
Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/bd80780f19b4f9b4a765acc353c8dbc130274dd6.1392103744.git.yangds.fnst@cn.fujitsu.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 kernel/sched/auto_group.c |  2 +-
 kernel/sched/core.c       | 12 ++++++------
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
index 4a07353..e73efba 100644
--- a/kernel/sched/auto_group.c
+++ b/kernel/sched/auto_group.c
@@ -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);
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 67a24fa..67fcadb 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -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;

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [tip:sched/core] sys: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE.
  2014-02-11  7:34 ` [PATCH 7/9] sys: " Dongsheng Yang
  2014-02-11 18:27   ` Kees Cook
@ 2014-02-21 21:34   ` tip-bot for Dongsheng Yang
  2014-02-22 18:04   ` tip-bot for Dongsheng Yang
  2 siblings, 0 replies; 44+ messages in thread
From: tip-bot for Dongsheng Yang @ 2014-02-21 21:34 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, peterz, holt, viro, ebiederm, keescook,
	akpm, sfr, tglx, oleg, yangds.fnst

Commit-ID:  4870c6e5774424c994bfd606cd8adb8818e8a85c
Gitweb:     http://git.kernel.org/tip/4870c6e5774424c994bfd606cd8adb8818e8a85c
Author:     Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
AuthorDate: Tue, 11 Feb 2014 15:34:51 +0800
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 21 Feb 2014 21:43:21 +0100

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

Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Robin Holt <holt@sgi.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Kees Cook <keescook@chromium.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/0261f094b836f1acbcdf52e7166487c0c77323c8.1392103744.git.yangds.fnst@cn.fujitsu.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 kernel/sys.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/sys.c b/kernel/sys.c
index c0a58be..adaeab6 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -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);

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [tip:sched/core] workqueue: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE.
  2014-02-11  7:34 ` [PATCH 8/9] workqueue: " Dongsheng Yang
  2014-02-11 17:50   ` Tejun Heo
@ 2014-02-21 21:34   ` tip-bot for Dongsheng Yang
  2014-02-22 18:04   ` tip-bot for Dongsheng Yang
  2 siblings, 0 replies; 44+ messages in thread
From: tip-bot for Dongsheng Yang @ 2014-02-21 21:34 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, peterz, tj, tglx, yangds.fnst

Commit-ID:  dbebf7f826e1b3935f8bcd5d9681bf97708a7ddb
Gitweb:     http://git.kernel.org/tip/dbebf7f826e1b3935f8bcd5d9681bf97708a7ddb
Author:     Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
AuthorDate: Tue, 11 Feb 2014 15:34:52 +0800
Committer:  Thomas Gleixner <tglx@linutronix.de>
CommitDate: Fri, 21 Feb 2014 21:43:21 +0100

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

Cc: Ingo Molnar <mingo@kernel.org>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/6d85138180c00ce86975addab6e34b24b84f00a5.1392103744.git.yangds.fnst@cn.fujitsu.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
 kernel/workqueue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 193e977..3fa5b8f 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -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;

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* Re: [PATCH 9/9] trace: Replace hardcoding of 19 with MAX_NICE.
  2014-02-11  7:34 ` [PATCH 9/9] trace: Replace hardcoding of 19 with MAX_NICE Dongsheng Yang
@ 2014-02-22  9:05   ` Dongsheng Yang
  2014-02-22  9:27     ` Peter Zijlstra
  2014-02-24 10:46     ` Peter Zijlstra
  2014-02-24 14:12   ` [PATCH Resend] " Dongsheng Yang
  1 sibling, 2 replies; 44+ messages in thread
From: Dongsheng Yang @ 2014-02-22  9:05 UTC (permalink / raw)
  Cc: Dongsheng Yang, linux-kernel, Steven Rostedt,
	Frederic Weisbecker, Ingo Molnar, Peter Zijlstra

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


On 02/11/2014 03:34 PM, Dongsheng Yang wrote:
> Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
> cc: Steven Rostedt <rostedt@goodmis.org>
> cc: Frederic Weisbecker <fweisbec@gmail.com>
> cc: Ingo Molnar <mingo@redhat.com>
> ---
>   kernel/trace/ring_buffer_benchmark.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/kernel/trace/ring_buffer_benchmark.c b/kernel/trace/ring_buffer_benchmark.c
> index a5457d5..0434ff1 100644
> --- a/kernel/trace/ring_buffer_benchmark.c
> +++ b/kernel/trace/ring_buffer_benchmark.c
> @@ -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);


^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 9/9] trace: Replace hardcoding of 19 with MAX_NICE.
  2014-02-22  9:05   ` Dongsheng Yang
@ 2014-02-22  9:27     ` Peter Zijlstra
  2014-02-24 10:46     ` Peter Zijlstra
  1 sibling, 0 replies; 44+ messages in thread
From: Peter Zijlstra @ 2014-02-22  9:27 UTC (permalink / raw)
  To: Dongsheng Yang
  Cc: linux-kernel, Steven Rostedt, Frederic Weisbecker, Ingo Molnar

On Sat, Feb 22, 2014 at 05:05:36PM +0800, Dongsheng Yang wrote:
> 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.

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [tip:sched/core] sched/prio: Use DEFAULT_PRIO to define NICE_TO_PRIO() and PRIO_TO_NICE()
  2014-02-11  7:34 ` [PATCH 1/9] sched: Prio: Use DEFAULT_PRIO to define NICE_TO_PRIO and PRIO_TO_NICE Dongsheng Yang
  2014-02-21 21:32   ` [tip:sched/core] " tip-bot for Dongsheng Yang
@ 2014-02-22 18:03   ` tip-bot for Dongsheng Yang
  1 sibling, 0 replies; 44+ messages in thread
From: tip-bot for Dongsheng Yang @ 2014-02-22 18:03 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, peterz, tglx, yangds.fnst

Commit-ID:  7e298d60f717257dc8365c975f45ff9c37165362
Gitweb:     http://git.kernel.org/tip/7e298d60f717257dc8365c975f45ff9c37165362
Author:     Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
AuthorDate: Tue, 11 Feb 2014 15:34:45 +0800
Committer:  Ingo Molnar <mingo@kernel.org>
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).

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/4e28ec36fb49e8906027cbbdd900ab26a149905e.1392103744.git.yangds.fnst@cn.fujitsu.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 include/linux/sched/prio.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/linux/sched/prio.h b/include/linux/sched/prio.h
index 410ccb7..1ceaaa1 100644
--- a/include/linux/sched/prio.h
+++ b/include/linux/sched/prio.h
@@ -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

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [tip:sched/core] sched/prio: Add 3 macros of MAX_NICE, MIN_NICE and NICE_WIDTH in prio.h
  2014-02-11  7:34 ` [PATCH 2/9] sched: prio: Add 3 macros of MAX_NICE, MIN_NICE and NICE_WIDTH in prio.h Dongsheng Yang
  2014-02-21 21:33   ` [tip:sched/core] " tip-bot for Dongsheng Yang
@ 2014-02-22 18:03   ` tip-bot for Dongsheng Yang
  1 sibling, 0 replies; 44+ messages in thread
From: tip-bot for Dongsheng Yang @ 2014-02-22 18:03 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, peterz, tglx, yangds.fnst

Commit-ID:  3ee237dddcd885d4e525791299d62de33b2ca117
Gitweb:     http://git.kernel.org/tip/3ee237dddcd885d4e525791299d62de33b2ca117
Author:     Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
AuthorDate: Tue, 11 Feb 2014 15:34:46 +0800
Committer:  Ingo Molnar <mingo@kernel.org>
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.

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/3994e89327b2b15f992277cdf9f409c516f87d1b.1392103744.git.yangds.fnst@cn.fujitsu.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
[ Collapsed two small patches. ]
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 include/linux/sched/prio.h | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/include/linux/sched/prio.h b/include/linux/sched/prio.h
index 1ceaaa1..ac32258 100644
--- a/include/linux/sched/prio.h
+++ b/include/linux/sched/prio.h
@@ -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 ]

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [tip:sched/core] rcu: Use MAX_NICE to replace hardcoding of 19
  2014-02-11  7:34 ` [PATCH 5/9] rcu: Use MAX_NICE to replace hard coding of 19 Dongsheng Yang
  2014-02-11 15:37   ` Josh Triplett
  2014-02-21 21:33   ` [tip:sched/core] " tip-bot for Dongsheng Yang
@ 2014-02-22 18:03   ` tip-bot for Dongsheng Yang
  2 siblings, 0 replies; 44+ messages in thread
From: tip-bot for Dongsheng Yang @ 2014-02-22 18:03 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, peterz, paulmck, tglx, josh, yangds.fnst

Commit-ID:  d277d868dab6537a85f4757e39648b1d6afc60d5
Gitweb:     http://git.kernel.org/tip/d277d868dab6537a85f4757e39648b1d6afc60d5
Author:     Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
AuthorDate: Tue, 11 Feb 2014 15:34:49 +0800
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Sat, 22 Feb 2014 18:15:24 +0100

rcu: Use MAX_NICE to replace hardcoding of 19

Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Cc: "Paul E. McKenney" <paulmck@linux.vnet.ibm.com>
Link: http://lkml.kernel.org/r/5b3bf232f41b33ab703a1595e94671b303e2d1fc.1392103744.git.yangds.fnst@cn.fujitsu.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/rcu/torture.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/rcu/torture.c b/kernel/rcu/torture.c
index 732f8ae..219761d 100644
--- a/kernel/rcu/torture.c
+++ b/kernel/rcu/torture.c
@@ -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 =

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [tip:sched/core] sched: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE
  2014-02-11  7:34 ` [PATCH 6/9] sched: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE Dongsheng Yang
  2014-02-21 21:33   ` [tip:sched/core] " tip-bot for Dongsheng Yang
@ 2014-02-22 18:03   ` tip-bot for Dongsheng Yang
  1 sibling, 0 replies; 44+ messages in thread
From: tip-bot for Dongsheng Yang @ 2014-02-22 18:03 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, peterz, tglx, yangds.fnst

Commit-ID:  75e45d512f257beedae0d8a67d053cde5537bd4c
Gitweb:     http://git.kernel.org/tip/75e45d512f257beedae0d8a67d053cde5537bd4c
Author:     Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
AuthorDate: Tue, 11 Feb 2014 15:34:50 +0800
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Sat, 22 Feb 2014 18:15:54 +0100

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

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/bd80780f19b4f9b4a765acc353c8dbc130274dd6.1392103744.git.yangds.fnst@cn.fujitsu.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/sched/auto_group.c |  2 +-
 kernel/sched/core.c       | 12 ++++++------
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/kernel/sched/auto_group.c b/kernel/sched/auto_group.c
index 4a07353..e73efba 100644
--- a/kernel/sched/auto_group.c
+++ b/kernel/sched/auto_group.c
@@ -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);
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index cc4965e..a8a73b8 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -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;

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [tip:sched/core] sys: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE
  2014-02-11  7:34 ` [PATCH 7/9] sys: " Dongsheng Yang
  2014-02-11 18:27   ` Kees Cook
  2014-02-21 21:34   ` [tip:sched/core] " tip-bot for Dongsheng Yang
@ 2014-02-22 18:04   ` tip-bot for Dongsheng Yang
  2 siblings, 0 replies; 44+ messages in thread
From: tip-bot for Dongsheng Yang @ 2014-02-22 18:04 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, holt, peterz, viro, ebiederm, keescook,
	akpm, sfr, tglx, oleg, yangds.fnst

Commit-ID:  c4a4d2f43177f6165132c6d36a4d46963018f726
Gitweb:     http://git.kernel.org/tip/c4a4d2f43177f6165132c6d36a4d46963018f726
Author:     Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
AuthorDate: Tue, 11 Feb 2014 15:34:51 +0800
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Sat, 22 Feb 2014 18:16:19 +0100

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

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Robin Holt <holt@sgi.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Kees Cook <keescook@chromium.org>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Stephen Rothwell <sfr@canb.auug.org.au>
Link: http://lkml.kernel.org/r/0261f094b836f1acbcdf52e7166487c0c77323c8.1392103744.git.yangds.fnst@cn.fujitsu.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/sys.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/sys.c b/kernel/sys.c
index c0a58be..adaeab6 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -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);

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* [tip:sched/core] workqueue: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE
  2014-02-11  7:34 ` [PATCH 8/9] workqueue: " Dongsheng Yang
  2014-02-11 17:50   ` Tejun Heo
  2014-02-21 21:34   ` [tip:sched/core] " tip-bot for Dongsheng Yang
@ 2014-02-22 18:04   ` tip-bot for Dongsheng Yang
  2 siblings, 0 replies; 44+ messages in thread
From: tip-bot for Dongsheng Yang @ 2014-02-22 18:04 UTC (permalink / raw)
  To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, peterz, tj, tglx, yangds.fnst

Commit-ID:  144818422bfa272531250473b888394c21e6fe19
Gitweb:     http://git.kernel.org/tip/144818422bfa272531250473b888394c21e6fe19
Author:     Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
AuthorDate: Tue, 11 Feb 2014 15:34:52 +0800
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Sat, 22 Feb 2014 18:16:41 +0100

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

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Acked-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Link: http://lkml.kernel.org/r/6d85138180c00ce86975addab6e34b24b84f00a5.1392103744.git.yangds.fnst@cn.fujitsu.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/workqueue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index 193e977..3fa5b8f 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -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;

^ permalink raw reply related	[flat|nested] 44+ messages in thread

* Re: [PATCH 9/9] trace: Replace hardcoding of 19 with MAX_NICE.
  2014-02-22  9:05   ` Dongsheng Yang
  2014-02-22  9:27     ` Peter Zijlstra
@ 2014-02-24 10:46     ` Peter Zijlstra
  2014-02-24 14:08       ` Dongsheng Yang
  1 sibling, 1 reply; 44+ messages in thread
From: Peter Zijlstra @ 2014-02-24 10:46 UTC (permalink / raw)
  To: Dongsheng Yang
  Cc: linux-kernel, Steven Rostedt, Frederic Weisbecker, Ingo Molnar

On Sat, Feb 22, 2014 at 05:05:36PM +0800, Dongsheng Yang wrote:
> 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.

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH 9/9] trace: Replace hardcoding of 19 with MAX_NICE.
  2014-02-24 10:46     ` Peter Zijlstra
@ 2014-02-24 14:08       ` Dongsheng Yang
  0 siblings, 0 replies; 44+ messages in thread
From: Dongsheng Yang @ 2014-02-24 14:08 UTC (permalink / raw)
  To: Peter Zijlstra
  Cc: linux-kernel, Steven Rostedt, Frederic Weisbecker, Ingo Molnar

On 02/24/2014 06:46 PM, Peter Zijlstra wrote:
> On Sat, Feb 22, 2014 at 05:05:36PM +0800, Dongsheng Yang wrote:
>> 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.
>
> 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 majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>


^ permalink raw reply	[flat|nested] 44+ messages in thread

* [PATCH Resend] trace: Replace hardcoding of 19 with MAX_NICE.
  2014-02-11  7:34 ` [PATCH 9/9] trace: Replace hardcoding of 19 with MAX_NICE Dongsheng Yang
  2014-02-22  9:05   ` Dongsheng Yang
@ 2014-02-24 14:12   ` Dongsheng Yang
  2014-02-24 14:22     ` Peter Zijlstra
                       ` (2 more replies)
  1 sibling, 3 replies; 44+ messages in thread
From: Dongsheng Yang @ 2014-02-24 14:12 UTC (permalink / raw)
  To: linux-kernel
  Cc: Dongsheng Yang, Steven Rostedt, Frederic Weisbecker, Ingo Molnar,
	Peter Zijlstra

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
cc: Steven Rostedt <rostedt@goodmis.org>
cc: Frederic Weisbecker <fweisbec@gmail.com>
cc: Ingo Molnar <mingo@redhat.com>
cc: Peter Zijlstra <peterz@infradead.org>
---
 kernel/trace/ring_buffer_benchmark.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/trace/ring_buffer_benchmark.c b/kernel/trace/ring_buffer_benchmark.c
index a5457d5..0434ff1 100644
--- a/kernel/trace/ring_buffer_benchmark.c
+++ b/kernel/trace/ring_buffer_benchmark.c
@@ -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);
-- 
1.8.2.1


^ permalink raw reply related	[flat|nested] 44+ messages in thread

* Re: [PATCH Resend] trace: Replace hardcoding of 19 with MAX_NICE.
  2014-02-24 14:12   ` [PATCH Resend] " Dongsheng Yang
@ 2014-02-24 14:22     ` Peter Zijlstra
  2014-02-24 14:29     ` Steven Rostedt
  2014-02-27 13:33     ` [tip:sched/core] " tip-bot for Dongsheng Yang
  2 siblings, 0 replies; 44+ messages in thread
From: Peter Zijlstra @ 2014-02-24 14:22 UTC (permalink / raw)
  To: Dongsheng Yang
  Cc: linux-kernel, Steven Rostedt, Frederic Weisbecker, Ingo Molnar

On Mon, Feb 24, 2014 at 10:12:01PM +0800, Dongsheng Yang wrote:
> Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>

"Use MAX_NICE instead of the value 19 for ring_buffer_benchmark."

> cc: Steven Rostedt <rostedt@goodmis.org>
> cc: Frederic Weisbecker <fweisbec@gmail.com>
> cc: Ingo Molnar <mingo@redhat.com>
> cc: Peter Zijlstra <peterz@infradead.org>
> ---

Thanks.

^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH Resend] trace: Replace hardcoding of 19 with MAX_NICE.
  2014-02-24 14:12   ` [PATCH Resend] " Dongsheng Yang
  2014-02-24 14:22     ` Peter Zijlstra
@ 2014-02-24 14:29     ` Steven Rostedt
  2014-02-24 14:48       ` Peter Zijlstra
  2014-02-27 13:33     ` [tip:sched/core] " tip-bot for Dongsheng Yang
  2 siblings, 1 reply; 44+ messages in thread
From: Steven Rostedt @ 2014-02-24 14:29 UTC (permalink / raw)
  To: Dongsheng Yang
  Cc: linux-kernel, Frederic Weisbecker, Ingo Molnar, Peter Zijlstra

On Mon, 24 Feb 2014 22:12:01 +0800
Dongsheng Yang <yangds.fnst@cn.fujitsu.com> wrote:

> Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
> cc: Steven Rostedt <rostedt@goodmis.org>
> cc: Frederic Weisbecker <fweisbec@gmail.com>
> cc: Ingo Molnar <mingo@redhat.com>
> cc: Peter Zijlstra <peterz@infradead.org>

Peter,

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

-- Steve

> ---
>  kernel/trace/ring_buffer_benchmark.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/kernel/trace/ring_buffer_benchmark.c b/kernel/trace/ring_buffer_benchmark.c
> index a5457d5..0434ff1 100644
> --- a/kernel/trace/ring_buffer_benchmark.c
> +++ b/kernel/trace/ring_buffer_benchmark.c
> @@ -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);


^ permalink raw reply	[flat|nested] 44+ messages in thread

* Re: [PATCH Resend] trace: Replace hardcoding of 19 with MAX_NICE.
  2014-02-24 14:29     ` Steven Rostedt
@ 2014-02-24 14:48       ` Peter Zijlstra
  0 siblings, 0 replies; 44+ messages in thread
From: Peter Zijlstra @ 2014-02-24 14:48 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Dongsheng Yang, linux-kernel, Frederic Weisbecker, Ingo Molnar

On Mon, Feb 24, 2014 at 09:29:34AM -0500, Steven Rostedt wrote:
> On Mon, 24 Feb 2014 22:12:01 +0800
> Dongsheng Yang <yangds.fnst@cn.fujitsu.com> wrote:
> 
> > Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
> > cc: Steven Rostedt <rostedt@goodmis.org>
> > cc: Frederic Weisbecker <fweisbec@gmail.com>
> > cc: Ingo Molnar <mingo@redhat.com>
> > cc: Peter Zijlstra <peterz@infradead.org>
> 
> Peter,
> 
> If you want to take this, you can add my Acked-by.

Done, thanks!

^ permalink raw reply	[flat|nested] 44+ messages in thread

* [tip:sched/core] trace: Replace hardcoding of 19 with MAX_NICE
  2014-02-24 14:12   ` [PATCH Resend] " Dongsheng Yang
  2014-02-24 14:22     ` Peter Zijlstra
  2014-02-24 14:29     ` Steven Rostedt
@ 2014-02-27 13:33     ` tip-bot for Dongsheng Yang
  2 siblings, 0 replies; 44+ messages in thread
From: tip-bot for Dongsheng Yang @ 2014-02-27 13:33 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, mingo, peterz, fweisbec, rostedt, tglx, yangds.fnst

Commit-ID:  2b3942e4bb20ef8ef26515bd958c2df83d9a6210
Gitweb:     http://git.kernel.org/tip/2b3942e4bb20ef8ef26515bd958c2df83d9a6210
Author:     Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
AuthorDate: Mon, 24 Feb 2014 22:12:01 +0800
Committer:  Ingo Molnar <mingo@kernel.org>
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.

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Signed-off-by: Peter Zijlstra <peterz@infradead.org>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Link: http://lkml.kernel.org/r/1393251121-25534-1-git-send-email-yangds.fnst@cn.fujitsu.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/trace/ring_buffer_benchmark.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/kernel/trace/ring_buffer_benchmark.c b/kernel/trace/ring_buffer_benchmark.c
index a5457d5..0434ff1 100644
--- a/kernel/trace/ring_buffer_benchmark.c
+++ b/kernel/trace/ring_buffer_benchmark.c
@@ -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);

^ permalink raw reply related	[flat|nested] 44+ messages in thread

end of thread, other threads:[~2014-02-27 13:34 UTC | newest]

Thread overview: 44+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-11  7:34 [PATCH 0/9] Add MAX_NICE, MIN_NICE and NICE_WIDTH macros in prio.h Dongsheng Yang
2014-02-11  7:34 ` [PATCH 1/9] sched: Prio: Use DEFAULT_PRIO to define NICE_TO_PRIO and PRIO_TO_NICE Dongsheng Yang
2014-02-21 21:32   ` [tip:sched/core] " tip-bot for Dongsheng Yang
2014-02-22 18:03   ` [tip:sched/core] sched/prio: Use DEFAULT_PRIO to define NICE_TO_PRIO() and PRIO_TO_NICE() tip-bot for Dongsheng Yang
2014-02-11  7:34 ` [PATCH 2/9] sched: prio: Add 3 macros of MAX_NICE, MIN_NICE and NICE_WIDTH in prio.h Dongsheng Yang
2014-02-21 21:33   ` [tip:sched/core] " tip-bot for Dongsheng Yang
2014-02-22 18:03   ` [tip:sched/core] sched/prio: " tip-bot for Dongsheng Yang
2014-02-11  7:34 ` [PATCH 3/9] sched: prio: Use NICE_WIDTH macro to avoid using of hard coding of 40 and 20 " Dongsheng Yang
2014-02-21 21:33   ` [tip:sched/core] " tip-bot for Dongsheng Yang
2014-02-11  7:34 ` [PATCH 4/9] sched: prio: Add spaces before and after operator of '-' Dongsheng Yang
2014-02-21 21:33   ` [tip:sched/core] " tip-bot for Dongsheng Yang
2014-02-11  7:34 ` [PATCH 5/9] rcu: Use MAX_NICE to replace hard coding of 19 Dongsheng Yang
2014-02-11 15:37   ` Josh Triplett
2014-02-11 16:13     ` Paul E. McKenney
2014-02-11 16:42       ` Peter Zijlstra
2014-02-11 17:42         ` Paul E. McKenney
2014-02-21 21:33   ` [tip:sched/core] " tip-bot for Dongsheng Yang
2014-02-22 18:03   ` [tip:sched/core] rcu: Use MAX_NICE to replace hardcoding " tip-bot for Dongsheng Yang
2014-02-11  7:34 ` [PATCH 6/9] sched: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE Dongsheng Yang
2014-02-21 21:33   ` [tip:sched/core] " tip-bot for Dongsheng Yang
2014-02-22 18:03   ` tip-bot for Dongsheng Yang
2014-02-11  7:34 ` [PATCH 7/9] sys: " Dongsheng Yang
2014-02-11 18:27   ` Kees Cook
2014-02-12  3:59     ` Dongsheng Yang
2014-02-12  6:40       ` Kees Cook
2014-02-21 21:34   ` [tip:sched/core] " tip-bot for Dongsheng Yang
2014-02-22 18:04   ` tip-bot for Dongsheng Yang
2014-02-11  7:34 ` [PATCH 8/9] workqueue: " Dongsheng Yang
2014-02-11 17:50   ` Tejun Heo
2014-02-21 21:34   ` [tip:sched/core] " tip-bot for Dongsheng Yang
2014-02-22 18:04   ` tip-bot for Dongsheng Yang
2014-02-11  7:34 ` [PATCH 9/9] trace: Replace hardcoding of 19 with MAX_NICE Dongsheng Yang
2014-02-22  9:05   ` Dongsheng Yang
2014-02-22  9:27     ` Peter Zijlstra
2014-02-24 10:46     ` Peter Zijlstra
2014-02-24 14:08       ` Dongsheng Yang
2014-02-24 14:12   ` [PATCH Resend] " Dongsheng Yang
2014-02-24 14:22     ` Peter Zijlstra
2014-02-24 14:29     ` Steven Rostedt
2014-02-24 14:48       ` Peter Zijlstra
2014-02-27 13:33     ` [tip:sched/core] " tip-bot for Dongsheng Yang
2014-02-14  9:22 ` [PATCH 0/9] Add MAX_NICE, MIN_NICE and NICE_WIDTH macros in prio.h Dongsheng Yang
2014-02-14  9:51   ` Peter Zijlstra
2014-02-14  9:54     ` Dongsheng Yang

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.