AMD-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Auld <matthew.auld@intel.com>
To: "Tvrtko Ursulin" <tvrtko.ursulin@igalia.com>,
	"Li, Yunxiang (Teddy)" <Yunxiang.Li@amd.com>,
	"Koenig, Christian" <Christian.Koenig@amd.com>,
	"Christian König" <ckoenig.leichtzumerken@gmail.com>,
	"amd-gfx@lists.freedesktop.org" <amd-gfx@lists.freedesktop.org>
Cc: "Deucher, Alexander" <Alexander.Deucher@amd.com>
Subject: Re: [PATCH v7 4/4] drm/amdgpu: track bo memory stats at runtime
Date: Thu, 14 Nov 2024 09:06:33 +0000	[thread overview]
Message-ID: <1e64ea08-a317-4475-974f-61788799982e@intel.com> (raw)
In-Reply-To: <dd23e624-c8c5-41f4-b4b0-316351d8c8e4@igalia.com>

Hi,

On 13/11/2024 17:30, Tvrtko Ursulin wrote:
> 
> On 13/11/2024 17:01, Li, Yunxiang (Teddy) wrote:
>> [Public]
>>
>>> From: Koenig, Christian <Christian.Koenig@amd.com>
>>> Sent: Wednesday, November 13, 2024 9:22
>>> Am 13.11.24 um 14:53 schrieb Li, Yunxiang (Teddy):
>>>> [Public]
>>>>
>>>>> From: Koenig, Christian <Christian.Koenig@amd.com>
>>>>> Sent: Wednesday, November 13, 2024 6:39 Am 13.11.24 um 11:25 schrieb
>>>>> Tvrtko Ursulin:
>>>>>> On 13/11/2024 08:49, Christian König wrote:
>>>>>>> Am 12.11.24 um 19:16 schrieb Li, Yunxiang (Teddy):
>>>>>>>> [SNIP]
>>>>>>>>>> +   size = sign * amdgpu_bo_size(bo);
>>>>>>>>>> +   res = bo->tbo.resource;
>>>>>>>>>> +   type = res ? res->mem_type :
>>>>>>>>>> amdgpu_bo_get_preferred_placement(bo);
>>>>>>>>> Again, it's a clear NAK from my side to do stuff like that.
>>>>>>>>>
>>>>>>>>> When there isn't any backing store the BO should *not* be
>>>>>>>>> accounted to anything.
>>>>>>>> I don't have a preference either way, but I think it should be a
>>>>>>>> separate discussion to properly define what drm-total- means.
>>>>>> Total must show the total size of all BOs which exist even if they
>>>>>> don't currently have a backing store. That's how drm-usage-stats.rst
>>>>>> defines the field and that is how all the other drivers work.
>>>>> In that case we should only look at the preferred placement and not
>>>>> the backing store at all.
>>>>>
>>>>> But that makes the total identical to the requested value, doesn't it?
>>>> Yes, the issue is not which BO needs to be counted but where they 
>>>> should be
>>> counted. This gets more complicated if we consider BOs to prefer 
>>> multiple
>>> placements.
>>>>
>>>> IMO it makes sense to have drm-total- to work like the legacy amd- 
>>>> requested-
>>> where we look at BO's preferred placement. For multiple preferred 
>>> placements we
>>> say that the implementation needs to pick one of them to avoid double 
>>> counting, but
>>> which one is up to the implementation as long as it's done in a 
>>> consistent manner.
>>> Does that sound reasonable?
>>>
>>> Yeah that works for me. Just don't look at both bo- 
>>> >preferred_placement and bo-
>>>> tbo.resource because that will certainly be inconsistent in some use 
>>>> cases.
>>
>> oof, from the commit message i915/xe is doing the exact opposite, BO 
>> gets counted in the totals for all the possible(preferred?) regions.
> 
> Which commit message? I was doing that early during i915 patch 
> development but stopped in v2:
> 
> commit 968853033d8aa4dbb80fbafa6f5d9b6a0ea21272
> Author: Tvrtko Ursulin <tursulin@ursulin.net>
> Date:   Tue Nov 7 10:18:06 2023 +0000
> 
>      drm/i915: Implement fdinfo memory stats printing
> 
>      Use the newly added drm_print_memory_stats helper to show memory
>      utilisation of our objects in drm/driver specific fdinfo output.
> 
>      To collect the stats we walk the per memory regions object lists
>      and accumulate object size into the respective drm_memory_stats
>      categories.
> 
>      v2:
>       * Only account against the active region.
> 
> ^^^ THIS ^^^
> 
>       * Use DMA_RESV_USAGE_BOOKKEEP when testing for active. (Tejas)
> 
>      v3:
>       * Update commit text. (Aravind)
>       * Update to use memory regions uabi names.
> 
> In code that would be here:
> 
> static void
> obj_meminfo(struct drm_i915_gem_object *obj,
>          struct drm_memory_stats stats[INTEL_REGION_UNKNOWN])
> {
>      const enum intel_region_id id = obj->mm.region ?
>                      obj->mm.region->id : INTEL_REGION_SMEM;
> 
> So either active region or SMEM if no backing store. Maybe that should 
> be improved too. Grr (to myself).
> 
> I don't see xe is counting total against all regions either, apart that 
> maybe it has potential null ptr deref?
> 
> static void bo_meminfo(struct xe_bo *bo,
>                 struct drm_memory_stats stats[TTM_NUM_MEM_TYPES])
> {
>      u64 sz = bo->size;
>      u32 mem_type = bo->ttm.resource->mem_type;
> 
> Or is bo->ttm.resource always present in xe? Adding Matt according to 
> git blame.

Right, we shouldn't currently have a way of seeing NULL resource here in 
xe, at least if we are holding the bo lock.

> 
> Regards,
> 
> Tvrtko
> 
>>
>> Teddy


  reply	other threads:[~2024-11-14  9:06 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-10 15:41 [PATCH v7 0/4] rework bo mem stats tracking Yunxiang Li
2024-11-10 15:41 ` [PATCH v7 1/4] drm: add drm_memory_stats_is_zero Yunxiang Li
2024-11-10 15:41 ` [PATCH v7 2/4] drm: make drm-active- stats optional Yunxiang Li
2024-11-11  9:14   ` Jani Nikula
2024-11-11 14:28     ` [PATCH v8 " Yunxiang Li
2024-11-11 10:29   ` [PATCH v7 " Tvrtko Ursulin
2024-11-18 15:17     ` Li, Yunxiang (Teddy)
2024-11-18 15:42       ` Tvrtko Ursulin
2024-11-10 15:41 ` [PATCH v7 3/4] drm/amdgpu: remove unused function parameter Yunxiang Li
2024-11-10 15:41 ` [PATCH v7 4/4] drm/amdgpu: track bo memory stats at runtime Yunxiang Li
2024-11-12 10:54   ` Christian König
2024-11-12 18:16     ` Li, Yunxiang (Teddy)
2024-11-13  8:49       ` Christian König
2024-11-13 10:25         ` Tvrtko Ursulin
2024-11-13 11:38           ` Christian König
2024-11-13 13:53             ` Li, Yunxiang (Teddy)
2024-11-13 14:22               ` Christian König
2024-11-13 17:01                 ` Li, Yunxiang (Teddy)
2024-11-13 17:30                   ` Tvrtko Ursulin
2024-11-14  9:06                     ` Matthew Auld [this message]
2024-11-14 15:52                     ` Li, Yunxiang (Teddy)
2024-11-13 14:09         ` Li, Yunxiang (Teddy)
2024-11-13 14:19           ` Christian König

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=1e64ea08-a317-4475-974f-61788799982e@intel.com \
    --to=matthew.auld@intel.com \
    --cc=Alexander.Deucher@amd.com \
    --cc=Christian.Koenig@amd.com \
    --cc=Yunxiang.Li@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=ckoenig.leichtzumerken@gmail.com \
    --cc=tvrtko.ursulin@igalia.com \
    /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