All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3 for-tip] use task_nice() in tracing to git rid of an open coded impolementation of it.
@ 2014-03-12 10:26 Dongsheng Yang
  2014-03-12 10:26 ` [PATCH 1/3 Resend] tracing: Use inline task_nice() to get rid of an open coded implementation " Dongsheng Yang
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Dongsheng Yang @ 2014-03-12 10:26 UTC (permalink / raw)
  To: linux-kernel; +Cc: rostedt, fweisbec, mingo, Dongsheng Yang

Hi Steven,
	The [1/3] in this thread is a copy of 

1390430505-17234-1-git-send-email-yangds.fnst@cn.fujitsu.com.

	At that time, you said you will take this patch if task_nice()
is implemeted as a inline function. Now it is done, I wish you can give
it an ack. If you have a time, please take a look at the other patches
in this thread. Thank you.

Dongsheng Yang (3):
  tracing: Use inline task_nice() to get rid of an open coded
    implementation of it.
  sched/prio: Replace hardcoding of 40 with NICE_WIDTH.
  sched: Use clamp() and clamp_val() to make it more readable.

 kernel/sched/core.c  | 11 ++---------
 kernel/trace/trace.c |  2 +-
 2 files changed, 3 insertions(+), 10 deletions(-)

-- 
1.8.2.1


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

* [PATCH 1/3 Resend] tracing: Use inline task_nice() to get rid of an open coded implementation of it.
  2014-03-12 10:26 [PATCH 0/3 for-tip] use task_nice() in tracing to git rid of an open coded impolementation of it Dongsheng Yang
@ 2014-03-12 10:26 ` Dongsheng Yang
  2014-03-19  2:15   ` Steven Rostedt
  2014-03-12 10:26 ` [PATCH 2/3] sched/prio: Replace hardcoding of 40 with NICE_WIDTH Dongsheng Yang
  2014-03-12 10:26 ` [PATCH 3/3] sched: Use clamp() and clamp_val() to make it more readable Dongsheng Yang
  2 siblings, 1 reply; 11+ messages in thread
From: Dongsheng Yang @ 2014-03-12 10:26 UTC (permalink / raw)
  To: linux-kernel; +Cc: rostedt, fweisbec, mingo, Dongsheng Yang

Function task_nice() was reimplemented as inline function, we can use it here
to replace the open coded implementation.

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
cc: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/trace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 815c878..dba0e3d 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1003,7 +1003,7 @@ __update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu)
 	else
 		max_data->uid = task_uid(tsk);
 
-	max_data->nice = tsk->static_prio - 20 - MAX_RT_PRIO;
+	max_data->nice = task_nice(tsk);
 	max_data->policy = tsk->policy;
 	max_data->rt_priority = tsk->rt_priority;
 
-- 
1.8.2.1


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

* [PATCH 2/3] sched/prio: Replace hardcoding of 40 with NICE_WIDTH.
  2014-03-12 10:26 [PATCH 0/3 for-tip] use task_nice() in tracing to git rid of an open coded impolementation of it Dongsheng Yang
  2014-03-12 10:26 ` [PATCH 1/3 Resend] tracing: Use inline task_nice() to get rid of an open coded implementation " Dongsheng Yang
@ 2014-03-12 10:26 ` Dongsheng Yang
  2014-03-12 10:26 ` [PATCH 3/3] sched: Use clamp() and clamp_val() to make it more readable Dongsheng Yang
  2 siblings, 0 replies; 11+ messages in thread
From: Dongsheng Yang @ 2014-03-12 10:26 UTC (permalink / raw)
  To: linux-kernel; +Cc: rostedt, fweisbec, mingo, Dongsheng Yang

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
---
 kernel/sched/core.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 9e126a2..259ab85 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3068,10 +3068,10 @@ SYSCALL_DEFINE1(nice, int, increment)
 	 * We don't have to worry. Conceptually one call occurs first
 	 * and we have a single winner.
 	 */
-	if (increment < -40)
-		increment = -40;
-	if (increment > 40)
-		increment = 40;
+	if (increment < -NICE_WIDTH)
+		increment = -NICE_WIDTH;
+	if (increment > NICE_WIDTH)
+		increment = NICE_WIDTH;
 
 	nice = task_nice(current) + increment;
 	if (nice < MIN_NICE)
-- 
1.8.2.1


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

* [PATCH 3/3] sched: Use clamp() and clamp_val() to make it more readable.
  2014-03-12 10:26 [PATCH 0/3 for-tip] use task_nice() in tracing to git rid of an open coded impolementation of it Dongsheng Yang
  2014-03-12 10:26 ` [PATCH 1/3 Resend] tracing: Use inline task_nice() to get rid of an open coded implementation " Dongsheng Yang
  2014-03-12 10:26 ` [PATCH 2/3] sched/prio: Replace hardcoding of 40 with NICE_WIDTH Dongsheng Yang
