From: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
To: "Li, Yunxiang (Teddy)" <Yunxiang.Li@amd.com>,
"dri-devel@lists.freedesktop.org"
<dri-devel@lists.freedesktop.org>,
"amd-gfx@lists.freedesktop.org" <amd-gfx@lists.freedesktop.org>,
"Koenig, Christian" <Christian.Koenig@amd.com>
Cc: "Deucher, Alexander" <Alexander.Deucher@amd.com>
Subject: Re: [PATCH v6 4/5] drm: add drm_memory_stats_is_zero
Date: Thu, 7 Nov 2024 14:43:55 +0000 [thread overview]
Message-ID: <bac29354-640f-4f39-b694-b611407c35ae@igalia.com> (raw)
In-Reply-To: <SA1PR12MB8599D376A7EBAB3F46302297ED5C2@SA1PR12MB8599.namprd12.prod.outlook.com>
On 07/11/2024 14:17, Li, Yunxiang (Teddy) wrote:
> [AMD Official Use Only - AMD Internal Distribution Only]
>
>> From: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
>> Sent: Thursday, November 7, 2024 5:41
>> On 25/10/2024 18:41, Yunxiang Li wrote:
>>> Add a helper to check if the memory stats is zero, this will be used
>>> to check for memory accounting errors.
>>>
>>> Signed-off-by: Yunxiang Li <Yunxiang.Li@amd.com>
>>> ---
>>> drivers/gpu/drm/drm_file.c | 9 +++++++++
>>> include/drm/drm_file.h | 1 +
>>> 2 files changed, 10 insertions(+)
>>>
>>> diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
>>> index 714e42b051080..75ed701d80f74 100644
>>> --- a/drivers/gpu/drm/drm_file.c
>>> +++ b/drivers/gpu/drm/drm_file.c
>>> @@ -859,6 +859,15 @@ static void print_size(struct drm_printer *p, const char
>> *stat,
>>> drm_printf(p, "drm-%s-%s:\t%llu%s\n", stat, region, sz, units[u]);
>>> }
>>>
>>> +int drm_memory_stats_is_zero(const struct drm_memory_stats *stats) {
>>> + return (stats->shared == 0 &&
>>> + stats->private == 0 &&
>>> + stats->resident == 0 &&
>>> + stats->purgeable == 0 &&
>>> + stats->active == 0);
>>> +}
>>
>> Could use mem_is_zero() for some value of source/binary compactness.
>
> Yeah, the patch set started out with that when it's just a function in amdgpu, but Christ didn't like it.
Okay, I don't feel so strongly about the implementation details.
>>> +EXPORT_SYMBOL(drm_memory_stats_is_zero);
>>> +
>>
>> I am not a huge fan of adding this as an interface as the only caller appears to be a
>> sanity check in amdgpu_vm_fini():
>>
>> if (!amdgpu_vm_stats_is_zero(vm))
>> dev_err(adev->dev, "VM memory stats is non-zero when fini\n");
>>
>> But I guess there is some value in sanity checking since amdgpu does not have a
>> notion of debug only code (compiled at production and exercised via a test suite).
>>
>> I do suggest to demote the dev_err to notice log level would suffice and be more
>> accurate.
>
> I think it's very important to have a check like this when we have a known invariant, especially in this case where there's stat tracking code spread out everywhere and we have very little chance of catching a bug right when it happened. And since whenever this check fails we know for sure there is a bug, I don't see the harm of keeping it as an error.
It would indeed be a programming error if it can happen, but from the
point of view of a driver and system log I think a warning is actually
right.
Regards,
Tvrtko
>
> Now that I think about it, I probably want to have the process & task name in here to aid in reproduction.
>
> Teddy
next prev parent reply other threads:[~2024-11-08 8:59 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-25 17:41 [PATCH v6 0/5] rework bo mem stats tracking Yunxiang Li
2024-10-25 17:41 ` [PATCH v6 1/5] drm/amdgpu: remove unused function parameter Yunxiang Li
2024-10-25 17:41 ` [PATCH v6 2/5] drm/amdgpu: make drm-memory-* report resident memory Yunxiang Li
2024-10-25 17:41 ` [PATCH v6 3/5] drm/amdgpu: stop tracking visible memory stats Yunxiang Li
2024-10-25 17:41 ` [PATCH v6 4/5] drm: add drm_memory_stats_is_zero Yunxiang Li
2024-10-31 12:34 ` Christian König
2024-11-07 10:41 ` Tvrtko Ursulin
2024-11-07 14:17 ` Li, Yunxiang (Teddy)
2024-11-07 14:43 ` Tvrtko Ursulin [this message]
2024-11-07 14:47 ` Christian König
2024-10-25 17:41 ` [PATCH v6 5/5] drm/amdgpu: track bo memory stats at runtime Yunxiang Li
2024-10-31 12:53 ` Christian König
2024-10-31 13:48 ` Li, Yunxiang (Teddy)
2024-11-07 10:48 ` Tvrtko Ursulin
2024-11-07 14:24 ` Li, Yunxiang (Teddy)
2024-11-07 14:55 ` Tvrtko Ursulin
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=bac29354-640f-4f39-b694-b611407c35ae@igalia.com \
--to=tvrtko.ursulin@igalia.com \
--cc=Alexander.Deucher@amd.com \
--cc=Christian.Koenig@amd.com \
--cc=Yunxiang.Li@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=dri-devel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.