mm/vmstat: use this_cpu_try_cmpxchg in mod_{zone,node}_state
authorUros Bizjak <ubizjak@gmail.com>
Mon, 4 Sep 2023 15:08:49 +0000 (17:08 +0200)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 4 Oct 2023 17:32:20 +0000 (10:32 -0700)
commit77cd814835df22e177a9caac1b046f7ffdfeedd0
tree0c93012406c3a1f6c74a4de1822524dcfa90f527
parent91e79d22be75fec88ae58d274a7c9e49d6215099
mm/vmstat: use this_cpu_try_cmpxchg in mod_{zone,node}_state

Use this_cpu_try_cmpxchg instead of this_cpu_cmpxchg (*ptr, old, new) ==
old in mod_zone_state and mod_node_state.  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, try_cmpxchg implicitly assigns old *ptr value to "old" when cmpxchg
fails.  There is no need to re-read the value in the loop.

No functional change intended.

Link: https://lkml.kernel.org/r/20230904150917.8318-1-ubizjak@gmail.com
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/vmstat.c