* [PATCH] drm/i915/active: Use try_cmpxchg() in active_fence_cb()
@ 2024-10-03 8:44 Uros Bizjak
2024-10-23 12:53 ` Jani Nikula
0 siblings, 1 reply; 2+ messages in thread
From: Uros Bizjak @ 2024-10-03 8:44 UTC (permalink / raw)
To: intel-gfx, dri-devel, linux-kernel
Cc: Uros Bizjak, Jani Nikula, Joonas Lahtinen, Rodrigo Vivi,
Tvrtko Ursulin, David Airlie, Simona Vetter
Replace this pattern in active_fence_cb():
cmpxchg(*ptr, old, new) == old
... with the simpler and faster:
try_cmpxchg(*ptr, &old, new)
The x86 CMPXCHG instruction returns success in the ZF flag,
so this change saves a compare after the CMPXCHG.
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>
---
drivers/gpu/drm/i915/i915_active.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/i915/i915_active.c b/drivers/gpu/drm/i915/i915_active.c
index 5ec293011d99..35319228bc51 100644
--- a/drivers/gpu/drm/i915/i915_active.c
+++ b/drivers/gpu/drm/i915/i915_active.c
@@ -212,7 +212,7 @@ active_fence_cb(struct dma_fence *fence, struct dma_fence_cb *cb)
struct i915_active_fence *active =
container_of(cb, typeof(*active), cb);
- return cmpxchg(__active_fence_slot(active), fence, NULL) == fence;
+ return try_cmpxchg(__active_fence_slot(active), &fence, NULL);
}
static void
--
2.46.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] drm/i915/active: Use try_cmpxchg() in active_fence_cb()
2024-10-03 8:44 [PATCH] drm/i915/active: Use try_cmpxchg() in active_fence_cb() Uros Bizjak
@ 2024-10-23 12:53 ` Jani Nikula
0 siblings, 0 replies; 2+ messages in thread
From: Jani Nikula @ 2024-10-23 12:53 UTC (permalink / raw)
To: Uros Bizjak, intel-gfx, dri-devel, linux-kernel
Cc: Uros Bizjak, Joonas Lahtinen, Rodrigo Vivi, Tvrtko Ursulin,
David Airlie, Simona Vetter
On Thu, 03 Oct 2024, Uros Bizjak <ubizjak@gmail.com> wrote:
> Replace this pattern in active_fence_cb():
>
> cmpxchg(*ptr, old, new) == old
>
> ... with the simpler and faster:
>
> try_cmpxchg(*ptr, &old, new)
>
> The x86 CMPXCHG instruction returns success in the ZF flag,
> so this change saves a compare after the CMPXCHG.
>
> 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>
Pushed to drm-intel-next, thanks for the patch.
BR,
Jani.
> ---
> drivers/gpu/drm/i915/i915_active.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_active.c b/drivers/gpu/drm/i915/i915_active.c
> index 5ec293011d99..35319228bc51 100644
> --- a/drivers/gpu/drm/i915/i915_active.c
> +++ b/drivers/gpu/drm/i915/i915_active.c
> @@ -212,7 +212,7 @@ active_fence_cb(struct dma_fence *fence, struct dma_fence_cb *cb)
> struct i915_active_fence *active =
> container_of(cb, typeof(*active), cb);
>
> - return cmpxchg(__active_fence_slot(active), fence, NULL) == fence;
> + return try_cmpxchg(__active_fence_slot(active), &fence, NULL);
> }
>
> static void
--
Jani Nikula, Intel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2024-10-23 12:53 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-03 8:44 [PATCH] drm/i915/active: Use try_cmpxchg() in active_fence_cb() Uros Bizjak
2024-10-23 12:53 ` Jani Nikula
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox