[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen staging] x86/memsharing: use an atomic add instead of a cmpxchg loop
commit 6d05d529404a7fad1ed277865ceb31273272a23e Author: Jan Beulich <jbeulich@xxxxxxxx> AuthorDate: Thu Feb 29 08:19:22 2024 +0100 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Thu Feb 29 08:19:22 2024 +0100 x86/memsharing: use an atomic add instead of a cmpxchg loop The usage of a cmpxchg loop in get_next_handle() is unnecessary, as the same can be achieved with an atomic increment, which is both simpler to read, and avoid any need for a loop. The cmpxchg usage is likely a remnant of 32bit support, which didn't have an instruction to do an atomic 64bit add, and instead a cmpxchg had to be used. Suggested-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> Signed-of-by: Roger Pau Monné <roger.pau@xxxxxxxxxx> Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx> Reviewed-by: Julien Grall <jgrall@xxxxxxxxxx> Acked-by: Tamas K Lengyel <tamas@xxxxxxxxxxxxx> --- xen/arch/x86/mm/mem_sharing.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/xen/arch/x86/mm/mem_sharing.c b/xen/arch/x86/mm/mem_sharing.c index 4f810706a3..fe299a2bf9 100644 --- a/xen/arch/x86/mm/mem_sharing.c +++ b/xen/arch/x86/mm/mem_sharing.c @@ -179,13 +179,7 @@ static void mem_sharing_page_unlock(struct page_info *pg) static shr_handle_t get_next_handle(void) { - /* Get the next handle get_page style */ - uint64_t x, y = next_handle; - do { - x = y; - } - while ( (y = cmpxchg(&next_handle, x, x + 1)) != x ); - return x + 1; + return arch_fetch_and_add(&next_handle, 1) + 1; } static atomic_t nr_saved_mfns = ATOMIC_INIT(0); -- generated by git-patchbot for /home/xen/git/xen.git#staging
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |