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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Zp3NXf9UBCtFKBsa@MiWiFi-R3L-srv>
Date: Mon, 22 Jul 2024 11:09:17 +0800
From: Baoquan He <bhe@...hat.com>
To: Uros Bizjak <ubizjak@...il.com>
Cc: akpm@...ux-foundation.org, kexec@...ts.infradead.org,
	linux-kernel@...r.kernel.org,
	Eric Biederman <ebiederm@...ssion.com>
Subject: Re: [PATCH] kexec: Use atomic_try_cmpxchg_acquire() in
 kexec_trylock()

On 07/19/24 at 12:38pm, Uros Bizjak wrote:
> Use atomic_try_cmpxchg_acquire(*ptr, &old, new) instead of
> atomic_cmpxchg_acquire(*ptr, old, new) == old in kexec_trylock().
> x86 CMPXCHG instruction returns success in ZF flag, so
> this change saves a compare after cmpxchg.

Seems it can simplify code even though on non-x86 arch, should we
replace atomic_try_cmpxchg_acquire() with atomic_try_cmpxchg_acquire()
in all similar places?

For this one,

Acked-by: Baoquan He <bhe@...hat.com>

> 
> Signed-off-by: Uros Bizjak <ubizjak@...il.com>
> Cc: Eric Biederman <ebiederm@...ssion.com>
> ---
>  kernel/kexec_internal.h | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/kexec_internal.h b/kernel/kexec_internal.h
> index 2595defe8c0d..d35d9792402d 100644
> --- a/kernel/kexec_internal.h
> +++ b/kernel/kexec_internal.h
> @@ -23,7 +23,8 @@ int kimage_is_destination_range(struct kimage *image,
>  extern atomic_t __kexec_lock;
>  static inline bool kexec_trylock(void)
>  {
> -	return atomic_cmpxchg_acquire(&__kexec_lock, 0, 1) == 0;
> +	int old = 0;
> +	return atomic_try_cmpxchg_acquire(&__kexec_lock, &old, 1);
>  }
>  static inline void kexec_unlock(void)
>  {
> -- 
> 2.42.0
> 
> 
> _______________________________________________
> kexec mailing list
> kexec@...ts.infradead.org
> http://lists.infradead.org/mailman/listinfo/kexec
> 


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