From: Jan Kara <jack@suse.cz>
To: Yu Kuai <yukuai3@huawei.com>
Cc: jack@suse.cz, paolo.valente@linaro.org, axboe@kernel.dk,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
yi.zhang@huawei.com
Subject: Re: [PATCH -next 1/2] block, bfq: protect 'bfqd->queued' by 'bfqd->lock'
Date: Wed, 11 May 2022 15:52:27 +0200 [thread overview]
Message-ID: <20220511135227.lawvrlrajtyszwfb@quack3.lan> (raw)
In-Reply-To: <20220510131629.1964415-2-yukuai3@huawei.com>
On Tue 10-05-22 21:16:28, Yu Kuai wrote:
> If bfq_schedule_dispatch() is called from bfq_idle_slice_timer_body(),
> then 'bfqd->queued' is read without holding 'bfqd->lock'. This is
> wrong since it can be wrote concurrently.
>
> Fix the problem by holding 'bfqd->lock' for bfq_schedule_dispatch(),
> like everywhere else.
>
> Signed-off-by: Yu Kuai <yukuai3@huawei.com>
Looks good. Feel free to add:
Reviewed-by: Jan Kara <jack@suse.cz>
Honza
> ---
> block/bfq-iosched.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/block/bfq-iosched.c b/block/bfq-iosched.c
> index 272d48d8f326..61750696e87f 100644
> --- a/block/bfq-iosched.c
> +++ b/block/bfq-iosched.c
> @@ -456,6 +456,8 @@ static struct bfq_io_cq *bfq_bic_lookup(struct request_queue *q)
> */
> void bfq_schedule_dispatch(struct bfq_data *bfqd)
> {
> + lockdep_assert_held(&bfqd->lock);
> +
> if (bfqd->queued != 0) {
> bfq_log(bfqd, "schedule dispatch");
> blk_mq_run_hw_queues(bfqd->queue, true);
> @@ -6898,8 +6900,8 @@ bfq_idle_slice_timer_body(struct bfq_data *bfqd, struct bfq_queue *bfqq)
> bfq_bfqq_expire(bfqd, bfqq, true, reason);
>
> schedule_dispatch:
> - spin_unlock_irqrestore(&bfqd->lock, flags);
> bfq_schedule_dispatch(bfqd);
> + spin_unlock_irqrestore(&bfqd->lock, flags);
> }
>
> /*
> --
> 2.31.1
>
--
Jan Kara <jack@suse.com>
SUSE Labs, CR
next prev parent reply other threads:[~2022-05-11 13:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-10 13:16 [PATCH -next 0/2] block, bfq: make bfq_has_work() more accurate Yu Kuai
2022-05-10 13:16 ` [PATCH -next 1/2] block, bfq: protect 'bfqd->queued' by 'bfqd->lock' Yu Kuai
2022-05-11 13:52 ` Jan Kara [this message]
2022-05-10 13:16 ` [PATCH -next 2/2] block, bfq: make bfq_has_work() more accurate Yu Kuai
2022-05-11 14:08 ` Jan Kara
2022-05-12 1:30 ` yukuai (C)
2022-05-12 17:10 ` Jan Kara
2022-05-13 1:08 ` yukuai (C)
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=20220511135227.lawvrlrajtyszwfb@quack3.lan \
--to=jack@suse.cz \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paolo.valente@linaro.org \
--cc=yi.zhang@huawei.com \
--cc=yukuai3@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
all inboxes | Powered by JetHome®