From: Thomas Gleixner <tglx@linutronix.de>
To: Benno Lossin <benno.lossin@proton.me>,
Andreas Hindborg <nmi@metaspace.dk>,
Miguel Ojeda <ojeda@kernel.org>,
Alex Gaynor <alex.gaynor@gmail.com>,
Wedson Almeida Filho <wedsonaf@gmail.com>,
Anna-Maria Behnsen <anna-maria@linutronix.de>,
Frederic Weisbecker <frederic@kernel.org>
Cc: "Andreas Hindborg" <a.hindborg@samsung.com>,
"Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Alice Ryhl" <aliceryhl@google.com>,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] rust: hrtimer: introduce hrtimer support
Date: Tue, 30 Apr 2024 19:05:37 +0200 [thread overview]
Message-ID: <87o79qsrvi.ffs@tglx> (raw)
In-Reply-To: <a7a560c7-fb8c-4adf-9f46-2e272f24b335@proton.me>
On Fri, Apr 26 2024 at 07:52, Benno Lossin wrote:
> On 25.04.24 11:46, Andreas Hindborg wrote:
>> +#[pinned_drop]
>> +impl<T> PinnedDrop for Timer<T> {
>> + fn drop(self: Pin<&mut Self>) {
>> + // SAFETY: By struct invariant `self.timer` was initialized by
>> + // `hrtimer_init` so by C API contract it is safe to call
>> + // `hrtimer_cancel`.
>> + unsafe {
>> + bindings::hrtimer_cancel(self.timer.get());
>> + }
>> + }
>> +}
>
> Why is this needed? The only way to schedule a timer using this API is
> by having an `Arc` with a timer-containing struct inside. But to
> schedule the `Arc`, you consume one refcount which is then sent to the
> timer subsystem. So it is impossible for the refcount to drop below zero
> while the timer is scheduled, but not yet running.
> Do you need to call `hrtimer_cancel` after/while a timer is running?
>
> Also is it ok to call `hrtimer_cancel` inside the timer callback? Since
> that can happen when the timer callback owns the last refcount.
You cannot invoke hrtimer_cancel() from within the callback. That
deadlocks because hrtimer_cancel() waits for the callback to complete.
Thanks,
tglx
next prev parent reply other threads:[~2024-04-30 17:05 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-25 9:46 [PATCH] rust: hrtimer: introduce hrtimer support Andreas Hindborg
2024-04-26 7:52 ` Benno Lossin
2024-04-26 9:27 ` Andreas Hindborg
2024-04-29 17:31 ` Boqun Feng
2024-04-30 12:33 ` Andreas Hindborg
2024-04-30 15:17 ` Boqun Feng
2024-04-30 18:22 ` Andreas Hindborg
2024-04-30 17:05 ` Thomas Gleixner [this message]
2024-04-29 12:49 ` Alice Ryhl
2024-04-29 13:47 ` Andreas Hindborg
2024-04-30 17:02 ` Thomas Gleixner
2024-04-30 18:18 ` Andreas Hindborg
2024-04-30 22:25 ` Thomas Gleixner
2024-05-01 11:37 ` 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=87o79qsrvi.ffs@tglx \
--to=tglx@linutronix.de \
--cc=a.hindborg@samsung.com \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=anna-maria@linutronix.de \
--cc=benno.lossin@proton.me \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=frederic@kernel.org \
--cc=gary@garyguo.net \
--cc=linux-kernel@vger.kernel.org \
--cc=nmi@metaspace.dk \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=wedsonaf@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.