drm/i915: Implement fdinfo memory stats printing
Subsystems (2)
PATCH 1/1 drm/i915: Implement fdinfo memory stats printing
From: Tvrtko Ursulin <[email protected]>
Use the newly added drm_print_memory_stats helper to show memory utilisation of our objects in drm/driver specific fdinfo output.
To collect the stats we walk the per memory regions object lists and accumulate object size into the respective drm_memory_stats categories.
Objects with multiple possible placements are reported in multiple regions for total and shared sizes, while other categories are counted only for the currently active region.
--- drivers/gpu/drm/i915/i915_drm_client.c | 66 ++++++++++++++++++++++++++ 1 file changed, 66 insertions(+)
drivers/gpu/drm/i915/i915_drm_client.c +66 -0
@@ -41,6 +41,70 @@ void __i915_drm_client_free(struct kref *kref) }#ifdef CONFIG_PROC_FS +static void +add_obj_meminfo (struct drm_i915_gem_object *obj, +struct intel_memory_region *mr, +struct drm_memory_stats stats[INTEL_REGION_UNKNOWN ]) +{ +u64 sz = obj->base.size; +enum intel_region_id id; +unsigned int i; + + id = mr->id; +if (obj->base.handle_count >1 ) + stats[id].shared += sz; +else + stats[id].private += sz; + +if (i915_gem_object_has_pages (obj)) { + stats[id].resident += sz; + +if (!dma_resv_test_signaled (obj->base.resv, +dma_resv_usage_rw (true))) + stats[id].active += sz; +else if (i915_gem_object_is_shrinkable (obj) && + obj->mm.madv ==I915_MADV_DONTNEED ) + stats[id].purgeable += sz; + } + +/* Attribute size and shared to all possible object memory regions. */ +for (i =0 ; i < obj->mm.n_placements; i++) { +if (obj->mm.placements[i] == mr) +continue ; + + id = obj->mm.placements[i]->id; +if (obj->base.handle_count >1 ) + stats[id].shared += sz; +else + stats[id].private += sz; + } +} + +static void show_meminfo (struct drm_printer *p,struct drm_file *file) +{ +struct drm_i915_file_private *file_priv = file->driver_priv; +struct drm_memory_stats stats[INTEL_REGION_UNKNOWN ] = {}; +struct drm_i915_private *i915 = file_priv->i915; +struct intel_memory_region *mr; +unsigned int id; + +for_each_memory_region (mr, i915, id) { +struct drm_i915_gem_object *obj; + +mutex_lock (&mr->objects.lock); +list_for_each_entry (obj, &mr->objects.list, mm.region_link) +add_obj_meminfo (obj, mr, stats); +mutex_unlock (&mr->objects.lock); + } + +for_each_memory_region (mr, i915, id) +drm_print_memory_stats (p, + &stats[id], +DRM_GEM_OBJECT_RESIDENT | +DRM_GEM_OBJECT_PURGEABLE , + mr->name); +} +static const char *const uabi_class_names[] = { [I915_ENGINE_CLASS_RENDER ] ="render" , [I915_ENGINE_CLASS_COPY] = "copy",
@@ -102,6 +166,8 @@ void i915_drm_client_fdinfo(struct drm_printer *p, struct drm_file *file)* ****************************************************************** */ +show_meminfo (p, file); +if (GRAPHICS_VER (i915) <8 )return ;
Signature · 1 line
2.39.2
Patchwork
CI[Intel-gfx] ✗ Fi.CI.BUILD: failure for drm/i915: Implement fdinfo memory stats printing
== Series Details ==
== Series Details ==
Series: drm/i915: Implement fdinfo memory stats printing
URL : https://patchwork.freedesktop.org/series/118870/
State : failure
== Summary ==
Error: patch https://patchwork.freedesktop.org/api/1.0/series/118870/revisions/1/mbox/ not applied
Applying: drm/i915: Implement fdinfo memory stats printing
Using index info to reconstruct a base tree...
M drivers/gpu/drm/i915/i915_drm_client.c
Falling back to patching base and 3-way merge...
Auto-merging drivers/gpu/drm/i915/i915_drm_client.c
CONFLICT (content): Merge conflict in drivers/gpu/drm/i915/i915_drm_client.c
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 drm/i915: Implement fdinfo memory stats printing
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Build failed, no error log produced
Hi Tvrtko,
Quoted 41 lines · Tvrtko Ursulin
From: Tvrtko Ursulin <[email protected]>
Use the newly added
drm_print_memory_statshelper to show memory utilisation of our objects in drm/driver specific fdinfo output.To collect the stats we walk the per memory regions object lists and accumulate object size into the respective
drm_memory_statscategories.Objects with multiple possible placements are reported in multiple regions for total and shared sizes, while other categories are counted only for the currently active region.
Signed-off-by Tvrtko Ursulin <[email protected]>Cc Rob Clark <[email protected]>--- drivers/gpu/drm/i915/i915_drm_client.c | 66 ++++++++++++++++++++++++++ 1 file changed, 66 insertions(+)drivers/gpu/drm/i915/i915_drm_client.c +14
-0@@ -41,6 +41,70 @@ void __i915_drm_client_free(struct kref *kref) }#ifdef CONFIG_PROC_FS +static void +add_obj_meminfo (struct drm_i915_gem_object *obj, +struct intel_memory_region *mr, +struct drm_memory_stats stats[INTEL_REGION_UNKNOWN ]) +{ +u64 sz = obj->base.size; +enum intel_region_id id; +unsigned int i; + + id = mr->id; +if (obj->base.handle_count >1 ) + stats[id].shared += sz; +else + stats[id].private += sz;
drivers/gpu/drm/i915/i915_drm_client.c void __i915_drm_client_free(struct kref *kref) · line 67
Quoted 10 lines
drivers/gpu/drm/i915/i915_drm_client.c +10
-0+ +if (i915_gem_object_has_pages (obj)) { + stats[id].resident += sz; + +if (!dma_resv_test_signaled (obj->base.resv, +dma_resv_usage_rw (true))) + stats[id].active += sz; +else if (i915_gem_object_is_shrinkable (obj) && + obj->mm.madv ==I915_MADV_DONTNEED ) + stats[id].purgeable += sz;
this is a bit off... otherwise:
Andi
Quoted 54 lines
drivers/gpu/drm/i915/i915_drm_client.c +42
-0+ } + +/* Attribute size and shared to all possible object memory regions. */ +for (i =0 ; i < obj->mm.n_placements; i++) { +if (obj->mm.placements[i] == mr) +continue ; + + id = obj->mm.placements[i]->id; +if (obj->base.handle_count >1 ) + stats[id].shared += sz; +else + stats[id].private += sz; + } +} + +static void show_meminfo (struct drm_printer *p,struct drm_file *file) +{ +struct drm_i915_file_private *file_priv = file->driver_priv; +struct drm_memory_stats stats[INTEL_REGION_UNKNOWN ] = {}; +struct drm_i915_private *i915 = file_priv->i915; +struct intel_memory_region *mr; +unsigned int id; + +for_each_memory_region (mr, i915, id) { +struct drm_i915_gem_object *obj; + +mutex_lock (&mr->objects.lock); +list_for_each_entry (obj, &mr->objects.list, mm.region_link) +add_obj_meminfo (obj, mr, stats); +mutex_unlock (&mr->objects.lock); + } + +for_each_memory_region (mr, i915, id) +drm_print_memory_stats (p, + &stats[id], +DRM_GEM_OBJECT_RESIDENT | +DRM_GEM_OBJECT_PURGEABLE , + mr->name); +} +static const char *const uabi_class_names[] = { [I915_ENGINE_CLASS_RENDER ] ="render" , [I915_ENGINE_CLASS_COPY ] ="copy" ,@@ -102,6 +166,8 @@ void i915_drm_client_fdinfo(struct drm_printer *p, struct drm_file *file)* ****************************************************************** */ +show_meminfo (p, file); +if (GRAPHICS_VER (i915) <8 )return ;Signature · 1 line
2.39.2
Quoted 57 lines · Andi Shyti
Hi Tvrtko,
Quoted 41 lines · Tvrtko Ursulin
From: Tvrtko Ursulin <[email protected]>
Use the newly added
drm_print_memory_statshelper to show memory utilisation of our objects in drm/driver specific fdinfo output.To collect the stats we walk the per memory regions object lists and accumulate object size into the respective
drm_memory_statscategories.Objects with multiple possible placements are reported in multiple regions for total and shared sizes, while other categories are counted only for the currently active region.
Signed-off-by Tvrtko Ursulin <[email protected]>Cc Rob Clark <[email protected]>--- drivers/gpu/drm/i915/i915_drm_client.c | 66 ++++++++++++++++++++++++++ 1 file changed, 66 insertions(+)drivers/gpu/drm/i915/i915_drm_client.c +14
-0@@ -41,6 +41,70 @@ void __i915_drm_client_free(struct kref *kref) }#ifdef CONFIG_PROC_FS +static void +add_obj_meminfo (struct drm_i915_gem_object *obj, +struct intel_memory_region *mr, +struct drm_memory_stats stats[INTEL_REGION_UNKNOWN ]) +{ +u64 sz = obj->base.size; +enum intel_region_id id; +unsigned int i; + + id = mr->id; +if (obj->base.handle_count >1 ) + stats[id].shared += sz; +else + stats[id].private += sz;drivers/gpu/drm/i915/i915_drm_client.c void __i915_drm_client_free(struct kref *kref) · line 67
Quoted 10 lines
drivers/gpu/drm/i915/i915_drm_client.c +10
-0+ +if (i915_gem_object_has_pages (obj)) { + stats[id].resident += sz; + +if (!dma_resv_test_signaled (obj->base.resv, +dma_resv_usage_rw (true))) + stats[id].active += sz; +else if (i915_gem_object_is_shrinkable (obj) && + obj->mm.madv ==I915_MADV_DONTNEED ) + stats[id].purgeable += sz;this is a bit off... otherwise:
Quoted 1 line
Reviewed-by Andi Shyti <[email protected]>
Thanks!
I will sit on this until I can find time to add some tests to drm_fdinfo.c.
Regards,
Tvrtko
Quoted 57 lines
Andi
Quoted 54 lines
drivers/gpu/drm/i915/i915_drm_client.c +42
-0+ } + +/* Attribute size and shared to all possible object memory regions. */ +for (i =0 ; i < obj->mm.n_placements; i++) { +if (obj->mm.placements[i] == mr) +continue ; + + id = obj->mm.placements[i]->id; +if (obj->base.handle_count >1 ) + stats[id].shared += sz; +else + stats[id].private += sz; + } +} + +static void show_meminfo (struct drm_printer *p,struct drm_file *file) +{ +struct drm_i915_file_private *file_priv = file->driver_priv; +struct drm_memory_stats stats[INTEL_REGION_UNKNOWN ] = {}; +struct drm_i915_private *i915 = file_priv->i915; +struct intel_memory_region *mr; +unsigned int id; + +for_each_memory_region (mr, i915, id) { +struct drm_i915_gem_object *obj; + +mutex_lock (&mr->objects.lock); +list_for_each_entry (obj, &mr->objects.list, mm.region_link) +add_obj_meminfo (obj, mr, stats); +mutex_unlock (&mr->objects.lock); + } + +for_each_memory_region (mr, i915, id) +drm_print_memory_stats (p, + &stats[id], +DRM_GEM_OBJECT_RESIDENT | +DRM_GEM_OBJECT_PURGEABLE , + mr->name); +} +static const char *const uabi_class_names[] = { [I915_ENGINE_CLASS_RENDER ] ="render" , [I915_ENGINE_CLASS_COPY ] ="copy" ,@@ -102,6 +166,8 @@ void i915_drm_client_fdinfo(struct drm_printer *p, struct drm_file *file)* ****************************************************************** */ +show_meminfo (p, file); +if (GRAPHICS_VER (i915) <8 )return ;Signature · 1 line
2.39.2
Quoted 58 lines · Tvrtko Ursulin
Quoted 56 lines · Andi Shyti
Hi Tvrtko,
Quoted 40 lines · Tvrtko Ursulin
From: Tvrtko Ursulin <[email protected]>
Use the newly added
drm_print_memory_statshelper to show memory utilisation of our objects in drm/driver specific fdinfo output.To collect the stats we walk the per memory regions object lists and accumulate object size into the respective
drm_memory_statscategories.Objects with multiple possible placements are reported in multiple regions for total and shared sizes, while other categories are counted only for the currently active region.
Signed-off-by Tvrtko Ursulin <[email protected]>Cc Rob Clark <[email protected]>---
drivers/gpu/drm/i915/i915_drm_client.c| 66 ++++++++++++++++++++++++++1 file changed, 66 insertions(+)drivers/gpu/drm/i915/i915_drm_client.c +14
-0@@ -41,6 +41,70 @@ void __i915_drm_client_free(struct kref *kref) } #ifdef CONFIG_PROC_FS +static void +add_obj_meminfo (struct drm_i915_gem_object *obj, + struct intel_memory_region *mr, + struct drm_memory_stats stats[INTEL_REGION_UNKNOWN]) +{ + u64 sz = obj->base.size; + enum intel_region_id id; + unsigned int i; + + id = mr->id; + if (obj->base.handle_count > 1) + stats[id].shared += sz; + else + stats[id].private += sz;drivers/gpu/drm/i915/i915_drm_client.c void __i915_drm_client_free(struct kref *kref) · line 66
Quoted 10 lines
drivers/gpu/drm/i915/i915_drm_client.c +10
-0+ + if (i915_gem_object_has_pages(obj)) { + stats[id].resident += sz; + + if (!dma_resv_test_signaled(obj->base.resv, + dma_resv_usage_rw(true))) + stats[id].active += sz; + else if (i915_gem_object_is_shrinkable(obj) && + obj->mm.madv == I915_MADV_DONTNEED) + stats[id].purgeable += sz;this is a bit off... otherwise:
Quoted 5 lines
Quoted 1 line
Reviewed-by Andi Shyti <[email protected]>Thanks!
I will sit on this until I can find time to add some tests to
drm_fdinfo.c.
Actually.. Aravind pointed off list that my brain wasn't switched on when writing this. Fdinfo stats need to be per client and this patch is therefore almost completely bogus.
Regards,
Tvrtko
Quoted 57 lines
Quoted 57 lines
Andi
Quoted 54 lines
drivers/gpu/drm/i915/i915_drm_client.c +3
-0+ } + + /* Attribute size and shared to all possible object memoryregions. */
+ for (i = 0; i <obj->mm.n_placements; i++) {
+ if (obj->mm.placements[i] == mr)
+ continue;drivers/gpu/drm/i915/i915_drm_client.c +34
-0+ + id = obj->mm.placements[i]->id; + if (obj->base.handle_count > 1) + stats[id].shared += sz; + else + stats[id].private += sz; + } +} + +static void show_meminfo (struct drm_printer *p,struct drm_file *file) +{ + struct drm_i915_file_private *file_priv = file->driver_priv; + struct drm_memory_stats stats[INTEL_REGION_UNKNOWN] = {}; + struct drm_i915_private *i915 = file_priv->i915; + struct intel_memory_region *mr; + unsigned int id; + + for_each_memory_region(mr, i915, id) { + struct drm_i915_gem_object *obj; + + mutex_lock(&mr->objects.lock); + list_for_each_entry(obj, &mr->objects.list, mm.region_link) + add_obj_meminfo(obj, mr, stats); + mutex_unlock(&mr->objects.lock); + } + + for_each_memory_region(mr, i915, id) + drm_print_memory_stats(p, + &stats[id], + DRM_GEM_OBJECT_RESIDENT | + DRM_GEM_OBJECT_PURGEABLE, + mr->name); +} +static const char * const uabi_class_names[] = { [
I915_ENGINE_CLASS_RENDER] = "render", [I915_ENGINE_CLASS_COPY] = "copy",drivers/gpu/drm/i915/i915_drm_client.c +2
-0@@ -102,6 +166,8 @@ void i915_drm_client_fdinfo(struct drm_printer*p, struct drm_file *file) * ****************************************************************** */ + show_meminfo(p, file); + if (GRAPHICS_VER(i915) < 8) return;Signature · 1 line
2.39.2