mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Tao Cui <cui.tao@linux.dev>,
	axboe@kernel.dk, hch@lst.de,
	Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Cc: cuitao@kylinos.cn, linux-block@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] loop: defer the queue limits clear to a workqueue
Date: Fri, 25 Sep 2026 09:22:00 -0700	[thread overview]
Message-ID: <bcf71ef1-427f-47ff-9880-c87ef0654259@acm.org> (raw)
In-Reply-To: <2df087b0-2a00-4e30-8e6c-d2f76e3ebd79@linux.dev>

On 9/24/26 6:29 PM, Tao Cui wrote:
> 在 2026/9/25 02:01, Bart Van Assche 写道:
>> On 9/24/26 3:20 AM, Tao Cui wrote:
>>>        queue_limits_commit_update(lo->lo_queue, &lim);
>>> +    mutex_unlock(&lo->clear_limits_lock);
>>
>> Since the mutex_lock(&lo->clear_limits_lock) call occurs after
>> queue_limits_start_update(), please move the
>> mutex_unlock(&lo->clear_limits_lock) call above the
>> queue_limits_commit_update() call. This has no impact on
>> correctness nor on the lock nesting order but makes the code
>> easier to follow.
>>
> 
> On moving mutex_unlock() above queue_limits_commit_update(): with
> the generation counters removed, the mutex is what keeps consuming
> clear_limits_mode and committing the resulting queue limits atomic
> with respect to a rebind. blk_mq_freeze_queue() is
> reference-counted, so the workfn and loop_change_fd() can both hold
> a freeze concurrently. If the workfn drops the mutex after consuming
> a non-zero mode but before queue_limits_commit_update(),
> loop_change_fd() could install a new backing file in that window,
> and the pending clear would then be committed to the new file. Since
> loop_change_fd() does not recompute the queue limits afterward, the
> incorrectly cleared discard limits would persist until the next
> reconfiguration.
> 
> For that reason, I'd prefer to keep the mutex held until after
> queue_limits_commit_update(). I can add a comment explaining this if
> that would help.

This seems fragile to me. Can this race be solved by calling
cancel_work_sync(&lo->clear_limits_work) before the backing file is
changed?

Thanks,

Bart.

  reply	other threads:[~2026-09-25 16:22 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-24 10:20 Tao Cui
2026-09-24 10:32 ` Tao Cui
2026-09-24 18:01 ` Bart Van Assche
2026-09-25  1:29   ` Tao Cui
2026-09-25 16:22     ` Bart Van Assche [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-08-28  7:20 Tao Cui
2026-08-28 16:34 ` Bart Van Assche
2026-08-31 13:34   ` Tao Cui
2026-08-31 16:25 ` Bart Van Assche
2026-09-01 13:14   ` Tao Cui
2026-09-01 17:29 ` Bart Van Assche

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=bcf71ef1-427f-47ff-9880-c87ef0654259@acm.org \
    --to=bvanassche@acm.org \
    --cc=axboe@kernel.dk \
    --cc=cui.tao@linux.dev \
    --cc=cuitao@kylinos.cn \
    --cc=hch@lst.de \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=penguin-kernel@I-love.SAKURA.ne.jp \
    /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®