From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.144 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796529193; b=nNrvtv8/sX0xhYlllJn+Ufuyo+4vSknp0l6QOmGxEvOaPnQ+b6aHU6iPplS5fQ2EYxw0 P0cyzWtrVB+aAfLPGUqgWWa+yk3SKSDRJgrZE1OQmFTvzGMWYCkKjhDyNYb6HubsFNVCa +0TLL58Xfe6Kx1agJK19hz7VHD3ag89X+BnocqExrBvmIp3+szk/XawJzZHiKwU9eP818 dkmprtYVC8eQ851Yzaj79YJ32McQSnG8qGJE3d0LUFvswqZQhoPDLHGh5Bv6uPIX/jKpZ 85RY1fzPTib9RtFSh9zVym60PGDa+6zPzf39tL7Z74A8YpeupHqAmjRR6t2y1DiOZsA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796529193; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Message-ID:Date:MIME-Version:User-Agent: Cc:Subject:To:References:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=FGEuKlS7IORBaxiHHFQ3xFdNxmnUvEi7A/lpc2RyVDo=; b=lcHyWebYhKqqs31bg9jRilnD8ScfNIFclPri0j2raSntCAzKhDrmBi350sMvUaMYWOnL BA1vPShK9t/z29vOw1iSJvh0mub9speNqlkODCZjqqO4s8cuoBkmXhuMYMXrmwyN7ca5d CSXBKD2dOv3jcZFl1X0F+/IYrT9n9IP9nBtyWuKqUVcxxF9GiJ2gQsK16EQFCptKcB9SO 7PqhYaGTvGfVQSlUDFskq1xTaOdaQ4cAC8cTvB83a8W3H2Tygm+wKMMWIjbQ3xfiYF3mt cjut1BxCS+U8gG7OiTRWN0oczLjSgluSyvaJt+o2WOt/CyBbJBDS4pw0gOeVJHmU/xw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b="B45iOf2/"; arc=none smtp.remote-ip=91.218.175.144 Received: from mta0.migadu.com (out-144.mta0.migadu.com [91.218.175.144]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DA0A4606A31F for ; Sun, 6 Dec 2026 03:53:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DA0A4606A31F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=B45iOf2/ X-Envelope-To: linux-block@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=V9Hu8sSxpTFxToQDcgsC9slLHGQklBeZXAqkWDLMHhY=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1796529189; v=1; x=1797133989; b=B45iOf2/IajzE1TCi9SGe1mZOUFHU6Bv57sTODI+WRTjn00b+psAE2o5BuzNW7LpjN/7Na5d uUAzpdoA7ufPFPv1Zwz5WvRCGcNJ33NrUThnXrm1UIgdLbm6hPsLnT60hlMyUp79ckzSLV1USko MFbX3tYRRFtyUzsVzLLFPfxA= X-Envelope-To: linux-block@vger.kernel.org Received: by smtp.migadu.com with ESMTPS id a683226c0f5045f1; Sun, 06 Dec 2026 03:53:09 +0000 X-Mizu-Trace-ID: a683226c0f5045f1 X-Migadu-Flow: FLOW_OUT Message-ID: <31ece5c2-a3bb-4c03-a41a-f596cf92845c@linux.dev> Date: Sun, 6 Dec 2026 11:53:02 +0800 X-Mailing-List: linux-block@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Cc: cui.tao@linux.dev, hch@lst.de, Tetsuo Handa , cuitao@kylinos.cn, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Shin'ichiro Kawasaki Subject: Re: [PATCH v10] loop: defer the queue limits clear to a workqueue To: Bart Van Assche , axboe@kernel.dk References: <20261126054223.176824-1-cui.tao@linux.dev> <20261203081657.2577866-1-cui.tao@linux.dev> From: Tao Cui In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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.