mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Philipp Stanner <phasta@mailbox.org>
To: Tejun Heo <tj@kernel.org>, Alice Ryhl <aliceryhl@google.com>
Cc: "Lai Jiangshan" <jiangshanlai@gmail.com>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Miguel Ojeda" <ojeda@kernel.org>,
	"Boqun Feng" <boqun@kernel.org>, "Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Benno Lossin" <lossin@kernel.org>,
	"Andreas Hindborg" <a.hindborg@kernel.org>,
	"Trevor Gross" <tmgross@umich.edu>,
	"Daniel Almeida" <daniel.almeida@collabora.com>,
	"Tamir Duberstein" <tamird@kernel.org>,
	"Alexandre Courbot" <acourbot@nvidia.com>,
	"Onur Özkan" <work@onurozkan.dev>,
	"John Hubbard" <jhubbard@nvidia.com>,
	"Philipp Stanner" <phasta@kernel.org>,
	rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
	driver-core@lists.linux.dev
Subject: Re: [PATCH v4 5/5] rust: workqueue: add ScopedWork for non-'static work items
Date: Mon, 30 Nov 2026 18:02:11 +0100	[thread overview]
Message-ID: <f15f3e98ccd4d74a02c75cd8b0034efed8db0c09.camel@mailbox.org> (raw)
In-Reply-To: <2ac377700fd9cd17c32aae2a9d3dbea7@kernel.org>

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 wonder
> whether taking workqueue lifetime out of the compiler-managed lifetime
> rules could make it simpler. Something like the following:

[…]

> 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

  reply	other threads:[~2026-11-30 17:02 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 14:12 [PATCH v4 0/5] workqueue: OwnedQueue and ScopedWork Alice Ryhl
2026-11-19 14:12 ` [PATCH v4 1/5] rust: workqueue: support stack-allocated work items Alice Ryhl
2026-11-19 14:37   ` Gary Guo
2026-11-19 15:17     ` Alice Ryhl
2026-11-25 16:56       ` Gary Guo
2026-11-19 14:12 ` [PATCH v4 2/5] rust: workqueue: restrict delayed work to global wqs Alice Ryhl
2026-11-19 14:12 ` [PATCH v4 3/5] rust: workqueue: create workqueue subdirectory Alice Ryhl
2026-11-19 14:37   ` Gary Guo
2026-11-19 14:12 ` [PATCH v4 4/5] rust: workqueue: add creation of workqueues Alice Ryhl
2026-11-25 16:57   ` Gary Guo
2026-11-26  7:56   ` kernel test robot
2026-11-19 14:12 ` [PATCH v4 5/5] rust: workqueue: add ScopedWork for non-'static work items Alice Ryhl
2026-11-25 16:44   ` Tejun Heo
2026-11-25 17:09     ` Gary Guo
2026-11-25 18:17     ` Alice Ryhl
2026-11-26 12:22       ` Tejun Heo
2026-11-26 12:43         ` Alice Ryhl
2026-11-27 16:12           ` Tejun Heo
2026-11-30 17:02             ` Philipp Stanner [this message]
2026-11-30 17:04             ` Alice Ryhl
2026-11-25 17:09   ` Gary Guo

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=f15f3e98ccd4d74a02c75cd8b0034efed8db0c09.camel@mailbox.org \
    --to=phasta@mailbox.org \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=dakr@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=driver-core@lists.linux.dev \
    --cc=gary@garyguo.net \
    --cc=jhubbard@nvidia.com \
    --cc=jiangshanlai@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=phasta@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tamird@kernel.org \
    --cc=tj@kernel.org \
    --cc=tmgross@umich.edu \
    --cc=work@onurozkan.dev \
    /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®