drm/amdgpu: free resources on fence usage query
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): [email protected]
PATCH 1/2 drm/amdgpu: free resources on fence usage query
Free the resources if the fence needs to be ignored during the ratio calculation
Signed-off-by David M Nieto <[email protected]>
Change-Id Ibfc55a94c53d4b3a1dba8fff4c53fd893195bb96
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +6 -2
@@ -669,11 +669,15 @@ void amdgpu_ctx_fence_time(struct amdgpu_ctx *ctx, struct amdgpu_ctx_entity *cenif (!fence)continue ; s_fence =to_drm_sched_fence (fence); -if (!dma_fence_is_signaled (&s_fence->scheduled)) +if (!dma_fence_is_signaled (&s_fence->scheduled)) { +dma_fence_put (fence);continue ; + } t1 = s_fence->scheduled.timestamp; -if (t1 >= now) +if (!ktime_before (t1, now)) { +dma_fence_put (fence);continue ; + }if (dma_fence_is_signaled (&s_fence->finished) && s_fence->finished.timestamp < now) *total +=ktime_sub (s_fence->finished.timestamp, t1);
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/2 drm/amdgpu: fix fence calculation
The proper metric for fence utilization over several contexts is an harmonic mean, but such calculation is prohibitive in kernel space, so the code approximates it.
Because the approximation diverges when one context has a very small ratio compared with the other context, this change filter out ratios smaller that 0.01%
Signed-off-by David M Nieto <[email protected]>
Change-Id I5b6e0ce5f489a5f55855d35354a6a3653e9d613b
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 13 ++++++++++++- drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h | 1 + 2 files changed, 13 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c +12 -1
@@ -703,11 +703,22 @@ ktime_t amdgpu_ctx_mgr_fence_usage(struct amdgpu_ctx_mgr *mgr, uint32_t hwip, idp = &mgr->ctx_handles;mutex_lock (&mgr->lock);idr_for_each_entry (idp, ctx, id) { +ktime_t ttotal =0 , tmax =0 ; +if (!ctx->entities[hwip][idx])continue ; centity = ctx->entities[hwip][idx]; -amdgpu_ctx_fence_time (ctx, centity, &total, &max); +amdgpu_ctx_fence_time (ctx, centity, &ttotal, &tmax); + +/* Harmonic mean approximation diverges for very small +* values. If ratio < 0.01% ignore +*/ +if (AMDGPU_CTX_FENCE_USAGE_MIN_RATIO (tmax, ttotal)) +continue ; + + total =ktime_add (total, ttotal); + max =ktime_after (tmax, max) ? tmax : max; }mutex_unlock (&mgr->lock);
drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h +1 -0
@@ -30,6 +30,7 @@ struct drm_file;struct amdgpu_fpriv ;#define AMDGPU_MAX_ENTITY_NUM 4 +#define AMDGPU_CTX_FENCE_USAGE_MIN_RATIO (max, total) (max > 16384ULL*total)struct amdgpu_ctx_entity {uint64_t sequence;
Signature · 6 lines
2.17.1 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx