Commit cdf9df0
locking/x86/xen: Use try_cmpxchg() in xen_alloc_p2m_entry()
Use try_cmpxchg() instead of cmpxchg(*ptr, old, new) == old.
The x86 CMPXCHG instruction returns success in the ZF flag,
so this change saves a compare after CMPXCHG.
Also, try_cmpxchg() implicitly assigns old *ptr value to "old"
when CMPXCHG fails. There is no need to explicitly assign
old *ptr value to the temporary, which can simplify the
surrounding source code.
No functional change intended.
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Reviewed-by: Juergen Gross <jgross@suse.com>
Cc: Juergen Gross <jgross@suse.com>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Dave Hansen <dave.hansen@linux.intel.com>
Cc: "H. Peter Anvin" <hpa@zytor.com>
Link: https://lore.kernel.org/r/20240405083335.507471-1-ubizjak@gmail.com
Signed-off-by: Juergen Gross <jgross@suse.com>1 parent a38297e commit cdf9df0
1 file changed
+5
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
555 | 555 | | |
556 | 556 | | |
557 | 557 | | |
558 | | - | |
559 | 558 | | |
560 | 559 | | |
561 | 560 | | |
| |||
565 | 564 | | |
566 | 565 | | |
567 | 566 | | |
568 | | - | |
569 | | - | |
570 | | - | |
571 | | - | |
572 | | - | |
| 567 | + | |
| 568 | + | |
573 | 569 | | |
| 570 | + | |
| 571 | + | |
| 572 | + | |
574 | 573 | | |
575 | 574 | | |
576 | 575 | | |
| |||
0 commit comments