Skip to contentSkip to conversation

drm/amdgpu: add new trace event for page table update v3

PATCH Superseded Shashank Sharma 4 participants 15 messages Aug 13, 2020 – Aug 19, 2020

Subsystems (2)

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/1 drm/amdgpu: add new trace event for page table update v3

This patch adds a new trace event to track the PTE update events. This specific event will provide information like:
- start and end of virtual memory mapping
- HW engine flags for the map
- physical address for mapping

This will be particularly useful for memory profiling tools (like RMV) which are monitoring the page table update events.

V2: Added physical address lookup logic in trace point
V3: switch to use __dynamic_array
added nptes int the TPprint arguments list added page size in the arg list
V4: Addressed Christian's review comments
add start/end instead of seg
use incr instead of page_sz to be accurate

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 37 +++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c    |  9 ++++--
 2 files changed, 44 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +37 -0
index 63e734a125fb..df12cf8466c2 100644
@@ -321,6 +321,43 @@ DEFINE_EVENT(amdgpu_vm_mapping, amdgpu_vm_bo_cs,
 	    TP_ARGS(mapping)
 );
 
+TRACE_EVENT(amdgpu_vm_update_ptes,
+	    TP_PROTO(struct amdgpu_vm_update_params *p,
+		     uint64_t start, uint64_t end,
+		     unsigned int nptes, uint64_t dst,
+		     uint64_t incr, uint64_t flags),
+	TP_ARGS(p, start, end, nptes, dst, incr, flags),
+	TP_STRUCT__entry(
+			 __field(u64, start)
+			 __field(u64, end)
+			 __field(u64, flags)
+			 __field(unsigned int, nptes)
+			 __field(u64, incr)
+			 __dynamic_array(u64, dst, nptes)
+	),
+
+	TP_fast_assign(
+			unsigned int i;
+
+			__entry->start = start;
+			__entry->end = end;
+			__entry->flags = flags;
+			__entry->incr = incr;
+			__entry->nptes = nptes;
+			for (i = 0; i < nptes; ++i) {
+				u64 addr = p->pages_addr ? amdgpu_vm_map_gart(
+					p->pages_addr, dst) : dst;
+
+				((u64 *)__get_dynamic_array(dst))[i] = addr;
+				dst += incr;
+			}
+	),
+	TP_printk("start:0x%010llx end:0x%010llx, flags:0x%llx, incr:%llu,"
+		  " dst:\n%s", __entry->start, __entry->end, __entry->flags,
+		  __entry->incr, __print_array(
+		  __get_dynamic_array(dst), __entry->nptes, 8))
+);
+
 TRACE_EVENT(amdgpu_vm_set_ptes,
 	    TP_PROTO(uint64_t pe, uint64_t addr, unsigned count,
 		     uint32_t incr, uint64_t flags, bool direct),
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +7 -2
index 71e005cf2952..b5dbb5e8bc61 100644
@@ -1513,17 +1513,22 @@ static int amdgpu_vm_update_ptes(struct amdgpu_vm_update_params *params,
 		do {
 			uint64_t upd_end = min(entry_end, frag_end);
 			unsigned nptes = (upd_end - frag_start) >> shift;
+			uint64_t upd_flags = flags | AMDGPU_PTE_FRAG(frag);
 
 			/* This can happen when we set higher level PDs to
 			 * silent to stop fault floods.
 			 */
 			nptes = max(nptes, 1u);
+
+			trace_amdgpu_vm_update_ptes(params, frag_start, upd_end,
+						    nptes, dst, incr,
+						    upd_flags);
 			amdgpu_vm_update_flags(params, pt, cursor.level,
 					       pe_start, dst, nptes, incr,
-					       flags | AMDGPU_PTE_FRAG(frag));
+					       upd_flags);
 
 			pe_start += nptes * 8;
-			dst += (uint64_t)nptes * AMDGPU_GPU_PAGE_SIZE << shift;
+			dst += nptes * incr;
 
 			frag_start = upd_end;
 			if (frag_start >= frag_end) {
Signature · 6 lines
2.25.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
maintainer
#1 lore raw

Am 13.08.20 um 05:04 schrieb Shashank Sharma:

Quoted 37 lines

This patch adds a new trace event to track the PTE update events. This specific event will provide information like:
- start and end of virtual memory mapping
- HW engine flags for the map
- physical address for mapping

This will be particularly useful for memory profiling tools (like RMV) which are monitoring the page table update events.

V2: Added physical address lookup logic in trace point
V3: switch to use __dynamic_array
added nptes int the TPprint arguments list added page size in the arg list
V4: Addressed Christian's review comments
add start/end instead of seg
use incr instead of page_sz to be accurate

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 37 +++++++++++++++++++++++
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c    |  9 ++++--
  2 files changed, 44 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +3 -0
index 63e734a125fb..df12cf8466c2 100644
@@ -321,6 +321,43 @@ DEFINE_EVENT(amdgpu_vm_mapping, amdgpu_vm_bo_cs,
  	    TP_ARGS(mapping)
  );
 
+TRACE_EVENT(amdgpu_vm_update_ptes,
+	    TP_PROTO(struct amdgpu_vm_update_params *p,
+		     uint64_t start, uint64_t end,

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h DEFINE_EVENT(amdgpu_vm_mapping, amdgpu_vm_bo_cs, · line 336

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +10 -0
+		     unsigned int nptes, uint64_t dst,
+		     uint64_t incr, uint64_t flags),
+	TP_ARGS(p, start, end, nptes, dst, incr, flags),
+	TP_STRUCT__entry(
+			 __field(u64, start)
+			 __field(u64, end)
+			 __field(u64, flags)
+			 __field(unsigned int, nptes)
+			 __field(u64, incr)
+			 __dynamic_array(u64, dst, nptes)

As discussed with the trace subsystem maintainer we need to add the pid and probably the VM context ID we use here to identify the updated VM.

Christian.

Quoted 46 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +24 -0
+	),
+
+	TP_fast_assign(
+			unsigned int i;
+
+			__entry->start = start;
+			__entry->end = end;
+			__entry->flags = flags;
+			__entry->incr = incr;
+			__entry->nptes = nptes;
+			for (i = 0; i < nptes; ++i) {
+				u64 addr = p->pages_addr ? amdgpu_vm_map_gart(
+					p->pages_addr, dst) : dst;
+
+				((u64 *)__get_dynamic_array(dst))[i] = addr;
+				dst += incr;
+			}
+	),
+	TP_printk("start:0x%010llx end:0x%010llx, flags:0x%llx, incr:%llu,"
+		  " dst:\n%s", __entry->start, __entry->end, __entry->flags,
+		  __entry->incr, __print_array(
+		  __get_dynamic_array(dst), __entry->nptes, 8))
+);
+
  TRACE_EVENT(amdgpu_vm_set_ptes,
  	    TP_PROTO(uint64_t pe, uint64_t addr, unsigned count,
  		     uint32_t incr, uint64_t flags, bool direct),
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +5 -0
index 71e005cf2952..b5dbb5e8bc61 100644
@@ -1513,17 +1513,22 @@ static int amdgpu_vm_update_ptes(struct amdgpu_vm_update_params *params,
  		do {
  			uint64_t upd_end = min(entry_end, frag_end);
  			unsigned nptes = (upd_end - frag_start) >> shift;
+			uint64_t upd_flags = flags | AMDGPU_PTE_FRAG(frag);
 
  			/* This can happen when we set higher level PDs to
  			 * silent to stop fault floods.
  			 */
  			nptes = max(nptes, 1u);
+
+			trace_amdgpu_vm_update_ptes(params, frag_start, upd_end,
+						    nptes, dst, incr,
+						    upd_flags);
  			amdgpu_vm_update_flags(params, pt, cursor.level,

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c static int amdgpu_vm_update_ptes(struct amdgpu_vm_update_params *params, · line 1534

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2 -2
  					       pe_start, dst, nptes, incr,
-					       flags | AMDGPU_PTE_FRAG(frag));
+					       upd_flags);
 
  			pe_start += nptes * 8;
-			dst += (uint64_t)nptes * AMDGPU_GPU_PAGE_SIZE << shift;
+			dst += nptes * incr;
 
  			frag_start = upd_end;
  			if (frag_start >= frag_end) {

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#2 lore raw
Quoted 51 lines · Christian König

Am 13.08.20 um 05:04 schrieb Shashank Sharma:

Quoted 37 lines

This patch adds a new trace event to track the PTE update events. This specific event will provide information like:
- start and end of virtual memory mapping
- HW engine flags for the map
- physical address for mapping

This will be particularly useful for memory profiling tools (like RMV) which are monitoring the page table update events.

V2: Added physical address lookup logic in trace point
V3: switch to use __dynamic_array
added nptes int the TPprint arguments list added page size in the arg list
V4: Addressed Christian's review comments
add start/end instead of seg
use incr instead of page_sz to be accurate

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 37 +++++++++++++++++++++++
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c    |  9 ++++--
  2 files changed, 44 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +3 -0
index 63e734a125fb..df12cf8466c2 100644
@@ -321,6 +321,43 @@ DEFINE_EVENT(amdgpu_vm_mapping, amdgpu_vm_bo_cs,
  	    TP_ARGS(mapping)
  );
 
+TRACE_EVENT(amdgpu_vm_update_ptes,
+	    TP_PROTO(struct amdgpu_vm_update_params *p,
+		     uint64_t start, uint64_t end,

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h DEFINE_EVENT(amdgpu_vm_mapping, amdgpu_vm_bo_cs, · line 336

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +10 -0
+		     unsigned int nptes, uint64_t dst,
+		     uint64_t incr, uint64_t flags),
+	TP_ARGS(p, start, end, nptes, dst, incr, flags),
+	TP_STRUCT__entry(
+			 __field(u64, start)
+			 __field(u64, end)
+			 __field(u64, flags)
+			 __field(unsigned int, nptes)
+			 __field(u64, incr)
+			 __dynamic_array(u64, dst, nptes)

As discussed with the trace subsystem maintainer we need to add the pid and probably the VM context ID we use here to identify the updated VM.

Quoted 1 line

Christian.

I printed both vm->task_info.pid Vs current->pid for testing, and I can see different values coming out of .

gnome-shell-2114  [011]    41.812894: amdgpu_vm_update_ptes: start:0x0800102e80 end:0x0800102e82, flags:0x80, incr:4096, pid=2128 vmid=0 cpid=2114

pid is vm->task_info.pid=2128 whereas cpid=2114 is current.pid.

Which is the one we want to send with the event ?

Trace event by default seems to be adding the process name and id at the header of the event (gnome-shell-2114), which is same as current.pid

Also, is it ok to extract vmid from job->vmid ?

Regards

Shashank

Quoted 51 lines
Quoted 51 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +24 -0
+	),
+
+	TP_fast_assign(
+			unsigned int i;
+
+			__entry->start = start;
+			__entry->end = end;
+			__entry->flags = flags;
+			__entry->incr = incr;
+			__entry->nptes = nptes;
+			for (i = 0; i < nptes; ++i) {
+				u64 addr = p->pages_addr ? amdgpu_vm_map_gart(
+					p->pages_addr, dst) : dst;
+
+				((u64 *)__get_dynamic_array(dst))[i] = addr;
+				dst += incr;
+			}
+	),
+	TP_printk("start:0x%010llx end:0x%010llx, flags:0x%llx, incr:%llu,"
+		  " dst:\n%s", __entry->start, __entry->end, __entry->flags,
+		  __entry->incr, __print_array(
+		  __get_dynamic_array(dst), __entry->nptes, 8))
+);
+
  TRACE_EVENT(amdgpu_vm_set_ptes,
  	    TP_PROTO(uint64_t pe, uint64_t addr, unsigned count,
  		     uint32_t incr, uint64_t flags, bool direct),
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +6 -1
index 71e005cf2952..b5dbb5e8bc61 100644
@@ -1513,17 +1513,22 @@ static int amdgpu_vm_update_ptes(struct amdgpu_vm_update_params *params,
  		do {
  			uint64_t upd_end = min(entry_end, frag_end);
  			unsigned nptes = (upd_end - frag_start) >> shift;
+			uint64_t upd_flags = flags | AMDGPU_PTE_FRAG(frag);
 
  			/* This can happen when we set higher level PDs to
  			 * silent to stop fault floods.
  			 */
  			nptes = max(nptes, 1u);
+
+			trace_amdgpu_vm_update_ptes(params, frag_start, upd_end,
+						    nptes, dst, incr,
+						    upd_flags);
  			amdgpu_vm_update_flags(params, pt, cursor.level,
  					       pe_start, dst, nptes, incr,
-					       flags | AMDGPU_PTE_FRAG(frag));
+					       upd_flags);
 
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c static int amdgpu_vm_update_ptes(struct amdgpu_vm_update_params *params, · line 1534

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -1
  			pe_start += nptes * 8;
-			dst += (uint64_t)nptes * AMDGPU_GPU_PAGE_SIZE << shift;
+			dst += nptes * incr;
 
  			frag_start = upd_end;
  			if (frag_start >= frag_end) {

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

maintainer
#3 lore raw

Am 19.08.20 um 13:52 schrieb Shashank Sharma:

Quoted 52 lines · Christian König
Quoted 51 lines

Am 13.08.20 um 05:04 schrieb Shashank Sharma:

Quoted 37 lines

This patch adds a new trace event to track the PTE update events. This specific event will provide information like:
- start and end of virtual memory mapping
- HW engine flags for the map
- physical address for mapping

This will be particularly useful for memory profiling tools (like RMV) which are monitoring the page table update events.

V2: Added physical address lookup logic in trace point
V3: switch to use __dynamic_array
added nptes int the TPprint arguments list added page size in the arg list
V4: Addressed Christian's review comments
add start/end instead of seg
use incr instead of page_sz to be accurate

---
   drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 37 +++++++++++++++++++++++
   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c    |  9 ++++--
   2 files changed, 44 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +3 -0
index 63e734a125fb..df12cf8466c2 100644
@@ -321,6 +321,43 @@ DEFINE_EVENT(amdgpu_vm_mapping, amdgpu_vm_bo_cs,
   	    TP_ARGS(mapping)
   );
 
+TRACE_EVENT(amdgpu_vm_update_ptes,
+	    TP_PROTO(struct amdgpu_vm_update_params *p,
+		     uint64_t start, uint64_t end,

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h DEFINE_EVENT(amdgpu_vm_mapping, amdgpu_vm_bo_cs, · line 336

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +10 -0
+		     unsigned int nptes, uint64_t dst,
+		     uint64_t incr, uint64_t flags),
+	TP_ARGS(p, start, end, nptes, dst, incr, flags),
+	TP_STRUCT__entry(
+			 __field(u64, start)
+			 __field(u64, end)
+			 __field(u64, flags)
+			 __field(unsigned int, nptes)
+			 __field(u64, incr)
+			 __dynamic_array(u64, dst, nptes)

As discussed with the trace subsystem maintainer we need to add the pid and probably the VM context ID we use here to identify the updated VM.

Quoted 8 lines
Quoted 1 line

Christian.

I printed both vm->task_info.pid Vs current->pid for testing, and I can see different values coming out of .

gnome-shell-2114  [011]    41.812894: amdgpu_vm_update_ptes: start:0x0800102e80 end:0x0800102e82, flags:0x80, incr:4096, pid=2128 vmid=0 cpid=2114

pid is vm->task_info.pid=2128 whereas cpid=2114 is current.pid.

Which is the one we want to send with the event ?

That is vm->task_info.pid, since this is the PID which is using the VM for command submission.

Quoted 4 lines

Trace event by default seems to be adding the process name and id at the header of the event (gnome-shell-2114), which is same as current.pid

Also, is it ok to extract vmid from job->vmid ?

Only in trace_amdgpu_vm_grab_id(), in all other cases it's probably not assigned yet.

Christian.

Quoted 56 lines

Regards

Shashank

Quoted 50 lines
Quoted 50 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +24 -0
+	),
+
+	TP_fast_assign(
+			unsigned int i;
+
+			__entry->start = start;
+			__entry->end = end;
+			__entry->flags = flags;
+			__entry->incr = incr;
+			__entry->nptes = nptes;
+			for (i = 0; i < nptes; ++i) {
+				u64 addr = p->pages_addr ? amdgpu_vm_map_gart(
+					p->pages_addr, dst) : dst;
+
+				((u64 *)__get_dynamic_array(dst))[i] = addr;
+				dst += incr;
+			}
+	),
+	TP_printk("start:0x%010llx end:0x%010llx, flags:0x%llx, incr:%llu,"
+		  " dst:\n%s", __entry->start, __entry->end, __entry->flags,
+		  __entry->incr, __print_array(
+		  __get_dynamic_array(dst), __entry->nptes, 8))
+);
+
   TRACE_EVENT(amdgpu_vm_set_ptes,
   	    TP_PROTO(uint64_t pe, uint64_t addr, unsigned count,
   		     uint32_t incr, uint64_t flags, bool direct),
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +6 -1
index 71e005cf2952..b5dbb5e8bc61 100644
@@ -1513,17 +1513,22 @@ static int amdgpu_vm_update_ptes(struct amdgpu_vm_update_params *params,
   		do {
   			uint64_t upd_end = min(entry_end, frag_end);
   			unsigned nptes = (upd_end - frag_start) >> shift;
+			uint64_t upd_flags = flags | AMDGPU_PTE_FRAG(frag);
 
   			/* This can happen when we set higher level PDs to
   			 * silent to stop fault floods.
   			 */
   			nptes = max(nptes, 1u);
+
+			trace_amdgpu_vm_update_ptes(params, frag_start, upd_end,
+						    nptes, dst, incr,
+						    upd_flags);
   			amdgpu_vm_update_flags(params, pt, cursor.level,
   					       pe_start, dst, nptes, incr,
-					       flags | AMDGPU_PTE_FRAG(frag));
+					       upd_flags);
 
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c static int amdgpu_vm_update_ptes(struct amdgpu_vm_update_params *params, · line 1534

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -1
   			pe_start += nptes * 8;
-			dst += (uint64_t)nptes * AMDGPU_GPU_PAGE_SIZE << shift;
+			dst += nptes * incr;
 
   			frag_start = upd_end;
   			if (frag_start >= frag_end) {

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#4 lore raw
Quoted 56 lines · Christian König

Am 19.08.20 um 13:52 schrieb Shashank Sharma:

Quoted 55 lines · Christian König
Quoted 51 lines

Am 13.08.20 um 05:04 schrieb Shashank Sharma:

Quoted 37 lines

This patch adds a new trace event to track the PTE update events. This specific event will provide information like:
- start and end of virtual memory mapping
- HW engine flags for the map
- physical address for mapping

This will be particularly useful for memory profiling tools (like RMV) which are monitoring the page table update events.

V2: Added physical address lookup logic in trace point
V3: switch to use __dynamic_array
added nptes int the TPprint arguments list added page size in the arg list
V4: Addressed Christian's review comments
add start/end instead of seg
use incr instead of page_sz to be accurate

---
   drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 37 +++++++++++++++++++++++
   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c    |  9 ++++--
   2 files changed, 44 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +3 -0
index 63e734a125fb..df12cf8466c2 100644
@@ -321,6 +321,43 @@ DEFINE_EVENT(amdgpu_vm_mapping, amdgpu_vm_bo_cs,
   	    TP_ARGS(mapping)
   );
 
+TRACE_EVENT(amdgpu_vm_update_ptes,
+	    TP_PROTO(struct amdgpu_vm_update_params *p,
+		     uint64_t start, uint64_t end,

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h DEFINE_EVENT(amdgpu_vm_mapping, amdgpu_vm_bo_cs, · line 336

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +10 -0
+		     unsigned int nptes, uint64_t dst,
+		     uint64_t incr, uint64_t flags),
+	TP_ARGS(p, start, end, nptes, dst, incr, flags),
+	TP_STRUCT__entry(
+			 __field(u64, start)
+			 __field(u64, end)
+			 __field(u64, flags)
+			 __field(unsigned int, nptes)
+			 __field(u64, incr)
+			 __dynamic_array(u64, dst, nptes)

As discussed with the trace subsystem maintainer we need to add the pid and probably the VM context ID we use here to identify the updated VM.

Quoted 1 line

Christian.

I printed both vm->task_info.pid Vs current->pid for testing, and I can see different values coming out of .

Quoted 7 lines
Quoted 5 lines

gnome-shell-2114  [011]    41.812894: amdgpu_vm_update_ptes: start:0x0800102e80 end:0x0800102e82, flags:0x80, incr:4096, pid=2128 vmid=0 cpid=2114

pid is vm->task_info.pid=2128 whereas cpid=2114 is current.pid.

Which is the one we want to send with the event ?

That is vm->task_info.pid, since this is the PID which is using the VM for command submission.

got it.

Quoted 6 lines
Quoted 4 lines

Trace event by default seems to be adding the process name and id at the header of the event (gnome-shell-2114), which is same as current.pid

Also, is it ok to extract vmid from job->vmid ?

Only in trace_amdgpu_vm_grab_id(), in all other cases it's probably not assigned yet.

Ok, let me check how can we get vmid from this context we are sending the event from. Or maybe I we should  keep V5 with pid only, and later send a separate patch to add vmid ?

- Shashank

Quoted 57 lines

Christian.

Quoted 55 lines

Regards

Shashank

Quoted 50 lines
Quoted 50 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +24 -0
+	),
+
+	TP_fast_assign(
+			unsigned int i;
+
+			__entry->start = start;
+			__entry->end = end;
+			__entry->flags = flags;
+			__entry->incr = incr;
+			__entry->nptes = nptes;
+			for (i = 0; i < nptes; ++i) {
+				u64 addr = p->pages_addr ? amdgpu_vm_map_gart(
+					p->pages_addr, dst) : dst;
+
+				((u64 *)__get_dynamic_array(dst))[i] = addr;
+				dst += incr;
+			}
+	),
+	TP_printk("start:0x%010llx end:0x%010llx, flags:0x%llx, incr:%llu,"
+		  " dst:\n%s", __entry->start, __entry->end, __entry->flags,
+		  __entry->incr, __print_array(
+		  __get_dynamic_array(dst), __entry->nptes, 8))
+);
+
   TRACE_EVENT(amdgpu_vm_set_ptes,
   	    TP_PROTO(uint64_t pe, uint64_t addr, unsigned count,
   		     uint32_t incr, uint64_t flags, bool direct),
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +6 -1
index 71e005cf2952..b5dbb5e8bc61 100644
@@ -1513,17 +1513,22 @@ static int amdgpu_vm_update_ptes(struct amdgpu_vm_update_params *params,
   		do {
   			uint64_t upd_end = min(entry_end, frag_end);
   			unsigned nptes = (upd_end - frag_start) >> shift;
+			uint64_t upd_flags = flags | AMDGPU_PTE_FRAG(frag);
 
   			/* This can happen when we set higher level PDs to
   			 * silent to stop fault floods.
   			 */
   			nptes = max(nptes, 1u);
+
+			trace_amdgpu_vm_update_ptes(params, frag_start, upd_end,
+						    nptes, dst, incr,
+						    upd_flags);
   			amdgpu_vm_update_flags(params, pt, cursor.level,
   					       pe_start, dst, nptes, incr,
-					       flags | AMDGPU_PTE_FRAG(frag));
+					       upd_flags);
 
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c static int amdgpu_vm_update_ptes(struct amdgpu_vm_update_params *params, · line 1534

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -1
   			pe_start += nptes * 8;
-			dst += (uint64_t)nptes * AMDGPU_GPU_PAGE_SIZE << shift;
+			dst += nptes * incr;
 
   			frag_start = upd_end;
   			if (frag_start >= frag_end) {

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#5 lore raw

Am 19.08.20 um 14:19 schrieb Shashank Sharma:

Quoted 64 lines · Christian König
Quoted 56 lines

Am 19.08.20 um 13:52 schrieb Shashank Sharma:

Quoted 55 lines · Christian König
Quoted 51 lines

Am 13.08.20 um 05:04 schrieb Shashank Sharma:

Quoted 37 lines

This patch adds a new trace event to track the PTE update events. This specific event will provide information like:
- start and end of virtual memory mapping
- HW engine flags for the map
- physical address for mapping

This will be particularly useful for memory profiling tools (like RMV) which are monitoring the page table update events.

V2: Added physical address lookup logic in trace point
V3: switch to use __dynamic_array
added nptes int the TPprint arguments list added page size in the arg list
V4: Addressed Christian's review comments
add start/end instead of seg
use incr instead of page_sz to be accurate

---
    drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 37 +++++++++++++++++++++++
    drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c    |  9 ++++--
    2 files changed, 44 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +3 -0
index 63e734a125fb..df12cf8466c2 100644
@@ -321,6 +321,43 @@ DEFINE_EVENT(amdgpu_vm_mapping, amdgpu_vm_bo_cs,
    	    TP_ARGS(mapping)
    );
 
+TRACE_EVENT(amdgpu_vm_update_ptes,
+	    TP_PROTO(struct amdgpu_vm_update_params *p,
+		     uint64_t start, uint64_t end,

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h DEFINE_EVENT(amdgpu_vm_mapping, amdgpu_vm_bo_cs, · line 336

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +10 -0
+		     unsigned int nptes, uint64_t dst,
+		     uint64_t incr, uint64_t flags),
+	TP_ARGS(p, start, end, nptes, dst, incr, flags),
+	TP_STRUCT__entry(
+			 __field(u64, start)
+			 __field(u64, end)
+			 __field(u64, flags)
+			 __field(unsigned int, nptes)
+			 __field(u64, incr)
+			 __dynamic_array(u64, dst, nptes)

As discussed with the trace subsystem maintainer we need to add the pid and probably the VM context ID we use here to identify the updated VM.

Quoted 1 line

Christian.

I printed both vm->task_info.pid Vs current->pid for testing, and I can see different values coming out of .

Quoted 7 lines
Quoted 5 lines

gnome-shell-2114  [011]    41.812894: amdgpu_vm_update_ptes: start:0x0800102e80 end:0x0800102e82, flags:0x80, incr:4096, pid=2128 vmid=0 cpid=2114

pid is vm->task_info.pid=2128 whereas cpid=2114 is current.pid.

Which is the one we want to send with the event ?

That is vm->task_info.pid, since this is the PID which is using the VM for command submission.

Quoted 8 lines

got it.

Quoted 6 lines
Quoted 4 lines

Trace event by default seems to be adding the process name and id at the header of the event (gnome-shell-2114), which is same as current.pid

Also, is it ok to extract vmid from job->vmid ?

Only in trace_amdgpu_vm_grab_id(), in all other cases it's probably not assigned yet.

Ok, let me check how can we get vmid from this context we are sending the event from. Or maybe I we should  keep V5 with pid only, and later send a separate patch to add vmid ?

I'm not sure how you want to get a VMID in the first place. We dynamically assign VMIDs during command submission.

See the amdgpu_vm_grab_id trace point.

Christian.

Quoted 63 lines

- Shashank

Quoted 60 lines

Christian.

Quoted 58 lines

Regards

Shashank

Quoted 54 lines
Quoted 54 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +24 -0
+	),
+
+	TP_fast_assign(
+			unsigned int i;
+
+			__entry->start = start;
+			__entry->end = end;
+			__entry->flags = flags;
+			__entry->incr = incr;
+			__entry->nptes = nptes;
+			for (i = 0; i < nptes; ++i) {
+				u64 addr = p->pages_addr ? amdgpu_vm_map_gart(
+					p->pages_addr, dst) : dst;
+
+				((u64 *)__get_dynamic_array(dst))[i] = addr;
+				dst += incr;
+			}
+	),
+	TP_printk("start:0x%010llx end:0x%010llx, flags:0x%llx, incr:%llu,"
+		  " dst:\n%s", __entry->start, __entry->end, __entry->flags,
+		  __entry->incr, __print_array(
+		  __get_dynamic_array(dst), __entry->nptes, 8))
+);
+
    TRACE_EVENT(amdgpu_vm_set_ptes,
    	    TP_PROTO(uint64_t pe, uint64_t addr, unsigned count,
    		     uint32_t incr, uint64_t flags, bool direct),
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +7 -2
index 71e005cf2952..b5dbb5e8bc61 100644
@@ -1513,17 +1513,22 @@ static int amdgpu_vm_update_ptes(struct amdgpu_vm_update_params *params,
    		do {
    			uint64_t upd_end = min(entry_end, frag_end);
    			unsigned nptes = (upd_end - frag_start) >> shift;
+			uint64_t upd_flags = flags | AMDGPU_PTE_FRAG(frag);
 
    			/* This can happen when we set higher level PDs to
    			 * silent to stop fault floods.
    			 */
    			nptes = max(nptes, 1u);
+
+			trace_amdgpu_vm_update_ptes(params, frag_start, upd_end,
+						    nptes, dst, incr,
+						    upd_flags);
    			amdgpu_vm_update_flags(params, pt, cursor.level,
    					       pe_start, dst, nptes, incr,
-					       flags | AMDGPU_PTE_FRAG(frag));
+					       upd_flags);
 
    			pe_start += nptes * 8;
-			dst += (uint64_t)nptes * AMDGPU_GPU_PAGE_SIZE << shift;
+			dst += nptes * incr;
 
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c static int amdgpu_vm_update_ptes(struct amdgpu_vm_update_params *params, · line 1534

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +0 -0
    			frag_start = upd_end;
    			if (frag_start >= frag_end) {

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#6 lore raw
Quoted 69 lines · Christian König

Am 19.08.20 um 14:19 schrieb Shashank Sharma:

Quoted 68 lines · Christian König
Quoted 56 lines

Am 19.08.20 um 13:52 schrieb Shashank Sharma:

Quoted 55 lines · Christian König
Quoted 51 lines

Am 13.08.20 um 05:04 schrieb Shashank Sharma:

Quoted 37 lines

This patch adds a new trace event to track the PTE update events. This specific event will provide information like:
- start and end of virtual memory mapping
- HW engine flags for the map
- physical address for mapping

This will be particularly useful for memory profiling tools (like RMV) which are monitoring the page table update events.

V2: Added physical address lookup logic in trace point
V3: switch to use __dynamic_array
added nptes int the TPprint arguments list added page size in the arg list
V4: Addressed Christian's review comments
add start/end instead of seg
use incr instead of page_sz to be accurate

---
    drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 37 +++++++++++++++++++++++
    drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c    |  9 ++++--
    2 files changed, 44 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +3 -0
index 63e734a125fb..df12cf8466c2 100644
@@ -321,6 +321,43 @@ DEFINE_EVENT(amdgpu_vm_mapping, amdgpu_vm_bo_cs,
    	    TP_ARGS(mapping)
    );
 
+TRACE_EVENT(amdgpu_vm_update_ptes,
+	    TP_PROTO(struct amdgpu_vm_update_params *p,
+		     uint64_t start, uint64_t end,

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h DEFINE_EVENT(amdgpu_vm_mapping, amdgpu_vm_bo_cs, · line 336

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +10 -0
+		     unsigned int nptes, uint64_t dst,
+		     uint64_t incr, uint64_t flags),
+	TP_ARGS(p, start, end, nptes, dst, incr, flags),
+	TP_STRUCT__entry(
+			 __field(u64, start)
+			 __field(u64, end)
+			 __field(u64, flags)
+			 __field(unsigned int, nptes)
+			 __field(u64, incr)
+			 __dynamic_array(u64, dst, nptes)

As discussed with the trace subsystem maintainer we need to add the pid and probably the VM context ID we use here to identify the updated VM.

Quoted 1 line

Christian.

I printed both vm->task_info.pid Vs current->pid for testing, and I can see different values coming out of .

Quoted 7 lines
Quoted 5 lines

gnome-shell-2114  [011]    41.812894: amdgpu_vm_update_ptes: start:0x0800102e80 end:0x0800102e82, flags:0x80, incr:4096, pid=2128 vmid=0 cpid=2114

pid is vm->task_info.pid=2128 whereas cpid=2114 is current.pid.

Which is the one we want to send with the event ?

That is vm->task_info.pid, since this is the PID which is using the VM for command submission.

got it.

Quoted 3 lines
Quoted 3 lines

Trace event by default seems to be adding the process name and id at the header of the event (gnome-shell-2114), which is same as current.pid

Quoted 8 lines
Quoted 4 lines
Quoted 3 lines
Quoted 1 line

Also, is it ok to extract vmid from job->vmid ?

Only in trace_amdgpu_vm_grab_id(), in all other cases it's probably not assigned yet.

Ok, let me check how can we get vmid from this context we are sending the event from. Or maybe I we should  keep V5 with pid only, and later send a separate patch to add vmid ?

I'm not sure how you want to get a VMID in the first place. We dynamically assign VMIDs during command submission.

See the amdgpu_vm_grab_id trace point.

Actually I was adding vmid to address this last comment on V4:

Quoted 1 line

and probably the VM context ID we use here to identify the updated VM.

I assumed you meant the vmid by this, is that not so ?

Regards

Shashank

Quoted 71 lines

Christian.

Quoted 68 lines

- Shashank

Quoted 56 lines

Christian.

Quoted 54 lines

Regards

Shashank

Quoted 50 lines
Quoted 50 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +24 -0
+	),
+
+	TP_fast_assign(
+			unsigned int i;
+
+			__entry->start = start;
+			__entry->end = end;
+			__entry->flags = flags;
+			__entry->incr = incr;
+			__entry->nptes = nptes;
+			for (i = 0; i < nptes; ++i) {
+				u64 addr = p->pages_addr ? amdgpu_vm_map_gart(
+					p->pages_addr, dst) : dst;
+
+				((u64 *)__get_dynamic_array(dst))[i] = addr;
+				dst += incr;
+			}
+	),
+	TP_printk("start:0x%010llx end:0x%010llx, flags:0x%llx, incr:%llu,"
+		  " dst:\n%s", __entry->start, __entry->end, __entry->flags,
+		  __entry->incr, __print_array(
+		  __get_dynamic_array(dst), __entry->nptes, 8))
+);
+
    TRACE_EVENT(amdgpu_vm_set_ptes,
    	    TP_PROTO(uint64_t pe, uint64_t addr, unsigned count,
    		     uint32_t incr, uint64_t flags, bool direct),
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +6 -1
index 71e005cf2952..b5dbb5e8bc61 100644
@@ -1513,17 +1513,22 @@ static int amdgpu_vm_update_ptes(struct amdgpu_vm_update_params *params,
    		do {
    			uint64_t upd_end = min(entry_end, frag_end);
    			unsigned nptes = (upd_end - frag_start) >> shift;
+			uint64_t upd_flags = flags | AMDGPU_PTE_FRAG(frag);
 
    			/* This can happen when we set higher level PDs to
    			 * silent to stop fault floods.
    			 */
    			nptes = max(nptes, 1u);
+
+			trace_amdgpu_vm_update_ptes(params, frag_start, upd_end,
+						    nptes, dst, incr,
+						    upd_flags);
    			amdgpu_vm_update_flags(params, pt, cursor.level,
    					       pe_start, dst, nptes, incr,
-					       flags | AMDGPU_PTE_FRAG(frag));
+					       upd_flags);
 
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c static int amdgpu_vm_update_ptes(struct amdgpu_vm_update_params *params, · line 1534

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -1
    			pe_start += nptes * 8;
-			dst += (uint64_t)nptes * AMDGPU_GPU_PAGE_SIZE << shift;
+			dst += nptes * incr;
 
    			frag_start = upd_end;
    			if (frag_start >= frag_end) {

_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=02%7C01%7Cshashank.sharma%40amd.com%7C294c0cf0460847953e8308d8443c163c%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637334372147156674&amp;sdata=3sWZcuLcWVTcspxhRq6gT1SM%2BvHQCrJqmJijKgREks0%3D&amp;reserved=0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

maintainer
#7 lore raw

Am 19.08.20 um 14:37 schrieb Shashank Sharma:

Quoted 73 lines · Christian König
Quoted 72 lines

Am 19.08.20 um 14:19 schrieb Shashank Sharma:

Quoted 71 lines · Christian König
Quoted 56 lines

Am 19.08.20 um 13:52 schrieb Shashank Sharma:

Quoted 55 lines · Christian König
Quoted 51 lines

Am 13.08.20 um 05:04 schrieb Shashank Sharma:

Quoted 37 lines

This patch adds a new trace event to track the PTE update events. This specific event will provide information like:
- start and end of virtual memory mapping
- HW engine flags for the map
- physical address for mapping

This will be particularly useful for memory profiling tools (like RMV) which are monitoring the page table update events.

V2: Added physical address lookup logic in trace point
V3: switch to use __dynamic_array
added nptes int the TPprint arguments list added page size in the arg list
V4: Addressed Christian's review comments
add start/end instead of seg
use incr instead of page_sz to be accurate

---
     drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 37 +++++++++++++++++++++++
     drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c    |  9 ++++--
     2 files changed, 44 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +3 -0
index 63e734a125fb..df12cf8466c2 100644
@@ -321,6 +321,43 @@ DEFINE_EVENT(amdgpu_vm_mapping, amdgpu_vm_bo_cs,
     	    TP_ARGS(mapping)
     );
 
+TRACE_EVENT(amdgpu_vm_update_ptes,
+	    TP_PROTO(struct amdgpu_vm_update_params *p,
+		     uint64_t start, uint64_t end,

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h DEFINE_EVENT(amdgpu_vm_mapping, amdgpu_vm_bo_cs, · line 336

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +10 -0
+		     unsigned int nptes, uint64_t dst,
+		     uint64_t incr, uint64_t flags),
+	TP_ARGS(p, start, end, nptes, dst, incr, flags),
+	TP_STRUCT__entry(
+			 __field(u64, start)
+			 __field(u64, end)
+			 __field(u64, flags)
+			 __field(unsigned int, nptes)
+			 __field(u64, incr)
+			 __dynamic_array(u64, dst, nptes)

As discussed with the trace subsystem maintainer we need to add the pid and probably the VM context ID we use here to identify the updated VM.

Quoted 1 line

Christian.

I printed both vm->task_info.pid Vs current->pid for testing, and I can see different values coming out of .

Quoted 7 lines
Quoted 5 lines

gnome-shell-2114  [011]    41.812894: amdgpu_vm_update_ptes: start:0x0800102e80 end:0x0800102e82, flags:0x80, incr:4096, pid=2128 vmid=0 cpid=2114

pid is vm->task_info.pid=2128 whereas cpid=2114 is current.pid.

Which is the one we want to send with the event ?

That is vm->task_info.pid, since this is the PID which is using the VM for command submission.

got it.

Quoted 6 lines
Quoted 4 lines

Trace event by default seems to be adding the process name and id at the header of the event (gnome-shell-2114), which is same as current.pid

Also, is it ok to extract vmid from job->vmid ?

Only in trace_amdgpu_vm_grab_id(), in all other cases it's probably not assigned yet.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Ok, let me check how can we get vmid from this context we are sending the event from. Or maybe I we should  keep V5 with pid only, and later send a separate patch to add vmid ?

I'm not sure how you want to get a VMID in the first place. We dynamically assign VMIDs during command submission.

See the amdgpu_vm_grab_id trace point.

Actually I was adding vmid to address this last comment on V4:

Quoted 1 line

and probably the VM context ID we use here to identify the updated VM.

I assumed you meant the vmid by this, is that not so ?

Ah! No that's something completely different :)

The VMID is a 4bit hardware identifier used for TLB optimization.

The VM context ID is an unique 64bit number, we usually use vm->immediate.fence_context for this.

Regards,
Christian.

Quoted 76 lines

Regards

Shashank

Quoted 70 lines

Christian.

Quoted 68 lines

- Shashank

Quoted 56 lines

Christian.

Quoted 54 lines

Regards

Shashank

Quoted 50 lines
Quoted 50 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +24 -0
+	),
+
+	TP_fast_assign(
+			unsigned int i;
+
+			__entry->start = start;
+			__entry->end = end;
+			__entry->flags = flags;
+			__entry->incr = incr;
+			__entry->nptes = nptes;
+			for (i = 0; i < nptes; ++i) {
+				u64 addr = p->pages_addr ? amdgpu_vm_map_gart(
+					p->pages_addr, dst) : dst;
+
+				((u64 *)__get_dynamic_array(dst))[i] = addr;
+				dst += incr;
+			}
+	),
+	TP_printk("start:0x%010llx end:0x%010llx, flags:0x%llx, incr:%llu,"
+		  " dst:\n%s", __entry->start, __entry->end, __entry->flags,
+		  __entry->incr, __print_array(
+		  __get_dynamic_array(dst), __entry->nptes, 8))
+);
+
     TRACE_EVENT(amdgpu_vm_set_ptes,
     	    TP_PROTO(uint64_t pe, uint64_t addr, unsigned count,
     		     uint32_t incr, uint64_t flags, bool direct),
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +6 -1
index 71e005cf2952..b5dbb5e8bc61 100644
@@ -1513,17 +1513,22 @@ static int amdgpu_vm_update_ptes(struct amdgpu_vm_update_params *params,
     		do {
     			uint64_t upd_end = min(entry_end, frag_end);
     			unsigned nptes = (upd_end - frag_start) >> shift;
+			uint64_t upd_flags = flags | AMDGPU_PTE_FRAG(frag);
 
     			/* This can happen when we set higher level PDs to
     			 * silent to stop fault floods.
     			 */
     			nptes = max(nptes, 1u);
+
+			trace_amdgpu_vm_update_ptes(params, frag_start, upd_end,
+						    nptes, dst, incr,
+						    upd_flags);
     			amdgpu_vm_update_flags(params, pt, cursor.level,
     					       pe_start, dst, nptes, incr,
-					       flags | AMDGPU_PTE_FRAG(frag));
+					       upd_flags);
 
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c static int amdgpu_vm_update_ptes(struct amdgpu_vm_update_params *params, · line 1534

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -1
     			pe_start += nptes * 8;
-			dst += (uint64_t)nptes * AMDGPU_GPU_PAGE_SIZE << shift;
+			dst += nptes * incr;
 
     			frag_start = upd_end;
     			if (frag_start >= frag_end) {

_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=02%7C01%7Cshashank.sharma%40amd.com%7C294c0cf0460847953e8308d8443c163c%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637334372147156674&amp;sdata=3sWZcuLcWVTcspxhRq6gT1SM%2BvHQCrJqmJijKgREks0%3D&amp;reserved=0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#8 lore raw
Quoted 80 lines · Christian König

Am 19.08.20 um 14:37 schrieb Shashank Sharma:

Quoted 79 lines · Christian König
Quoted 69 lines

Am 19.08.20 um 14:19 schrieb Shashank Sharma:

Quoted 68 lines · Christian König
Quoted 56 lines

Am 19.08.20 um 13:52 schrieb Shashank Sharma:

Quoted 55 lines · Christian König
Quoted 51 lines

Am 13.08.20 um 05:04 schrieb Shashank Sharma:

Quoted 37 lines

This patch adds a new trace event to track the PTE update events. This specific event will provide information like:
- start and end of virtual memory mapping
- HW engine flags for the map
- physical address for mapping

This will be particularly useful for memory profiling tools (like RMV) which are monitoring the page table update events.

V2: Added physical address lookup logic in trace point
V3: switch to use __dynamic_array
added nptes int the TPprint arguments list added page size in the arg list
V4: Addressed Christian's review comments
add start/end instead of seg
use incr instead of page_sz to be accurate

---
     drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 37 +++++++++++++++++++++++
     drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c    |  9 ++++--
     2 files changed, 44 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +3 -0
index 63e734a125fb..df12cf8466c2 100644
@@ -321,6 +321,43 @@ DEFINE_EVENT(amdgpu_vm_mapping, amdgpu_vm_bo_cs,
     	    TP_ARGS(mapping)
     );
 
+TRACE_EVENT(amdgpu_vm_update_ptes,
+	    TP_PROTO(struct amdgpu_vm_update_params *p,
+		     uint64_t start, uint64_t end,

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h DEFINE_EVENT(amdgpu_vm_mapping, amdgpu_vm_bo_cs, · line 336

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +10 -0
+		     unsigned int nptes, uint64_t dst,
+		     uint64_t incr, uint64_t flags),
+	TP_ARGS(p, start, end, nptes, dst, incr, flags),
+	TP_STRUCT__entry(
+			 __field(u64, start)
+			 __field(u64, end)
+			 __field(u64, flags)
+			 __field(unsigned int, nptes)
+			 __field(u64, incr)
+			 __dynamic_array(u64, dst, nptes)

As discussed with the trace subsystem maintainer we need to add the pid and probably the VM context ID we use here to identify the updated VM.

Quoted 1 line

Christian.

I printed both vm->task_info.pid Vs current->pid for testing, and I can see different values coming out of .

Quoted 7 lines
Quoted 5 lines

gnome-shell-2114  [011]    41.812894: amdgpu_vm_update_ptes: start:0x0800102e80 end:0x0800102e82, flags:0x80, incr:4096, pid=2128 vmid=0 cpid=2114

pid is vm->task_info.pid=2128 whereas cpid=2114 is current.pid.

Which is the one we want to send with the event ?

That is vm->task_info.pid, since this is the PID which is using the VM for command submission.

got it.

Quoted 3 lines
Quoted 3 lines

Trace event by default seems to be adding the process name and id at the header of the event (gnome-shell-2114), which is same as current.pid

Quoted 8 lines
Quoted 4 lines
Quoted 3 lines
Quoted 1 line

Also, is it ok to extract vmid from job->vmid ?

Only in trace_amdgpu_vm_grab_id(), in all other cases it's probably not assigned yet.

Ok, let me check how can we get vmid from this context we are sending the event from. Or maybe I we should  keep V5 with pid only, and later send a separate patch to add vmid ?

I'm not sure how you want to get a VMID in the first place. We dynamically assign VMIDs during command submission.

See the amdgpu_vm_grab_id trace point.

Actually I was adding vmid to address this last comment on V4:

Quoted 8 lines
Quoted 2 lines
Quoted 1 line

and probably the VM context ID we use here to identify the updated VM.

I assumed you meant the vmid by this, is that not so ?

Ah! No that's something completely different :)

The VMID is a 4bit hardware identifier used for TLB optimization.

The VM context ID is an unique 64bit number, we usually use vm->immediate.fence_context for this.

Damn, why is it never what you hope it to be :). Thanks for this information, I will check this out first.

- Shashank

Quoted 78 lines

Regards,
Christian.

Quoted 75 lines

Regards

Shashank

Quoted 70 lines

Christian.

Quoted 68 lines

- Shashank

Quoted 56 lines

Christian.

Quoted 54 lines

Regards

Shashank

Quoted 50 lines
Quoted 50 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +24 -0
+	),
+
+	TP_fast_assign(
+			unsigned int i;
+
+			__entry->start = start;
+			__entry->end = end;
+			__entry->flags = flags;
+			__entry->incr = incr;
+			__entry->nptes = nptes;
+			for (i = 0; i < nptes; ++i) {
+				u64 addr = p->pages_addr ? amdgpu_vm_map_gart(
+					p->pages_addr, dst) : dst;
+
+				((u64 *)__get_dynamic_array(dst))[i] = addr;
+				dst += incr;
+			}
+	),
+	TP_printk("start:0x%010llx end:0x%010llx, flags:0x%llx, incr:%llu,"
+		  " dst:\n%s", __entry->start, __entry->end, __entry->flags,
+		  __entry->incr, __print_array(
+		  __get_dynamic_array(dst), __entry->nptes, 8))
+);
+
     TRACE_EVENT(amdgpu_vm_set_ptes,
     	    TP_PROTO(uint64_t pe, uint64_t addr, unsigned count,
     		     uint32_t incr, uint64_t flags, bool direct),
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +6 -1
index 71e005cf2952..b5dbb5e8bc61 100644
@@ -1513,17 +1513,22 @@ static int amdgpu_vm_update_ptes(struct amdgpu_vm_update_params *params,
     		do {
     			uint64_t upd_end = min(entry_end, frag_end);
     			unsigned nptes = (upd_end - frag_start) >> shift;
+			uint64_t upd_flags = flags | AMDGPU_PTE_FRAG(frag);
 
     			/* This can happen when we set higher level PDs to
     			 * silent to stop fault floods.
     			 */
     			nptes = max(nptes, 1u);
+
+			trace_amdgpu_vm_update_ptes(params, frag_start, upd_end,
+						    nptes, dst, incr,
+						    upd_flags);
     			amdgpu_vm_update_flags(params, pt, cursor.level,
     					       pe_start, dst, nptes, incr,
-					       flags | AMDGPU_PTE_FRAG(frag));
+					       upd_flags);
 
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c static int amdgpu_vm_update_ptes(struct amdgpu_vm_update_params *params, · line 1534

Quoted 6 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -1
     			pe_start += nptes * 8;
-			dst += (uint64_t)nptes * AMDGPU_GPU_PAGE_SIZE << shift;
+			dst += nptes * incr;
 
     			frag_start = upd_end;
     			if (frag_start >= frag_end) {

_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=02%7C01%7Cshashank.sharma%40amd.com%7C294c0cf0460847953e8308d8443c163c%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637334372147156674&amp;sdata=3sWZcuLcWVTcspxhRq6gT1SM%2BvHQCrJqmJijKgREks0%3D&amp;reserved=0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#9 lore raw

Am 19.08.20 um 15:08 schrieb Shashank Sharma:

Quoted 82 lines · Christian König
Quoted 81 lines

Am 19.08.20 um 14:37 schrieb Shashank Sharma:

Quoted 80 lines · Christian König
Quoted 69 lines

Am 19.08.20 um 14:19 schrieb Shashank Sharma:

Quoted 68 lines · Christian König
Quoted 56 lines

Am 19.08.20 um 13:52 schrieb Shashank Sharma:

Quoted 55 lines · Christian König
Quoted 51 lines

Am 13.08.20 um 05:04 schrieb Shashank Sharma:

Quoted 37 lines

This patch adds a new trace event to track the PTE update events. This specific event will provide information like:
- start and end of virtual memory mapping
- HW engine flags for the map
- physical address for mapping

This will be particularly useful for memory profiling tools (like RMV) which are monitoring the page table update events.

V2: Added physical address lookup logic in trace point
V3: switch to use __dynamic_array
added nptes int the TPprint arguments list added page size in the arg list
V4: Addressed Christian's review comments
add start/end instead of seg
use incr instead of page_sz to be accurate

---
      drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 37 +++++++++++++++++++++++
      drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c    |  9 ++++--
      2 files changed, 44 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +3 -0
index 63e734a125fb..df12cf8466c2 100644
@@ -321,6 +321,43 @@ DEFINE_EVENT(amdgpu_vm_mapping, amdgpu_vm_bo_cs,
      	    TP_ARGS(mapping)
      );
 
+TRACE_EVENT(amdgpu_vm_update_ptes,
+	    TP_PROTO(struct amdgpu_vm_update_params *p,
+		     uint64_t start, uint64_t end,

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h DEFINE_EVENT(amdgpu_vm_mapping, amdgpu_vm_bo_cs, · line 336

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +10 -0
+		     unsigned int nptes, uint64_t dst,
+		     uint64_t incr, uint64_t flags),
+	TP_ARGS(p, start, end, nptes, dst, incr, flags),
+	TP_STRUCT__entry(
+			 __field(u64, start)
+			 __field(u64, end)
+			 __field(u64, flags)
+			 __field(unsigned int, nptes)
+			 __field(u64, incr)
+			 __dynamic_array(u64, dst, nptes)

As discussed with the trace subsystem maintainer we need to add the pid and probably the VM context ID we use here to identify the updated VM.

Quoted 1 line

Christian.

I printed both vm->task_info.pid Vs current->pid for testing, and I can see different values coming out of .

Quoted 7 lines
Quoted 5 lines

gnome-shell-2114  [011]    41.812894: amdgpu_vm_update_ptes: start:0x0800102e80 end:0x0800102e82, flags:0x80, incr:4096, pid=2128 vmid=0 cpid=2114

pid is vm->task_info.pid=2128 whereas cpid=2114 is current.pid.

Which is the one we want to send with the event ?

That is vm->task_info.pid, since this is the PID which is using the VM for command submission.

got it.

Quoted 3 lines
Quoted 3 lines

Trace event by default seems to be adding the process name and id at the header of the event (gnome-shell-2114), which is same as current.pid

Quoted 8 lines
Quoted 4 lines
Quoted 3 lines
Quoted 1 line

Also, is it ok to extract vmid from job->vmid ?

Only in trace_amdgpu_vm_grab_id(), in all other cases it's probably not assigned yet.

Ok, let me check how can we get vmid from this context we are sending the event from. Or maybe I we should  keep V5 with pid only, and later send a separate patch to add vmid ?

I'm not sure how you want to get a VMID in the first place. We dynamically assign VMIDs during command submission.

See the amdgpu_vm_grab_id trace point.

Actually I was adding vmid to address this last comment on V4:

Quoted 1 line

and probably the VM context ID we use here to identify the updated VM.

Quoted 8 lines
Quoted 7 lines
Quoted 1 line

I assumed you meant the vmid by this, is that not so ?

Ah! No that's something completely different :)

The VMID is a 4bit hardware identifier used for TLB optimization.

The VM context ID is an unique 64bit number, we usually use vm->immediate.fence_context for this.

Damn, why is it never what you hope it to be :). Thanks for this information, I will check this out first.

Multiple reasons :)

One is that I'm not a native speaker of English and only had very limited formal education in the language :)

Another one is that the hardware and driver is rather complicated.

Regards,
Christian.
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#10 lore raw
Quoted 90 lines · Christian König

Am 19.08.20 um 15:08 schrieb Shashank Sharma:

Quoted 89 lines · Christian König
Quoted 88 lines

Am 19.08.20 um 14:37 schrieb Shashank Sharma:

Quoted 73 lines · Christian König
Quoted 72 lines

Am 19.08.20 um 14:19 schrieb Shashank Sharma:

Quoted 71 lines · Christian König
Quoted 56 lines

Am 19.08.20 um 13:52 schrieb Shashank Sharma:

Quoted 55 lines · Christian König
Quoted 51 lines

Am 13.08.20 um 05:04 schrieb Shashank Sharma:

Quoted 37 lines

This patch adds a new trace event to track the PTE update events. This specific event will provide information like:
- start and end of virtual memory mapping
- HW engine flags for the map
- physical address for mapping

This will be particularly useful for memory profiling tools (like RMV) which are monitoring the page table update events.

V2: Added physical address lookup logic in trace point
V3: switch to use __dynamic_array
added nptes int the TPprint arguments list added page size in the arg list
V4: Addressed Christian's review comments
add start/end instead of seg
use incr instead of page_sz to be accurate

---
      drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 37 +++++++++++++++++++++++
      drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c    |  9 ++++--
      2 files changed, 44 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +3 -0
index 63e734a125fb..df12cf8466c2 100644
@@ -321,6 +321,43 @@ DEFINE_EVENT(amdgpu_vm_mapping, amdgpu_vm_bo_cs,
      	    TP_ARGS(mapping)
      );
 
+TRACE_EVENT(amdgpu_vm_update_ptes,
+	    TP_PROTO(struct amdgpu_vm_update_params *p,
+		     uint64_t start, uint64_t end,

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h DEFINE_EVENT(amdgpu_vm_mapping, amdgpu_vm_bo_cs, · line 336

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +10 -0
+		     unsigned int nptes, uint64_t dst,
+		     uint64_t incr, uint64_t flags),
+	TP_ARGS(p, start, end, nptes, dst, incr, flags),
+	TP_STRUCT__entry(
+			 __field(u64, start)
+			 __field(u64, end)
+			 __field(u64, flags)
+			 __field(unsigned int, nptes)
+			 __field(u64, incr)
+			 __dynamic_array(u64, dst, nptes)

As discussed with the trace subsystem maintainer we need to add the pid and probably the VM context ID we use here to identify the updated VM.

Quoted 1 line

Christian.

I printed both vm->task_info.pid Vs current->pid for testing, and I can see different values coming out of .

Quoted 7 lines
Quoted 5 lines

gnome-shell-2114  [011]    41.812894: amdgpu_vm_update_ptes: start:0x0800102e80 end:0x0800102e82, flags:0x80, incr:4096, pid=2128 vmid=0 cpid=2114

pid is vm->task_info.pid=2128 whereas cpid=2114 is current.pid.

Which is the one we want to send with the event ?

That is vm->task_info.pid, since this is the PID which is using the VM for command submission.

got it.

Quoted 6 lines
Quoted 4 lines

Trace event by default seems to be adding the process name and id at the header of the event (gnome-shell-2114), which is same as current.pid

Also, is it ok to extract vmid from job->vmid ?

Only in trace_amdgpu_vm_grab_id(), in all other cases it's probably not assigned yet.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Ok, let me check how can we get vmid from this context we are sending the event from. Or maybe I we should  keep V5 with pid only, and later send a separate patch to add vmid ?

I'm not sure how you want to get a VMID in the first place. We dynamically assign VMIDs during command submission.

See the amdgpu_vm_grab_id trace point.

Actually I was adding vmid to address this last comment on V4:

Quoted 1 line

and probably the VM context ID we use here to identify the updated VM.

I assumed you meant the vmid by this, is that not so ?

Ah! No that's something completely different :)

The VMID is a 4bit hardware identifier used for TLB optimization.

The VM context ID is an unique 64bit number, we usually use vm->immediate.fence_context for this.

Quoted 7 lines
Quoted 1 line

Damn, why is it never what you hope it to be :). Thanks for this information, I will check this out first.

Multiple reasons :)

One is that I'm not a native speaker of English and only had very limited formal education in the language :)

Another one is that the hardware and driver is rather complicated.

Nah, I think you were pretty clear in the communication,

I will be a good software engineer, and go ahead and blame it on the hardware :D.

Thanks again, I will check to add the vm context here.

- Shashank

Quoted 3 lines

Regards,
Christian.

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#11 lore raw
In reply to Christian König

Hi Christian,

Quoted 56 lines · Christian König

Am 19.08.20 um 13:52 schrieb Shashank Sharma:

Quoted 55 lines · Christian König
Quoted 51 lines

Am 13.08.20 um 05:04 schrieb Shashank Sharma:

Quoted 37 lines

This patch adds a new trace event to track the PTE update events. This specific event will provide information like:
- start and end of virtual memory mapping
- HW engine flags for the map
- physical address for mapping

This will be particularly useful for memory profiling tools (like RMV) which are monitoring the page table update events.

V2: Added physical address lookup logic in trace point
V3: switch to use __dynamic_array
      added nptes int the TPprint arguments list added page size in the arg list
V4: Addressed Christian's review comments
      add start/end instead of seg
      use incr instead of page_sz to be accurate

---
   drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 37
+++++++++++++++++++++++
   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c    |  9 ++++--

   2 files changed, 44 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +2 -0
index 63e734a125fb..df12cf8466c2 100644
@@ -321,6 +321,43 @@ DEFINE_EVENT(amdgpu_vm_mapping, amdgpu_vm_bo_cs,
            TP_ARGS(mapping)
    );
    +TRACE_EVENT(amdgpu_vm_update_ptes,
+        TP_PROTO(struct amdgpu_vm_update_params *p,
+             uint64_t start, uint64_t end,

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h DEFINE_EVENT(amdgpu_vm_mapping, amdgpu_vm_bo_cs, · line 335

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +10 -0
+             unsigned int nptes, uint64_t dst,
+             uint64_t incr, uint64_t flags),
+    TP_ARGS(p, start, end, nptes, dst, incr, flags),
+    TP_STRUCT__entry(
+             __field(u64, start)
+             __field(u64, end)
+             __field(u64, flags)
+             __field(unsigned int, nptes)
+             __field(u64, incr)
+             __dynamic_array(u64, dst, nptes)

As discussed with the trace subsystem maintainer we need to add the pid and probably the VM context ID we use here to identify the updated VM.

Quoted 1 line

Christian.

I printed both vm->task_info.pid Vs current->pid for testing, and I can see different values coming out of .

Quoted 7 lines
Quoted 5 lines

gnome-shell-2114  [011]    41.812894: amdgpu_vm_update_ptes: start:0x0800102e80 end:0x0800102e82, flags:0x80, incr:4096, pid=2128 vmid=0 cpid=2114

pid is vm->task_info.pid=2128 whereas cpid=2114 is current.pid.

Which is the one we want to send with the event ?

That is vm->task_info.pid, since this is the PID which is using the VM for command submission.

Noob question:

Why these two pids are different ? Is it like that, the cpid-2114 process created a page/memory-area and now pid-2128 using that page/memory-area to submit a command ?

Regards,

Nirmoy

Quoted 68 lines
Quoted 5 lines

Trace event by default seems to be adding the process name and id at the header of the event (gnome-shell-2114), which is same as current.pid

Also, is it ok to extract vmid from job->vmid ?

Only in trace_amdgpu_vm_grab_id(), in all other cases it's probably not assigned yet.

Christian.

Quoted 58 lines

Regards

Shashank

Quoted 52 lines
Quoted 52 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +19 -0
+    ),
+
+    TP_fast_assign(
+            unsigned int i;
+
+            __entry->start = start;
+            __entry->end = end;
+            __entry->flags = flags;
+            __entry->incr = incr;
+            __entry->nptes = nptes;
+            for (i = 0; i < nptes; ++i) {
+                u64 addr = p->pages_addr ? amdgpu_vm_map_gart(
+                    p->pages_addr, dst) : dst;
+
+                ((u64 *)__get_dynamic_array(dst))[i] = addr;
+                dst += incr;
+            }
+    ),
+    TP_printk("start:0x%010llx end:0x%010llx, flags:0x%llx, 

incr:%llu,"
+          " dst:\n%s", __entry->start, __entry->end, __entry->flags, +          __entry->incr, __print_array(
+          __get_dynamic_array(dst), __entry->nptes, 8))

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +2 -0
+);
+

   TRACE_EVENT(amdgpu_vm_set_ptes,
           TP_PROTO(uint64_t pe, uint64_t addr, unsigned count, uint32_t incr, uint64_t flags, bool direct),

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +6 -2
index 71e005cf2952..b5dbb5e8bc61 100644
@@ -1513,17 +1513,22 @@ static int amdgpu_vm_update_ptes(struct 
 amdgpu_vm_update_params *params,
            do {
                uint64_t upd_end = min(entry_end, frag_end);
                unsigned nptes = (upd_end - frag_start) >> shift;
+            uint64_t upd_flags = flags | AMDGPU_PTE_FRAG(frag);
                   /* This can happen when we set higher level PDs to
                 * silent to stop fault floods.
                 */
                nptes = max(nptes, 1u);
+
+            trace_amdgpu_vm_update_ptes(params, frag_start, upd_end,
+                            nptes, dst, incr,
+                            upd_flags);
                amdgpu_vm_update_flags(params, pt, cursor.level,
                               pe_start, dst, nptes, incr,
-                           flags | AMDGPU_PTE_FRAG(frag));
+                           upd_flags);
                   pe_start += nptes * 8;
-            dst += (uint64_t)nptes * AMDGPU_GPU_PAGE_SIZE << shift;
Quoted 9 lines
Quoted 3 lines
Quoted 3 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c static int amdgpu_vm_update_ptes(struct amdgpu_vm_update_params *params, · line 1534

Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +1 -0
+            dst += nptes * incr;
                   frag_start = upd_end;
                if (frag_start >= frag_end) {

_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=02%7C01%7Cnirmoy.das%40amd.com%7Ccf56b7d79fe847f9e0ae08d84438a89e%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637334357456981915&amp;sdata=pix8Q%2FIHwTA4CGoYRVdKyDEzQHmx4ASKgAbcgwUKWBQ%3D&amp;reserved=0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#12 lore raw
Quoted 69 lines · Nirmoy

Hi Christian,

Quoted 65 lines · Christian König

Am 19.08.20 um 13:52 schrieb Shashank Sharma:

Quoted 64 lines · Christian König
Quoted 52 lines

Am 13.08.20 um 05:04 schrieb Shashank Sharma:

Quoted 38 lines

This patch adds a new trace event to track the PTE update events. This specific event will provide information like:
- start and end of virtual memory mapping
- HW engine flags for the map
- physical address for mapping

This will be particularly useful for memory profiling tools (like RMV) which are monitoring the page table update events.

V2: Added physical address lookup logic in trace point
V3: switch to use __dynamic_array
      added nptes int the TPprint arguments list added page size in the arg list
V4: Addressed Christian's review comments
      add start/end instead of seg
      use incr instead of page_sz to be accurate

---
   drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 37
+++++++++++++++++++++++
   drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c    |  9 ++++--

   2 files changed, 44 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +2 -0
index 63e734a125fb..df12cf8466c2 100644
@@ -321,6 +321,43 @@ DEFINE_EVENT(amdgpu_vm_mapping, amdgpu_vm_bo_cs,
            TP_ARGS(mapping)
    );
    +TRACE_EVENT(amdgpu_vm_update_ptes,
+        TP_PROTO(struct amdgpu_vm_update_params *p,
+             uint64_t start, uint64_t end,

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h DEFINE_EVENT(amdgpu_vm_mapping, amdgpu_vm_bo_cs, · line 335

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +10 -0
+             unsigned int nptes, uint64_t dst,
+             uint64_t incr, uint64_t flags),
+    TP_ARGS(p, start, end, nptes, dst, incr, flags),
+    TP_STRUCT__entry(
+             __field(u64, start)
+             __field(u64, end)
+             __field(u64, flags)
+             __field(unsigned int, nptes)
+             __field(u64, incr)
+             __dynamic_array(u64, dst, nptes)

As discussed with the trace subsystem maintainer we need to add the pid and probably the VM context ID we use here to identify the updated VM.

Quoted 1 line

Christian.

I printed both vm->task_info.pid Vs current->pid for testing, and I can see different values coming out of .

gnome-shell-2114  [011]    41.812894: amdgpu_vm_update_ptes:
start:0x0800102e80 end:0x0800102e82, flags:0x80, incr:4096, pid=2128 vmid=0 cpid=2114

pid is vm->task_info.pid=2128 whereas cpid=2114 is current.pid.

Which is the one we want to send with the event ?

Quoted 8 lines
Quoted 2 lines

That is vm->task_info.pid, since this is the PID which is using the VM for command submission.

Noob question:

Why these two pids are different ? Is it like that, the cpid-2114 process created a page/memory-area and now pid-2128 using that page/memory-area to submit a command ?

My understanding is that this is due to a server-client arrangement, where a client process can create a memory map and fill it for the submission, but it doesnt have privilege to  do that, and that should be done by the server process (like X/wayland etc)

- Shashank

Quoted 84 lines

Regards,

Nirmoy

Quoted 76 lines
Quoted 5 lines

Trace event by default seems to be adding the process name and id at the header of the event (gnome-shell-2114), which is same as current.pid

Also, is it ok to extract vmid from job->vmid ?

Only in trace_amdgpu_vm_grab_id(), in all other cases it's probably not assigned yet.

Christian.

Quoted 53 lines

Regards

Shashank

Quoted 48 lines
Quoted 48 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +19 -0
+    ),
+
+    TP_fast_assign(
+            unsigned int i;
+
+            __entry->start = start;
+            __entry->end = end;
+            __entry->flags = flags;
+            __entry->incr = incr;
+            __entry->nptes = nptes;
+            for (i = 0; i < nptes; ++i) {
+                u64 addr = p->pages_addr ? amdgpu_vm_map_gart(
+                    p->pages_addr, dst) : dst;
+
+                ((u64 *)__get_dynamic_array(dst))[i] = addr;
+                dst += incr;
+            }
+    ),
+    TP_printk("start:0x%010llx end:0x%010llx, flags:0x%llx, 

incr:%llu,"
+          " dst:\n%s", __entry->start, __entry->end, __entry->flags, +          __entry->incr, __print_array(
+          __get_dynamic_array(dst), __entry->nptes, 8))

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +2 -0
+);
+

   TRACE_EVENT(amdgpu_vm_set_ptes,
           TP_PROTO(uint64_t pe, uint64_t addr, unsigned count, uint32_t incr, uint64_t flags, bool direct),

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +5 -0
index 71e005cf2952..b5dbb5e8bc61 100644
@@ -1513,17 +1513,22 @@ static int amdgpu_vm_update_ptes(struct 
 amdgpu_vm_update_params *params,
            do {
                uint64_t upd_end = min(entry_end, frag_end);
                unsigned nptes = (upd_end - frag_start) >> shift;
+            uint64_t upd_flags = flags | AMDGPU_PTE_FRAG(frag);
                   /* This can happen when we set higher level PDs to
                 * silent to stop fault floods.
                 */
                nptes = max(nptes, 1u);
+
+            trace_amdgpu_vm_update_ptes(params, frag_start, upd_end,
+                            nptes, dst, incr,
+                            upd_flags);
                amdgpu_vm_update_flags(params, pt, cursor.level,
Quoted 8 lines
Quoted 8 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c static int amdgpu_vm_update_ptes(struct amdgpu_vm_update_params *params, · line 1534

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c +2 -2
                               pe_start, dst, nptes, incr,
-                           flags | AMDGPU_PTE_FRAG(frag));
+                           upd_flags);
                   pe_start += nptes * 8;
-            dst += (uint64_t)nptes * AMDGPU_GPU_PAGE_SIZE << shift;
+            dst += nptes * incr;
                   frag_start = upd_end;
                if (frag_start >= frag_end) {

_______________________________________________
amd-gfx mailing list
[email protected]
https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Flists.freedesktop.org%2Fmailman%2Flistinfo%2Famd-gfx&amp;data=02%7C01%7Cnirmoy.das%40amd.com%7Ccf56b7d79fe847f9e0ae08d84438a89e%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637334357456981915&amp;sdata=pix8Q%2FIHwTA4CGoYRVdKyDEzQHmx4ASKgAbcgwUKWBQ%3D&amp;reserved=0

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#13 lore raw

Am 19.08.20 um 14:51 schrieb Shashank Sharma:

Quoted 70 lines · Nirmoy
Quoted 69 lines

Hi Christian,

Quoted 65 lines · Christian König

Am 19.08.20 um 13:52 schrieb Shashank Sharma:

Quoted 64 lines · Christian König
Quoted 52 lines

Am 13.08.20 um 05:04 schrieb Shashank Sharma:

Quoted 38 lines

This patch adds a new trace event to track the PTE update events. This specific event will provide information like:
- start and end of virtual memory mapping
- HW engine flags for the map
- physical address for mapping

This will be particularly useful for memory profiling tools (like RMV) which are monitoring the page table update events.

V2: Added physical address lookup logic in trace point
V3: switch to use __dynamic_array
      added nptes int the TPprint arguments list added page size in the arg list
V4: Addressed Christian's review comments
      add start/end instead of seg
      use incr instead of page_sz to be accurate

---
    drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 37
+++++++++++++++++++++++
    drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c    |  9 ++++--
    2 files changed, 44 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +2 -0
index 63e734a125fb..df12cf8466c2 100644
@@ -321,6 +321,43 @@ DEFINE_EVENT(amdgpu_vm_mapping, amdgpu_vm_bo_cs,
            TP_ARGS(mapping)
    );
    +TRACE_EVENT(amdgpu_vm_update_ptes,
+        TP_PROTO(struct amdgpu_vm_update_params *p,
+             uint64_t start, uint64_t end,

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h DEFINE_EVENT(amdgpu_vm_mapping, amdgpu_vm_bo_cs, · line 335

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +10 -0
+             unsigned int nptes, uint64_t dst,
+             uint64_t incr, uint64_t flags),
+    TP_ARGS(p, start, end, nptes, dst, incr, flags),
+    TP_STRUCT__entry(
+             __field(u64, start)
+             __field(u64, end)
+             __field(u64, flags)
+             __field(unsigned int, nptes)
+             __field(u64, incr)
+             __dynamic_array(u64, dst, nptes)

As discussed with the trace subsystem maintainer we need to add the pid and probably the VM context ID we use here to identify the updated VM.

Quoted 1 line

Christian.

I printed both vm->task_info.pid Vs current->pid for testing, and I can see different values coming out of .

gnome-shell-2114  [011]    41.812894: amdgpu_vm_update_ptes:
start:0x0800102e80 end:0x0800102e82, flags:0x80, incr:4096, pid=2128 vmid=0 cpid=2114

pid is vm->task_info.pid=2128 whereas cpid=2114 is current.pid.

Which is the one we want to send with the event ?

Quoted 8 lines
Quoted 7 lines
Quoted 2 lines

That is vm->task_info.pid, since this is the PID which is using the VM for command submission.

Noob question:

Why these two pids are different ? Is it like that, the cpid-2114 process created a page/memory-area and now pid-2128 using that page/memory-area to submit a command ?

My understanding is that this is due to a server-client arrangement, where a client process can create a memory map and fill it for the submission, but it doesnt have privilege to  do that, and that should be done by the server process (like X/wayland etc)

That's close but not quite correct.

One use case is what Shashank describes here where the server allocates something on behalves of the client and because of delayed updates we end up updating the page tables in a different process then where something is really used.

But the more command use case is eviction where process A is kicking out BOs of process B and because of this the page table of process B are updated in the context of A.

Regards,
Christian.

Quoted 3 lines

- Shashank

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#14 lore raw
Quoted 79 lines · Christian König

Am 19.08.20 um 14:51 schrieb Shashank Sharma:

Quoted 78 lines · Nirmoy
Quoted 77 lines

Hi Christian,

Quoted 63 lines · Christian König

Am 19.08.20 um 13:52 schrieb Shashank Sharma:

Quoted 62 lines · Christian König
Quoted 53 lines

Am 13.08.20 um 05:04 schrieb Shashank Sharma:

Quoted 39 lines

This patch adds a new trace event to track the PTE update events. This specific event will provide information like:
- start and end of virtual memory mapping
- HW engine flags for the map
- physical address for mapping

This will be particularly useful for memory profiling tools (like RMV) which are monitoring the page table update events.

V2: Added physical address lookup logic in trace point
V3: switch to use __dynamic_array
       added nptes int the TPprint arguments list added page size in the arg list
V4: Addressed Christian's review comments
       add start/end instead of seg
       use incr instead of page_sz to be accurate

---
    drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 37
+++++++++++++++++++++++
    drivers/gpu/drm/amd/amdgpu/amdgpu_vm.c    |  9 ++++--

    2 files changed, 44 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +2 -0
index 63e734a125fb..df12cf8466c2 100644
@@ -321,6 +321,43 @@ DEFINE_EVENT(amdgpu_vm_mapping, 
 amdgpu_vm_bo_cs,
             TP_ARGS(mapping)
     );
     +TRACE_EVENT(amdgpu_vm_update_ptes,
+        TP_PROTO(struct amdgpu_vm_update_params *p,
+             uint64_t start, uint64_t end,

drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h DEFINE_EVENT(amdgpu_vm_mapping, · line 336

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h +10 -0
+             unsigned int nptes, uint64_t dst,
+             uint64_t incr, uint64_t flags),
+    TP_ARGS(p, start, end, nptes, dst, incr, flags),
+    TP_STRUCT__entry(
+             __field(u64, start)
+             __field(u64, end)
+             __field(u64, flags)
+             __field(unsigned int, nptes)
+             __field(u64, incr)
+             __dynamic_array(u64, dst, nptes)

As discussed with the trace subsystem maintainer we need to add the pid and probably the VM context ID we use here to identify the updated VM.

Quoted 1 line

Christian.

I printed both vm->task_info.pid Vs current->pid for testing, and I can see different values coming out of .

gnome-shell-2114  [011]    41.812894: amdgpu_vm_update_ptes:
start:0x0800102e80 end:0x0800102e82, flags:0x80, incr:4096, pid=2128 vmid=0 cpid=2114

Quoted 5 lines
Quoted 3 lines

pid is vm->task_info.pid=2128 whereas cpid=2114 is current.pid.

Which is the one we want to send with the event ?

That is vm->task_info.pid, since this is the PID which is using the VM for command submission.

Noob question:

Why these two pids are different ? Is it like that, the cpid-2114 process created a page/memory-area and now pid-2128 using that page/memory-area to submit a command ?

Quoted 8 lines
Quoted 1 line

My understanding is that this is due to a server-client arrangement, where a client process can create a memory map and fill it for the submission, but it doesnt have privilege to  do that, and that should be done by the server process (like X/wayland etc)

That's close but not quite correct.

One use case is what Shashank describes here where the server allocates something on behalves of the client and because of delayed updates we end up updating the page tables in a different process then where something is really used.

But the more command use case is eviction where process A is kicking out BOs of process B and because of this the page table of process B are updated in the context of A.

Understood, thanks Christain and Shashank for the explanation!

Nirmoy.

Quoted 8 lines

Regards,
Christian.

Quoted 3 lines

- Shashank

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx