zram: use try_cmpxchg in update_used_max
authorUros Bizjak <ubizjak@gmail.com>
Tue, 18 Oct 2022 14:51:54 +0000 (16:51 +0200)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 9 Nov 2022 01:37:13 +0000 (17:37 -0800)
commit70ec04f3486103819807b061b50a99f6e1d2bf36
tree21d513186676f0f3b97bfacb075675b1733b45e4
parent9fb6beea79c6e7c959adf4fb7b94cf9a6028b941
zram: use try_cmpxchg in update_used_max

Use try_cmpxchg instead of cmpxchg (*ptr, old, new) == old in
update_used_max.  x86 CMPXCHG instruction returns success in ZF flag, so
this change saves a compare after cmpxchg (and related move instruction in
front of cmpxchg).

Also, reorder code a bit to remove additional compare and conditional jump
from the assembly code.  Together, hese two changes save 15 bytes from the
function when compiled for x86_64.

No functional change intended.

Link: https://lkml.kernel.org/r/20221018145154.3699-1-ubizjak@gmail.com
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Reviewed-by: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Nitin Gupta <ngupta@vflare.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
drivers/block/zram/zram_drv.c