linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hannes Reinecke <hare@suse.de>
To: Damien Le Moal <Damien.LeMoal@wdc.com>,
	Jens Axboe <axboe@kernel.dk>,
	"linux-block@vger.kernel.org" <linux-block@vger.kernel.org>,
	Paolo Valente <paolo.valente@linaro.org>,
	"linux-f2fs-devel@lists.sourceforge.net" 
	<linux-f2fs-devel@lists.sourceforge.net>,
	Jaegeuk Kim <jaegeuk@kernel.org>, Chao Yu <yuchao0@huawei.com>
Subject: Re: [PATCH v2 2/4] block: fix ioprio interface
Date: Fri, 6 Aug 2021 10:38:04 +0200	[thread overview]
Message-ID: <5b2642eb-2817-3814-3469-71027d6b629d@suse.de> (raw)
In-Reply-To: <DM6PR04MB70818B00518B40E671481E76E7F39@DM6PR04MB7081.namprd04.prod.outlook.com>

On 8/6/21 8:57 AM, Damien Le Moal wrote:
> On 2021/08/06 15:35, Hannes Reinecke wrote:
>> On 8/6/21 7:11 AM, Damien Le Moal wrote:
>>> An iocb aio_reqprio field is 16-bits (u16) but often handled as an int
>>> in the block layer. E.g. ioprio_check_cap() takes an int as argument.
>>> With such implicit int casting function calls, the upper 16-bits of the
>>> int argument may be left uninitialized by the compiler, resulting in
>>> invalid values for the IOPRIO_PRIO_CLASS() macro (garbage upper bits)
>>> and in an error return for functions such as ioprio_check_cap().
>>>
>>> Fix this by masking the result of the shift by IOPRIO_CLASS_SHIFT bits
>>> in the IOPRIO_PRIO_CLASS() macro. The new macro IOPRIO_CLASS_MASK
>>> defines the 3-bits mask for the priority class.
>>>
>>> While at it, cleanup the following:
>>> * Apply the mask IOPRIO_PRIO_MASK to the data argument of the
>>>    IOPRIO_PRIO_VALUE() macro to ignore upper bits of the data value.
>>> * Remove unnecessary parenthesis around fixed values in the macro
>>>    definitions in include/uapi/linux/ioprio.h.
>>> * Update the outdated mention of CFQ in the comment describing priority
>>>    classes and instead mention BFQ and mq-deadline.
>>> * Change the argument name of the IOPRIO_PRIO_CLASS() and
>>>    IOPRIO_PRIO_DATA() macros from "mask" to "ioprio" to reflect the fact
>>>    that an IO priority value should be passed rather than a mask.
>>> * Change the ioprio_valid() macro into an inline function, adding a
>>>    check on the maximum value of the class of a priority value as
>>>    defined by the IOPRIO_CLASS_MAX enum value. Move this function to
>>>    the kernel side in include/linux/ioprio.h.
>>> * Remove the unnecessary "else" after the return statements in
>>>    task_nice_ioclass().
>>>
>>> Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
>>> ---
>>>   include/linux/ioprio.h      | 15 ++++++++++++---
>>>   include/uapi/linux/ioprio.h | 19 +++++++++++--------
>>>   2 files changed, 23 insertions(+), 11 deletions(-)
>>>
>>> diff --git a/include/linux/ioprio.h b/include/linux/ioprio.h
>>> index ef9ad4fb245f..9b3a6d8172b4 100644
>>> --- a/include/linux/ioprio.h
>>> +++ b/include/linux/ioprio.h
>>> @@ -8,6 +8,16 @@
>>>   
>>>   #include <uapi/linux/ioprio.h>
>>>   
>>> +/*
>>> + * Check that a priority value has a valid class.
>>> + */
>>> +static inline bool ioprio_valid(unsigned short ioprio)
>>
>> Wouldn't it be better to use 'u16' here as type, as we're relying on the 
>> number of bits?
> 
> Other functions in block/ioprio.c and in include/linux/ioprio.h use "unsigned
> short", so I followed. But many functions, if not most, use "int". This is all a
> bit of a mess. I think we need a "typedef ioprio_t u16;" to clean things up. But
> there are a lot of places to fix. I can add such patch... Worth it ?
> 
Possibly not.
Consider my comment retracted :-)

Cheers,

Hannes
-- 
Dr. Hannes Reinecke		           Kernel Storage Architect
hare@suse.de			                  +49 911 74053 688
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), GF: Felix Imendörffer

  reply	other threads:[~2021-08-06  8:38 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-06  5:11 [PATCH v2 0/4] IO priority fixes and improvements Damien Le Moal
2021-08-06  5:11 ` [PATCH v2 1/4] block: bfq: fix bfq_set_next_ioprio_data() Damien Le Moal
2021-08-06  6:33   ` Hannes Reinecke
2021-08-06  5:11 ` [PATCH v2 2/4] block: fix ioprio interface Damien Le Moal
2021-08-06  6:35   ` Hannes Reinecke
2021-08-06  6:57     ` Damien Le Moal
2021-08-06  8:38       ` Hannes Reinecke [this message]
2021-08-06  5:11 ` [PATCH v2 3/4] block: rename IOPRIO_BE_NR Damien Le Moal
2021-08-06  6:37   ` Hannes Reinecke
2021-08-06  6:52     ` Damien Le Moal
2021-08-06  5:11 ` [PATCH v2 4/4] block: fix default IO priority handling Damien Le Moal
2021-08-06  6:39   ` Hannes Reinecke

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=5b2642eb-2817-3814-3469-71027d6b629d@suse.de \
    --to=hare@suse.de \
    --cc=Damien.LeMoal@wdc.com \
    --cc=axboe@kernel.dk \
    --cc=jaegeuk@kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=paolo.valente@linaro.org \
    --cc=yuchao0@huawei.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;
as well as URLs for NNTP newsgroup(s).