From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=80.241.56.171 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796058150; b=dtWepL5PNPCmTCaQaa1E2OypgEQ8DaRpOfHa65RsSkznpYs6t4jSQncnI59KeVgvVhXs 7y6zdNDq6VA95AGEt6/LEzuVzOOhVcQfR8yiTITiUZ8gN2RbNR7c/67RjrrMbaWk2O7a3 0tvKGyeXKtvgIQwQVRTfDN64ET8OyZ2dswmZzFQ6UD53lP0Y2wfXaLDGIo4aOhWjNLmDA kZBEzA5zdeWQVy7JHYJ8gRMRV69fovuho5ssx40NeWdT5JSWHEGD9A7bwdPqylqcmUC3t OHt3wfapK0/WKKnCYXSkfI6Wqkz5Fi/SFGCRDSIUZLMoerROqIesrprzjkisZLyWhcA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796058150; h=DMARC-Filter:Received:DKIM-Signature:Message-ID:Subject:From: Reply-To:To:Cc:Date:In-Reply-To:References:Content-Type: Content-Transfer-Encoding:User-Agent:MIME-Version:X-MBO-RS-ID: X-MBO-RS-META:X-Rspamd-Queue-Id; bh=nyajPpyBavb0N5n7hhOQiItg+WEkBZS4zgC4lpI1zPU=; b=RFZij6ejNg8eq43QBb8CWJ8YxW+hCzbcniz4ljzti7qaG6vt/e9KFGczbn/J0ZtgKHbN N06tpqCVqCUiywTpu3+g/wwo75MS9xIegeE1Ww86KQaUrCNxN0tOKFgxTVBn2l08XzKDR wKgA3H7gYru15XzRPYADduVytIJqaGMKzzSy+owD7eAxBFrzi8m5p+cjMvNxny70bVVZI McQOpYELdLa/13Px0tVfA9gsONllxMvE2D8m43nFzN5x8V1tazO7oONnsJ2GdosDe4yP7 QbTFkA4gOFqQkkpTU9Joj82xegclap9vbg8H1INQlDL1jzS6TFCn/rriNTAw2Qd0mHA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=mailbox.org; spf=pass smtp.mailfrom=mailbox.org; dkim=pass header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=yFjzPog0; arc=none smtp.remote-ip=80.241.56.171 Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [80.241.56.171]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 38D67606A325; Mon, 30 Nov 2026 17:02:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 38D67606A325 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mailbox.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=mailbox.org header.i=@mailbox.org header.a=rsa-sha256 header.s=mail20150812 header.b=yFjzPog0 Received: from smtp102.mailbox.org (smtp102.mailbox.org [IPv6:2001:67c:2050:b231:465::102]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519MLKEM768 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4jdVgb4SZmzMkyn; Mon, 30 Nov 2026 18:02:19 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1796058139; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nyajPpyBavb0N5n7hhOQiItg+WEkBZS4zgC4lpI1zPU=; b=yFjzPog0mLbX6aFLYToHEaJapwzBVmRQWz1LrAV/G157koVkWLUGa9BQFtRccp2A4P5awD joBYq3HeDqqPM0/6pd5F25QGvZVirb9toRLndz93hOD32b7yGdJIehyp1EpINnVLEiKebC WMRoWWUB7Ji/7vnRNRsG0bsalIVrTN1dXjjZmnBLG/JEoMrxp7RWTwZkfG0TZHklrA9CXU NZHvNOgo/qZhXZ46OxauxTvd6Dkr5ZZrM2W34xuS4YsRSA0R7kjFnKHThOiR/kNIBVv9/P LRUAFMmMtIm27y9QjMzwQElRQ/M2jc7rvrTQZ1okSezm3h1hO4as7A18NoJMUw== Authentication-Results: outgoing_mbo_mout; dkim=none; spf=pass (outgoing_mbo_mout: domain of phasta@mailbox.org designates 2001:67c:2050:b231:465::102 as permitted sender) smtp.mailfrom=phasta@mailbox.org Message-ID: Subject: Re: [PATCH v4 5/5] rust: workqueue: add ScopedWork for non-'static work items From: Philipp Stanner Reply-To: phasta@kernel.org To: Tejun Heo , Alice Ryhl Cc: Lai Jiangshan , Danilo Krummrich , Miguel Ojeda , Boqun Feng , Gary Guo , =?ISO-8859-1?Q?Bj=F6rn?= Roy Baron , Benno Lossin , Andreas Hindborg , Trevor Gross , Daniel Almeida , Tamir Duberstein , Alexandre Courbot , Onur =?ISO-8859-1?Q?=D6zkan?= , John Hubbard , Philipp Stanner , rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org, driver-core@lists.linux.dev Date: Mon, 30 Nov 2026 18:02:11 +0100 In-Reply-To: <2ac377700fd9cd17c32aae2a9d3dbea7@kernel.org> References: <20261119-rust-workqueue-v4-0-707c68994940@google.com> <20261119-rust-workqueue-v4-5-707c68994940@google.com> <5eec17370f67438e43bb1c82b1d6a16b@kernel.org> <20261125181752.2027207-1-aliceryhl@google.com> <2ac377700fd9cd17c32aae2a9d3dbea7@kernel.org> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.60.2 (3.60.2-3.fc44) 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 X-MBO-RS-ID: 03dd2d0765108f44137 X-MBO-RS-META: san17nr4cdd9i7tzhd7wow8a35zisgr8 X-Rspamd-Queue-Id: 4jdVgb4SZmzMkyn Howdy, just 2 cents from me: On Fri, 2026-11-27 at 06:12 -1000, Tejun Heo wrote: > I didn't explain myself well. I'm not saying that the current scheme > doesn't work. My concern is how easy the interface is to use, and I wonde= r > whether taking workqueue lifetime out of the compiler-managed lifetime > rules could make it simpler. Something like the following: [=E2=80=A6] > Workqueue looks the way it does because it's C and leaves all lifetime > management to its users. Carrying the same model over to Rust and then > wrapping it for each use case seems like a missed opportunity. I don't > know Rust well, so I could just be blowing hot air. The thing is that in C the only real tools for lifetime management at our disposal are either doing it right manually with discipline, or to do refcounting. Exposed refcounting, as Danilo pointed out many times, has the disadvantage of objects being able to live longer than they should, like outliving driver unbind. Next to refcounting, Rust has borrow-checked lifetimes. IMO you are right that they make the code more difficult to write and read. But effectively, if you do "internal refcounting" then you just *re- implement* lifetime-checked references with refcounts: an internal refcount, wrapped-away for the user, and constructors and destructors (in?)transparently manage the count. Whereas with lifetimes the rules of drop order become visible to the user directly. Which is what you want, basically: tear down A before B. Refcounts would then, in this "Rust model", be the tool of choice if you really *don't know* how long something shall live, for example with objects you loan to userspace. Greetings, Philipp