Skip to contentSkip to conversation

kexec-use-atomic_try_cmpxchg_acquire-in-kexec_trylock.patch removed from -mm tree

merged mm-nonmm-stable Andrew Morton 1 participant 1 message Sep 2, 2024

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: kexec: use atomic_try_cmpxchg_acquire() in kexec_trylock()
has been removed from the -mm tree. Its filename was
kexec-use-atomic_try_cmpxchg_acquire-in-kexec_trylock.patch

This patch was dropped because it was merged into the mm-nonmm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Uros Bizjak <[email protected]>
Subject: kexec: use atomic_try_cmpxchg_acquire() in kexec_trylock()
Date: Fri, 19 Jul 2024 12:38:52 +0200

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.

---

 kernel/kexec_internal.h |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/kexec_internal.h renamed from kernel/kexec_internal.h~kexec-use-atomic_try_cmpxchg_acquire-in-kexec_trylock +2 -1
@@ -23,7 +23,8 @@ int kimage_is_destination_range(struct k
 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)
 {

_

Patches currently in -mm which might be from [email protected] are

errh-add-err_ptr_pcpu-ptr_err_pcpu-and-is_err_pcpu-macros.patch mm-kmemleak-use-is_err_pcpu-for-pointer-in-the-percpu-address-space.patch squashfs-fix-percpu-address-space-issues-in-decompressor_multi_percpuc.patch