Linux block layer
 help / color / mirror / Atom feed
From: Bart Van Assche <bart.vanassche@gmail.com>
To: Yu Kuai <yukuai@fygo.io>, tj@kernel.org, josef@toxicpanda.com
Cc: axboe@kernel.dk, linux-block@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] blk-iocost: use irq-safe locking in cgroup handlers
Date: Mon, 1 Jun 2026 14:50:08 -0700	[thread overview]
Message-ID: <8709b8e7-8328-47e8-950f-e5726bd70dbc@gmail.com> (raw)
In-Reply-To: <20260601061312.896801-1-yukuai@fygo.io>

On 5/31/26 11:13 PM, Yu Kuai wrote:
> @@ -3378,14 +3378,14 @@ static u64 ioc_cost_model_prfill(struct seq_file *sf,
>   	if (!dname)
>   		return 0;
>   
> -	spin_lock(&ioc->lock);
> +	spin_lock_irq(&ioc->lock);
>   	seq_printf(sf, "%s ctrl=%s model=linear "
>   		   "rbps=%llu rseqiops=%llu rrandiops=%llu "
>   		   "wbps=%llu wseqiops=%llu wrandiops=%llu\n",
>   		   dname, ioc->user_cost_model ? "user" : "auto",
>   		   u[I_LCOEF_RBPS], u[I_LCOEF_RSEQIOPS], u[I_LCOEF_RRANDIOPS],
>   		   u[I_LCOEF_WBPS], u[I_LCOEF_WSEQIOPS], u[I_LCOEF_WRANDIOPS]);
> -	spin_unlock(&ioc->lock);
> +	spin_unlock_irq(&ioc->lock);
>   	return 0;
>   }

This change is wrong. ioc_cost_model_prfill() only has one caller,
namely blkcg_print_blkgs(). blkcg_print_blkgs() calls the above function
with interrupts disabled. The spin_unlock_irq(&ioc->lock) at the end of
the above function enables interrupts while q->queue_lock is held. If an
interrupt happens on the same CPU core before q->queue_lock is unlocked,
and that interrupt tries to lock q->queue_lock, a deadlock will occur.

Bart.

  parent reply	other threads:[~2026-06-01 21:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-01  6:13 [PATCH] blk-iocost: use irq-safe locking in cgroup handlers Yu Kuai
2026-06-01 18:59 ` Jens Axboe
2026-06-01 21:50 ` Bart Van Assche [this message]
2026-06-02  4:00   ` Yu Kuai
2026-06-02 13:25   ` Jens Axboe
2026-06-02 15:56     ` Yu Kuai
2026-06-02 16:11       ` Yu Kuai

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=8709b8e7-8328-47e8-950f-e5726bd70dbc@gmail.com \
    --to=bart.vanassche@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=josef@toxicpanda.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tj@kernel.org \
    --cc=yukuai@fygo.io \
    /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