public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: linux-kernel@vger.kernel.org, joe@perches.com, mingo@kernel.org,
	tglx@linutronix.de, heiko.carstens@de.ibm.com,
	Jens Axboe <axboe@kernel.dk>
Subject: Re: [PATCH 07/16] ioprio: Add a macro named NICE_TO_IOPRIO.
Date: Tue, 11 Mar 2014 17:34:20 +0800	[thread overview]
Message-ID: <531ED89C.4050408@cn.fujitsu.com> (raw)
In-Reply-To: <20140311092856.GU9987@twins.programming.kicks-ass.net>

On 03/11/2014 05:28 PM, Peter Zijlstra wrote:
> On Tue, Mar 11, 2014 at 05:20:28PM +0800, Dongsheng Yang wrote:
>> As the task nice value is in [-20, 19] and the io priority is in [0, 7],
>> and the convert method from niceval to ioprio is implemented with an
>> opened code in task_nice_ioprio().
>>
>> This patch move the implementation to a macro NICE_TO_IOPRIO, making
>> it more readable and modular.
>>
>> Signed-off-by: Dongsheng Yang <yangds.fnst@cn.fujitsu.com>
>> ---
>>   include/linux/ioprio.h | 7 ++++++-
>>   1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/include/linux/ioprio.h b/include/linux/ioprio.h
>> index beb9ce1..c0faa0b 100644
>> --- a/include/linux/ioprio.h
>> +++ b/include/linux/ioprio.h
>> @@ -18,6 +18,11 @@
>>   #define ioprio_valid(mask)	(IOPRIO_PRIO_CLASS((mask)) != IOPRIO_CLASS_NONE)
>>   
>>   /*
>> + * Convert the nice value [19,-20] to io priority value [0,7].
>> + */
>> +#define NICE_TO_IOPRIO(nice)	(nice_to_rlimit(nice) / 5)
>> +
>> +/*
>>    * These are the io priority groups as implemented by CFQ. RT is the realtime
>>    * class, it always gets premium service. BE is the best-effort scheduling
>>    * class, the default for any process. IDLE is the idle scheduling class, it
>> @@ -52,7 +57,7 @@ enum {
>>    */
>>   static inline int task_nice_ioprio(struct task_struct *task)
>>   {
>> -	return (task_nice(task) + 20) / 5;
>> +	return NICE_TO_IOPRIO(task_nice(task));
>>   }
> How exactly is adding a macro and code complexity making this code
> better?

About this patch, I think convert a nice value in [-20, 19] to ioprio in 
[0, 7]
is a common requirement. So I add a macro NICE_TO_IOPRIO to achieve it.

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


  reply	other threads:[~2014-03-11  9:36 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-11  9:20 [PATCH 00/16 for-tip V2] A series patches about sched priority Dongsheng Yang
2014-03-11  9:20 ` [PATCH 01/16] sched/prio: Add a inline function named nice_to_rlimit() in prio.h Dongsheng Yang
2014-03-11  9:20 ` [PATCH 02/16] kernel/sys: Replace opened code implementation with nice_to_rlimit() Dongsheng Yang
2014-03-11  9:26   ` Peter Zijlstra
2014-03-11  9:27     ` Dongsheng Yang
2014-03-11  9:20 ` [PATCH 03/16] workqueue: Replace hardcoding of -20 with MIN_NICE Dongsheng Yang
2014-03-11  9:20 ` [PATCH 04/16] locktorture: Replace hardcoding of 19 with MAX_NICE Dongsheng Yang
2014-03-11  9:20 ` [PATCH 05/16] tools/mq_perf_tests: Replace hardcoding of -20 with MIN_NICE Dongsheng Yang
2014-03-11  9:20 ` [PATCH 06/16] mm: Replace hardcoding of 19 with MAX_NICE Dongsheng Yang
2014-03-11  9:20 ` [PATCH 07/16] ioprio: Add a macro named NICE_TO_IOPRIO Dongsheng Yang
2014-03-11  9:28   ` Peter Zijlstra
2014-03-11  9:34     ` Dongsheng Yang [this message]
2014-03-11  9:20 ` [PATCH 08/16] fs/hearbeat: Replace hardcoding of -20 with MIN_NICE Dongsheng Yang
2014-03-11  9:20 ` [PATCH 09/16] driver/block: " Dongsheng Yang
2014-03-11  9:20 ` [PATCH 10/16] driver/char: Replace hardcoding of 19 with MAX_NICE Dongsheng Yang
2014-03-11  9:20 ` [PATCH 11/16] drivers/s390: " Dongsheng Yang
2014-03-11  9:20 ` [PATCH 12/16] sched/prio: Add an inline function named rlimit_to_nice in prio.h Dongsheng Yang
2014-03-11  9:20 ` [PATCH 13/16] driver/staging/android: Use rlimit_to_nice to replace opened code implementation Dongsheng Yang
2014-03-11  9:20 ` [PATCH 14/16] driver/staging/lustre: Replace hardcoding of -20 with MIN_NICE Dongsheng Yang
2014-03-11  9:20 ` [PATCH 15/16] driver/scsi: " Dongsheng Yang
2014-03-11  9:20 ` [PATCH 16/16] sched: Get rid of opened code implementation of funtion nice_to_rlimit() 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=531ED89C.4050408@cn.fujitsu.com \
    --to=yangds.fnst@cn.fujitsu.com \
    --cc=axboe@kernel.dk \
    --cc=heiko.carstens@de.ibm.com \
    --cc=joe@perches.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /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