dma-buf: avoid scheduling on fence status query
Subsystems (3)
PATCH 1/1 dma-buf: avoid scheduling on fence status query
When a timeout of zero is specified, the caller is only interested in the fence status.
In the current implementation, dma_fence_default_wait will always call schedule_timeout() at least once for an unsignaled fence. This adds a significant overhead to a fence status query.
Avoid this overhead by returning early if a zero timeout is specified.
---
This heavily affects the performance of the Source2 engine running on radv.
This patch improves dota2(radv) perf on a i7-6700k+RX480 system from 72fps->81fps.
drivers/dma-buf/dma-fence.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/dma-buf/dma-fence.c +3 -0
@@ -380,6 +380,9 @@ dma_fence_default_wait(struct dma_fence *fence, bool intr, signed long timeout)if (test_bit (DMA_FENCE_FLAG_SIGNALED_BIT , &fence->flags))return ret; +if (!timeout) +return 0 ; +spin_lock_irqsave (fence->lock, flags);if (intr &&signal_pending (current)) {
Signature · 6 lines
2.9.3 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
CC a few extra lists I missed.
Regards,
Andres
Quoted 36 lines · Andres Rodriguez
When a timeout of zero is specified, the caller is only interested in the fence status.
In the current implementation,
dma_fence_default_waitwill always callschedule_timeout()at least once for an unsignaled fence. This adds a significant overhead to a fence status query.Avoid this overhead by returning early if a zero timeout is specified.
Signed-off-by Andres Rodriguez <[email protected]>---
This heavily affects the performance of the Source2 engine running on radv.
This patch improves dota2(radv) perf on a i7-6700k+RX480 system from 72fps->81fps.
drivers/dma-buf/dma-fence.c | 3 +++ 1 file changed, 3 insertions(+)drivers/dma-buf/dma-fence.c +3
-0@@ -380,6 +380,9 @@ dma_fence_default_wait(struct dma_fence *fence, bool intr, signed long timeout)if (test_bit (DMA_FENCE_FLAG_SIGNALED_BIT , &fence->flags))return ret; +if (!timeout) +return 0 ; +spin_lock_irqsave (fence->lock, flags);if (intr &&signal_pending (current)) {
Christian König
NAKNAK, I'm wondering how often I have to reject that change. We should probably add a comment here.
Even with a zero timeout we still need to enable signaling, otherwise some fence will never signal if userspace just polls on them.
If a caller is only interested in the fence status without enabling the signaling it should call dma_fence_is_signaled() instead.
Regards,
Christian.
Am 26.04.2017 um 04:50 schrieb Andres Rodriguez:
Quoted 43 lines
CC a few extra lists I missed.
Regards,
AndresQuoted 37 lines · Andres Rodriguez
When a timeout of zero is specified, the caller is only interested in the fence status.
In the current implementation,
dma_fence_default_waitwill always callschedule_timeout()at least once for an unsignaled fence. This adds a significant overhead to a fence status query.Avoid this overhead by returning early if a zero timeout is specified.
Signed-off-by Andres Rodriguez <[email protected]>---
This heavily affects the performance of the Source2 engine running on radv.
This patch improves dota2(radv) perf on a i7-6700k+RX480 system from 72fps->81fps.
drivers/dma-buf/dma-fence.c | 3 +++ 1 file changed, 3 insertions(+)drivers/dma-buf/dma-fence.c +3
-0@@ -380,6 +380,9 @@ dma_fence_default_wait(struct dma_fence *fence, bool intr, signed long timeout) if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags)) return ret; +if (!timeout) +return 0 ; +spin_lock_irqsave (fence->lock, flags);if (intr && signal_pending(current)) {
Quoted 8 lines · Christian König
NAK, I'm wondering how often I have to reject that change. We should probably add a comment here.
Even with a zero timeout we still need to enable signaling, otherwise some fence will never signal if userspace just polls on them.
If a caller is only interested in the fence status without enabling the signaling it should call
dma_fence_is_signaled()instead.
Can we not move the return 0 (with spin unlock) down after we enabling signalling, but before
we enter the schedule_timeout(1)?
Dave.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Am 26.04.2017 um 11:59 schrieb Dave Airlie:
Quoted 12 lines · Christian König
Quoted 8 lines
NAK, I'm wondering how often I have to reject that change. We should probably add a comment here.
Even with a zero timeout we still need to enable signaling, otherwise some fence will never signal if userspace just polls on them.
If a caller is only interested in the fence status without enabling the signaling it should call
dma_fence_is_signaled()instead.Can we not move the return 0 (with spin unlock) down after we enabling signalling, but before
we enter theschedule_timeout(1)?
Yes, that would be an option.
Christian.
Quoted 2 lines
Dave.
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 10 lines · Christian König
Am 26.04.2017 um 11:59 schrieb Dave Airlie:
Quoted 9 lines
Quoted 7 lines · Christian König
NAK, I'm wondering how often I have to reject that change. We should probably add a comment here.
Even with a zero timeout we still need to enable signaling, otherwise some
fence will never signal if userspace just polls on them.
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
If a caller is only interested in the fence status without enabling the signaling it should call
dma_fence_is_signaled()instead.Can we not move the return 0 (with spin unlock) down after we enabling signalling, but before
we enter theschedule_timeout(1)?Yes, that would be an option.
I was actually arguing with Dave about this on IRC yesterday. Seems like I owe him a beer now.
-Andres
Quoted 6 lines
Christian.
Quoted 2 lines
Dave.