<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<p style="font-family:Calibri;font-size:10pt;color:#0000FF;margin:5pt;font-style:normal;font-weight:normal;text-decoration:none;" align="Left">
[AMD Official Use Only - AMD Internal Distribution Only]<br>
</p>
<br>
<div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Let's drop this patch: the amdgpu_vm_*_ptes events already contain all the info I need.</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Thanks,</div>
<div class="elementToProof" style="font-family: Aptos, Aptos_EmbeddedFont, Aptos_MSFontService, Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Pierre-Eric</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Christian König <ckoenig.leichtzumerken@gmail.com><br>
<b>Sent:</b> Monday, June 3, 2024 4:12 PM<br>
<b>To:</b> Pierre-Eric Pelloux-Prayer <pierre-eric@damsy.net>; Koenig, Christian <Christian.Koenig@amd.com>; Pelloux-Prayer, Pierre-Eric <Pierre-eric.Pelloux-prayer@amd.com>; Deucher, Alexander <Alexander.Deucher@amd.com>; amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Subject:</b> Re: [PATCH 1/2] amdgpu: add the amdgpu_vm ptr in the vm_bo_map/unmap events</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">Am 03.06.24 um 13:52 schrieb Pierre-Eric Pelloux-Prayer:<br>
> Hi Christia,<br>
><br>
> Le 03/06/2024 ā 11:58, Christian König a écrit :<br>
>> Am 03.06.24 um 10:46 schrieb Pierre-Eric Pelloux-Prayer:<br>
>>> These 2 traces events are tied to a specific VM so in order for them<br>
>>> to be useful for a tool we need to trace the amdgpu_vm as well.<br>
>><br>
>> The bo_va already contains the VM pointer the map/unmap operation <br>
>> belongs to.<br>
>><br>
><br>
> Indeed, I've missed that. I'll fix that in v2.<br>
><br>
>>><br>
>>> Signed-off-by: Pierre-Eric Pelloux-Prayer <br>
>>> <pierre-eric.pelloux-prayer@amd.com><br>
>>> ---<br>
>>> drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 20 ++++++++++++--------<br>
>>> drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c | 8 ++++----<br>
>>> 2 files changed, 16 insertions(+), 12 deletions(-)<br>
>>><br>
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h <br>
>>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h<br>
>>> index f539b1d00234..c84050d318d6 100644<br>
>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h<br>
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h<br>
>>> @@ -243,10 +243,11 @@ TRACE_EVENT(amdgpu_vm_grab_id,<br>
>>> );<br>
>>> TRACE_EVENT(amdgpu_vm_bo_map,<br>
>>> - TP_PROTO(struct amdgpu_bo_va *bo_va,<br>
>>> + TP_PROTO(struct amdgpu_vm *vm, struct amdgpu_bo_va *bo_va,<br>
>>> struct amdgpu_bo_va_mapping *mapping),<br>
>>> - TP_ARGS(bo_va, mapping),<br>
>>> + TP_ARGS(vm, bo_va, mapping),<br>
>>> TP_STRUCT__entry(<br>
>>> + __field(struct amdgpu_vm *, vm)<br>
>>> __field(struct amdgpu_bo *, bo)<br>
>>> __field(long, start)<br>
>>> __field(long, last)<br>
>>> @@ -255,22 +256,24 @@ TRACE_EVENT(amdgpu_vm_bo_map,<br>
>>> ),<br>
>>> TP_fast_assign(<br>
>>> + __entry->vm = vm;<br>
>>> __entry->bo = bo_va ? bo_va->base.bo : NULL;<br>
>>> __entry->start = mapping->start;<br>
>>> __entry->last = mapping->last;<br>
>>> __entry->offset = mapping->offset;<br>
>>> __entry->flags = mapping->flags;<br>
>>> ),<br>
>>> - TP_printk("bo=%p, start=%lx, last=%lx, offset=%010llx, <br>
>>> flags=%llx",<br>
>>> - __entry->bo, __entry->start, __entry->last,<br>
>>> + TP_printk("vm=%p bo=%p, start=%lx, last=%lx, <br>
>>> offset=%010llx, flags=%llx",<br>
>>> + __entry->vm, __entry->bo, __entry->start, __entry->last,<br>
>>> __entry->offset, __entry->flags)<br>
>>> );<br>
>>> TRACE_EVENT(amdgpu_vm_bo_unmap,<br>
>>> - TP_PROTO(struct amdgpu_bo_va *bo_va,<br>
>>> + TP_PROTO(struct amdgpu_vm *vm, struct amdgpu_bo_va *bo_va,<br>
>>> struct amdgpu_bo_va_mapping *mapping),<br>
>>> - TP_ARGS(bo_va, mapping),<br>
>>> + TP_ARGS(vm, bo_va, mapping),<br>
>>> TP_STRUCT__entry(<br>
>>> + __field(struct amdgpu_vm *, vm)<br>
>>> __field(struct amdgpu_bo *, bo)<br>
>>> __field(long, start)<br>
>>> __field(long, last)<br>
>>> @@ -279,14 +282,15 @@ TRACE_EVENT(amdgpu_vm_bo_unmap,<br>
>>> ),<br>
>>> TP_fast_assign(<br>
>>> + __entry->vm = vm;<br>
>>> __entry->bo = bo_va ? bo_va->base.bo : NULL;<br>
>>> __entry->start = mapping->start;<br>
>>> __entry->last = mapping->last;<br>
>>> __entry->offset = mapping->offset;<br>
>>> __entry->flags = mapping->flags;<br>
>>> ),<br>
>>> - TP_printk("bo=%p, start=%lx, last=%lx, offset=%010llx, <br>
>>> flags=%llx",<br>
>>> - __entry->bo, __entry->start, __entry->last,<br>
>>> + TP_printk("vm=%p bo=%p, start=%lx, last=%lx, <br>
>>> offset=%010llx, flags=%llx",<br>
>>> + __entry->vm, __entry->bo, __entry->start, __entry->last,<br>
>>> __entry->offset, __entry->flags)<br>
>>> );<br>
>>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c <br>
>>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<br>
>>> index 3abfa66d72a2..e04928d2e26a 100644<br>
>>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<br>
>>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c<br>
>>> @@ -1642,7 +1642,7 @@ static void amdgpu_vm_bo_insert_map(struct <br>
>>> amdgpu_device *adev,<br>
>>> if (amdgpu_vm_is_bo_always_valid(vm, bo) && !bo_va->base.moved)<br>
>>> amdgpu_vm_bo_moved(&bo_va->base);<br>
>>> - trace_amdgpu_vm_bo_map(bo_va, mapping);<br>
>>> + trace_amdgpu_vm_bo_map(vm, bo_va, mapping);<br>
>>> }<br>
>>> /* Validate operation parameters to prevent potential abuse */<br>
>>> @@ -1834,7 +1834,7 @@ int amdgpu_vm_bo_unmap(struct amdgpu_device <br>
>>> *adev,<br>
>>> list_del(&mapping->list);<br>
>>> amdgpu_vm_it_remove(mapping, &vm->va);<br>
>>> mapping->bo_va = NULL;<br>
>>> - trace_amdgpu_vm_bo_unmap(bo_va, mapping);<br>
>>> + trace_amdgpu_vm_bo_unmap(vm, bo_va, mapping);<br>
>>> if (valid)<br>
>>> list_add(&mapping->list, &vm->freed);<br>
>>> @@ -1929,7 +1929,7 @@ int amdgpu_vm_bo_clear_mappings(struct <br>
>>> amdgpu_device *adev,<br>
>>> tmp->bo_va = NULL;<br>
>>> list_add(&tmp->list, &vm->freed);<br>
>>> - trace_amdgpu_vm_bo_unmap(NULL, tmp);<br>
>>> + trace_amdgpu_vm_bo_unmap(vm, NULL, tmp);<br>
>><br>
>> That bo_va is NULL here is probably a bug and should be fixed.<br>
><br>
> Would something like this work?<br>
><br>
> trace_amdgpu_vm_bo_unmap(tmp->bo_va, tmp);<br>
> tmp->bo_va = NULL;<br>
> list_add(&tmp->list, &vm->freed);<br>
<br>
It's not 100% accurate because only parts of the mapping is unmapped, <br>
but yes I think that should work.<br>
<br>
Regards,<br>
Christian.<br>
<br>
><br>
> Thanks,<br>
> Pierre-Eric<br>
><br>
><br>
>><br>
>> Regards,<br>
>> Christian.<br>
>><br>
>>> }<br>
>>> /* Insert partial mapping before the range */<br>
>>> @@ -2056,7 +2056,7 @@ void amdgpu_vm_bo_del(struct amdgpu_device *adev,<br>
>>> list_del(&mapping->list);<br>
>>> amdgpu_vm_it_remove(mapping, &vm->va);<br>
>>> mapping->bo_va = NULL;<br>
>>> - trace_amdgpu_vm_bo_unmap(bo_va, mapping);<br>
>>> + trace_amdgpu_vm_bo_unmap(vm, bo_va, mapping);<br>
>>> list_add(&mapping->list, &vm->freed);<br>
>>> }<br>
>>> list_for_each_entry_safe(mapping, next, &bo_va->invalids, list) {<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>