AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: "Nieto, David M" <David.Nieto@amd.com>,
	"amd-gfx@lists.freedesktop.org" <amd-gfx@lists.freedesktop.org>
Subject: Re: [PATCH 2/2] drm/amdgpu: fix fence calculation
Date: Wed, 12 May 2021 08:56:02 +0200	[thread overview]
Message-ID: <f689c523-c60a-a0d2-ca6a-5dcb043ffc91@gmail.com> (raw)
In-Reply-To: <9b373f49-51ad-089c-2494-032b13a9a39c@gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 3786 bytes --]

And BTW amdgpu_ctx_fence_time() should probably be static.

Christian.

Am 12.05.21 um 08:55 schrieb Christian König:
> In this case amdgpu_ctx_fence_time should probably be changed to 
> initialize the variable itself.
>
> That is really bad coding style otherwise.
>
> Christian.
>
> Am 11.05.21 um 20:14 schrieb Nieto, David M:
>>
>> [AMD Official Use Only - Internal Distribution Only]
>>
>>
>> The local variables need to be initialized to zero, since 
>> amdgpu_ctx_fence_time accumulates and does not initialize
>>
>> David
>> ------------------------------------------------------------------------
>> *From:* Christian König <ckoenig.leichtzumerken@gmail.com>
>> *Sent:* Tuesday, May 11, 2021 12:53 AM
>> *To:* Nieto, David M <David.Nieto@amd.com>; 
>> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>
>> *Subject:* Re: [PATCH 2/2] drm/amdgpu: fix fence calculation
>> Am 10.05.21 um 22:29 schrieb David M Nieto:
>> > 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 <david.nieto@amd.com>
>> > 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(-)
>> >
>> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c 
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
>> > index 9036c93b4a0c..89ee464b9424 100644
>> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
>> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
>> > @@ -698,16 +698,27 @@ ktime_t amdgpu_ctx_mgr_fence_usage(struct 
>> amdgpu_ctx_mgr *mgr, uint32_t hwip,
>> >        struct amdgpu_ctx_entity *centity;
>> >        ktime_t total = 0, max = 0;
>> >
>> > +
>>
>> Unrelated white space change.
>>
>> >        if (idx >= AMDGPU_MAX_ENTITY_NUM)
>> >                return 0;
>> >        idp = &mgr->ctx_handles;
>> >        mutex_lock(&mgr->lock);
>> >        idr_for_each_entry(idp, ctx, id) {
>> > +             ktime_t ttotal = tmax = ktime_set(0, 0);
>>
>> There should be a blank line between decleration and code and please
>> don't initialize local variables if it isn't necessary.
>>
>> Christian.
>>
>> >                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);
>> > diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h 
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h
>> > index 10dcf59a5c6b..3541dfb059ec 100644
>> > --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h
>> > +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.h
>> > @@ -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;
>>
>


[-- Attachment #1.2: Type: text/html, Size: 10545 bytes --]

[-- Attachment #2: Type: text/plain, Size: 154 bytes --]

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

  reply	other threads:[~2021-05-12  6:56 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-06 22:37 David M Nieto
2021-05-06 22:37 ` [PATCH 1/2] drm/amdgpu: free resources on fence usage query David M Nieto
2021-05-06 22:37 ` [PATCH 2/2] drm/amdgpu: fix fence calculation David M Nieto
2021-05-07  7:18   ` Christian König
2021-05-10 20:29     ` [PATCH 1/2] drm/amdgpu: free resources on fence usage query David M Nieto
2021-05-10 20:29       ` [PATCH 2/2] drm/amdgpu: fix fence calculation David M Nieto
2021-05-11  7:53         ` Christian König
2021-05-11 18:14           ` Nieto, David M
2021-05-12  6:55             ` Christian König
2021-05-12  6:56               ` Christian König [this message]
2021-05-12 19:40                 ` Nieto, David M
2021-05-12 19:45                 ` [PATCH 1/2] drm/amdgpu: free resources on fence usage query David M Nieto
2021-05-12 19:45                   ` [PATCH 2/2] drm/amdgpu: fix fence calculation David M Nieto
2021-05-13  8:11                     ` Christian König
2021-05-13 17:42                       ` Nieto, David M
2021-05-13 17:45                       ` [PATCH 1/2] drm/amdgpu: free resources on fence usage query David M Nieto
2021-05-13 17:45                         ` [PATCH 2/2] drm/amdgpu: fix fence calculation (v2) David M Nieto
2021-05-13 18:00                         ` [PATCH 1/2] drm/amdgpu: free resources on fence usage query Alex Deucher
2021-05-14  7:26                           ` Christian König
2021-05-14 14:01                             ` Alex Deucher
     [not found] <579fa92-ad25-323a-0c41-ac07ac47fa42@gmail.com>
2021-05-11 18:27 ` David M Nieto
2021-05-11 18:27   ` [PATCH 2/2] drm/amdgpu: fix fence calculation David M Nieto

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f689c523-c60a-a0d2-ca6a-5dcb043ffc91@gmail.com \
    --to=ckoenig.leichtzumerken@gmail.com \
    --cc=David.Nieto@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox