BPF List
 help / color / mirror / Atom feed
From: Ankur Arora <ankur.a.arora@oracle.com>
To: sashiko-reviews@lists.linux.dev
Cc: Ankur Arora <ankur.a.arora@oracle.com>, bpf@vger.kernel.org
Subject: Re: [PATCH v15 02/16] arm64: barrier: Support smp_cond_load_relaxed_timeout()
Date: Mon, 31 Aug 2026 20:55:06 -0700	[thread overview]
Message-ID: <87tso9zkv9.fsf@oracle.com> (raw)
In-Reply-To: <20260831215941.B32531F000E9@smtp.kernel.org>


sashiko-bot@kernel.org writes:

> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Low] Module linkage failure due to unexported symbol `arch_timer_evtstrm_available`.
> --
>
> commit 6f96330ea583f1ff6aede67a83cdc552196dad11
> Author: Ankur Arora <ankur.a.arora@oracle.com>
>
> arm64: barrier: Support smp_cond_load_relaxed_timeout()
>
> This commit introduces an optimized cpu_poll_relax() for ARM64 that uses
> __cmpwait_relaxed() to wait for a value change. It gates this logic on
> arch_timer_evtstrm_available() being true to avoid blocking forever without
> periodic wakeups from the event stream.
>
>> diff --git a/arch/arm64/include/asm/barrier.h b/arch/arm64/include/asm/barrier.h
>> --- a/arch/arm64/include/asm/barrier.h
>> +++ b/arch/arm64/include/asm/barrier.h
>
> [ ... ]
>
>> +/* Re-declared here to avoid include dependency. */
>> +extern bool arch_timer_evtstrm_available(void);
>> +
>> +/*
>> + * In the common case, cpu_poll_relax() sits waiting in __cmpwait_relaxed()
>> + * for @ptr value to change.
>> + *
>> + * State this by defining CPU_POLL_RELAX_WAITS which enables a time-check
>> + * optimization in smp_cond_load_{relaxed,acquire}_timeout().
>> + */
>> +#define CPU_POLL_RELAX_WAITS
>> +
>> +#define cpu_poll_relax(ptr, val, timeout_ns) do {			\
>> +	if (arch_timer_evtstrm_available())				\
>> +		__cmpwait_relaxed(ptr, val);				\
>> +	else								\
>> +		cpu_relax();						\
>> +} while (0)
>
> [Severity: Low]
> Will this cause a module linkage failure if a loadable kernel module
> uses smp_cond_load_relaxed_timeout() or similar APIs?
>
> Since cpu_poll_relax() is a macro, it expands directly in the caller's
> code. However, looking at drivers/clocksource/arm_arch_timer.c, it appears
> that arch_timer_evtstrm_available() is not exported to loadable modules:
>
> drivers/clocksource/arm_arch_timer.c:arch_timer_evtstrm_available() {
>         /*
>          * We might get called from a preemptible context.
>          ...
> }
>
> Without an EXPORT_SYMBOL declaration, any loadable module utilizing this
> polling macro will fail to link with an unknown symbol error. Should
> arch_timer_evtstrm_available be exported to support loadable modules?

As mentioned in https://lore.kernel.org/all/87qzkk2hxz.fsf@oracle.com/:

This interface mostly exists (or wants to) to unify spin-wait with
timeout where the waiting can be done via a spinning cpu_relax() or
arm64 style waiting on a cacheline (WFE/WFET).

Currently, almost all of the users of smp_cond_load_{acquire,relaxed}
are in kernel/

$ git grep -E 'smp_cond_load_acquire|smp_cond_load_relaxed' kernel/ | wc
27     145    2191

The only non kernel/ users are in:
$ git grep -E 'smp_cond_load_acquire|smp_cond_load_relaxed' arch/ drivers/ mm/ fs/
arch/arm64/include/asm/mte.h:   smp_cond_load_acquire(&page->flags.f, VAL & (1UL << PG_mte_tagged));
arch/arm64/include/asm/mte.h:   smp_cond_load_acquire(&folio->flags.f, VAL & (1UL << PG_mte_tagged));
arch/arm64/mm/mmu.c:            smp_cond_load_acquire(&idmap_kpti_bbml2_flag, VAL == num_online_cpus());
drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c:    smp_cond_load_relaxed(cmd, !VAL || (ret = queue_poll(&qp)));

So I don't expect this to be needed in kernel modules any time soon.
And if it is, we can export the symbol then.

--
ankur

  reply	other threads:[~2026-09-01  3:55 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-31 20:22 [PATCH v15 00/16] barrier: Add smp_cond_load_{relaxed,acquire}_timeout() Ankur Arora
2026-08-31 20:22 ` [PATCH v15 01/16] asm-generic: barrier: Add smp_cond_load_relaxed_timeout() Ankur Arora
2026-08-31 21:50   ` sashiko-bot
2026-08-31 20:22 ` [PATCH v15 02/16] arm64: barrier: Support smp_cond_load_relaxed_timeout() Ankur Arora
2026-08-31 21:59   ` sashiko-bot
2026-09-01  3:55     ` Ankur Arora [this message]
2026-08-31 20:22 ` [PATCH v15 03/16] arm64/delay: move, fixup usecs_to_cycles() Ankur Arora
2026-08-31 22:06   ` sashiko-bot
2026-08-31 20:22 ` [PATCH v15 04/16] arm64: support WFET in smp_cond_load_relaxed_timeout() Ankur Arora
2026-08-31 21:16   ` bot+bpf-ci
2026-08-31 22:19   ` sashiko-bot
2026-08-31 20:22 ` [PATCH v15 05/16] arm64: rqspinlock: Remove private copy of smp_cond_load_acquire_timewait() Ankur Arora
2026-08-31 20:22 ` [PATCH v15 06/16] asm-generic: barrier: Add smp_cond_load_acquire_timeout() Ankur Arora
2026-08-31 21:17   ` bot+bpf-ci
2026-08-31 22:36   ` sashiko-bot
2026-08-31 20:22 ` [PATCH v15 07/16] atomic: Add atomic_cond_read_*_timeout() Ankur Arora
2026-08-31 21:16   ` bot+bpf-ci
2026-08-31 22:47   ` sashiko-bot
2026-08-31 20:22 ` [PATCH v15 08/16] locking/atomic: scripts: build atomic_long_cond_read_*_timeout() Ankur Arora
2026-08-31 20:22 ` [PATCH v15 09/16] bpf/rqspinlock: switch check_timeout() to a clock interface Ankur Arora
2026-08-31 21:16   ` bot+bpf-ci
2026-08-31 20:22 ` [PATCH v15 10/16] bpf/rqspinlock: Use smp_cond_load_acquire_timeout() Ankur Arora
2026-08-31 21:31   ` bot+bpf-ci
2026-08-31 20:22 ` [PATCH v15 11/16] sched: add need-resched timed wait interface Ankur Arora
2026-08-31 20:22 ` [PATCH v15 12/16] cpuidle/poll_state: Wait for need-resched via tif_need_resched_relaxed_wait() Ankur Arora
2026-08-31 23:20   ` sashiko-bot
2026-09-01  4:46     ` Ankur Arora
2026-08-31 20:22 ` [PATCH v15 13/16] arm64/delay: enable testing smp_cond_load_relaxed_timeout() Ankur Arora
2026-08-31 21:16   ` bot+bpf-ci
2026-08-31 23:28   ` sashiko-bot
2026-09-01  4:53     ` Ankur Arora
2026-08-31 20:22 ` [PATCH v15 14/16] barrier: add tests for smp_cond_load_*_timeout() Ankur Arora
2026-08-31 21:17   ` bot+bpf-ci
2026-08-31 20:22 ` [PATCH v15 15/16] barrier: timeout validity checks for smp_cond_load_relaxed_timeout() Ankur Arora
2026-08-31 21:16   ` bot+bpf-ci
2026-08-31 20:22 ` [PATCH v15 16/16] barrier: timeout validity checks for smp_cond_load_acquire_timeout() Ankur Arora

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=87tso9zkv9.fsf@oracle.com \
    --to=ankur.a.arora@oracle.com \
    --cc=bpf@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.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