• Uros Bizjak's avatar
    mm/vmalloc: use __this_cpu_try_cmpxchg() in preload_this_cpu_lock() · f56810c9
    Uros Bizjak authored
    Use __this_cpu_try_cmpxchg() instead of __this_cpu_cmpxchg (*ptr, old,
    new) == old in preload_this_cpu_lock().  x86 CMPXCHG instruction returns
    success in ZF flag, so this change saves a compare after cmpxchg.
    
    The generated code improves from:
    
        4bb6:	48 85 f6             	test   %rsi,%rsi
        4bb9:	0f 84 10 fa ff ff    	je     45cf <...>
        4bbf:	4c 89 e8             	mov    %r13,%rax
        4bc2:	65 48 0f b1 35 00 00 	cmpxchg %rsi,%gs:0x0(%rip)
        4bc9:	00 00
        4bcb:	48 85 c0             	test   %rax,%rax
        4bce:	0f 84 fb f9 ff ff    	je     45cf <...>
    
    to:
    
        4bb6:	48 85 f6             	test   %rsi,%rsi
        4bb9:	0f 84 10 fa ff ff    	je     45cf <...>
        4bbf:	4c 89 e8             	mov    %r13,%rax
        4bc2:	65 48 0f b1 35 00 00 	cmpxchg %rsi,%gs:0x0(%rip)
        4bc9:	00 00
        4bcb:	0f 84 fe f9 ff ff    	je     45cf <...>
    
    No functional change intended.
    
    Link: https://lkml.kernel.org/r/20240528144345.5980-2-ubizjak@gmail.comSigned-off-by: default avatarUros Bizjak <ubizjak@gmail.com>
    Reviewed-by: default avatarUladzislau Rezki (Sony) <urezki@gmail.com>
    Cc: Christoph Hellwig <hch@infradead.org>
    Cc: Lorenzo Stoakes <lstoakes@gmail.com>
    Cc: Dennis Zhou <dennis@kernel.org>
    Cc: Tejun Heo <tj@kernel.org>
    Cc: Christoph Lameter <cl@linux.com>
    Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
    f56810c9
vmalloc.c 132 KB