diff options
| author | 2026-10-06 16:57:25 +0200 | |
|---|---|---|
| committer | 2026-10-07 11:40:29 +0200 | |
| commit | e18a697f7a9b2a1e24df9da34c6ac857de61a2d2 (patch) | |
| tree | dfe3d737cd09c1b6af1909e4fb8a63fdfb8259cb /scripts/Makefile.thinlto | |
| parent | perf mutex: Add DEFINE_MUTEX() static initializer (diff) | |
perf mutex: Add DO_ONCE() for one-time initialization
For lazy init that more than one thread can race into, without
pthread_once() so that it stays within perf's locking primitives and
clang's -Wthread-safety keeps an eye on the mutexes involved.
Mirrors the kernel's include/linux/once.h DO_ONCE(), dropping its
static key fast path, unnecessary at these cold init paths: a per call
site static bool plus a statically initialized mutex, double checked.
As there, code reachable from more than one call site must go through
a common helper.
The lockless fast path reads ___done with an acquire, paired with a
release store after fn(), so that fn()'s side effects are visible to
threads taking the fast path, which the dropped static key used to
guarantee.
The __atomic builtins are used rather than smp_load_acquire()/
smp_store_release() because ThreadSanitizer understands them,
avoiding reports on ___done and on what fn() initialized.
Assisted-by: LLM
Reviewed-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'scripts/Makefile.thinlto')
0 files changed, 0 insertions, 0 deletions
