From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.238 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796529193; b=xRDUWQY4I0eYQ9zfp7LY96eSdb/kQZ/zLNifdYZFy965HusH7keEKh7OaxSgRlh+bbn/ l0TuDGPbssqLVcyBJSXLudq95MOqfYOdpYtKucASsqG4qhBOrNyH4WaZS31NWE76f7Xjw p4PfB8xYPOYPdCSb0rj83iz6nCrvnvWWhKCL31yKujawXLAp7V8wxos/4fnBNqWD2PH2h rL4epymHX4tsuEjg0KwXxxeD6CTHKtlwzhGRllwa38SLpm79fM47Xcit4l+9fTclX5bNp 82RCob15xIa8aGdvBFXNElXLxvfXwEAbhUrZwknGQq0FnsRbnljsItUXbyjVOCswakA== 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=DQIoS1gr6q4uX5qGRsruN/HtkOCqfE4hPsSp2G5UKqljaqg2qITR6wRlvrYo0NDZJ0oQ cc2smodh6QphyJCLbiuK3CIhumZD/SlQcsJulYCn+opOMr3eVj+vhnLcLuPfTjVOB//TH hL/2F0ddymYZvmwMBBI90VZ/peIeKQSmhr6qGjmWgZU4yn4wuT37GZcCvIWuYHSAqY2VQ XtDEjQ4NEBzEgQCryi4eqxXukr75xcvMU/ghRK61xTo3P5ZJWKqgSMTtNF//URpnBRDpP duCMbab3VHHmNRjDk30bspobifC4ffhOsGDf5ThvWHRocF5PlKBtqma+R0uvvdPaFVA== 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=95.215.58.238 Received: from mta1.migadu.com (out-238.mta1.migadu.com [95.215.58.238]) (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 E390B606A321 for ; Sun, 6 Dec 2026 03:53:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E390B606A321 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-kernel@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-kernel@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-kernel@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.