From: Andreas Hindborg <a.hindborg@kernel.org>
To: FUJITA Tomonori <tomo@flapping.org>
Cc: tomo@flapping.org, gary@garyguo.net, ojeda@kernel.org,
acourbot@nvidia.com, aliceryhl@google.com,
anna-maria@linutronix.de, bjorn3_gh@protonmail.com,
boqun@kernel.org, dakr@kernel.org, daniel.almeida@collabora.com,
frederic@kernel.org, jstultz@google.com, lossin@kernel.org,
lyude@redhat.com, sboyd@kernel.org, tamird@kernel.org,
tglx@kernel.org, tmgross@umich.edu, work@onurozkan.dev,
rust-for-linux@vger.kernel.org, fujita.tomonori@gmail.com
Subject: Re: [PATCH 0/4] Fix forward()/expires() racing with concurrent arming
Date: Thu, 20 Aug 2026 11:00:21 +0200 [thread overview]
Message-ID: <87h5kp88uy.fsf@kernel.org> (raw)
In-Reply-To: <20260819.220106.1561543001385383760.tomo@flapping.org>
FUJITA Tomonori <tomo@flapping.org> writes:
> On Tue, 18 Aug 2026 13:59:30 +0200
> Andreas Hindborg <a.hindborg@kernel.org> wrote:
>
>> "FUJITA Tomonori" <tomo@flapping.org> writes:
>>
>>> On Tue, 18 Aug 2026 11:02:27 +0200
>>> Andreas Hindborg <a.hindborg@kernel.org> wrote:
>>>
>>>>> perf and CFS bandwidth have a flag as well as a lock. The flag is "do
>>>>> not arm while armed", which is the same rule the types enforce
>>>>> here. rtc and the softlockup watchdog look like they cancel first and
>>>>> then start instead. None of them arms a timer that is active, so I
>>>>> would rather the abstraction did not allow it either. Does that seem
>>>>> reasonable?
>>>>
>>>> I am fine with preventing starting a timer that is Started or Running,
>>>> but I am not liking the `UniqueArc` requirement.
>>>>
>>>> I have a use case in `rnull` where I have to start a timer behind an
>>>> `Arc` with no way to obtain a `UniqueArc`, so I would prefer if that use
>>>> case keeps on working. Without this, I would have to allocate a box and
>>>> put it behind a lock, leading to double indirection.
>>>
>>> Before the UniqueArc requirement, I would like to check which timer
>>> you have in mind? The bandwidth timer, the per-command timer, or
>>> something else? The two seem to need different things, so I would
>>> rather not guess.
>>
>> The bandwidth timer. It is started from an `Arc<NullBlkDevice>:
>> HasHrTimer`. If we make the suggested change to `ArcTimerHandle`, I
>> think I would need to change the `NullBlkDevice::bandwidth_timer` from
>> an embedded `HrTimer` to a `SpinLock<Box<HrTimer>>` or something like
>> that.
>>
>> Maybe this is fine. I don't think it will affect performance for `rnull`
>> - this is already a throttled path. But it gives slightly more
>> convoluted code in the caller by reducing the way we can use the API.
>
> I think we can allow creating HrTimerArc<T> from Arc<T>, so that UniqueArc is
> not required. ListArc does the same with AtomicTracker, an atomic bool in the
> object that records whether a ListArc exists:
>
> HrTimerArc::try_from_arc(Arc<T>) -> Result<HrTimerArc<T>, Arc<T>>
>
> It fails when there is already another HrTimerArc for the object.
>
>> For the completion timer, the change you propose would work fine I
>> think. I would just start the timer via the unique request reference
>> rather than the shared one. This is probably a better way to do it
>> anyway.
>
> Agreed.
We discussed this at the call last night. We came to the conclusion that
we would like to experiment with the solution outlined by Gary, where we
inject `expires` into the callback handler, and the callback handler
returns a forward duration in addition to a restart value. Because with
that approach, we can avoid adding complexity to the Arc end of the API.
For the best implementation of this scheme, we probably need to change
some bits in the C code, add an additional path. Down the line, we could
also see how man callers of the C code can be changed to use this
pattern.
Do you want to send a patch based on this solution Tomo?
Best regards,
Andreas Hindborg
next prev parent reply other threads:[~2026-08-20 9:00 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-13 13:48 [PATCH 0/4] Fix forward()/expires() racing with concurrent arming FUJITA Tomonori
2026-08-13 13:48 ` [PATCH v1 1/4] rust: hrtimer: Introduce HrTimerArc to make arming exclusive FUJITA Tomonori
2026-08-13 13:48 ` [PATCH v1 2/4] rust: hrtimer: Introduce HrTimerPin " FUJITA Tomonori
2026-08-13 13:48 ` [PATCH v1 3/4] rust: hrtimer: Restrict expires() to safe contexts FUJITA Tomonori
2026-08-13 13:48 ` [PATCH v1 4/4] rust: hrtimer: Make HrTimer repr(transparent) FUJITA Tomonori
2026-08-13 14:16 ` [PATCH 0/4] Fix forward()/expires() racing with concurrent arming Gary Guo
2026-08-13 23:47 ` FUJITA Tomonori
2026-08-14 0:54 ` Gary Guo
2026-08-14 13:48 ` FUJITA Tomonori
2026-08-14 14:24 ` Gary Guo
2026-08-18 0:56 ` FUJITA Tomonori
2026-08-17 15:40 ` Gary Guo
2026-08-18 1:35 ` FUJITA Tomonori
2026-08-17 15:26 ` Andreas Hindborg
2026-08-18 2:26 ` FUJITA Tomonori
2026-08-18 9:02 ` Andreas Hindborg
2026-08-18 11:21 ` FUJITA Tomonori
2026-08-18 11:59 ` Andreas Hindborg
2026-08-19 13:01 ` FUJITA Tomonori
2026-08-20 9:00 ` Andreas Hindborg [this message]
2026-08-20 9:21 ` FUJITA Tomonori
2026-08-20 12:34 ` Andreas Hindborg
2026-08-20 12:53 ` FUJITA Tomonori
2026-08-21 7:13 ` Andreas Hindborg
2026-08-21 9:53 ` FUJITA Tomonori
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=87h5kp88uy.fsf@kernel.org \
--to=a.hindborg@kernel.org \
--cc=acourbot@nvidia.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=frederic@kernel.org \
--cc=fujita.tomonori@gmail.com \
--cc=gary@garyguo.net \
--cc=jstultz@google.com \
--cc=lossin@kernel.org \
--cc=lyude@redhat.com \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=sboyd@kernel.org \
--cc=tamird@kernel.org \
--cc=tglx@kernel.org \
--cc=tmgross@umich.edu \
--cc=tomo@flapping.org \
--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 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.