]> git.baikalelectronics.ru Git - kernel.git/commit
netdev: Use try_cmpxchg in napi_if_scheduled_mark_missed
authorUros Bizjak <ubizjak@gmail.com>
Mon, 22 Aug 2022 14:32:43 +0000 (16:32 +0200)
committerJakub Kicinski <kuba@kernel.org>
Thu, 25 Aug 2022 21:20:35 +0000 (14:20 -0700)
commitc1fa8ba79889cc0c520b5025615422373b271711
tree59874de2ee8d35ea7645e97fa02b878a68febf6e
parentf499bad8483c0ad1b173e6490f7948d433fdb71b
netdev: Use try_cmpxchg in napi_if_scheduled_mark_missed

Use try_cmpxchg instead of cmpxchg (*ptr, old, new) == old in
napi_if_scheduled_mark_missed. 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, enabling further code simplifications.

Cc: Eric Dumazet <edumazet@google.com>
Cc: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Link: https://lore.kernel.org/r/20220822143243.2798-1-ubizjak@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
include/linux/netdevice.h