drm/amdgpu: avoid scheduling on fence status query
Subsystems (2)
RFC 1/1 drm/amdgpu: avoid scheduling on fence status query
When amdgpu_cs_wait_ioctl is called with a timeout of zero, the caller is just interested in the current status of the fence.
The default implementation of dma_fence_wait_timeout on an unsignaled fence will always call schedule_timeout(), even if the timeout is zero. This may result in significant overhead for clients that heavily use this interface.
This patch avoids the dma_fence_wait_timeout overhead by directly checking the fence status.
---
I'm not sure if we should be working around this issue at the amdgpu level, or at fixing the dma_fence_default_wait level instead.
Source2 games like dota2 are affected by this overhead. This patch improves dota2 perf on a i7-6700k+RX480 system from 72fps->81fps.
Patch is for drm-next-4.12-wip since this branch is where we operate on dma_fences directly.
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 5 ++++- drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 5 +++++ drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h | 1 + 3 files changed, 10 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c +4 -1
@@ -1168,7 +1168,10 @@ int amdgpu_cs_wait_ioctl(struct drm_device *dev, void *data,if (IS_ERR (fence)) r =PTR_ERR (fence);else if (fence) { - r =dma_fence_wait_timeout (fence, true, timeout); +if (timeout) + r =dma_fence_wait_timeout (fence, true, timeout); +else + r =amdgpu_fence_test_signaled (fence);dma_fence_put (fence); }else r =1 ;
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +5 -0
@@ -122,6 +122,11 @@ static u32 amdgpu_fence_read(struct amdgpu_ring *ring)return seq; } +bool amdgpu_fence_test_signaled (struct dma_fence *fence) +{ +return test_bit (DMA_FENCE_FLAG_SIGNALED_BIT , &fence->flags); +} +/** * amdgpu_fence_emit - emit a fence on the requested ring *
drivers/gpu/drm/amd/amdgpu/amdgpu_ring.h +1 -0
@@ -84,6 +84,7 @@ int amdgpu_fence_driver_start_ring(struct amdgpu_ring *ring, unsigned irq_type);void amdgpu_fence_driver_suspend (struct amdgpu_device *adev);void amdgpu_fence_driver_resume (struct amdgpu_device *adev); +bool amdgpu_fence_test_signaled (struct dma_fence *fence);int amdgpu_fence_emit (struct amdgpu_ring *ring,struct dma_fence **fence);void amdgpu_fence_process (struct amdgpu_ring *ring);int amdgpu_fence_wait_empty (struct amdgpu_ring *ring);
Signature · 6 lines
2.9.3 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
A message that is not in the archive (sent off-list or not yet received): 20170426002830.6099-1-andresx7-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Quoted 8 lines · Andres Rodriguez
When
amdgpu_cs_wait_ioctlis called with a timeout of zero, the caller is just interested in the current status of the fence.The default implementation of
dma_fence_wait_timeouton an unsignaled fence will always callschedule_timeout(), even if the timeout is zero. This may result in significant overhead for clients that heavily use this interface.
Quoted 8 lines
This patch avoids the
dma_fence_wait_timeoutoverhead by directly checking the fence status.Signed-off-by Andres Rodriguez <[email protected]>---
I'm not sure if we should be working around this issue at the amdgpu level, or at fixing the
dma_fence_default_waitlevel instead.
I'd say the latter, assuming it can give the same benefit.
Signature · 6 lines
Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx