Re: [PATCH 1/2 v2] lib/vsprintf: Remove static_branch_likely() from __ptr_to_hashval().

From: Jason A. Donenfeld
Date: Mon Aug 01 2022 - 08:31:55 EST


On Fri, Jul 29, 2022 at 05:47:15PM +0200, Sebastian Andrzej Siewior wrote:
> Using static_branch_likely() to signal that ptr_key has been filled is a
> bit much given that it is not a fast path.
>
> Replace static_branch_likely() with bool for condition and a memory
> barrier for ptr_key.
>
> Suggested-by: Petr Mladek <pmladek@xxxxxxxx>
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
> ---
> lib/vsprintf.c | 19 ++++++++-----------
> 1 file changed, 8 insertions(+), 11 deletions(-)
>
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
> @@ -750,12 +750,7 @@ static int __init debug_boot_weak_hash_e
> }
> early_param("debug_boot_weak_hash", debug_boot_weak_hash_enable);
>
> -static DEFINE_STATIC_KEY_FALSE(filled_random_ptr_key);
> -
> -static void enable_ptr_key_workfn(struct work_struct *work)
> -{
> - static_branch_enable(&filled_random_ptr_key);
> -}
> +static bool filled_random_ptr_key;

This should be __read_mostly, right? Just like ptr_key.

Jason