]> Gentwo Git Trees - linux/.git/commit
drm/i915/active: Use try_cmpxchg64() in __active_lookup()
authorUros Bizjak <ubizjak@gmail.com>
Thu, 14 Aug 2025 06:43:26 +0000 (07:43 +0100)
committerTvrtko Ursulin <tursulin@ursulin.net>
Fri, 15 Aug 2025 08:17:11 +0000 (09:17 +0100)
commit60b006b7cf0dd5e8ee99bd77fb4573e1a3956035
tree1e889971a940288d69270456d62934cf3eafa705
parent317be9c64215f264740c6dffb0a44216960875b2
drm/i915/active: Use try_cmpxchg64() in __active_lookup()

Replace this pattern in __active_lookup():

    cmpxchg64(*ptr, old, new) == old

... with the simpler and faster:

    try_cmpxchg64(*ptr, &old, new)

The x86 CMPXCHG instruction returns success in the ZF flag,
so this change saves a compare after the CMPXCHG.

The patch also improves the explanation of what the code really
does. cmpxchg64() will *succeed* for the winner of the race and
try_cmpxchg64() nicely documents this fact.

No functional change intended.

Signed-off-by: Uros Bizjak <ubizjak@gmail.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Tvrtko Ursulin <tursulin@ursulin.net>
Cc: David Airlie <airlied@gmail.com>
Cc: Simona Vetter <simona@ffwll.ch>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
Signed-off-by: Tvrtko Ursulin <tursulin@ursulin.net>
Link: https://lore.kernel.org/r/20250814064326.95519-1-tvrtko.ursulin@igalia.com
drivers/gpu/drm/i915/i915_active.c