From: Tejun Heo <tj@kernel.org>
To: Jinke Han <hanjinke.666@bytedance.com>
Cc: axboe@kernel.dk, linux-block@vger.kernel.org,
linux-kernel@vger.kernel.org, cgroups@vger.kernel.org
Subject: Re: [PATCH] block: don't allow the same type rq_qos add more than once
Date: Mon, 18 Jul 2022 09:22:47 -1000 [thread overview]
Message-ID: <YtWzB6T7GBb7fiNe@slm.duckdns.org> (raw)
In-Reply-To: <20220718083646.67601-1-hanjinke.666@bytedance.com>
Hello,
On Mon, Jul 18, 2022 at 04:36:46PM +0800, Jinke Han wrote:
> When the io.cost.qos file is written by two cpu concurrently, rq_qos may
> be added to one disk twice. In that case, there will be two iocs enabled
> and running on one disk. They own different iocgs on their active list.
> In the ioc_timer_fn function, because of the iocgs from two ioc have the
> same root iocg, the root iocg's walk_list may be overwritten by each
> other and this lead to list add/del corrutions in building or destorying
> the inner_walk list.
>
> And so far, the blk-rq-qos framework works in case that one instance for
> one type rq_qos per queue by default. This patch make this explicit and
> also fix the crash above.
Ah, good catch. Looks great. Just a few nits below.
> Signed-off-by: hanjinke <hanjinke.666@bytedance.com>
Can you please use your full name in FIRST LAST form on the SOB line?
> --- a/block/blk-iocost.c
> +++ b/block/blk-iocost.c
> @@ -2886,7 +2886,12 @@ static int blk_iocost_init(struct request_queue *q)
> * called before policy activation completion, can't assume that the
> * target bio has an iocg associated and need to test for NULL iocg.
> */
> - rq_qos_add(q, rqos);
> + ret = rq_qos_add(q, rqos);
> + if (ret) {
> + free_percpu(ioc->pcpu_stat);
> + kfree(ioc);
> + return ret;
Given that these get repeated for policy activation failure, it'd prolly be
better to factor them out at the end and use gotos and make all of the users
use the same pattern.
> +static inline int rq_qos_add(struct request_queue *q, struct rq_qos *rqos)
> {
> /*
> * No IO can be in-flight when adding rqos, so freeze queue, which
> @@ -98,6 +98,8 @@ static inline void rq_qos_add(struct request_queue *q, struct rq_qos *rqos)
> blk_mq_freeze_queue(q);
>
> spin_lock_irq(&q->queue_lock);
> + if (rq_qos_id(q, rqos->id))
> + goto out;
Maybe rename the goto label to ebusy so that it's `goto ebusy`?
Other than the nits, please feel free to add
Acked-by: Tejun Heo <tj@kernel.org>
Thanks.
--
tejun
next prev parent reply other threads:[~2022-07-18 19:22 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-18 8:36 Jinke Han
2022-07-18 19:22 ` Tejun Heo [this message]
2022-07-19 6:53 ` Muchun Song
2022-07-19 7:50 ` hanjinke
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=YtWzB6T7GBb7fiNe@slm.duckdns.org \
--to=tj@kernel.org \
--cc=axboe@kernel.dk \
--cc=cgroups@vger.kernel.org \
--cc=hanjinke.666@bytedance.com \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@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
all inboxes | Powered by JetHome®