diff mbox series

[v4,02/19] block: introduce ioprio hints

Message ID 20230309215516.3800571-3-niklas.cassel@wdc.com
State New
Headers show
Series Add Command Duration Limits support | expand

Commit Message

Niklas Cassel March 9, 2023, 9:54 p.m. UTC
From: Damien Le Moal <damien.lemoal@opensource.wdc.com>

IO priorities currently only use 6-bits of the 16-bits ioprio value: the
3-upper bits are used to define up to 8 priority classes (4 of which are
valid) and the 3 lower bits of the value are used to define a priority
level for the real-time and best-effort class.

The remaining 10-bits between the IO priority class and level are
unused, and in fact, cannot be used by the user as doing so would
either result in the value being completely ignored, or in an error
returned by ioprio_check_cap().

Use these 10-bits of an ioprio value to allow a user to specify IO
hints. An IO hint is defined as a 10-bits value, allowing up to 1023
different hints to be specified, with the value 0 being reserved as the
"no hint" case. An IO hint can apply to any IO that specifies a valid
priority class other than NONE, regardless of the IO priority level
specified.

To do so, the macros IOPRIO_PRIO_HINT() and IOPRIO_PRIO_VALUE_HINT() are
introduced in include/uapi/linux/ioprio.h to respectively allow a user
to get and set a hint in an ioprio value.

To support the ATA and SCSI command duration limits feature, 7 hints
are defined: IOPRIO_HINT_DEV_DURATION_LIMIT_1 to
IOPRIO_HINT_DEV_DURATION_LIMIT_7, allowing a user to specify which
command duration limit descriptor should be applied to the commands
serving an IO. Specifying these hints has for now no effect whatsoever
if the target block devices do not support the command duration limits
feature. However, in the future, block IO schedulers can be modified to
optimize IO issuing order based on these hints, even for devices that
do not support the command duration limits feature.

Given that the 7 duration limits hints defined have no effect on any
block layer component, the actual definition of the duration limits
implied by these hints remains at the device level.

Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>
---
 include/uapi/linux/ioprio.h | 49 +++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

Comments

Damien Le Moal March 16, 2023, 2 a.m. UTC | #1
On 2023/03/10 6:54, Niklas Cassel wrote:
> From: Damien Le Moal <damien.lemoal@opensource.wdc.com>
> 
> IO priorities currently only use 6-bits of the 16-bits ioprio value: the
> 3-upper bits are used to define up to 8 priority classes (4 of which are
> valid) and the 3 lower bits of the value are used to define a priority
> level for the real-time and best-effort class.
> 
> The remaining 10-bits between the IO priority class and level are
> unused, and in fact, cannot be used by the user as doing so would
> either result in the value being completely ignored, or in an error
> returned by ioprio_check_cap().
> 
> Use these 10-bits of an ioprio value to allow a user to specify IO
> hints. An IO hint is defined as a 10-bits value, allowing up to 1023
> different hints to be specified, with the value 0 being reserved as the
> "no hint" case. An IO hint can apply to any IO that specifies a valid
> priority class other than NONE, regardless of the IO priority level
> specified.
> 
> To do so, the macros IOPRIO_PRIO_HINT() and IOPRIO_PRIO_VALUE_HINT() are
> introduced in include/uapi/linux/ioprio.h to respectively allow a user
> to get and set a hint in an ioprio value.
> 
> To support the ATA and SCSI command duration limits feature, 7 hints
> are defined: IOPRIO_HINT_DEV_DURATION_LIMIT_1 to
> IOPRIO_HINT_DEV_DURATION_LIMIT_7, allowing a user to specify which
> command duration limit descriptor should be applied to the commands
> serving an IO. Specifying these hints has for now no effect whatsoever
> if the target block devices do not support the command duration limits
> feature. However, in the future, block IO schedulers can be modified to
> optimize IO issuing order based on these hints, even for devices that
> do not support the command duration limits feature.
> 
> Given that the 7 duration limits hints defined have no effect on any
> block layer component, the actual definition of the duration limits
> implied by these hints remains at the device level.
> 
> Signed-off-by: Damien Le Moal <damien.lemoal@opensource.wdc.com>
> Signed-off-by: Niklas Cassel <niklas.cassel@wdc.com>

Jens, Martin,

Any thoughts on this new interface ?

