Re: [Linux kernel bug] INFO: task hung in blk_mq_get_tag

From: Sam Sun
Date: Mon May 13 2024 - 08:58:08 EST


On Mon, May 13, 2024 at 6:54 PM Hillf Danton <hdanton@xxxxxxxx> wrote:
>
> On Mon, 13 May 2024 10:38:34 +0800 Sam Sun <samsun1006219@xxxxxxxxx>
> > Dear developers and maintainers,
> >
> > We encountered a task hung in function blk_mq_get_tag. It was tested
> > against the latest upstream kernel which was compiled by clang 14.
>
> BTW make it clear if repro is available and if you could test patches
> in reply.
>

Thanks for pointing this out! I am happy to help testing patches. As
for repro, I have a C repro available, but it is too long so that I
attached it to the first email. Should I just paste repro with bug
report?

> Thanks for your report. See if the below low-hang pear is sweet, I
> mean see if it could survive your repro.
>
> --- x/block/blk-mq-tag.c
> +++ y/block/blk-mq-tag.c
> @@ -180,8 +180,10 @@ unsigned int blk_mq_get_tag(struct blk_m
> sbitmap_prepare_to_wait(bt, ws, &wait, TASK_UNINTERRUPTIBLE);
>
> tag = __blk_mq_get_tag(data, bt);
> - if (tag != BLK_MQ_NO_TAG)
> + if (tag != BLK_MQ_NO_TAG) {
> + sbitmap_finish_wait(bt, ws, &wait);
> break;
> + }
>
> bt_prev = bt;
> io_schedule();
> @@ -208,8 +210,6 @@ unsigned int blk_mq_get_tag(struct blk_m
> ws = bt_wait_ptr(bt, data->hctx);
> } while (1);
>
> - sbitmap_finish_wait(bt, ws, &wait);
> -
> found_tag:
> /*
> * Give up this allocation if the hctx is inactive. The caller will
> --

I applied this patch and tried using the C repro, but it still crashed
with the same task hang kernel dump log.

Best Regards,
Yue