public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
To: Kees Cook <keescook@chromium.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Oleg Nesterov <oleg@redhat.com>, Robin Holt <holt@sgi.com>,
	Al Viro <viro@zeniv.linux.org.uk>,
	"Eric W. Biederman" <ebiederm@xmission.com>,
	Stephen Rothwell <sfr@canb.auug.org.au>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@kernel.org>
Subject: Re: [PATCH 7/9] sys: Replace hardcoding of -20 and 19 with MIN_NICE and MAX_NICE.
Date: Wed, 12 Feb 2014 11:59:28 +0800	[thread overview]
Message-ID: <52FAF1A0.8040605@cn.fujitsu.com> (raw)
In-Reply-To: <CAGXu5j+wSEnWAwgUBM47C8TXiEzmJt-J6sGHNEewwXqb5FgGEA@mail.gmail.com>

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


  reply	other threads:[~2014-02-12  3:59 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

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=52FAF1A0.8040605@cn.fujitsu.com \
    --to=yangds.fnst@cn.fujitsu.com \
    --cc=akpm@linux-foundation.org \
    --cc=ebiederm@xmission.com \
    --cc=holt@sgi.com \
    --cc=keescook@chromium.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=sfr@canb.auug.org.au \
    --cc=viro@zeniv.linux.org.uk \
    /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