Bart,

I would like to hear your opinion as well.


> ---
>  include/uapi/linux/ioprio.h | 49 +++++++++++++++++++++++++++++++++++++
>  1 file changed, 49 insertions(+)
> 
> diff --git a/include/uapi/linux/ioprio.h b/include/uapi/linux/ioprio.h
> index 4444b4e4fdad..607c7617b9d2 100644
> --- a/include/uapi/linux/ioprio.h
> +++ b/include/uapi/linux/ioprio.h
> @@ -58,4 +58,53 @@ enum {
>  #define IOPRIO_NORM	4
>  #define IOPRIO_BE_NORM	IOPRIO_NORM
>  
> +/*
> + * The 10-bits between the priority class and the priority level are used to
> + * optionally define IO hints for any combination of IO priority class and
> + * level. Depending on the kernel configuration, IO scheduler being used and
> + * the target IO device being used, hints can influence how IOs are processed
> + * without affecting the IO scheduling ordering defined by the IO priority
> + * class and level.
> + */
> +#define IOPRIO_HINT_SHIFT		IOPRIO_LEVEL_NR_BITS
> +#define IOPRIO_HINT_NR_BITS		10
> +#define IOPRIO_NR_HINTS			(1 << IOPRIO_HINT_NR_BITS)
> +#define IOPRIO_HINT_MASK		(IOPRIO_NR_HINTS - 1)
> +#define IOPRIO_PRIO_HINT(ioprio)	\
> +	(((ioprio) >> IOPRIO_HINT_SHIFT) & IOPRIO_HINT_MASK)
> +
> +/*
> + * Alternate macro for IOPRIO_PRIO_VALUE() to define an IO priority with
> + * a class, level and hint.
> + */
> +#define IOPRIO_PRIO_VALUE_HINT(class, level, hint)		 \
> +	((((class) & IOPRIO_CLASS_MASK) << IOPRIO_CLASS_SHIFT) | \
> +	 (((hint) & IOPRIO_HINT_MASK) << IOPRIO_HINT_SHIFT) |	 \
> +	 ((level) & IOPRIO_LEVEL_MASK))
> +
> +/*
> + * IO hints.
> + */
> +enum {
> +	/* No hint */
> +	IOPRIO_HINT_NONE = 0,
> +
> +	/*
> +	 * Device command duration limits: indicate to the device a desired
> +	 * duration limit for the commands that will be used to process an IO.
> +	 * These will currently only be effective for SCSI and ATA devices that
> +	 * support the command duration limits feature. If this feature is
> +	 * enabled, then the commands issued to the device to process an IO with
> +	 * one of these hints set will have the duration limit index (dld field)
> +	 * set to the value of the hint.
> +	 */
> +	IOPRIO_HINT_DEV_DURATION_LIMIT_1 = 1,
> +	IOPRIO_HINT_DEV_DURATION_LIMIT_2 = 2,
> +	IOPRIO_HINT_DEV_DURATION_LIMIT_3 = 3,
> +	IOPRIO_HINT_DEV_DURATION_LIMIT_4 = 4,
> +	IOPRIO_HINT_DEV_DURATION_LIMIT_5 = 5,
> +	IOPRIO_HINT_DEV_DURATION_LIMIT_6 = 6,
> +	IOPRIO_HINT_DEV_DURATION_LIMIT_7 = 7,
> +};
> +
>  #endif /* _UAPI_LINUX_IOPRIO_H */
Bart Van Assche March 16, 2023, 6:41 p.m. UTC | #2
On 3/15/23 19:00, Damien Le Moal wrote:
> Bart,
> 
> I would like to hear your opinion as well.

Isn't sending a ping after only three days a bit soon for such a large 
patch?

Regarding your question: I like the block/ioprio.c changes in this 
version of this patch series much better than the changes in the 
previous version of this patch series.

No objections from my side about the changes in this patch (02/19).

Thanks,

Bart.
Niklas Cassel March 17, 2023, 9:23 a.m. UTC | #3
Hello Bart,

On Thu, Mar 16, 2023 at 11:41:21AM -0700, Bart Van Assche wrote:
> On 3/15/23 19:00, Damien Le Moal wrote:
> > Bart,
> > 
> > I would like to hear your opinion as well.
> 
> Isn't sending a ping after only three days a bit soon for such a large
> patch?

While I was never really any good at math, I'm quite sure that 16-9=7 :)

Which is the recommended (minimum) time to wait before you ping someone:
https://www.kernel.org/doc/html/latest/process/submitting-patches.html#don-t-get-discouraged-or-impatient


> 
> Regarding your question: I like the block/ioprio.c changes in this version
> of this patch series much better than the changes in the previous version of
> this patch series.
> 
> No objections from my side about the changes in this patch (02/19).

You are one of the main people who didn't fancy the old user facing API.
I think that you (and Martin) gave some really good points, we listened
and came up with a new user facing API.

When you have the time, we would be very grateful if you could provide
a more thorough review, i.e. provide a R-b tag or give some feedback.

Your help is appreciated!


Kind regards,
Niklas
Bart Van Assche March 17, 2023, 4:56 p.m. UTC | #4
On 3/17/23 02:23, Niklas Cassel wrote:
> When you have the time, we would be very grateful if you could provide
> a more thorough review, i.e. provide a R-b tag or give some feedback.
> 
> Your help is appreciated!

Although I'm overloaded, I will try to find some time to review this 
patch series.

Thanks,

Bart.
diff mbox series

Patch

diff --git a/include/uapi/linux/ioprio.h b/include/uapi/linux/ioprio.h
index 4444b4e4fdad..607c7617b9d2 100644
--- a/include/uapi/linux/ioprio.h
+++ b/include/uapi/linux/ioprio.h
@@ -58,4 +58,53 @@  enum {
 #define IOPRIO_NORM	4
 #define IOPRIO_BE_NORM	IOPRIO_NORM
 
+/*
+ * The 10-bits between the priority class and the priority level are used to
+ * optionally define IO hints for any combination of IO priority class and
+ * level. Depending on the kernel configuration, IO scheduler being used and
+ * the target IO device being used, hints can influence how IOs are processed
+ * without affecting the IO scheduling ordering defined by the IO priority
+ * class and level.
+ */
+#define IOPRIO_HINT_SHIFT		IOPRIO_LEVEL_NR_BITS
+#define IOPRIO_HINT_NR_BITS		10
+#define IOPRIO_NR_HINTS			(1 << IOPRIO_HINT_NR_BITS)
+#define IOPRIO_HINT_MASK		(IOPRIO_NR_HINTS - 1)
+#define IOPRIO_PRIO_HINT(ioprio)	\
+	(((ioprio) >> IOPRIO_HINT_SHIFT) & IOPRIO_HINT_MASK)
+
+/*
+ * Alternate macro for IOPRIO_PRIO_VALUE() to define an IO priority with
+ * a class, level and hint.
+ */
+#define IOPRIO_PRIO_VALUE_HINT(class, level, hint)		 \
+	((((class) & IOPRIO_CLASS_MASK) << IOPRIO_CLASS_SHIFT) | \
+	 (((hint) & IOPRIO_HINT_MASK) << IOPRIO_HINT_SHIFT) |	 \
+	 ((level) & IOPRIO_LEVEL_MASK))
+
+/*
+ * IO hints.
+ */
+enum {
+	/* No hint */
+	IOPRIO_HINT_NONE = 0,
+
+	/*
+	 * Device command duration limits: indicate to the device a desired
+	 * duration limit for the commands that will be used to process an IO.
+	 * These will currently only be effective for SCSI and ATA devices that
+	 * support the command duration limits feature. If this feature is
+	 * enabled, then the commands issued to the device to process an IO with
+	 * one of these hints set will have the duration limit index (dld field)
+	 * set to the value of the hint.
+	 */
+	IOPRIO_HINT_DEV_DURATION_LIMIT_1 = 1,
+	IOPRIO_HINT_DEV_DURATION_LIMIT_2 = 2,
+	IOPRIO_HINT_DEV_DURATION_LIMIT_3 = 3,
+	IOPRIO_HINT_DEV_DURATION_LIMIT_4 = 4,
+	IOPRIO_HINT_DEV_DURATION_LIMIT_5 = 5,
+	IOPRIO_HINT_DEV_DURATION_LIMIT_6 = 6,
+	IOPRIO_HINT_DEV_DURATION_LIMIT_7 = 7,
+};
+
 #endif /* _UAPI_LINUX_IOPRIO_H */