@ 2014-03-12 10:26 ` Dongsheng Yang
  2014-03-19  2:16   ` Steven Rostedt
  2 siblings, 1 reply; 11+ messages in thread
From: Dongsheng Yang @ 2014-03-12 10:26 UTC (permalink / raw)
  To: linux-kernel; +Cc: rostedt, fweisbec, mingo, Dongsheng Yang

As Kees suggested, I use clamp() function to replace the if and
else branch, making it more readable and modular.

Suggested-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
---
 kernel/sched/core.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 259ab85..85f4231 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -3068,17 +3068,10 @@ SYSCALL_DEFINE1(nice, int, increment)
 	 * We don't have to worry. Conceptually one call occurs first
 	 * and we have a single winner.
 	 */
-	if (increment < -NICE_WIDTH)
-		increment = -NICE_WIDTH;
-	if (increment > NICE_WIDTH)
-		increment = NICE_WIDTH;
-
+	increment = clamp(increment, -NICE_WIDTH, NICE_WIDTH);
 	nice = task_nice(current) + increment;
-	if (nice < MIN_NICE)
-		nice = MIN_NICE;
-	if (nice > MAX_NICE)
-		nice = MAX_NICE;
 
+	nice = clamp_val(nice, MIN_NICE, MAX_NICE);
 	if (increment < 0 && !can_nice(current, nice))
 		return -EPERM;
 
-- 
1.8.2.1


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

* Re: [PATCH 1/3 Resend] tracing: Use inline task_nice() to get rid of an open coded implementation of it.
  2014-03-12 10:26 ` [PATCH 1/3 Resend] tracing: Use inline task_nice() to get rid of an open coded implementation " Dongsheng Yang
@ 2014-03-19  2:15   ` Steven Rostedt
  2014-03-19  2:20     ` Dongsheng Yang
  2014-05-08  6:38     ` [PATCH RESEND] " Dongsheng Yang
  0 siblings, 2 replies; 11+ messages in thread
From: Steven Rostedt @ 2014-03-19  2:15 UTC (permalink / raw)
  To: Dongsheng Yang; +Cc: linux-kernel, fweisbec, mingo

On Wed, 12 Mar 2014 18:26:42 +0800
Dongsheng Yang <yangds.fnst@cn.fujitsu.com> wrote:

> Function task_nice() was reimplemented as inline function, we can use it here
> to replace the open coded implementation.
> 
> Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
> cc: Steven Rostedt <rostedt@goodmis.org>
> ---
>  kernel/trace/trace.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> index 815c878..dba0e3d 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
> @@ -1003,7 +1003,7 @@ __update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu)
>  	else
>  		max_data->uid = task_uid(tsk);
>  
> -	max_data->nice = tsk->static_prio - 20 - MAX_RT_PRIO;
> +	max_data->nice = task_nice(tsk);

task_nice() is still an extern function in mainline, and this is the
tracing side. I rather wait till it becomes inline in Linus's tree
before I take this.

-- Steve

>  	max_data->policy = tsk->policy;
>  	max_data->rt_priority = tsk->rt_priority;
>  


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

* Re: [PATCH 3/3] sched: Use clamp() and clamp_val() to make it more readable.
  2014-03-12 10:26 ` [PATCH 3/3] sched: Use clamp() and clamp_val() to make it more readable Dongsheng Yang
@ 2014-03-19  2:16   ` Steven Rostedt
  2014-03-19  2:19     ` Dongsheng Yang
  0 siblings, 1 reply; 11+ messages in thread
From: Steven Rostedt @ 2014-03-19  2:16 UTC (permalink / raw)
  To: Dongsheng Yang; +Cc: linux-kernel, fweisbec, mingo

On Wed, 12 Mar 2014 18:26:44 +0800
Dongsheng Yang <yangds.fnst@cn.fujitsu.com> wrote:

> As Kees suggested, I use clamp() function to replace the if and
> else branch, making it more readable and modular.
> 
> Suggested-by: Kees Cook <keescook@chromium.org>
> Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
> ---
>  kernel/sched/core.c | 11 ++---------
>  1 file changed, 2 insertions(+), 9 deletions(-)
> 
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 259ab85..85f4231 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -3068,17 +3068,10 @@ SYSCALL_DEFINE1(nice, int, increment)
>  	 * We don't have to worry. Conceptually one call occurs first
>  	 * and we have a single winner.
>  	 */
> -	if (increment < -NICE_WIDTH)
> -		increment = -NICE_WIDTH;
> -	if (increment > NICE_WIDTH)
> -		increment = NICE_WIDTH;
> -

Patch 2 and 3 need to be merged into a single patch.

-- Steve

> +	increment = clamp(increment, -NICE_WIDTH, NICE_WIDTH);
>  	nice = task_nice(current) + increment;
> -	if (nice < MIN_NICE)
> -		nice = MIN_NICE;
> -	if (nice > MAX_NICE)
> -		nice = MAX_NICE;
>  
> +	nice = clamp_val(nice, MIN_NICE, MAX_NICE);
>  	if (increment < 0 && !can_nice(current, nice))
>  		return -EPERM;
>  


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

* Re: [PATCH 3/3] sched: Use clamp() and clamp_val() to make it more readable.
  2014-03-19  2:16   ` Steven Rostedt
