From: Joe Perches <joe@perches.com>
To: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
Cc: linux-kernel@vger.kernel.org, fweisbec@gmail.com,
rostedt@goodmis.org, peterz@infradead.org, mingo@redhat.com,
Kees Cook <keescook@chromium.org>
Subject: Re: [PATCH 2/3] sched: Use clamp() and clamp_val() to make it more readable.
Date: Wed, 05 Mar 2014 07:17:36 -0800 [thread overview]
Message-ID: <1394032656.3271.51.camel@joe-AO722> (raw)
In-Reply-To: <0b02fa0f05c9cebca19cadce92cb8c85ee130ce0.1394022835.git.yangds.fnst@cn.fujitsu.com>
On Wed, 2014-03-05 at 20:36 +0800, Dongsheng Yang 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>
[]
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
[]
> @@ -3070,17 +3070,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;
> -
> + increment = clamp(increment, -40, 40);
Maybe:
increment = clamp(increment, -(NICE_MAX - NICE_MIN + 1),
, NICE_MAX - NICE_MIN + 1)
or add yet another define like #define NICE_RANGE
or #define NICE_MAX_INCREMENT
next prev parent reply other threads:[~2014-03-05 15:17 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-05 12:36 [PATCH 1/3] tracing: Use inline task_nice() to get rid of an open coded implementation of it Dongsheng Yang
2014-03-05 12:36 ` [PATCH 2/3] sched: Use clamp() and clamp_val() to make it more readable Dongsheng Yang
2014-03-05 15:17 ` Joe Perches [this message]
2014-03-05 15:26 ` Steven Rostedt
2014-03-05 15:29 ` Joe Perches
2014-03-05 12:36 ` [PATCH 3/3] sched/prio: Replace hardcoding of 40 with NICE_WIDTH Dongsheng Yang
2014-03-10 22:23 ` [PATCH] kernel/sys: Replace hardcoding of 20 with MAX_NICE + 1 Joe Perches
2014-03-11 1:17 ` Dongsheng Yang
2014-03-11 2:21 ` Joe Perches
2014-03-11 2:35 ` Dongsheng Yang
2014-03-11 5:04 ` [PATCH 1/3] tracing: Use inline task_nice() to get rid of an open coded implementation of it 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=1394032656.3271.51.camel@joe-AO722 \
--to=joe@perches.com \
--cc=fweisbec@gmail.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--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®