From: Damien Le Moal <damien.lemoal@opensource.wdc.com>
To: Jan Kara <jack@suse.cz>, Jens Axboe <axboe@kernel.dk>
Cc: linux-block@vger.kernel.org,
Niklas Cassel <Niklas.Cassel@wdc.com>,
Bart Van Assche <bvanassche@acm.org>
Subject: Re: [PATCH 6/8] blk-ioprio: Convert from rqos policy to direct call
Date: Thu, 16 Jun 2022 12:14:31 +0900 [thread overview]
Message-ID: <0f6e149e-b93f-1236-23a7-f7b8fa9719a1@opensource.wdc.com> (raw)
In-Reply-To: <20220615161616.5055-6-jack@suse.cz>
On 6/16/22 01:16, Jan Kara wrote:
> Convert blk-ioprio handling from a rqos policy to a direct call from
> blk_mq_submit_bio(). Firstly, blk-ioprio is not a much of a rqos policy
> anyway, it just needs a hook in bio submission path to set the bio's IO
> priority. Secondly, the rqos .track hook gets actually called too late
> for blk-ioprio purposes and introducing a special rqos hook just for
> blk-ioprio looks even weirder.
>
> Signed-off-by: Jan Kara <jack@suse.cz>
> ---
> block/blk-cgroup.c | 1 +
> block/blk-ioprio.c | 50 +++++-----------------------------------------
> block/blk-ioprio.h | 9 +++++++++
> block/blk-mq.c | 8 ++++++++
> 4 files changed, 23 insertions(+), 45 deletions(-)
>
> diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
> index 764e740b0c0f..6906981563f8 100644
> --- a/block/blk-cgroup.c
> +++ b/block/blk-cgroup.c
> @@ -1299,6 +1299,7 @@ int blkcg_init_queue(struct request_queue *q)
> ret = blk_iolatency_init(q);
> if (ret) {
> blk_throtl_exit(q);
> + blk_ioprio_exit(q);
> goto err_destroy_all;
> }
>
> diff --git a/block/blk-ioprio.c b/block/blk-ioprio.c
> index 3f605583598b..c00060a02c6e 100644
> --- a/block/blk-ioprio.c
> +++ b/block/blk-ioprio.c
> @@ -181,17 +181,12 @@ static struct blkcg_policy ioprio_policy = {
> .pd_free_fn = ioprio_free_pd,
> };
>
> -struct blk_ioprio {
> - struct rq_qos rqos;
> -};
> -
> -static void blkcg_ioprio_track(struct rq_qos *rqos, struct request *rq,
> - struct bio *bio)
> +void blkcg_set_ioprio(struct bio *bio)
> {
> struct ioprio_blkcg *blkcg = ioprio_blkcg_from_bio(bio);
> u16 prio;
>
> - if (blkcg->prio_policy == POLICY_NO_CHANGE)
> + if (!blkcg || blkcg->prio_policy == POLICY_NO_CHANGE)
See my comment on patch 8.
> return;
>
> /*
> @@ -207,49 +202,14 @@ static void blkcg_ioprio_track(struct rq_qos *rqos, struct request *rq,
> bio->bi_ioprio = prio;
> }
>
> -static void blkcg_ioprio_exit(struct rq_qos *rqos)
> +void blk_ioprio_exit(struct request_queue *q)
> {
> - struct blk_ioprio *blkioprio_blkg =
> - container_of(rqos, typeof(*blkioprio_blkg), rqos);
> -
> - blkcg_deactivate_policy(rqos->q, &ioprio_policy);
> - kfree(blkioprio_blkg);
> + blkcg_deactivate_policy(q, &ioprio_policy);
> }
>
> -static struct rq_qos_ops blkcg_ioprio_ops = {
> - .track = blkcg_ioprio_track,
> - .exit = blkcg_ioprio_exit,
> -};
> -
> int blk_ioprio_init(struct request_queue *q)
> {
> - struct blk_ioprio *blkioprio_blkg;
> - struct rq_qos *rqos;
> - int ret;
> -
> - blkioprio_blkg = kzalloc(sizeof(*blkioprio_blkg), GFP_KERNEL);
> - if (!blkioprio_blkg)
> - return -ENOMEM;
> -
> - ret = blkcg_activate_policy(q, &ioprio_policy);
> - if (ret) {
> - kfree(blkioprio_blkg);
> - return ret;
> - }
> -
> - rqos = &blkioprio_blkg->rqos;
> - rqos->id = RQ_QOS_IOPRIO;
> - rqos->ops = &blkcg_ioprio_ops;
> - rqos->q = q;
> -
> - /*
> - * Registering the rq-qos policy after activating the blk-cgroup
> - * policy guarantees that ioprio_blkcg_from_bio(bio) != NULL in the
> - * rq-qos callbacks.
> - */
> - rq_qos_add(q, rqos);
> -
> - return 0;
> + return blkcg_activate_policy(q, &ioprio_policy);
> }
>
> static int __init ioprio_init(void)
> diff --git a/block/blk-ioprio.h b/block/blk-ioprio.h
> index a7785c2f1aea..5a1eb550e178 100644
> --- a/block/blk-ioprio.h
> +++ b/block/blk-ioprio.h
> @@ -6,14 +6,23 @@
> #include <linux/kconfig.h>
>
> struct request_queue;
> +struct bio;
>
> #ifdef CONFIG_BLK_CGROUP_IOPRIO
> int blk_ioprio_init(struct request_queue *q);
> +void blk_ioprio_exit(struct request_queue *q);
> +void blkcg_set_ioprio(struct bio *bio);
> #else
> static inline int blk_ioprio_init(struct request_queue *q)
> {
> return 0;
> }
> +static inline void blk_ioprio_exit(struct request_queue *q)
> +{
> +}
> +static inline void blkcg_set_ioprio(struct bio *bio)
> +{
> +}
> #endif
>
> #endif /* _BLK_IOPRIO_H_ */
> diff --git a/block/blk-mq.c b/block/blk-mq.c
> index e9bf950983c7..67a7bfa58b7c 100644
> --- a/block/blk-mq.c
> +++ b/block/blk-mq.c
> @@ -42,6 +42,7 @@
> #include "blk-stat.h"
> #include "blk-mq-sched.h"
> #include "blk-rq-qos.h"
> +#include "blk-ioprio.h"
>
> static DEFINE_PER_CPU(struct llist_head, blk_cpu_done);
>
> @@ -2790,6 +2791,11 @@ static inline struct request *blk_mq_get_cached_request(struct request_queue *q,
> return rq;
> }
>
> +static void bio_set_ioprio(struct bio *bio)
> +{
> + blkcg_set_ioprio(bio);
> +}
> +
> /**
> * blk_mq_submit_bio - Create and send a request to block device.
> * @bio: Bio pointer.
> @@ -2830,6 +2836,8 @@ void blk_mq_submit_bio(struct bio *bio)
>
> trace_block_getrq(bio);
>
> + bio_set_ioprio(bio);
> +
> rq_qos_track(q, rq, bio);
>
> blk_mq_bio_to_request(rq, bio, nr_segs);
--
Damien Le Moal
Western Digital Research
next prev parent reply other threads:[~2022-06-16 3:14 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-15 16:16 [PATCH 0/8 v2] block: Fix IO priority mess Jan Kara
2022-06-15 16:16 ` [PATCH 1/8] block: Fix handling of tasks without ioprio in ioprio_get(2) Jan Kara
2022-06-15 16:16 ` [PATCH 2/8] block: Make ioprio_best() static Jan Kara
2022-06-15 16:16 ` [PATCH 3/8] block: fix default IO priority handling again Jan Kara
2022-06-15 16:16 ` [PATCH 4/8] block: Return effective IO priority from get_current_ioprio() Jan Kara
2022-06-15 16:16 ` [PATCH 5/8] blk-ioprio: Remove unneeded field Jan Kara
2022-06-15 16:16 ` [PATCH 6/8] blk-ioprio: Convert from rqos policy to direct call Jan Kara
2022-06-16 3:14 ` Damien Le Moal [this message]
2022-06-15 16:16 ` [PATCH 7/8] block: Initialize bio priority earlier Jan Kara
2022-06-15 16:16 ` [PATCH 8/8] block: Always initialize bio IO priority on submit Jan Kara
2022-06-16 3:15 ` Damien Le Moal
2022-06-16 11:23 ` Jan Kara
2022-06-16 12:24 ` Jan Kara
2022-06-17 0:04 ` Damien Le Moal
2022-06-17 11:49 ` Jan Kara
2022-06-17 12:03 ` Damien Le Moal
2022-06-17 14:54 ` Jan Kara
2022-06-17 0:05 ` Damien Le Moal
2022-06-17 11:52 ` Jan Kara
2022-06-17 12:00 ` Damien Le Moal
-- strict thread matches above, loose matches on Subject: below --
2022-06-20 16:11 [PATCH 0/8 v3] block: Fix IO priority mess Jan Kara
2022-06-20 16:11 ` [PATCH 6/8] blk-ioprio: Convert from rqos policy to direct call Jan Kara
2022-06-21 0:00 ` Damien Le Moal
2022-06-21 8:21 ` Jan Kara
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=0f6e149e-b93f-1236-23a7-f7b8fa9719a1@opensource.wdc.com \
--to=damien.lemoal@opensource.wdc.com \
--cc=Niklas.Cassel@wdc.com \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=jack@suse.cz \
--cc=linux-block@vger.kernel.org \
/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