All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] blk-ioprio: Introduce promote-to-rt policy
@ 2023-02-20 13:54 ` Hou Tao
  0 siblings, 0 replies; 12+ messages in thread
From: Hou Tao @ 2023-02-20 13:54 UTC (permalink / raw)
  To: linux-block
  Cc: Bart Van Assche, Jan Kara, Bagas Sanjaya, Jens Axboe, cgroups,
	Tejun Heo, Zefan Li, Johannes Weiner, Jonathan Corbet,
	linux-kernel, linux-doc, houtao1

From: Hou Tao <houtao1@huawei.com>

Since commit a78418e6a04c ("block: Always initialize bio IO priority on
submit"), bio->bi_ioprio will never be IOPRIO_CLASS_NONE when calling
blkcg_set_ioprio(), so there will be no way to promote the io-priority
of one cgroup to IOPRIO_CLASS_RT, because bi_ioprio will always be
greater than or equals to IOPRIO_CLASS_RT.

It seems possible to call blkcg_set_ioprio() first then try to
initialize bi_ioprio later in bio_set_ioprio(), but this doesn't work
for bio in which bi_ioprio is already initialized (e.g., direct-io), so
introduce a new ioprio policy to promote the iopriority of bio to
IOPRIO_CLASS_RT if the ioprio is not already RT.

So introduce a new promote-to-rt policy to achieve this. For none-to-rt
policy, although it doesn't work now, but considering that its purpose
was also to override the io-priority to RT and allow for a smoother
transition, just keep it and treat it as an alias of the promote-to-rt
policy.

Signed-off-by: Hou Tao <houtao1@huawei.com>
---
v2:
 * Simplify the implementation of promote-to-rt (from Bart)
 * Make none-to-rt to work again by treating it as an alias of
   the promote-to-rt policy (from Bart & Jan)
 * fix the style of new content in cgroup-v2.rst (from Bagas)
 * set the default priority level to 4 instead of 0 for promote-to-rt

v1: https://lore.kernel.org/linux-block/20230201045227.2203123-1-houtao@huaweicloud.com

 Documentation/admin-guide/cgroup-v2.rst | 42 ++++++++++++++-----------
 block/blk-ioprio.c                      | 23 ++++++++++++--
 2 files changed, 44 insertions(+), 21 deletions(-)

diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-guide/cgroup-v2.rst
index 74cec76be9f2..ccfb9fdfbc16 100644
--- a/Documentation/admin-guide/cgroup-v2.rst
+++ b/Documentation/admin-guide/cgroup-v2.rst
@@ -2021,31 +2021,33 @@ that attribute:
   no-change
 	Do not modify the I/O priority class.
 
-  none-to-rt
-	For requests that do not have an I/O priority class (NONE),
-	change the I/O priority class into RT. Do not modify
-	the I/O priority class of other requests.
+  promote-to-rt
+	For requests that have a no-RT I/O priority class, change it into RT.
+	Also change the priority level of these requests to 4. Do not modify
+	the I/O priority of requests that have priority class RT.
 
   restrict-to-be
 	For requests that do not have an I/O priority class or that have I/O
-	priority class RT, change it into BE. Do not modify the I/O priority
-	class of requests that have priority class IDLE.
+	priority class RT, change it into BE. Also change the priority level
+	of these requests to 0. Do not modify the I/O priority class of
+	requests that have priority class IDLE.
 
   idle
 	Change the I/O priority class of all requests into IDLE, the lowest
 	I/O priority class.
 
+  none-to-rt
+	Deprecated. Just an alias for promote-to-rt.
+
 The following numerical values are associated with the I/O priority policies:
 
-+-------------+---+
-| no-change   | 0 |
-+-------------+---+
-| none-to-rt  | 1 |
-+-------------+---+
-| rt-to-be    | 2 |
-+-------------+---+
-| all-to-idle | 3 |
-+-------------+---+
++----------------+---+
+| no-change      | 0 |
++----------------+---+
+| rt-to-be       | 2 |
++----------------+---+
+| all-to-idle    | 3 |
++----------------+---+
 
 The numerical value that corresponds to each I/O priority class is as follows:
 
@@ -2061,9 +2063,13 @@ The numerical value that corresponds to each I/O priority class is as follows:
 
 The algorithm to set the I/O priority class for a request is as follows:
 
-- Translate the I/O priority class policy into a number.
-- Change the request I/O priority class into the maximum of the I/O priority
-  class policy number and the numerical I/O priority class.
+- If I/O priority class policy is promote-to-rt, change the request I/O
+  priority class to IOPRIO_CLASS_RT and change the request I/O priority
+  level to 4.
+- If I/O priorityt class is not promote-to-rt, translate the I/O priority
+  class policy into a number, then change the request I/O priority class
+  into the maximum of the I/O priority class policy number and the numerical
+  I/O priority class.
 
 PID
 ---
diff --git a/block/blk-ioprio.c b/block/blk-ioprio.c
index 8bb6b8eba4ce..4eba569d4823 100644
--- a/block/blk-ioprio.c
+++ b/block/blk-ioprio.c
@@ -23,25 +23,28 @@
 /**
  * enum prio_policy - I/O priority class policy.
  * @POLICY_NO_CHANGE: (default) do not modify the I/O priority class.
- * @POLICY_NONE_TO_RT: modify IOPRIO_CLASS_NONE into IOPRIO_CLASS_RT.
+ * @POLICY_PROMOTE_TO_RT: modify no-IOPRIO_CLASS_RT to IOPRIO_CLASS_RT.
  * @POLICY_RESTRICT_TO_BE: modify IOPRIO_CLASS_NONE and IOPRIO_CLASS_RT into
  *		IOPRIO_CLASS_BE.
  * @POLICY_ALL_TO_IDLE: change the I/O priority class into IOPRIO_CLASS_IDLE.
+ * @POLICY_NONE_TO_RT: an alias for POLICY_PROMOTE_TO_RT.
  *
  * See also <linux/ioprio.h>.
  */
 enum prio_policy {
 	POLICY_NO_CHANGE	= 0,
-	POLICY_NONE_TO_RT	= 1,
+	POLICY_PROMOTE_TO_RT	= 1,
 	POLICY_RESTRICT_TO_BE	= 2,
 	POLICY_ALL_TO_IDLE	= 3,
+	POLICY_NONE_TO_RT	= 4,
 };
 
 static const char *policy_name[] = {
 	[POLICY_NO_CHANGE]	= "no-change",
-	[POLICY_NONE_TO_RT]	= "none-to-rt",
+	[POLICY_PROMOTE_TO_RT]	= "promote-to-rt",
 	[POLICY_RESTRICT_TO_BE]	= "restrict-to-be",
 	[POLICY_ALL_TO_IDLE]	= "idle",
+	[POLICY_NONE_TO_RT]	= "none-to-rt",
 };
 
 static struct blkcg_policy ioprio_policy;
@@ -189,6 +192,20 @@ void blkcg_set_ioprio(struct bio *bio)
 	if (!blkcg || blkcg->prio_policy == POLICY_NO_CHANGE)
 		return;
 
+	if (blkcg->prio_policy == POLICY_PROMOTE_TO_RT ||
+	    blkcg->prio_policy == POLICY_NONE_TO_RT) {
+		/*
+		 * For RT threads, the default priority level is 4 because
+		 * task_nice is 0. By promoting non-RT io-priority to RT-class
+		 * and default level 4, those requests that are already
+		 * RT-class but need a higher io-priority can use ioprio_set()
+		 * to achieve this.
+		 */
+		if (IOPRIO_PRIO_CLASS(bio->bi_ioprio) != IOPRIO_CLASS_RT)
+			bio->bi_ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_RT, 4);
+		return;
+	}
+
 	/*
 	 * Except for IOPRIO_CLASS_NONE, higher I/O priority numbers
 	 * correspond to a lower priority. Hence, the max_t() below selects
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v2] blk-ioprio: Introduce promote-to-rt policy
@ 2023-02-20 13:54 ` Hou Tao
  0 siblings, 0 replies; 12+ messages in thread
