From: Ankur Arora <ankur.a.arora@oracle.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Ankur Arora <ankur.a.arora@oracle.com>,
linux-kernel@vger.kernel.org,
Linux-Arch <linux-arch@vger.kernel.org>,
linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org,
bpf@vger.kernel.org, Catalin Marinas <catalin.marinas@arm.com>,
Will Deacon <will@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Andrew Morton <akpm@linux-foundation.org>,
Mark Rutland <mark.rutland@arm.com>,
Haris Okanovic <harisokn@amazon.com>,
"Christoph Lameter (Ampere)" <cl@gentwo.org>,
Alexei Starovoitov <ast@kernel.org>,
"Rafael J . Wysocki" <rafael@kernel.org>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
Kumar Kartikeya Dwivedi <memxor@gmail.com>,
zhenglifeng1@huawei.com, xueshuai@linux.alibaba.com,
Joao Martins <joao.m.martins@oracle.com>,
Boris Ostrovsky <boris.ostrovsky@oracle.com>,
Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Subject: Re: [RESEND PATCH v7 2/7] arm64: barrier: Support smp_cond_load_relaxed_timeout()
Date: Tue, 28 Oct 2025 11:01:22 -0700 [thread overview]
Message-ID: <87qzumq51p.fsf@oracle.com> (raw)
In-Reply-To: <3642cfd1-7da6-4a75-80b7-00c21ab6955f@app.fastmail.com>
Arnd Bergmann <arnd@arndb.de> writes:
> On Tue, Oct 28, 2025, at 06:31, Ankur Arora wrote:
>> Support waiting in smp_cond_load_relaxed_timeout() via
>> __cmpwait_relaxed(). Limit this to when the event-stream is enabled,
>> to ensure that we wake from WFE periodically and don't block forever
>> if there are no stores to the cacheline.
>>
>> In the unlikely event that the event-stream is unavailable, fallback
>> to spin-waiting.
>>
>> Also set SMP_TIMEOUT_POLL_COUNT to 1 so we do the time-check for each
>> iteration in smp_cond_load_relaxed_timeout().
>
> After I looked at the entire series again, this one feels like
> a missed opportunity. Especially on low-power systems but possibly
> on any ARMv9.2+ implementation including Cortex-A320, it would
> be nice to be able to both turn off the event stream and also
> make this function take fewer wakeups:
>
>> +/* Re-declared here to avoid include dependency. */
>> +extern bool arch_timer_evtstrm_available(void);
>> +
>> +#define cpu_poll_relax(ptr, val) \
>> +do { \
>> + if (arch_timer_evtstrm_available()) \
>> + __cmpwait_relaxed(ptr, val); \
>> + else \
>> + cpu_relax(); \
>> +} while (0)
>> +
>
> Since the caller knows exactly how long it wants to wait for,
> we should be able to fit a 'wfet' based primitive in here and
> pass the timeout as another argument.
Per se, I don't disagree with this when it comes to WFET.
Handling a timeout, however, is messier when we use other mechanisms.
Some problems that came up in my earlier discussions with Catalin:
- when using WFE, we also need some notion of slack
- and if a caller specifies only a small or no slack, then we need
to combine WFE+cpu_relax()
- for platforms that only use a polling primitive, we want to check
the clock only intermittently for power reasons.
Now, this could be done with an architecture specific spin-count.
However, if the caller specifies a small slack, then we might need
to we check the clock more often as we get closer to the deadline etc.
A smaller problem was that different users want different clocks and so
folding the timeout in a 'timeout_cond_expr' lets us do away with the
interface having to handle any of that.
I had earlier versions [v2] [v3] which had rather elaborate policies for
handling timeout, slack etc. But, given that the current users of the
interface don't actually care about precision, all of that seemed
a little overengineered.
[v2] https://lore.kernel.org/lkml/20250502085223.1316925-1-ankur.a.arora@oracle.com/#r
[v3] https://lore.kernel.org/lkml/20250627044805.945491-1-ankur.a.arora@oracle.com/
--
ankur
next prev parent reply other threads:[~2025-10-28 18:01 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-28 5:31 [RESEND PATCH v7 0/7] barrier: Add smp_cond_load_*_timeout() Ankur Arora
2025-10-28 5:31 ` [RESEND PATCH v7 1/7] asm-generic: barrier: Add smp_cond_load_relaxed_timeout() Ankur Arora
2025-10-28 9:42 ` Arnd Bergmann
2025-10-29 3:17 ` Ankur Arora
2025-11-02 21:52 ` Arnd Bergmann
2025-11-03 21:41 ` Ankur Arora
2025-10-28 16:13 ` Christoph Lameter (Ampere)
2025-10-28 5:31 ` [RESEND PATCH v7 2/7] arm64: barrier: Support smp_cond_load_relaxed_timeout() Ankur Arora
2025-10-28 8:42 ` Arnd Bergmann
2025-10-28 16:21 ` Christoph Lameter (Ampere)
2025-10-28 18:01 ` Ankur Arora [this message]
2025-10-28 21:17 ` Catalin Marinas
2025-11-02 21:39 ` Arnd Bergmann
2025-11-03 21:00 ` Ankur Arora
2025-11-04 13:55 ` Catalin Marinas
2025-11-05 8:27 ` Ankur Arora
2025-11-05 10:37 ` Arnd Bergmann
2025-11-06 0:36 ` Ankur Arora
2025-10-28 5:31 ` [RESEND PATCH v7 3/7] arm64: rqspinlock: Remove private copy of smp_cond_load_acquire_timewait() Ankur Arora
2025-10-28 5:31 ` [RESEND PATCH v7 4/7] asm-generic: barrier: Add smp_cond_load_acquire_timeout() Ankur Arora
2025-10-28 5:31 ` [RESEND PATCH v7 5/7] atomic: Add atomic_cond_read_*_timeout() Ankur Arora
2025-10-28 5:31 ` [RESEND PATCH v7 6/7] rqspinlock: Use smp_cond_load_acquire_timeout() Ankur Arora
2025-10-28 5:31 ` [RESEND PATCH v7 7/7] cpuidle/poll_state: Poll via smp_cond_load_relaxed_timeout() Ankur Arora
2025-10-28 12:30 ` Rafael J. Wysocki
2025-10-29 4:41 ` Ankur Arora
2025-10-29 18:53 ` Rafael J. Wysocki
2025-10-29 19:13 ` Ankur Arora
2025-10-29 20:29 ` Rafael J. Wysocki
2025-10-29 21:01 ` Ankur Arora
2025-11-04 18:07 ` Rafael J. Wysocki
2025-11-05 8:30 ` Ankur Arora
2025-10-28 16:16 ` Christoph Lameter (Ampere)
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=87qzumq51p.fsf@oracle.com \
--to=ankur.a.arora@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=ast@kernel.org \
--cc=boris.ostrovsky@oracle.com \
--cc=bpf@vger.kernel.org \
--cc=catalin.marinas@arm.com \
--cc=cl@gentwo.org \
--cc=daniel.lezcano@linaro.org \
--cc=harisokn@amazon.com \
--cc=joao.m.martins@oracle.com \
--cc=konrad.wilk@oracle.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=memxor@gmail.com \
--cc=peterz@infradead.org \
--cc=rafael@kernel.org \
--cc=will@kernel.org \
--cc=xueshuai@linux.alibaba.com \
--cc=zhenglifeng1@huawei.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.