From: Steven Rostedt <rostedt@goodmis.org>
To: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
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: Tue, 18 Mar 2014 22:16:18 -0400 [thread overview]
Message-ID: <20140318221618.38da4688@gandalf.local.home> (raw)
In-Reply-To: <08e669fea4242209aa625237214410c6bbf67dba.1394619587.git.yangds.fnst@cn.fujitsu.com>
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;
>
next prev parent reply other threads:[~2014-03-19 2:16 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 [this message]
2014-03-19 2:19 ` Dongsheng Yang
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=20140318221618.38da4688@gandalf.local.home \
--to=rostedt@goodmis.org \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=yangds.fnst@cn.fujitsu.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®