From: Thomas Gleixner <tglx@kernel.org>
To: "Gary Guo" <gary@garyguo.net>, "Gary Guo" <gary@garyguo.net>,
"Andreas Hindborg" <a.hindborg@kernel.org>,
"Anna-Maria Behnsen" <anna-maria@linutronix.de>,
"Frederic Weisbecker" <frederic@kernel.org>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <lossin@kernel.org>,
"Alice Ryhl" <aliceryhl@google.com>,
"Trevor Gross" <tmgross@umich.edu>,
"Danilo Krummrich" <dakr@kernel.org>,
"Daniel Almeida" <daniel.almeida@collabora.com>,
"Tamir Duberstein" <tamird@kernel.org>,
"Alexandre Courbot" <acourbot@nvidia.com>,
"Onur Özkan" <work@onurozkan.dev>,
"Jani Nikula" <jani.nikula@linux.intel.com>,
"Joonas Lahtinen" <joonas.lahtinen@linux.intel.com>,
"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
"Tvrtko Ursulin" <tursulin@ursulin.net>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Lyude Paul" <lyude@redhat.com>,
"John Stultz" <jstultz@google.com>,
"Stephen Boyd" <sboyd@kernel.org>
Cc: Miguel Ojeda <ojeda@kernel.org>, Boqun Feng <boqun@kernel.org>,
FUJITA Tomonori <fujita.tomonori@gmail.com>,
linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org,
intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 1/6] hrtimer: add expiry injecting callback variant
Date: Thu, 01 Oct 2026 15:45:50 +0200 [thread overview]
Message-ID: <87fqyph6up.ffs@fw13> (raw)
In-Reply-To: <DLT1I5F55U3W.2N237BGZ1EDF1@garyguo.net>
On Thu, Oct 01 2026 at 00:29, Gary Guo wrote:
> On Wed Sep 30, 2026 at 10:43 PM BST, Thomas Gleixner wrote:
>> So what's your actual argument that you can't build a "safe" Rust API
>> around this?
>
> Sure, if all expiry read/update functions have their _safe_from_callback
> variant.
Why do you need more than the safe forward variant to solve
the problem of preventing that a callback forward and a concurrent start
collide and create inconsistent state?
Just to take a step back. We have two sorts of hrtimer usage:
1) a simple "start, wait or cancel, done" sequence, e.g. nanosleep()
2) a more complex scenario which has to take care of concurrency,
e.g. POSIX interval timers
#1 does not need any of this
#2 has almost always a related data structure, which needs to be kept
consistent by some form of serialization. The embedded hrtimer is
just a small low level detail of the overall use case logic.
The base lock _cannot_ provide the required serialization and any
amount of 'callback safe' addons will not change that.
I completely understand that you want to create a fool proof hrtimer
Rust API, but honestly that's just creating an illusion of correctness.
If the core provides you a get_expiry_safe() variant, which takes the
lock before reading, then what is the return value?
It's a snapshot which might be invalid at the time of usage already.
Ergo, if you need consistent state across concurrent contexts including
the callback, then the only solution for that is external serialization.
I'm not against hardening the core implementation against API misuse
where it makes sense. But that's hardening and cannot solve the other
problems which are solely in the scope of the usage sites.
Thanks,
tglx
next prev parent reply other threads:[~2026-10-01 13:45 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-25 12:16 [PATCH 0/6] hrtimer: add an " Andreas Hindborg
2026-08-25 12:16 ` [PATCH 1/6] hrtimer: add " Andreas Hindborg
2026-09-29 20:56 ` Thomas Gleixner
2026-09-30 13:14 ` Gary Guo
2026-09-30 21:43 ` Thomas Gleixner
2026-09-30 23:29 ` Gary Guo
2026-10-01 13:45 ` Thomas Gleixner [this message]
2026-08-25 12:16 ` [PATCH 2/6] drm/i915/pmu: use the expiry injecting hrtimer callback Andreas Hindborg
2026-08-25 12:16 ` [PATCH 3/6] rust: hrtimer: use the expiry injecting callback variant Andreas Hindborg
2026-08-25 12:16 ` [PATCH 4/6] rust: hrtimer: restrict expires() to exclusive access Andreas Hindborg
2026-08-25 12:16 ` [PATCH 5/6] rust: hrtimer: document deadlock when starting a timer in its handler Andreas Hindborg
2026-08-25 13:31 ` Gary Guo
2026-08-26 9:31 ` Andreas Hindborg
2026-08-25 12:16 ` [PATCH 6/6] rust: hrtimer: Make HrTimer repr(transparent) Andreas Hindborg
2026-08-25 13:33 ` Gary Guo
2026-08-26 9:30 ` Andreas Hindborg
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=87fqyph6up.ffs@fw13 \
--to=tglx@kernel.org \
--cc=a.hindborg@kernel.org \
--cc=acourbot@nvidia.com \
--cc=airlied@gmail.com \
--cc=aliceryhl@google.com \
--cc=anna-maria@linutronix.de \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun@kernel.org \
--cc=dakr@kernel.org \
--cc=daniel.almeida@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=frederic@kernel.org \
--cc=fujita.tomonori@gmail.com \
--cc=gary@garyguo.net \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=jstultz@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lossin@kernel.org \
--cc=lyude@redhat.com \
--cc=ojeda@kernel.org \
--cc=rodrigo.vivi@intel.com \
--cc=rust-for-linux@vger.kernel.org \
--cc=sboyd@kernel.org \
--cc=simona@ffwll.ch \
--cc=tamird@kernel.org \
--cc=tmgross@umich.edu \
--cc=tursulin@ursulin.net \
--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®