amd-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: "Li, Yunxiang (Teddy)" <Yunxiang.Li@amd.com>,
	"Christian König" <ckoenig.leichtzumerken@gmail.com>,
	"amd-gfx@lists.freedesktop.org" <amd-gfx@lists.freedesktop.org>,
	"tvrtko.ursulin@igalia.com" <tvrtko.ursulin@igalia.com>
Cc: "Deucher, Alexander" <Alexander.Deucher@amd.com>
Subject: Re: [PATCH v7 4/4] drm/amdgpu: track bo memory stats at runtime
Date: Wed, 13 Nov 2024 15:19:51 +0100	[thread overview]
Message-ID: <e04ecd40-5026-4be5-a0dc-d276f117ddba@amd.com> (raw)
In-Reply-To: <SA1PR12MB8599C03D7B92F3B24976552AED5A2@SA1PR12MB8599.namprd12.prod.outlook.com>

Am 13.11.24 um 15:09 schrieb Li, Yunxiang (Teddy):
> [Public]
>
>> From: Koenig, Christian <Christian.Koenig@amd.com>
>> Sent: Wednesday, November 13, 2024 3:49
>> Am 12.11.24 um 19:16 schrieb Li, Yunxiang (Teddy):
>>>> From: Christian König <ckoenig.leichtzumerken@gmail.com>
>>>> Sent: Tuesday, November 12, 2024 5:54
>>>> Am 10.11.24 um 16:41 schrieb Yunxiang Li:
>>>>> @@ -2612,7 +2707,6 @@ void amdgpu_vm_fini(struct amdgpu_device
>>>>> *adev, struct amdgpu_vm *vm)
>>>>>
>>>>>       root = amdgpu_bo_ref(vm->root.bo);
>>>>>       amdgpu_bo_reserve(root, true);
>>>>> -   amdgpu_vm_put_task_info(vm->task_info);
>>>>>       amdgpu_vm_set_pasid(adev, vm, 0);
>>>>>       dma_fence_wait(vm->last_unlocked, false);
>>>>>       dma_fence_put(vm->last_unlocked); @@ -2660,6 +2754,15 @@ void
>>>>> amdgpu_vm_fini(struct amdgpu_device *adev,
>>>> struct amdgpu_vm *vm)
>>>>>               }
>>>>>       }
>>>>>
>>>>> +   if (!amdgpu_vm_stats_is_zero(vm)) {
>>>>> +           struct amdgpu_task_info *ti = vm->task_info;
>>>>> +
>>>>> +           dev_warn(adev->dev,
>>>>> +                    "VM memory stats for proc %s(%d) task %s(%d) is
>>>>> + non-zero
>>>> when fini\n",
>>>>> +                    ti->process_name, ti->pid, ti->task_name, ti->tgid);
>>>>> +   }
>>>>> +
>>>>> +   amdgpu_vm_put_task_info(vm->task_info);
>>>> Please don't move the call to amdgpu_vm_put_task_info().
>>> Is keeping the task_info alive a hazard here? I could copy out the info, it just
>> seemed a bit wasteful.
>>
>> Ah, now I see why you have moved that.
>>
>> IIRC we need to free up the task info before releasing the PASID, but that info might
>> be outdated. Need to check the code.
>>
>> Does it work if you move the message further up or does the root PD then break
>> your neck because it isn't released yet?
>>
>> Thanks,
>> Christian.
> It needs to be after root BO is deleted. I think there's a way to go from pasid to task_info but not the other way around, so it should be safe? It's okay if the pasid/pid/etc gets recycled before we get here and we print outdated info since it's just so we know which application we should use to try to reproduce the bug.

Double checked that and the order is actually incorrect right now and 
your patch here is fixing it!

The call to amdgpu_vm_put_task_info() needs to be after the call to 
amdgpu_vm_set_pasid(adev, vm, 0) or otherwise fault handling might use a 
freed up task info.

So feel free to completely ignore my comment, you're actually fixing things.

Regards,
Christian.


>
> Teddy


      reply	other threads:[~2024-11-13 14:20 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
2024-11-14 15:52                     ` Li, Yunxiang (Teddy)
2024-11-13 14:09         ` Li, Yunxiang (Teddy)
2024-11-13 14:19           ` Christian König [this message]

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=e04ecd40-5026-4be5-a0dc-d276f117ddba@amd.com \
    --to=christian.koenig@amd.com \
    --cc=Alexander.Deucher@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;
as well as URLs for NNTP newsgroup(s).