@ 2014-03-19  2:19     ` Dongsheng Yang
  0 siblings, 0 replies; 11+ messages in thread
From: Dongsheng Yang @ 2014-03-19  2:19 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: linux-kernel, fweisbec, mingo

On 03/19/2014 10:16 AM, Steven Rostedt wrote:
> On Wed, 12 Mar 2014 18:26:44 +0800
> Dongsheng Yang <yangds.fnst@cn.fujitsu.com> wrote:
>
>> As Kees suggested, I use clamp() function to replace the if and
>> else branch, making it more readable and modular.
>>
>> Suggested-by: Kees Cook <keescook@chromium.org>
>> Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
>> ---
>>   kernel/sched/core.c | 11 ++---------
>>   1 file changed, 2 insertions(+), 9 deletions(-)
>>
>> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
>> index 259ab85..85f4231 100644
>> --- a/kernel/sched/core.c
>> +++ b/kernel/sched/core.c
>> @@ -3068,17 +3068,10 @@ SYSCALL_DEFINE1(nice, int, increment)
>>   	 * We don't have to worry. Conceptually one call occurs first
>>   	 * and we have a single winner.
>>   	 */
>> -	if (increment < -NICE_WIDTH)
>> -		increment = -NICE_WIDTH;
>> -	if (increment > NICE_WIDTH)
>> -		increment = NICE_WIDTH;
>> -
> Patch 2 and 3 need to be merged into a single patch.

Okey, I will squash them into one.

Thanx
>
> -- Steve
>
>> +	increment = clamp(increment, -NICE_WIDTH, NICE_WIDTH);
>>   	nice = task_nice(current) + increment;
>> -	if (nice < MIN_NICE)
>> -		nice = MIN_NICE;
>> -	if (nice > MAX_NICE)
>> -		nice = MAX_NICE;
>>   
>> +	nice = clamp_val(nice, MIN_NICE, MAX_NICE);
>>   	if (increment < 0 && !can_nice(current, nice))
>>   		return -EPERM;
>>   
>


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

* Re: [PATCH 1/3 Resend] tracing: Use inline task_nice() to get rid of an open coded implementation of it.
  2014-03-19  2:15   ` Steven Rostedt
@ 2014-03-19  2:20     ` Dongsheng Yang
  2014-05-08  6:38     ` [PATCH RESEND] " Dongsheng Yang
  1 sibling, 0 replies; 11+ messages in thread
From: Dongsheng Yang @ 2014-03-19  2:20 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: linux-kernel, fweisbec, mingo

On 03/19/2014 10:15 AM, Steven Rostedt wrote:
> On Wed, 12 Mar 2014 18:26:42 +0800
> Dongsheng Yang <yangds.fnst@cn.fujitsu.com> wrote:
>
>> Function task_nice() was reimplemented as inline function, we can use it here
>> to replace the open coded implementation.
>>
>> Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
>> cc: Steven Rostedt <rostedt@goodmis.org>
>> ---
>>   kernel/trace/trace.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
>> index 815c878..dba0e3d 100644
>> --- a/kernel/trace/trace.c
>> +++ b/kernel/trace/trace.c
>> @@ -1003,7 +1003,7 @@ __update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu)
>>   	else
>>   		max_data->uid = task_uid(tsk);
>>   
>> -	max_data->nice = tsk->static_prio - 20 - MAX_RT_PRIO;
>> +	max_data->nice = task_nice(tsk);
> task_nice() is still an extern function in mainline, and this is the
> tracing side. I rather wait till it becomes inline in Linus's tree
> before I take this.

Sounds reasonable to me.

Thanx.
>
> -- Steve
>
>>   	max_data->policy = tsk->policy;
>>   	max_data->rt_priority = tsk->rt_priority;
>>   
> --
> 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] 11+ messages in thread

