Skip to contentSkip to conversation

tracing/gpu: Add imported size to gpu_mem_imported tracepoint

PATCH Superseded Kalesh Singh 1 participant 1 message Aug 17, 2021 Tracing

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 tracing/gpu: Add imported size to gpu_mem_imported tracepoint

The existing gpu_mem_total tracepoint provides GPU drivers a uniform way to report the per-process and system-wide GPU memory usage. This tracepoint reports a single total of the GPU private allocations and the imported memory. [1]

To allow distinguishing GPU private vs imported memory, add an imported_size field to the gpu_mem_total tracepoint. GPU drivers can use this new field to report the per-process and global GPU-imported memory in a uniform way.

User space tools can detect and handle the old vs new gpu_mem_total format via the gpu_mem/gpu_mem_total/format file.

[1] https://lore.kernel.org/r/[email protected]/

---
Changes in v2:
- Add imported_size field to track imported memory instead of a separate tracepoint, per Ørjan

v1 of this patch can be found at:
https://lore.kernel.org/r/[email protected]/

 include/trace/events/gpu_mem.h | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
include/trace/events/gpu_mem.h +11 -6
index 26d871f96e94..ae6fab6bab7b 100644
@@ -15,7 +15,7 @@
 
 /*
  * The gpu_memory_total event indicates that there's an update to either the
- * global or process total gpu memory counters.
+ * global or process total and imported gpu memory counters.
  *
  * This event should be emitted whenever the kernel device driver allocates,
  * frees, imports, unimports memory in the GPU addressable space.
@@ -24,31 +24,36 @@
  *
  * @pid: Put 0 for global total, while positive pid for process total.
  *
- * @size: Size of the allocation in bytes.
+ * @size: Total size of allocated and imported memory in bytes.
+ *
+ * @imported_size: Total size of imported memory in bytes.
  *
  */
 TRACE_EVENT(gpu_mem_total,
 
-	TP_PROTO(uint32_t gpu_id, uint32_t pid, uint64_t size),
+	TP_PROTO(uint32_t gpu_id, uint32_t pid, uint64_t size, uint64_t imported_size),
 
-	TP_ARGS(gpu_id, pid, size),
+	TP_ARGS(gpu_id, pid, size, imported_size),
 
 	TP_STRUCT__entry(
 		__field(uint32_t, gpu_id)
 		__field(uint32_t, pid)
 		__field(uint64_t, size)
+		__field(uint64_t, imported_size)
 	),
 
 	TP_fast_assign(
 		__entry->gpu_id = gpu_id;
 		__entry->pid = pid;
 		__entry->size = size;
+		__entry->imported_size = imported_size;
 	),
 
-	TP_printk("gpu_id=%u pid=%u size=%llu",
+	TP_printk("gpu_id=%u pid=%u size=%llu imported_size=%llu",
 		__entry->gpu_id,
 		__entry->pid,
-		__entry->size)
+		__entry->size,
+		__entry->imported_size)
 );
 
 #endif /* _TRACE_GPU_MEM_H */

base-commit: a2824f19e6065a0d3735acd9fe7155b104e7edf5

Signature · 1 line
2.33.0.rc1.237.g0d66db33f3-goog