From: Hou Tao @ 2023-02-20 13:54 UTC (permalink / raw)
  To: linux-block-u79uwXL29TY76Z2rM5mHXA
  Cc: Bart Van Assche, Jan Kara, Bagas Sanjaya, Jens Axboe,
	cgroups-u79uwXL29TY76Z2rM5mHXA, Tejun Heo, Zefan Li,
	Johannes Weiner, Jonathan Corbet,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-doc-u79uwXL29TY76Z2rM5mHXA, houtao1-hv44wF8Li93QT0dZR+AlfA

From: Hou Tao <houtao1-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>

Since commit a78418e6a04c ("block: Always initialize bio IO priority on
submit"), bio->bi_ioprio will never be IOPRIO_CLASS_NONE when calling
blkcg_set_ioprio(), so there will be no way to promote the io-priority
of one cgroup to IOPRIO_CLASS_RT, because bi_ioprio will always be
greater than or equals to IOPRIO_CLASS_RT.

It seems possible to call blkcg_set_ioprio() first then try to
initialize bi_ioprio later in bio_set_ioprio(), but this doesn't work
for bio in which bi_ioprio is already initialized (e.g., direct-io), so
introduce a new ioprio policy to promote the iopriority of bio to
IOPRIO_CLASS_RT if the ioprio is not already RT.

So introduce a new promote-to-rt policy to achieve this. For none-to-rt
policy, although it doesn't work now, but considering that its purpose
was also to override the io-priority to RT and allow for a smoother
transition, just keep it and treat it as an alias of the promote-to-rt
policy.

Signed-off-by: Hou Tao <houtao1-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
---
v2:
 * Simplify the implementation of promote-to-rt (from Bart)
 * Make none-to-rt to work again by treating it as an alias of
   the promote-to-rt policy (from Bart & Jan)
 * fix the style of new content in cgroup-v2.rst (from Bagas)
 * set the default priority level to 4 instead of 0 for promote-to-rt

v1: https://lore.kernel.org/linux-block/20230201045227.2203123-1-houtao-XF6JlduFytWkHkcT6e4Xnw@public.gmane.org

 Documentation/admin-guide/cgroup-v2.rst | 42 ++++++++++++++-----------
 block/blk-ioprio.c                      | 23 ++++++++++++--
 2 files changed, 44 insertions(+), 21 deletions(-)

diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-guide/cgroup-v2.rst
index 74cec76be9f2..ccfb9fdfbc16 100644
--- a/Documentation/admin-guide/cgroup-v2.rst
+++ b/Documentation/admin-guide/cgroup-v2.rst
@@ -2021,31 +2021,33 @@ that attribute:
   no-change
 	Do not modify the I/O priority class.
 
-  none-to-rt
-	For requests that do not have an I/O priority class (NONE),
-	change the I/O priority class into RT. Do not modify
-	the I/O priority class of other requests.
+  promote-to-rt
+	For requests that have a no-RT I/O priority class, change it into RT.
+	Also change the priority level of these requests to 4. Do not modify
+	the I/O priority of requests that have priority class RT.
 
   restrict-to-be
 	For requests that do not have an I/O priority class or that have I/O
-	priority class RT, change it into BE. Do not modify the I/O priority
-	class of requests that have priority class IDLE.
+	priority class RT, change it into BE. Also change the priority level
+	of these requests to 0. Do not modify the I/O priority class of
+	requests that have priority class IDLE.
 
   idle
 	Change the I/O priority class of all requests into IDLE, the lowest
 	I/O priority class.
 
+  none-to-rt
+	Deprecated. Just an alias for promote-to-rt.
+
 The following numerical values are associated with the I/O priority policies:
 
-+-------------+---+
-| no-change   | 0 |
-+-------------+---+
-| none-to-rt  | 1 |
-+-------------+---+
-| rt-to-be    | 2 |
-+-------------+---+
-| all-to-idle | 3 |
-+-------------+---+
++----------------+---+
+| no-change      | 0 |
++----------------+---+
+| rt-to-be       | 2 |
++----------------+---+
+| all-to-idle    | 3 |
++----------------+---+
 
 The numerical value that corresponds to each I/O priority class is as follows:
 
@@ -2061,9 +2063,13 @@ The numerical value that corresponds to each I/O priority class is as follows:
 
 The algorithm to set the I/O priority class for a request is as follows:
 
-- Translate the I/O priority class policy into a number.
-- Change the request I/O priority class into the maximum of the I/O priority
-  class policy number and the numerical I/O priority class.
+- If I/O priority class policy is promote-to-rt, change the request I/O
+  priority class to IOPRIO_CLASS_RT and change the request I/O priority
+  level to 4.
+- If I/O priorityt class is not promote-to-rt, translate the I/O priority
+  class policy into a number, then change the request I/O priority class
+  into the maximum of the I/O priority class policy number and the numerical
+  I/O priority class.
 
 PID
 ---
diff --git a/block/blk-ioprio.c b/block/blk-ioprio.c
index 8bb6b8eba4ce..4eba569d4823 100644
--- a/block/blk-ioprio.c
+++ b/block/blk-ioprio.c
@@ -23,25 +23,28 @@
 /**
  * enum prio_policy - I/O priority class policy.
  * @POLICY_NO_CHANGE: (default) do not modify the I/O priority class.
- * @POLICY_NONE_TO_RT: modify IOPRIO_CLASS_NONE into IOPRIO_CLASS_RT.
+ * @POLICY_PROMOTE_TO_RT: modify no-IOPRIO_CLASS_RT to IOPRIO_CLASS_RT.
  * @POLICY_RESTRICT_TO_BE: modify IOPRIO_CLASS_NONE and IOPRIO_CLASS_RT into
  *		IOPRIO_CLASS_BE.
  * @POLICY_ALL_TO_IDLE: change the I/O priority class into IOPRIO_CLASS_IDLE.
+ * @POLICY_NONE_TO_RT: an alias for POLICY_PROMOTE_TO_RT.
  *
  * See also <linux/ioprio.h>.
  */
 enum prio_policy {
 	POLICY_NO_CHANGE	= 0,
-	POLICY_NONE_TO_RT	= 1,
+	POLICY_PROMOTE_TO_RT	= 1,
 	POLICY_RESTRICT_TO_BE	= 2,
 	POLICY_ALL_TO_IDLE	= 3,
+	POLICY_NONE_TO_RT	= 4,
 };
 
 static const char *policy_name[] = {
 	[POLICY_NO_CHANGE]	= "no-change",
-	[POLICY_NONE_TO_RT]	= "none-to-rt",
+	[POLICY_PROMOTE_TO_RT]	= "promote-to-rt",
 	[POLICY_RESTRICT_TO_BE]	= "restrict-to-be",
 	[POLICY_ALL_TO_IDLE]	= "idle",
+	[POLICY_NONE_TO_RT]	= "none-to-rt",
 };
 
 static struct blkcg_policy ioprio_policy;
@@ -189,6 +192,20 @@ void blkcg_set_ioprio(struct bio *bio)
 	if (!blkcg || blkcg->prio_policy == POLICY_NO_CHANGE)
 		return;
 
+	if (blkcg->prio_policy == POLICY_PROMOTE_TO_RT ||
+	    blkcg->prio_policy == POLICY_NONE_TO_RT) {
+		/*
+		 * For RT threads, the default priority level is 4 because
+		 * task_nice is 0. By promoting non-RT io-priority to RT-class
+		 * and default level 4, those requests that are already
+		 * RT-class but need a higher io-priority can use ioprio_set()
+		 * to achieve this.
+		 */
+		if (IOPRIO_PRIO_CLASS(bio->bi_ioprio) != IOPRIO_CLASS_RT)
+			bio->bi_ioprio = IOPRIO_PRIO_VALUE(IOPRIO_CLASS_RT, 4);
+		return;
+	}
+
 	/*
 	 * Except for IOPRIO_CLASS_NONE, higher I/O priority numbers
 	 * correspond to a lower priority. Hence, the max_t() below selects
-- 
2.29.2


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] blk-ioprio: Introduce promote-to-rt policy
  2023-02-20 13:54 ` Hou Tao
  (?)
@ 2023-02-21 16:37 ` Tejun Heo
  -1 siblings, 0 replies; 12+ messages in thread
From: Tejun Heo @ 2023-02-21 16:37 UTC (permalink / raw)
  To: Hou Tao
  Cc: linux-block, Bart Van Assche, Jan Kara, Bagas Sanjaya,
	Jens Axboe, cgroups, Zefan Li, Johannes Weiner, Jonathan Corbet,
	linux-kernel, linux-doc, houtao1

On Mon, Feb 20, 2023 at 09:54:28PM +0800, Hou Tao wrote:
> From: Hou Tao <houtao1@huawei.com>
> 
> Since commit a78418e6a04c ("block: Always initialize bio IO priority on
> submit"), bio->bi_ioprio will never be IOPRIO_CLASS_NONE when calling
> blkcg_set_ioprio(), so there will be no way to promote the io-priority
> of one cgroup to IOPRIO_CLASS_RT, because bi_ioprio will always be
> greater than or equals to IOPRIO_CLASS_RT.
> 
> It seems possible to call blkcg_set_ioprio() first then try to
> initialize bi_ioprio later in bio_set_ioprio(), but this doesn't work
> for bio in which bi_ioprio is already initialized (e.g., direct-io), so
> introduce a new ioprio policy to promote the iopriority of bio to
> IOPRIO_CLASS_RT if the ioprio is not already RT.
> 
> So introduce a new promote-to-rt policy to achieve this. For none-to-rt
> policy, although it doesn't work now, but considering that its purpose
> was also to override the io-priority to RT and allow for a smoother
> transition, just keep it and treat it as an alias of the promote-to-rt
> policy.
> 
> Signed-off-by: Hou Tao <houtao1@huawei.com>

Acked-by: Tejun Heo <tj@kernel.org>

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] blk-ioprio: Introduce promote-to-rt policy
  2023-02-20 13:54 ` Hou Tao
  (?)
  (?)
@ 2023-02-21 17:27 ` Bart Van Assche
  -1 siblings, 0 replies; 12+ messages in thread
From: Bart Van Assche @ 2023-02-21 17:27 UTC (permalink / raw)
  To: Hou Tao, linux-block
  Cc: Jan Kara, Bagas Sanjaya, Jens Axboe, cgroups, Tejun Heo,
	Zefan Li, Johannes Weiner, Jonathan Corbet, linux-kernel,
	linux-doc, houtao1

On 2/20/23 05:54, Hou Tao wrote:
> From: Hou Tao <houtao1@huawei.com>

Reviewed-by: Bart Van Assche <bvanassche@acm.org>

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] blk-ioprio: Introduce promote-to-rt policy
  2023-02-20 13:54 ` Hou Tao
                   ` (2 preceding siblings ...)
  (?)
@ 2023-02-21 18:04 ` Chaitanya Kulkarni
  -1 siblings, 0 replies; 12+ messages in thread
From: Chaitanya Kulkarni @ 2023-02-21 18:04 UTC (permalink / raw)
  To: Hou Tao, linux-block
  Cc: Bart Van Assche, Jan Kara, Bagas Sanjaya, Jens Axboe, cgroups,
	Tejun Heo, Zefan Li, Johannes Weiner, Jonathan Corbet,
	linux-kernel, linux-doc, houtao1

On 2/20/2023 5:54 AM, Hou Tao wrote:
> From: Hou Tao <houtao1@huawei.com>
> 
> Since commit a78418e6a04c ("block: Always initialize bio IO priority on
> submit"), bio->bi_ioprio will never be IOPRIO_CLASS_NONE when calling
> blkcg_set_ioprio(), so there will be no way to promote the io-priority
> of one cgroup to IOPRIO_CLASS_RT, because bi_ioprio will always be
> greater than or equals to IOPRIO_CLASS_RT.
> 
> It seems possible to call blkcg_set_ioprio() first then try to
> initialize bi_ioprio later in bio_set_ioprio(), but this doesn't work
> for bio in which bi_ioprio is already initialized (e.g., direct-io), so
> introduce a new ioprio policy to promote the iopriority of bio to
> IOPRIO_CLASS_RT if the ioprio is not already RT.
> 
> So introduce a new promote-to-rt policy to achieve this. For none-to-rt
> policy, although it doesn't work now, but considering that its purpose
> was also to override the io-priority to RT and allow for a smoother
> transition, just keep it and treat it as an alias of the promote-to-rt
> policy.
> 
> Signed-off-by: Hou Tao <houtao1@huawei.com>


Thanks for updating documentation and adding meaningful comment.

Looks good.

Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>

-ck



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] blk-ioprio: Introduce promote-to-rt policy
@ 2023-02-22  7:38   ` Bagas Sanjaya
  0 siblings, 0 replies; 12+ messages in thread
From: Bagas Sanjaya @ 2023-02-22  7:38 UTC (permalink / raw)
  To: Hou Tao, linux-block
  Cc: Bart Van Assche, Jan Kara, Jens Axboe, cgroups, Tejun Heo,
	Zefan Li, Johannes Weiner, Jonathan Corbet, linux-kernel,
	linux-doc, houtao1

On 2/20/23 20:54, Hou Tao wrote:
> diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-guide/cgroup-v2.rst
> index 74cec76be9f2..ccfb9fdfbc16 100644
> --- a/Documentation/admin-guide/cgroup-v2.rst
> +++ b/Documentation/admin-guide/cgroup-v2.rst
> @@ -2021,31 +2021,33 @@ that attribute:
>    no-change
>  	Do not modify the I/O priority class.
>  
> -  none-to-rt
> -	For requests that do not have an I/O priority class (NONE),
> -	change the I/O priority class into RT. Do not modify
> -	the I/O priority class of other requests.
> +  promote-to-rt
> +	For requests that have a no-RT I/O priority class, change it into RT.
"non-RT" maybe? Or the original wording is better?
> +	Also change the priority level of these requests to 4. Do not modify
> +	the I/O priority of requests that have priority class RT.>  
>    restrict-to-be
>  	For requests that do not have an I/O priority class or that have I/O
> -	priority class RT, change it into BE. Do not modify the I/O priority
> -	class of requests that have priority class IDLE.
> +	priority class RT, change it into BE. Also change the priority level
> +	of these requests to 0. Do not modify the I/O priority class of
> +	requests that have priority class IDLE.
>  
>    idle
>  	Change the I/O priority class of all requests into IDLE, the lowest
>  	I/O priority class.
>  
> +  none-to-rt
> +	Deprecated. Just an alias for promote-to-rt.
> +
>  The following numerical values are associated with the I/O priority policies:
>  
> -+-------------+---+
> -| no-change   | 0 |
> -+-------------+---+
> -| none-to-rt  | 1 |
> -+-------------+---+
> -| rt-to-be    | 2 |
> -+-------------+---+
> -| all-to-idle | 3 |
> -+-------------+---+
> ++----------------+---+
> +| no-change      | 0 |
> ++----------------+---+
> +| rt-to-be       | 2 |
> ++----------------+---+
> +| all-to-idle    | 3 |
> ++----------------+---+
>  
>  The numerical value that corresponds to each I/O priority class is as follows:
>  
> @@ -2061,9 +2063,13 @@ The numerical value that corresponds to each I/O priority class is as follows:
>  
>  The algorithm to set the I/O priority class for a request is as follows:
>  
> -- Translate the I/O priority class policy into a number.
> -- Change the request I/O priority class into the maximum of the I/O priority
> -  class policy number and the numerical I/O priority class.
> +- If I/O priority class policy is promote-to-rt, change the request I/O
> +  priority class to IOPRIO_CLASS_RT and change the request I/O priority
> +  level to 4.
> +- If I/O priorityt class is not promote-to-rt, translate the I/O priority
> +  class policy into a number, then change the request I/O priority class
> +  into the maximum of the I/O priority class policy number and the numerical
> +  I/O priority class.
>  
>  PID
>  ---

The rest is LGTM.

-- 
An old man doll... just what I always wanted! - Clara


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] blk-ioprio: Introduce promote-to-rt policy
@ 2023-02-22  7:38   ` Bagas Sanjaya
  0 siblings, 0 replies; 12+ messages in thread
From: Bagas Sanjaya @ 2023-02-22  7:38 UTC (permalink / raw)
  To: Hou Tao, linux-block-u79uwXL29TY76Z2rM5mHXA
  Cc: Bart Van Assche, Jan Kara, Jens Axboe,
	cgroups-u79uwXL29TY76Z2rM5mHXA, Tejun Heo, Zefan Li,
	Johannes Weiner, Jonathan Corbet,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-doc-u79uwXL29TY76Z2rM5mHXA, houtao1-hv44wF8Li93QT0dZR+AlfA

On 2/20/23 20:54, Hou Tao wrote:
> diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-guide/cgroup-v2.rst
> index 74cec76be9f2..ccfb9fdfbc16 100644
> --- a/Documentation/admin-guide/cgroup-v2.rst
> +++ b/Documentation/admin-guide/cgroup-v2.rst
> @@ -2021,31 +2021,33 @@ that attribute:
>    no-change
>  	Do not modify the I/O priority class.
>  
> -  none-to-rt
> -	For requests that do not have an I/O priority class (NONE),
> -	change the I/O priority class into RT. Do not modify
> -	the I/O priority class of other requests.
> +  promote-to-rt
> +	For requests that have a no-RT I/O priority class, change it into RT.
"non-RT" maybe? Or the original wording is better?
> +	Also change the priority level of these requests to 4. Do not modify
> +	the I/O priority of requests that have priority class RT.>  
>    restrict-to-be
>  	For requests that do not have an I/O priority class or that have I/O
> -	priority class RT, change it into BE. Do not modify the I/O priority
> -	class of requests that have priority class IDLE.
> +	priority class RT, change it into BE. Also change the priority level
> +	of these requests to 0. Do not modify the I/O priority class of
> +	requests that have priority class IDLE.
>  
>    idle
>  	Change the I/O priority class of all requests into IDLE, the lowest
>  	I/O priority class.
>  
> +  none-to-rt
> +	Deprecated. Just an alias for promote-to-rt.
> +
>  The following numerical values are associated with the I/O priority policies:
>  
> -+-------------+---+
> -| no-change   | 0 |
> -+-------------+---+
> -| none-to-rt  | 1 |
> -+-------------+---+
> -| rt-to-be    | 2 |
> -+-------------+---+
> -| all-to-idle | 3 |
> -+-------------+---+
> ++----------------+---+
> +| no-change      | 0 |
> ++----------------+---+
> +| rt-to-be       | 2 |
> ++----------------+---+
> +| all-to-idle    | 3 |
> ++----------------+---+
>  
>  The numerical value that corresponds to each I/O priority class is as follows:
>  
> @@ -2061,9 +2063,13 @@ The numerical value that corresponds to each I/O priority class is as follows:
>  
>  The algorithm to set the I/O priority class for a request is as follows:
>  
> -- Translate the I/O priority class policy into a number.
> -- Change the request I/O priority class into the maximum of the I/O priority
> -  class policy number and the numerical I/O priority class.
> +- If I/O priority class policy is promote-to-rt, change the request I/O
> +  priority class to IOPRIO_CLASS_RT and change the request I/O priority
> +  level to 4.
> +- If I/O priorityt class is not promote-to-rt, translate the I/O priority
> +  class policy into a number, then change the request I/O priority class
> +  into the maximum of the I/O priority class policy number and the numerical
> +  I/O priority class.
>  
>  PID
>  ---

The rest is LGTM.

-- 
An old man doll... just what I always wanted! - Clara


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] blk-ioprio: Introduce promote-to-rt policy
@ 2023-02-23  1:08     ` Hou Tao
  0 siblings, 0 replies; 12+ messages in thread
From: Hou Tao @ 2023-02-23  1:08 UTC (permalink / raw)
  To: Bagas Sanjaya, linux-block
  Cc: Bart Van Assche, Jan Kara, Jens Axboe, cgroups, Tejun Heo,
	Zefan Li, Johannes Weiner, Jonathan Corbet, linux-kernel,
	linux-doc, houtao1

Hi,

On 2/22/2023 3:38 PM, Bagas Sanjaya wrote:
> On 2/20/23 20:54, Hou Tao wrote:
>> diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-guide/cgroup-v2.rst
>> index 74cec76be9f2..ccfb9fdfbc16 100644
>> --- a/Documentation/admin-guide/cgroup-v2.rst
>> +++ b/Documentation/admin-guide/cgroup-v2.rst
>> @@ -2021,31 +2021,33 @@ that attribute:
>>    no-change
>>  	Do not modify the I/O priority class.
>>  
>> -  none-to-rt
>> -	For requests that do not have an I/O priority class (NONE),
>> -	change the I/O priority class into RT. Do not modify
>> -	the I/O priority class of other requests.
>> +  promote-to-rt
>> +	For requests that have a no-RT I/O priority class, change it into RT.
> "non-RT" maybe? Or the original wording is better?
Because promote-to-rt doesn't work like none-to-rt, so using the original word
is incorrect. Will fix it to non-RT in v3.
>> +	Also change the priority level of these requests to 4. Do not modify
>> +	the I/O priority of requests that have priority class RT.>  
>>    restrict-to-be
>>  	For requests that do not have an I/O priority class or that have I/O
>> -	priority class RT, change it into BE. Do not modify the I/O priority
>> -	class of requests that have priority class IDLE.
>> +	priority class RT, change it into BE. Also change the priority level
>> +	of these requests to 0. Do not modify the I/O priority class of
>> +	requests that have priority class IDLE.
>>  
>>    idle
>>  	Change the I/O priority class of all requests into IDLE, the lowest
>>  	I/O priority class.
>>  
>> +  none-to-rt
>> +	Deprecated. Just an alias for promote-to-rt.
>> +
>>  The following numerical values are associated with the I/O priority policies:
>>  
>> -+-------------+---+
>> -| no-change   | 0 |
>> -+-------------+---+
>> -| none-to-rt  | 1 |
>> -+-------------+---+
>> -| rt-to-be    | 2 |
>> -+-------------+---+
>> -| all-to-idle | 3 |
>> -+-------------+---+
>> ++----------------+---+
>> +| no-change      | 0 |
>> ++----------------+---+
>> +| rt-to-be       | 2 |
>> ++----------------+---+
>> +| all-to-idle    | 3 |
>> ++----------------+---+
>>  
>>  The numerical value that corresponds to each I/O priority class is as follows:
>>  
>> @@ -2061,9 +2063,13 @@ The numerical value that corresponds to each I/O priority class is as follows:
>>  
>>  The algorithm to set the I/O priority class for a request is as follows:
>>  
>> -- Translate the I/O priority class policy into a number.
>> -- Change the request I/O priority class into the maximum of the I/O priority
>> -  class policy number and the numerical I/O priority class.
>> +- If I/O priority class policy is promote-to-rt, change the request I/O
>> +  priority class to IOPRIO_CLASS_RT and change the request I/O priority
>> +  level to 4.
>> +- If I/O priorityt class is not promote-to-rt, translate the I/O priority
>> +  class policy into a number, then change the request I/O priority class
>> +  into the maximum of the I/O priority class policy number and the numerical
>> +  I/O priority class.
>>  
>>  PID
>>  ---
> The rest is LGTM.
Thanks for you review.
>


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] blk-ioprio: Introduce promote-to-rt policy
@ 2023-02-23  1:08     ` Hou Tao
  0 siblings, 0 replies; 12+ messages in thread
From: Hou Tao @ 2023-02-23  1:08 UTC (permalink / raw)
  To: Bagas Sanjaya, linux-block-u79uwXL29TY76Z2rM5mHXA
  Cc: Bart Van Assche, Jan Kara, Jens Axboe,
	cgroups-u79uwXL29TY76Z2rM5mHXA, Tejun Heo, Zefan Li,
	Johannes Weiner, Jonathan Corbet,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA,
	linux-doc-u79uwXL29TY76Z2rM5mHXA, houtao1-hv44wF8Li93QT0dZR+AlfA

Hi,

On 2/22/2023 3:38 PM, Bagas Sanjaya wrote:
> On 2/20/23 20:54, Hou Tao wrote:
>> diff --git a/Documentation/admin-guide/cgroup-v2.rst b/Documentation/admin-guide/cgroup-v2.rst
>> index 74cec76be9f2..ccfb9fdfbc16 100644
>> --- a/Documentation/admin-guide/cgroup-v2.rst
>> +++ b/Documentation/admin-guide/cgroup-v2.rst
>> @@ -2021,31 +2021,33 @@ that attribute:
>>    no-change
>>  	Do not modify the I/O priority class.
>>  
>> -  none-to-rt
>> -	For requests that do not have an I/O priority class (NONE),
>> -	change the I/O priority class into RT. Do not modify
>> -	the I/O priority class of other requests.
>> +  promote-to-rt
>> +	For requests that have a no-RT I/O priority class, change it into RT.
> "non-RT" maybe? Or the original wording is better?
Because promote-to-rt doesn't work like none-to-rt, so using the original word
is incorrect. Will fix it to non-RT in v3.
>> +	Also change the priority level of these requests to 4. Do not modify
>> +	the I/O priority of requests that have priority class RT.>  
>>    restrict-to-be
>>  	For requests that do not have an I/O priority class or that have I/O
>> -	priority class RT, change it into BE. Do not modify the I/O priority
>> -	class of requests that have priority class IDLE.
>> +	priority class RT, change it into BE. Also change the priority level
>> +	of these requests to 0. Do not modify the I/O priority class of
>> +	requests that have priority class IDLE.
>>  
>>    idle
>>  	Change the I/O priority class of all requests into IDLE, the lowest
>>  	I/O priority class.
>>  
>> +  none-to-rt
>> +	Deprecated. Just an alias for promote-to-rt.
>> +
>>  The following numerical values are associated with the I/O priority policies:
>>  
>> -+-------------+---+
>> -| no-change   | 0 |
>> -+-------------+---+
>> -| none-to-rt  | 1 |
>> -+-------------+---+
>> -| rt-to-be    | 2 |
>> -+-------------+---+
>> -| all-to-idle | 3 |
>> -+-------------+---+
>> ++----------------+---+
>> +| no-change      | 0 |
>> ++----------------+---+
>> +| rt-to-be       | 2 |
>> ++----------------+---+
>> +| all-to-idle    | 3 |
>> ++----------------+---+
>>  
>>  The numerical value that corresponds to each I/O priority class is as follows:
>>  
>> @@ -2061,9 +2063,13 @@ The numerical value that corresponds to each I/O priority class is as follows:
>>  
>>  The algorithm to set the I/O priority class for a request is as follows:
>>  
>> -- Translate the I/O priority class policy into a number.
>> -- Change the request I/O priority class into the maximum of the I/O priority
>> -  class policy number and the numerical I/O priority class.
>> +- If I/O priority class policy is promote-to-rt, change the request I/O
>> +  priority class to IOPRIO_CLASS_RT and change the request I/O priority
>> +  level to 4.
>> +- If I/O priorityt class is not promote-to-rt, translate the I/O priority
>> +  class policy into a number, then change the request I/O priority class
>> +  into the maximum of the I/O priority class policy number and the numerical
>> +  I/O priority class.
>>  
>>  PID
>>  ---
> The rest is LGTM.
Thanks for you review.
>


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] blk-ioprio: Introduce promote-to-rt policy
  2023-02-20 13:54 ` Hou Tao
                   ` (4 preceding siblings ...)
  (?)
@ 2023-02-27 13:03 ` Jan Kara
  2023-02-27 13:56   ` Hou Tao
  -1 siblings, 1 reply; 12+ messages in thread
From: Jan Kara @ 2023-02-27 13:03 UTC (permalink / raw)
  To: Hou Tao
  Cc: linux-block, Bart Van Assche, Jan Kara, Bagas Sanjaya,
	Jens Axboe, cgroups, Tejun Heo, Zefan Li, Johannes Weiner,
	Jonathan Corbet, linux-kernel, linux-doc, houtao1

On Mon 20-02-23 21:54:28, Hou Tao wrote:
> From: Hou Tao <houtao1@huawei.com>
> 
> Since commit a78418e6a04c ("block: Always initialize bio IO priority on
> submit"), bio->bi_ioprio will never be IOPRIO_CLASS_NONE when calling
> blkcg_set_ioprio(), so there will be no way to promote the io-priority
> of one cgroup to IOPRIO_CLASS_RT, because bi_ioprio will always be
> greater than or equals to IOPRIO_CLASS_RT.
> 
> It seems possible to call blkcg_set_ioprio() first then try to
> initialize bi_ioprio later in bio_set_ioprio(), but this doesn't work
> for bio in which bi_ioprio is already initialized (e.g., direct-io), so
> introduce a new ioprio policy to promote the iopriority of bio to
> IOPRIO_CLASS_RT if the ioprio is not already RT.
> 
> So introduce a new promote-to-rt policy to achieve this. For none-to-rt
> policy, although it doesn't work now, but considering that its purpose
> was also to override the io-priority to RT and allow for a smoother
> transition, just keep it and treat it as an alias of the promote-to-rt
> policy.
> 
> Signed-off-by: Hou Tao <houtao1@huawei.com>

Looks good to me. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

Just one question regarding doc below:

> ++----------------+---+
> +| no-change      | 0 |
> ++----------------+---+
> +| rt-to-be       | 2 |
> ++----------------+---+
> +| all-to-idle    | 3 |
> ++----------------+---+

Shouldn't there be preempt-to-rt somewhere in this table as well? Or why
this this in the doc at all? I'd consider the numbers to be kernel internal
thing?

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] blk-ioprio: Introduce promote-to-rt policy
  2023-02-27 13:03 ` Jan Kara
@ 2023-02-27 13:56   ` Hou Tao
  2023-02-27 15:02     ` Jan Kara
  0 siblings, 1 reply; 12+ messages in thread
From: Hou Tao @ 2023-02-27 13:56 UTC (permalink / raw)
  To: Jan Kara
  Cc: linux-block, Bart Van Assche, Bagas Sanjaya, Jens Axboe, cgroups,
	Tejun Heo, Zefan Li, Johannes Weiner, Jonathan Corbet,
	linux-kernel, linux-doc, houtao1

Hi

On 2/27/2023 9:03 PM, Jan Kara wrote:
> On Mon 20-02-23 21:54:28, Hou Tao wrote:
>> From: Hou Tao <houtao1@huawei.com>
>>
>> Since commit a78418e6a04c ("block: Always initialize bio IO priority on
>> submit"), bio->bi_ioprio will never be IOPRIO_CLASS_NONE when calling
>> blkcg_set_ioprio(), so there will be no way to promote the io-priority
>> of one cgroup to IOPRIO_CLASS_RT, because bi_ioprio will always be
>> greater than or equals to IOPRIO_CLASS_RT.
>>
>> It seems possible to call blkcg_set_ioprio() first then try to
>> initialize bi_ioprio later in bio_set_ioprio(), but this doesn't work
>> for bio in which bi_ioprio is already initialized (e.g., direct-io), so
>> introduce a new ioprio policy to promote the iopriority of bio to
>> IOPRIO_CLASS_RT if the ioprio is not already RT.
>>
>> So introduce a new promote-to-rt policy to achieve this. For none-to-rt
>> policy, although it doesn't work now, but considering that its purpose
>> was also to override the io-priority to RT and allow for a smoother
>> transition, just keep it and treat it as an alias of the promote-to-rt
>> policy.
>>
>> Signed-off-by: Hou Tao <houtao1@huawei.com>
> Looks good to me. Feel free to add:
>
> Reviewed-by: Jan Kara <jack@suse.cz>
Thanks for the review.
>
> Just one question regarding doc below:
>
>> ++----------------+---+
>> +| no-change      | 0 |
>> ++----------------+---+
>> +| rt-to-be       | 2 |
>> ++----------------+---+
>> +| all-to-idle    | 3 |
>> ++----------------+---+
> Shouldn't there be preempt-to-rt somewhere in this table as well? Or why
> this this in the doc at all? I'd consider the numbers to be kernel internal
> thing?
These numbers are used in the algorithm paragraph below to explain how the final
ioprio is calculated. For prompt-to-rt policy, the algorithm is different and
the number is unnecessary.

> 								Honza


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v2] blk-ioprio: Introduce promote-to-rt policy
  2023-02-27 13:56   ` Hou Tao
@ 2023-02-27 15:02     ` Jan Kara
  0 siblings, 0 replies; 12+ messages in thread
From: Jan Kara @ 2023-02-27 15:02 UTC (permalink / raw)
  To: Hou Tao
  Cc: Jan Kara, linux-block, Bart Van Assche, Bagas Sanjaya,
	Jens Axboe, cgroups, Tejun Heo, Zefan Li, Johannes Weiner,
	Jonathan Corbet, linux-kernel, linux-doc, houtao1

On Mon 27-02-23 21:56:25, Hou Tao wrote:
> Hi
> 
> On 2/27/2023 9:03 PM, Jan Kara wrote:
> > On Mon 20-02-23 21:54:28, Hou Tao wrote:
> >> From: Hou Tao <houtao1@huawei.com>
> >>
> >> Since commit a78418e6a04c ("block: Always initialize bio IO priority on
> >> submit"), bio->bi_ioprio will never be IOPRIO_CLASS_NONE when calling
> >> blkcg_set_ioprio(), so there will be no way to promote the io-priority
> >> of one cgroup to IOPRIO_CLASS_RT, because bi_ioprio will always be
> >> greater than or equals to IOPRIO_CLASS_RT.
> >>
> >> It seems possible to call blkcg_set_ioprio() first then try to
> >> initialize bi_ioprio later in bio_set_ioprio(), but this doesn't work
> >> for bio in which bi_ioprio is already initialized (e.g., direct-io), so
> >> introduce a new ioprio policy to promote the iopriority of bio to
> >> IOPRIO_CLASS_RT if the ioprio is not already RT.
> >>
> >> So introduce a new promote-to-rt policy to achieve this. For none-to-rt
> >> policy, although it doesn't work now, but considering that its purpose
> >> was also to override the io-priority to RT and allow for a smoother
> >> transition, just keep it and treat it as an alias of the promote-to-rt
> >> policy.
> >>
> >> Signed-off-by: Hou Tao <houtao1@huawei.com>
> > Looks good to me. Feel free to add:
> >
> > Reviewed-by: Jan Kara <jack@suse.cz>
> Thanks for the review.
> >
> > Just one question regarding doc below:
> >
> >> ++----------------+---+
> >> +| no-change      | 0 |
> >> ++----------------+---+
> >> +| rt-to-be       | 2 |
> >> ++----------------+---+
> >> +| all-to-idle    | 3 |
> >> ++----------------+---+
> > Shouldn't there be preempt-to-rt somewhere in this table as well? Or why
> > this this in the doc at all? I'd consider the numbers to be kernel internal
> > thing?
> These numbers are used in the algorithm paragraph below to explain how the final
> ioprio is calculated. For prompt-to-rt policy, the algorithm is different and
> the number is unnecessary.

I see, thanks for explanation.

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2023-02-27 15:02 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-20 13:54 [PATCH v2] blk-ioprio: Introduce promote-to-rt policy Hou Tao
2023-02-20 13:54 ` Hou Tao
2023-02-21 16:37 ` Tejun Heo
2023-02-21 17:27 ` Bart Van Assche
2023-02-21 18:04 ` Chaitanya Kulkarni
2023-02-22  7:38 ` Bagas Sanjaya
2023-02-22  7:38   ` Bagas Sanjaya
2023-02-23  1:08   ` Hou Tao
2023-02-23  1:08     ` Hou Tao
2023-02-27 13:03 ` Jan Kara
2023-02-27 13:56   ` Hou Tao
2023-02-27 15:02     ` Jan Kara

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.