* [PATCH RESEND] tracing: Use inline task_nice() to get rid of an open coded implementation of it.
  2014-03-19  2:15   ` Steven Rostedt
  2014-03-19  2:20     ` Dongsheng Yang
@ 2014-05-08  6:38     ` Dongsheng Yang
  2014-05-09  0:17       ` Dongsheng Yang
  1 sibling, 1 reply; 11+ messages in thread
From: Dongsheng Yang @ 2014-05-08  6:38 UTC (permalink / raw)
  To: rostedt; +Cc: linux-kernel, Dongsheng Yang

Function task_nice() was reimplemented as inline function, we can use it here
to replace the open coded implementation.

Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
cc: Steven Rostedt <rostedt@goodmis.org>
---
 kernel/trace/trace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
index 737b0ef..f296adc 100644
--- a/kernel/trace/trace.c
+++ b/kernel/trace/trace.c
@@ -1015,7 +1015,7 @@ __update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu)
 	else
 		max_data->uid = task_uid(tsk);
 
-	max_data->nice = tsk->static_prio - 20 - MAX_RT_PRIO;
+	max_data->nice = task_nice(tsk);
 	max_data->policy = tsk->policy;
 	max_data->rt_priority = tsk->rt_priority;
 
-- 
1.8.2.1


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

* Re: [PATCH RESEND] tracing: Use inline task_nice() to get rid of an open coded implementation of it.
  2014-05-08  6:38     ` [PATCH RESEND] " Dongsheng Yang
@ 2014-05-09  0:17       ` Dongsheng Yang
  2014-05-09  1:23         ` Steven Rostedt
  0 siblings, 1 reply; 11+ messages in thread
From: Dongsheng Yang @ 2014-05-09  0:17 UTC (permalink / raw)
  To: rostedt; +Cc: Dongsheng Yang, linux-kernel

Hi steven, as you request, I resend this patch now when function task_nice()
is already in mainline. Do you want to take it?

On 05/08/2014 03:38 PM, Dongsheng Yang wrote:
> Function task_nice() was reimplemented as inline function, we can use it here
> to replace the open coded implementation.
>
> Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
> cc: Steven Rostedt <rostedt@goodmis.org>
> ---
>   kernel/trace/trace.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c
> index 737b0ef..f296adc 100644
> --- a/kernel/trace/trace.c
> +++ b/kernel/trace/trace.c
> @@ -1015,7 +1015,7 @@ __update_max_tr(struct trace_array *tr, struct task_struct *tsk, int cpu)
>   	else
>   		max_data->uid = task_uid(tsk);
>   
> -	max_data->nice = tsk->static_prio - 20 - MAX_RT_PRIO;
> +	max_data->nice = task_nice(tsk);
>   	max_data->policy = tsk->policy;
>   	max_data->rt_priority = tsk->rt_priority;
>   


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

* Re: [PATCH RESEND] tracing: Use inline task_nice() to get rid of an open coded implementation of it.
  2014-05-09  0:17       ` Dongsheng Yang
@ 2014-05-09  1:23         ` Steven Rostedt
  0 siblings, 0 replies; 11+ messages in thread
From: Steven Rostedt @ 2014-05-09  1:23 UTC (permalink / raw)
  To: Dongsheng Yang; +Cc: linux-kernel

On Fri, 9 May 2014 09:17:27 +0900
Dongsheng Yang <yangds.fnst@cn.fujitsu.com> wrote:

> Hi steven, as you request, I resend this patch now when function task_nice()
> is already in mainline. Do you want to take it?
> 

Yeah, I probably will. I've just been a bit busy with other things at
the moment.

-- Steve

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

end of thread, other threads:[~2014-05-09  1:24 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-12 10:26 [PATCH 0/3 for-tip] use task_nice() in tracing to git rid of an open coded impolementation of it Dongsheng Yang
2014-03-12 10:26 ` [PATCH 1/3 Resend] tracing: Use inline task_nice() to get rid of an open coded implementation " Dongsheng Yang
2014-03-19  2:15   ` Steven Rostedt
2014-03-19  2:20     ` Dongsheng Yang
2014-05-08  6:38     ` [PATCH RESEND] " Dongsheng Yang
2014-05-09  0:17       ` Dongsheng Yang
2014-05-09  1:23         ` Steven Rostedt
2014-03-12 10:26 ` [PATCH 2/3] sched/prio: Replace hardcoding of 40 with NICE_WIDTH Dongsheng Yang
2014-03-12 10:26 ` [PATCH 3/3] sched: Use clamp() and clamp_val() to make it more readable Dongsheng Yang
2014-03-19  2:16   ` Steven Rostedt
2014-03-19  2:19     ` 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.