mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tao Cui <cui.tao@linux.dev>
To: Bart Van Assche <bvanassche@acm.org>, axboe@kernel.dk
Cc: cui.tao@linux.dev, hch@lst.de,
	Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>,
	cuitao@kylinos.cn, linux-block@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Subject: Re: [PATCH v10] loop: defer the queue limits clear to a workqueue
Date: Sun, 6 Dec 2026 11:53:02 +0800	[thread overview]
Message-ID: <31ece5c2-a3bb-4c03-a41a-f596cf92845c@linux.dev> (raw)
In-Reply-To: <dc6eeb74-5cb4-41a5-8aaa-9f48a203bc36@linux.dev>

Hello, Bart,

在 2026/12/4 17:58, Tao Cui 写道:
> Hello, Bart,
> 
> 在 2026/12/4 1:18, Bart Van Assche 写道:
>> On 12/3/26 12:16 AM, Tao Cui wrote:
>>> +        lo->clear_wq = alloc_workqueue("loopc%d",
>>> +                        WQ_UNBOUND | WQ_MEM_RECLAIM,
>>> +                        0, lo->lo_number);
>> WQ_MEM_RECLAIM creates a rescuer thread per loop device. Is that flag
>> really needed? Additionally, has it been considered to use a single
>> workqueue for all loop devices?
> Agreed on the flag: v11 drops it, loop%d, which runs the request path
> itself, does not use WQ_MEM_RECLAIM either.
> 
> On a single workqueue for all devices: I'd rather not, if you're OK
> with that.  The work function reads the loop_device, and the
> per-device queue is what keeps that safe, since lo_free_disk() destroys
> it before the loop_device is freed.  A shared queue cannot be destroyed
> at teardown, so the work item would have to carry a new reference on
> the loop device.  loop%d is per device already, so I'd keep this shape
> unless you prefer the shared queue.
I implemented your shared-queue suggestion and measured it against the
per-device one, and the tradeoff I mentioned turns out not to be a
real problem: the work item just carries a reference on the loop
device (get_device() when queued, put_device() when done), and nothing
else needs to change.

With your suggestion the clear workqueue is allocated once at module
init ("loopc") instead of per device.  Both variants pass the same
suite with identical results (loop/011, the concurrency sweep, the
mkfs/unbind stress, with PROVE_LOCKING enabled), and 16 devices
clearing concurrently converge in the same ~38ms on both.  The only
measurable difference is device lifecycle churn: a create/configure/
unbind/remove cycle takes ~9.9us with the shared queue vs ~10.4us with
the per-device queue, since the per-device version allocates and
destroys its workqueue under the global workqueue mutex every cycle.

So I'll use the shared queue in the series.

Thanks,
Tao.

      reply	other threads:[~2026-12-06  3:53 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26  5:42 [PATCH v8] " Tao Cui
2026-11-26 10:06 ` Tao Cui
2026-11-26 13:56 ` [PATCH v9] " Tao Cui
2026-11-26 15:32   ` Bart Van Assche
2026-11-30 10:20     ` Tao Cui
2026-11-30 14:04       ` Bart Van Assche
2026-11-30 14:57         ` Tao Cui
2026-11-30 16:34           ` Bart Van Assche
2026-12-01 13:14             ` Tao Cui
2026-12-02 15:13               ` Bart Van Assche
2026-12-03  8:08                 ` Tao Cui
2026-12-03  8:16 ` [PATCH v10] " Tao Cui
2026-12-03 17:18   ` Bart Van Assche
2026-12-04  9:58     ` Tao Cui
2026-12-06  3:53       ` Tao Cui [this message]

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=31ece5c2-a3bb-4c03-a41a-f596cf92845c@linux.dev \
    --to=cui.tao@linux.dev \
    --cc=axboe@kernel.dk \
    --cc=bvanassche@acm.org \
    --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 \
    --cc=shinichiro.kawasaki@wdc.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®