lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 12 Jun 2024 15:57:09 +0200
From: Uros Bizjak <ubizjak@...il.com>
To: Thomas Gleixner <tglx@...utronix.de>, LKML <linux-kernel@...r.kernel.org>
Cc: Steven Rostedt <rostedt@...dmis.org>, Sam Sun <samsun1006219@...il.com>,
 x86@...nel.org, syzkaller-bugs@...glegroups.com, xrivendell7@...il.com
Subject: Re: [patch 4/4] jump_label: Simplify and clarify
 static_key_fast_inc_cpus_locked()


> Make the code more obvious and add proper comments to avoid future head
> scratching.
> 
> Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
> ---
>   kernel/jump_label.c |   20 +++++++++++---------
>   1 file changed, 11 insertions(+), 9 deletions(-)
> 
> --- a/kernel/jump_label.c
> +++ b/kernel/jump_label.c
> @@ -162,22 +162,24 @@ bool static_key_slow_inc_cpuslocked(stru
>   	if (static_key_fast_inc_not_disabled(key))
>   		return true;
>   
> -	jump_label_lock();
> -	if (atomic_read(&key->enabled) == 0) {
> -		atomic_set(&key->enabled, -1);
> +	guard(mutex)(&jump_label_mutex);
> +	/* Try to mark it as 'enabling in progress. */

Missing closing quotation mark above.

> +	if (!atomic_cmpxchg(&key->enabled, 0, -1)) {

This can be:

int tmp = 0;
if (atomic_try_cmpxchg(&key->enabled, &tmp, -1)) {
...

and will result in more optimal code and will IMO also be more readable 
because it is clear that the code is executed when cmpxchg succeeds.

(BTW: The atomic_read()/atomic_set() pair can also be converted to 
cmpxchg in static_key_enable_cpuslocked().)

Uros.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