On Mon, Jul 07, 2025 at 01:38:23PM -0700, Juston Li wrote:
Add TRACE_GPU_MEM tracepoints for tracking global GPU memory usage.
These are required by VSR on Android 12+ for reporting GPU driver memory
allocations.
v5:
- Drop process_mem tracking
- Set the gpu_id field to dev->primary->index (Lucas, Tvrtko)
- Formatting cleanup under 80 columns
v3:
- Use now configurable CONFIG_TRACE_GPU_MEM instead of adding a
per-driver Kconfig (Lucas)
v2:
- Use u64 as preferred by checkpatch (Tvrtko)
- Fix errors in comments/Kconfig description (Tvrtko)
- drop redundant "CONFIG" in Kconfig
Signed-off-by: Juston Li <[email protected]>
Reviewed-by: Tvrtko Ursulin <[email protected]>
---
drivers/gpu/drm/xe/xe_bo.c | 22 ++++++++++++++++++++++
drivers/gpu/drm/xe/xe_device_types.h | 8 ++++++++
2 files changed, 30 insertions(+)
diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c
index 4e39188a021ab..950eef514c11c 100644
--- a/drivers/gpu/drm/xe/xe_bo.c
+++ b/drivers/gpu/drm/xe/xe_bo.c
@@ -19,6 +19,8 @@
#include <kunit/static_stub.h>
+#include <trace/events/gpu_mem.h>
+
#include "xe_device.h"
#include "xe_dma_buf.h"
#include "xe_drm_client.h"
@@ -418,6 +420,24 @@ static void xe_ttm_tt_account_subtract(struct xe_device
*xe, struct ttm_tt *tt)
xe_shrinker_mod_pages(xe->mem.shrinker, -(long)tt->num_pages,
0);
}
+#if IS_ENABLED(CONFIG_TRACE_GPU_MEM)
+static void update_global_total_pages(struct ttm_device *ttm_dev,
+ long num_pages)
+{
wouldn't it be better to move the ifdef inside the function?
Any compiler would remove the empty call regardless of the inline
annotation, so I think this would make it less error prone if we change
function signature.
No need to send a new version, I can move that while applying
if agreed.
Lucas De Marchi