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=iQahV41VMPXVdqlWNrCe5xpuOBU/769ByU36brm0TSxv/6Zm3bMNMOer6QCxnE5QYYOq LL+WrlyjIQWH1sV0kpxAhM4jZX4wO/ifsUbpXvigtZqtkFckrWH9WT/0s2XfcpDYbosaO svDrMDKlkbAM2C64ah2EFVRmYcpEN68iRMJUmqf1k5tCEs5jNftJNBpF6mv0vANlpETGj 9RhtHD2QScyByqafY9jFcmn1VQv2ZfDtowfT5cFKEEO+8yMxNOg8nZI8ZDuU/zMQ7SM1z IIneckEM327rkFKT66261D++ppBeNhCHR1qiCXomu8Lm+0hkKvqNXa0E/a0K5mJhCnQ== 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=4d4qFvbIITUY/O+3U/MRzRE8qupbnbqYEiahJVwCBs+/6dsJzelT8dzIR8Sm29cwQ3N3 vcL4/u4lY2xIfKL2zpYM6WftM5y3Q3tgVnmVQPD6zt1W1mXfm1OFFKZAgHOlXS43vhke5 p/gK6Vl26zy5/nQ3zgBrj9PkcA56VPz8aM5FnEnxfzF2FVZT1LKM8AQ2wMvehmD6jw9eF IjvLI6FJLmHLFGR7dj0+UYDVl9Hv5RAQECN+WuI5E8K0lgqFixISbmalK93pc3Vx4co+x DVJcUVykMTPr+sg/QNk6IBFH2ZoW9bkWQHnirXAyjuaDoTApoAK/XhRWl4BhAlCf29w== 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 0A495606A31C for ; Mon, 30 Nov 2026 17:02:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 0A495606A31C 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: driver-core@lists.linux.dev 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