* [PATCH] dma-fence: Use non-atomic bitops while under the lock
@ 2019-10-03 10:12 Tvrtko Ursulin
2019-10-03 12:20 ` [Intel-gfx] " Tvrtko Ursulin
0 siblings, 1 reply; 2+ messages in thread
From: Tvrtko Ursulin @ 2019-10-03 10:12 UTC (permalink / raw)
To: Intel-gfx; +Cc: dri-devel
From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
We do not have to use atomic bitops when already under the spinlock.
Saves on a handful of lock instruction prefixes, on x86 at least.
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: dri-devel@lists.freedesktop.org
Cc: Chris Wilson <chris@chris-wilson.co.uk>
---
drivers/dma-buf/dma-fence.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c
index 2c136aee3e79..f0b480042e2f 100644
--- a/drivers/dma-buf/dma-fence.c
+++ b/drivers/dma-buf/dma-fence.c
@@ -133,15 +133,15 @@ int dma_fence_signal_locked(struct dma_fence *fence)
lockdep_assert_held(fence->lock);
- if (unlikely(test_and_set_bit(DMA_FENCE_FLAG_SIGNALED_BIT,
- &fence->flags)))
+ if (unlikely(__test_and_set_bit(DMA_FENCE_FLAG_SIGNALED_BIT,
+ &fence->flags)))
return -EINVAL;
/* Stash the cb_list before replacing it with the timestamp */
list_replace(&fence->cb_list, &cb_list);
fence->timestamp = ktime_get();
- set_bit(DMA_FENCE_FLAG_TIMESTAMP_BIT, &fence->flags);
+ __set_bit(DMA_FENCE_FLAG_TIMESTAMP_BIT, &fence->flags);
trace_dma_fence_signaled(fence);
list_for_each_entry_safe(cur, tmp, &cb_list, node) {
@@ -343,8 +343,8 @@ int dma_fence_add_callback(struct dma_fence *fence, struct dma_fence_cb *cb,
spin_lock_irqsave(fence->lock, flags);
- was_set = test_and_set_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT,
- &fence->flags);
+ was_set = __test_and_set_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT,
+ &fence->flags);
if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags))
ret = -ENOENT;
@@ -473,8 +473,8 @@ dma_fence_default_wait(struct dma_fence *fence, bool intr, signed long timeout)
goto out;
}
- was_set = test_and_set_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT,
- &fence->flags);
+ was_set = __test_and_set_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT,
+ &fence->flags);
if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags))
goto out;
--
2.20.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Intel-gfx] [PATCH] dma-fence: Use non-atomic bitops while under the lock
2019-10-03 10:12 [PATCH] dma-fence: Use non-atomic bitops while under the lock Tvrtko Ursulin
@ 2019-10-03 12:20 ` Tvrtko Ursulin
0 siblings, 0 replies; 2+ messages in thread
From: Tvrtko Ursulin @ 2019-10-03 12:20 UTC (permalink / raw)
To: Intel-gfx; +Cc: dri-devel
On 03/10/2019 11:12, Tvrtko Ursulin wrote:
> From: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>
> We do not have to use atomic bitops when already under the spinlock.
>
> Saves on a handful of lock instruction prefixes, on x86 at least.
>
> Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Cc: dri-devel@lists.freedesktop.org
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> ---
> drivers/dma-buf/dma-fence.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c
> index 2c136aee3e79..f0b480042e2f 100644
> --- a/drivers/dma-buf/dma-fence.c
> +++ b/drivers/dma-buf/dma-fence.c
> @@ -133,15 +133,15 @@ int dma_fence_signal_locked(struct dma_fence *fence)
>
> lockdep_assert_held(fence->lock);
>
> - if (unlikely(test_and_set_bit(DMA_FENCE_FLAG_SIGNALED_BIT,
> - &fence->flags)))
> + if (unlikely(__test_and_set_bit(DMA_FENCE_FLAG_SIGNALED_BIT,
> + &fence->flags)))
This breaks left right and center so I guess it is more subtle than this!
Regards,
Tvrtko
> return -EINVAL;
>
> /* Stash the cb_list before replacing it with the timestamp */
> list_replace(&fence->cb_list, &cb_list);
>
> fence->timestamp = ktime_get();
> - set_bit(DMA_FENCE_FLAG_TIMESTAMP_BIT, &fence->flags);
> + __set_bit(DMA_FENCE_FLAG_TIMESTAMP_BIT, &fence->flags);
> trace_dma_fence_signaled(fence);
>
> list_for_each_entry_safe(cur, tmp, &cb_list, node) {
> @@ -343,8 +343,8 @@ int dma_fence_add_callback(struct dma_fence *fence, struct dma_fence_cb *cb,
>
> spin_lock_irqsave(fence->lock, flags);
>
> - was_set = test_and_set_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT,
> - &fence->flags);
> + was_set = __test_and_set_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT,
> + &fence->flags);
>
> if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags))
> ret = -ENOENT;
> @@ -473,8 +473,8 @@ dma_fence_default_wait(struct dma_fence *fence, bool intr, signed long timeout)
> goto out;
> }
>
> - was_set = test_and_set_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT,
> - &fence->flags);
> + was_set = __test_and_set_bit(DMA_FENCE_FLAG_ENABLE_SIGNAL_BIT,
> + &fence->flags);
>
> if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags))
> goto out;
>
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-10-03 12:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-10-03 10:12 [PATCH] dma-fence: Use non-atomic bitops while under the lock Tvrtko Ursulin
2019-10-03 12:20 ` [Intel-gfx] " Tvrtko Ursulin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox