From: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: linux-kernel@vger.kernel.org, fweisbec@gmail.com, mingo@redhat.com
Subject: Re: [PATCH 3/3] sched: Use clamp() and clamp_val() to make it more readable.
Date: Wed, 19 Mar 2014 10:19:29 +0800 [thread overview]
Message-ID: <5328FEB1.6080903@cn.fujitsu.com> (raw)
In-Reply-To: <20140318221618.38da4688@gandalf.local.home>
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;
>>
>
prev parent reply other threads:[~2014-03-19 2:21 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5328FEB1.6080903@cn.fujitsu.com \
--to=yangds.fnst@cn.fujitsu.com \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.