mirror of
https://github.com/torvalds/linux.git
synced 2026-11-06 21:58:01 +01:00
lib/vsprintf: Use acquire/release for ptr_key publication
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. Cc: Petr Mladek <pmladek@suse.com> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk> Cc: Sergey Senozhatsky <senozhatsky@chromium.org> Cc: Andrew Morton <akpm@linux-foundation.org> Assisted-by: DeepSeek:DeepSeek-V3 Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com> Reviewed-by: Petr Mladek <pmladek@suse.com> Link: https://patch.msgid.link/20260902074805.398540-3-ruanjinjie@huawei.com Signed-off-by: Petr Mladek <pmladek@suse.com>
This commit is contained in:
parent
77ae27fd98
commit
72d907f23e
|
|
@ -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);
|
||||
/*
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user