Replace the smp_wmb() + WRITE_ONCE() and READ_ONCE() + smp_rmb() barrier pair with smp_store_release()/smp_load_acquire() on filled_random_ptr_key. This expresses the publish/subscribe pattern more clearly and allows architectures with native acquire/release instructions (e.g. arm64's STLR/LDAR) to avoid the cost of full one-way barriers (DMB ISHST/ISHLD). No functional change intended. Assisted-by: DeepSeek:DeepSeek-V3 Signed-off-by: Jinjie Ruan --- lib/vsprintf.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/vsprintf.c b/lib/vsprintf.c index e285e8bc4712..d6f235e143b7 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -762,9 +762,8 @@ static int fill_ptr_key(struct notifier_block *nb, unsigned long action, void *d { get_random_bytes(&ptr_key, sizeof(ptr_key)); - /* Pairs with smp_rmb() before reading ptr_key. */ - smp_wmb(); - WRITE_ONCE(filled_random_ptr_key, true); + /* Pairs with smp_load_acquire() before reading ptr_key. */ + smp_store_release(&filled_random_ptr_key, true); return NOTIFY_DONE; } @@ -781,12 +780,10 @@ static inline int __ptr_to_hashval(const void *ptr, unsigned long *hashval_out) { unsigned long hashval; - if (!READ_ONCE(filled_random_ptr_key)) + /* Pairs with smp_store_release() after writing ptr_key. */ + if (!smp_load_acquire(&filled_random_ptr_key)) return -EBUSY; - /* Pairs with smp_wmb() after writing ptr_key. */ - smp_rmb(); - #ifdef CONFIG_64BIT hashval = (unsigned long)siphash_1u64((u64)ptr, &ptr_key); /* -- 2.34.1