[PATCH 17/17] [DEBUG] dump obj alloc and free stacks for objects freed during test
Robert Beckett
bob.beckett at collabora.com
Wed Jun 29 19:23:25 UTC 2022
Signed-off-by: Robert Beckett <bob.beckett at collabora.com>
---
drivers/gpu/drm/i915/gem/i915_gem_object.c | 12 ++++++++++++
drivers/gpu/drm/i915/gem/i915_gem_object_types.h | 3 +++
drivers/gpu/drm/i915/gt/selftest_reset.c | 12 ++++++++++--
3 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object.c b/drivers/gpu/drm/i915/gem/i915_gem_object.c
index 519887769c08..2df427a543d9 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_object.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_object.c
@@ -45,6 +45,16 @@ static struct kmem_cache *slab_objects;
static const struct drm_gem_object_funcs i915_gem_object_funcs;
+#define STACK_DEPTH 32
+static noinline void save_stack(depot_stack_handle_t *stack, gfp_t flags)
+{
+ unsigned long entries[STACK_DEPTH];
+ unsigned int num_entries;
+
+ num_entries = stack_trace_save(entries, ARRAY_SIZE(entries), 1);
+ *stack = stack_depot_save(entries, num_entries, flags);
+}
+
struct drm_i915_gem_object *i915_gem_object_alloc(void)
{
struct drm_i915_gem_object *obj;
@@ -53,6 +63,7 @@ struct drm_i915_gem_object *i915_gem_object_alloc(void)
if (!obj)
return NULL;
obj->base.funcs = &i915_gem_object_funcs;
+ save_stack(&obj->alloc_stack, GFP_KERNEL);
return obj;
}
@@ -371,6 +382,7 @@ static void i915_gem_free_object(struct drm_gem_object *gem_obj)
struct drm_i915_private *i915 = to_i915(obj->base.dev);
GEM_BUG_ON(i915_gem_object_is_framebuffer(obj));
+ save_stack(&obj->free_stack, GFP_ATOMIC);
/*
* Before we free the object, make sure any pure RCU-only
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_object_types.h b/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
index 13466cca7af8..8895d8b1ccff 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
+++ b/drivers/gpu/drm/i915/gem/i915_gem_object_types.h
@@ -8,6 +8,7 @@
#define __I915_GEM_OBJECT_TYPES_H__
#include <linux/mmu_notifier.h>
+#include <linux/stackdepot.h>
#include <drm/drm_gem.h>
#include <drm/ttm/ttm_bo_api.h>
@@ -640,6 +641,8 @@ struct drm_i915_gem_object {
void *gvt_info;
};
+ depot_stack_handle_t alloc_stack;
+ depot_stack_handle_t free_stack;
};
static inline struct drm_i915_gem_object *
diff --git a/drivers/gpu/drm/i915/gt/selftest_reset.c b/drivers/gpu/drm/i915/gt/selftest_reset.c
index 273f34aa4a59..110d39e7606e 100644
--- a/drivers/gpu/drm/i915/gt/selftest_reset.c
+++ b/drivers/gpu/drm/i915/gt/selftest_reset.c
@@ -4,10 +4,12 @@
*/
#include "drm/ttm/ttm_resource.h"
+#include "linux/stackdepot.h"
#include <linux/crc32.h>
#include <linux/highmem.h>
#include <linux/sched/mm.h>
+#include "gem/i915_gem_ttm.h"
#include "gem/i915_gem_stolen.h"
#include "intel_region_ttm.h"
@@ -67,6 +69,7 @@ struct dbg_man_func {
static void dbg_free(struct ttm_resource_manager *man, struct ttm_resource *res)
{
struct dbg_man_func *dbg = container_of(man->func, struct dbg_man_func, dbg);
+ struct drm_i915_gem_object *obj = res->bo == NULL ? NULL : i915_ttm_to_gem(res->bo);
if (res->placement & (1 << 31)) {
dbg->orig->free(man, res);
@@ -74,8 +77,13 @@ static void dbg_free(struct ttm_resource_manager *man, struct ttm_resource *res)
}
pr_info("BOB_DEBUG: %s(): man=%pS res={ start=0x%lx num_pages=0x%lx mem_type=0x%x placement=0x%x }\n",
__func__, man, res->start, res->num_pages, res->mem_type, res->placement);
- pr_info("BOB_DEBUG: %s(): STACK:\n", __func__);
- dump_stack();
+
+ if (obj) {
+ pr_info("BOB_DEBUG: %s(): ALLOC STACK:\n", __func__);
+ stack_depot_print(obj->alloc_stack);
+ pr_info("BOB_DEBUG: %s(): FREE STACK:\n", __func__);
+ stack_depot_print(obj->free_stack);
+ }
dbg->orig->free(man, res);
}
--
2.25.1
More information about the Intel-gfx-trybot
mailing list