Skip to contentSkip to conversation

drm/i915: Report correct GGTT space usage

PATCH Superseded Tvrtko Ursulin 3 participants 18 messages Jun 30, 2015 – Jul 2, 2015

Subsystems (2)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/i915: Report correct GGTT space usage

From: Tvrtko Ursulin <[email protected]>

Currently only normal views were accounted which under-accounts the usage as reported in debugfs.

Introduce new helper, i915_gem_obj_total_ggtt_size, and use it from call sites which want to know how much GGTT space are objects using.

---
 drivers/gpu/drm/i915/i915_debugfs.c |  8 ++++----
 drivers/gpu/drm/i915/i915_drv.h     |  3 +++
 drivers/gpu/drm/i915/i915_gem.c     | 16 +++++++++++++++-
 3 files changed, 22 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +4 -4
index 31d8768..3bb6c99 100644
@@ -269,7 +269,7 @@ static int i915_gem_stolen_list_info(struct seq_file *m, void *data)
 		list_add(&obj->obj_exec_link, &stolen);
 
 		total_obj_size += obj->base.size;
-		total_gtt_size += i915_gem_obj_ggtt_size(obj);
+		total_gtt_size += i915_gem_obj_total_ggtt_size(obj);
 		count++;
 	}
 	list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_list) {
@@ -299,7 +299,7 @@ static int i915_gem_stolen_list_info(struct seq_file *m, void *data)
 
 #define count_objects(list, member) do { \
 	list_for_each_entry(obj, list, member) { \
-		size += i915_gem_obj_ggtt_size(obj); \
+		size += i915_gem_obj_total_ggtt_size(obj); \
 		++count; \
 		if (obj->map_and_fenceable) { \
 			mappable_size += i915_gem_obj_ggtt_size(obj); \
@@ -405,7 +405,7 @@ static void print_batch_pool_stats(struct seq_file *m,
 
 #define count_vmas(list, member) do { \
 	list_for_each_entry(vma, list, member) { \
-		size += i915_gem_obj_ggtt_size(vma->obj); \
+		size += i915_gem_obj_total_ggtt_size(vma->obj); \
 		++count; \
 		if (vma->obj->map_and_fenceable) { \
 			mappable_size += i915_gem_obj_ggtt_size(vma->obj); \
@@ -535,7 +535,7 @@ static int i915_gem_gtt_info(struct seq_file *m, void *data)
 		describe_obj(m, obj);
 		seq_putc(m, '\n');
 		total_obj_size += obj->base.size;
-		total_gtt_size += i915_gem_obj_ggtt_size(obj);
+		total_gtt_size += i915_gem_obj_total_ggtt_size(obj);
 		count++;
 	}
 
drivers/gpu/drm/i915/i915_drv.h +3 -0
index ea9caf2..690b541 100644
@@ -3010,6 +3010,9 @@ i915_gem_obj_ggtt_size(struct drm_i915_gem_object *obj)
 	return i915_gem_obj_size(obj, i915_obj_to_ggtt(obj));
 }
 
+unsigned long
+i915_gem_obj_total_ggtt_size(struct drm_i915_gem_object *obj);
+
 static inline int __must_check
 i915_gem_obj_ggtt_pin(struct drm_i915_gem_object *obj,
 		      uint32_t alignment,
drivers/gpu/drm/i915/i915_gem.c +15 -1
index a2a4a27..7d69294 100644
@@ -156,7 +156,7 @@ i915_gem_get_aperture_ioctl(struct drm_device *dev, void *data,
 	mutex_lock(&dev->struct_mutex);
 	list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list)
 		if (i915_gem_obj_is_pinned(obj))
-			pinned += i915_gem_obj_ggtt_size(obj);
+			pinned += i915_gem_obj_total_ggtt_size(obj);
 	mutex_unlock(&dev->struct_mutex);
 
 	args->aper_size = dev_priv->gtt.base.total;
@@ -5469,3 +5469,17 @@ bool i915_gem_obj_is_pinned(struct drm_i915_gem_object *obj)
 	return false;
 }
 
+unsigned long
+i915_gem_obj_total_ggtt_size(struct drm_i915_gem_object *obj)
+{
+	unsigned long size = 0;
+	struct i915_vma *vma;
+
+	list_for_each_entry(vma, &obj->vma_list, vma_link) {
+		if (i915_is_ggtt(vma->vm) &&
+		    drm_mm_node_allocated(&vma->node))
+			size += vma->node.size;
+	}
+
+	return size;
+}
Signature · 6 lines
2.4.2

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

drivers/gpu/drm/i915/i915_gem.c i915_gem_get_aperture_ioctl(struct drm_device *dev, void *data, · line 159

Quoted 10 lines · Tvrtko Ursulin
drivers/gpu/drm/i915/i915_gem.c +1 -1
index a2a4a27..7d69294 100644
@@ -156,7 +156,7 @@ i915_gem_get_aperture_ioctl(struct drm_device *dev, void *data,
 	mutex_lock(&dev->struct_mutex);
 	list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list)
 		if (i915_gem_obj_is_pinned(obj))
-			pinned += i915_gem_obj_ggtt_size(obj);
+			pinned += i915_gem_obj_total_ggtt_size(obj);

Please just rewrite this as a single vma walk, or review the patches I sent to do so.
-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw
Quoted 14 lines · Chris Wilson

drivers/gpu/drm/i915/i915_gem.c i915_gem_get_aperture_ioctl(struct drm_device *dev, void *data, · line 159

Quoted 10 lines · Tvrtko Ursulin
drivers/gpu/drm/i915/i915_gem.c +1 -1
index a2a4a27..7d69294 100644
@@ -156,7 +156,7 @@ i915_gem_get_aperture_ioctl(struct drm_device *dev, void *data,
  	mutex_lock(&dev->struct_mutex);
  	list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list)
  		if (i915_gem_obj_is_pinned(obj))
-			pinned += i915_gem_obj_ggtt_size(obj);
+			pinned += i915_gem_obj_total_ggtt_size(obj);

Please just rewrite this as a single vma walk, or review the patches I sent to do so.

Sorry there is a lot of patches floating around and I don't know which ones you refer too.

I just noticed debugfs displays wrong values when GGTT views other than normal are present.

So just open code the loop in get_aperture you say?

It is slightly ugly when there are helpers, but it is also true different callers want to know slightly different things. (Difference between GGTT usage reported in get_aperture vs debugfs - pinned or just allocated.)

Regards,

Tvrtko
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#3 lore raw
Quoted 17 lines · Tvrtko Ursulin
Quoted 14 lines · Chris Wilson

drivers/gpu/drm/i915/i915_gem.c i915_gem_get_aperture_ioctl(struct drm_device *dev, void *data, · line 159

Quoted 10 lines · Tvrtko Ursulin
drivers/gpu/drm/i915/i915_gem.c +1 -1
index a2a4a27..7d69294 100644
@@ -156,7 +156,7 @@ i915_gem_get_aperture_ioctl(struct drm_device *dev, void *data,
 	mutex_lock(&dev->struct_mutex);
 	list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list)
 		if (i915_gem_obj_is_pinned(obj))
-			pinned += i915_gem_obj_ggtt_size(obj);
+			pinned += i915_gem_obj_total_ggtt_size(obj);

Please just rewrite this as a single vma walk, or review the patches I sent to do so.

Quoted 7 lines

Sorry there is a lot of patches floating around and I don't know which ones you refer too.

I just noticed debugfs displays wrong values when GGTT views other than normal are present.

So just open code the loop in get_aperture you say?

Yes.

Quoted 4 lines

It is slightly ugly when there are helpers, but it is also true different callers want to know slightly different things. (Difference between GGTT usage reported in get_aperture vs debugfs - pinned or just allocated.)

I've stopped taking notice of the GGTT usage in the debugfs output, it's archaic and doesn't help me anymore. The only case where it really matters is debugfs/i915_gem_gtt.
-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#4 lore raw

PATCH v2 1/1 drm/i915: Report correct GGTT space usage

From: Tvrtko Ursulin <[email protected]>

Currently only normal views were accounted which under-accounts the usage as reported in debugfs.

Introduce new helper, i915_gem_obj_total_ggtt_size, and use it from call sites which want to know how much GGTT space are objects using.

v2: Single loop in i915_gem_get_aperture_ioctl. (Chris Wilson)

Cc Joonas Lahtinen <[email protected]>
Cc Chris Wilson <[email protected]>
---
 drivers/gpu/drm/i915/i915_debugfs.c |  8 ++++----
 drivers/gpu/drm/i915/i915_drv.h     |  3 +++
 drivers/gpu/drm/i915/i915_gem.c     | 23 ++++++++++++++++++++---
 3 files changed, 27 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +4 -4
index 31d8768..3bb6c99 100644
@@ -269,7 +269,7 @@ static int i915_gem_stolen_list_info(struct seq_file *m, void *data)
 		list_add(&obj->obj_exec_link, &stolen);
 
 		total_obj_size += obj->base.size;
-		total_gtt_size += i915_gem_obj_ggtt_size(obj);
+		total_gtt_size += i915_gem_obj_total_ggtt_size(obj);
 		count++;
 	}
 	list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_list) {
@@ -299,7 +299,7 @@ static int i915_gem_stolen_list_info(struct seq_file *m, void *data)
 
 #define count_objects(list, member) do { \
 	list_for_each_entry(obj, list, member) { \
-		size += i915_gem_obj_ggtt_size(obj); \
+		size += i915_gem_obj_total_ggtt_size(obj); \
 		++count; \
 		if (obj->map_and_fenceable) { \
 			mappable_size += i915_gem_obj_ggtt_size(obj); \
@@ -405,7 +405,7 @@ static void print_batch_pool_stats(struct seq_file *m,
 
 #define count_vmas(list, member) do { \
 	list_for_each_entry(vma, list, member) { \
-		size += i915_gem_obj_ggtt_size(vma->obj); \
+		size += i915_gem_obj_total_ggtt_size(vma->obj); \
 		++count; \
 		if (vma->obj->map_and_fenceable) { \
 			mappable_size += i915_gem_obj_ggtt_size(vma->obj); \
@@ -535,7 +535,7 @@ static int i915_gem_gtt_info(struct seq_file *m, void *data)
 		describe_obj(m, obj);
 		seq_putc(m, '\n');
 		total_obj_size += obj->base.size;
-		total_gtt_size += i915_gem_obj_ggtt_size(obj);
+		total_gtt_size += i915_gem_obj_total_ggtt_size(obj);
 		count++;
 	}
 
drivers/gpu/drm/i915/i915_drv.h +3 -0
index ea9caf2..690b541 100644
@@ -3010,6 +3010,9 @@ i915_gem_obj_ggtt_size(struct drm_i915_gem_object *obj)
 	return i915_gem_obj_size(obj, i915_obj_to_ggtt(obj));
 }
 
+unsigned long
+i915_gem_obj_total_ggtt_size(struct drm_i915_gem_object *obj);
+
 static inline int __must_check
 i915_gem_obj_ggtt_pin(struct drm_i915_gem_object *obj,
 		      uint32_t alignment,
drivers/gpu/drm/i915/i915_gem.c +20 -3
index a2a4a27..32f6323 100644
@@ -150,13 +150,16 @@ i915_gem_get_aperture_ioctl(struct drm_device *dev, void *data,
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct drm_i915_gem_get_aperture *args = data;
 	struct drm_i915_gem_object *obj;
+	struct i915_vma *vma;
 	size_t pinned;
 
 	pinned = 0;
 	mutex_lock(&dev->struct_mutex);
-	list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list)
-		if (i915_gem_obj_is_pinned(obj))
-			pinned += i915_gem_obj_ggtt_size(obj);
+	list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) {
+		list_for_each_entry(vma, &obj->vma_list, vma_link)
+			if (i915_is_ggtt(vma->vm) && vma->pin_count)
+				pinned += vma->node.size;
+	}
 	mutex_unlock(&dev->struct_mutex);
 
 	args->aper_size = dev_priv->gtt.base.total;
@@ -5469,3 +5472,17 @@ bool i915_gem_obj_is_pinned(struct drm_i915_gem_object *obj)
 	return false;
 }
 
+unsigned long
+i915_gem_obj_total_ggtt_size(struct drm_i915_gem_object *obj)
+{
+	unsigned long size = 0;
+	struct i915_vma *vma;
+
+	list_for_each_entry(vma, &obj->vma_list, vma_link) {
+		if (i915_is_ggtt(vma->vm) &&
+		    drm_mm_node_allocated(&vma->node))
+			size += vma->node.size;
+	}
+
+	return size;
+}
Signature · 6 lines
2.4.2

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw

drivers/gpu/drm/i915/i915_gem.c i915_gem_get_aperture_ioctl(struct drm_device *dev, void *data, · line 159

Quoted 2 lines · Tvrtko Ursulin
drivers/gpu/drm/i915/i915_gem.c +2 -0
+	list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) {
+		list_for_each_entry(vma, &obj->vma_list, vma_link)

If only there was already a list of vma bound in the GGTT... -Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#6 lore raw
Quoted 5 lines · Chris Wilson

drivers/gpu/drm/i915/i915_gem.c i915_gem_get_aperture_ioctl(struct drm_device *dev, void *data, · line 159

Quoted 2 lines · Tvrtko Ursulin
drivers/gpu/drm/i915/i915_gem.c +2 -0
+	list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) {
+		list_for_each_entry(vma, &obj->vma_list, vma_link)

If only there was already a list of vma bound in the GGTT...

Let me guess, you have patches for that? :) But for this maybe not yet, if I can hazard a guess you are referring to the big VMA rewrite? Which is still in progress?

Regards,

Tvrtko
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#7 lore raw
Quoted 11 lines · Tvrtko Ursulin
Quoted 5 lines · Chris Wilson

drivers/gpu/drm/i915/i915_gem.c i915_gem_get_aperture_ioctl(struct drm_device *dev, void *data, · line 159

Quoted 2 lines · Tvrtko Ursulin
drivers/gpu/drm/i915/i915_gem.c +2 -0
+	list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list) {
+		list_for_each_entry(vma, &obj->vma_list, vma_link)

If only there was already a list of vma bound in the GGTT...

Let me guess, you have patches for that? :) But for this maybe not yet, if I can hazard a guess you are referring to the big VMA rewrite? Which is still in progress?

In upstream you can simply walk the lists of
i915->gtt.base.active/i915->gtt.base.inactive.
-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#8 lore raw

PATCH v3 1/1 drm/i915: Report correct GGTT space usage

From: Tvrtko Ursulin <[email protected]>

Currently only normal views were accounted which under-accounts the usage as reported in debugfs and by the GET_APERTURE ioctl.

Introduce new helper, i915_gem_obj_total_ggtt_size, and use it from call sites which want to know how much GGTT space are objects using.

v2: Single loop in i915_gem_get_aperture_ioctl. (Chris Wilson)

v3: Walk GGTT active/inactive lists in i915_gem_get_aperture_ioctl
for better efficiency. (Chris Wilson, Daniel Vetter)

Cc Joonas Lahtinen <[email protected]>
Cc Chris Wilson <[email protected]>
Cc Daniel Vetter <[email protected]>

---
Sorry guys for a period I was convinced "mm.bound_list" is actually "vm.bound_list". :)

---
 drivers/gpu/drm/i915/i915_debugfs.c |  8 ++++----
 drivers/gpu/drm/i915/i915_drv.h     |  3 +++
 drivers/gpu/drm/i915/i915_gem.c     | 26 ++++++++++++++++++++++----
 3 files changed, 29 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +4 -4
index 31d87685f3b9..3bb6c99d9869 100644
@@ -269,7 +269,7 @@ static int i915_gem_stolen_list_info(struct seq_file *m, void *data)
 		list_add(&obj->obj_exec_link, &stolen);
 
 		total_obj_size += obj->base.size;
-		total_gtt_size += i915_gem_obj_ggtt_size(obj);
+		total_gtt_size += i915_gem_obj_total_ggtt_size(obj);
 		count++;
 	}
 	list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_list) {
@@ -299,7 +299,7 @@ static int i915_gem_stolen_list_info(struct seq_file *m, void *data)
 
 #define count_objects(list, member) do { \
 	list_for_each_entry(obj, list, member) { \
-		size += i915_gem_obj_ggtt_size(obj); \
+		size += i915_gem_obj_total_ggtt_size(obj); \
 		++count; \
 		if (obj->map_and_fenceable) { \
 			mappable_size += i915_gem_obj_ggtt_size(obj); \
@@ -405,7 +405,7 @@ static void print_batch_pool_stats(struct seq_file *m,
 
 #define count_vmas(list, member) do { \
 	list_for_each_entry(vma, list, member) { \
-		size += i915_gem_obj_ggtt_size(vma->obj); \
+		size += i915_gem_obj_total_ggtt_size(vma->obj); \
 		++count; \
 		if (vma->obj->map_and_fenceable) { \
 			mappable_size += i915_gem_obj_ggtt_size(vma->obj); \
@@ -535,7 +535,7 @@ static int i915_gem_gtt_info(struct seq_file *m, void *data)
 		describe_obj(m, obj);
 		seq_putc(m, '\n');
 		total_obj_size += obj->base.size;
-		total_gtt_size += i915_gem_obj_ggtt_size(obj);
+		total_gtt_size += i915_gem_obj_total_ggtt_size(obj);
 		count++;
 	}
 
drivers/gpu/drm/i915/i915_drv.h +3 -0
index ea9caf22283f..690b541ed3b8 100644
@@ -3010,6 +3010,9 @@ i915_gem_obj_ggtt_size(struct drm_i915_gem_object *obj)
 	return i915_gem_obj_size(obj, i915_obj_to_ggtt(obj));
 }
 
+unsigned long
+i915_gem_obj_total_ggtt_size(struct drm_i915_gem_object *obj);
+
 static inline int __must_check
 i915_gem_obj_ggtt_pin(struct drm_i915_gem_object *obj,
 		      uint32_t alignment,
drivers/gpu/drm/i915/i915_gem.c +22 -4
index a2a4a271555c..76c72996be66 100644
@@ -149,14 +149,18 @@ i915_gem_get_aperture_ioctl(struct drm_device *dev, void *data,
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct drm_i915_gem_get_aperture *args = data;
-	struct drm_i915_gem_object *obj;
+	struct i915_gtt *ggtt = &dev_priv->gtt;
+	struct i915_vma *vma;
 	size_t pinned;
 
 	pinned = 0;
 	mutex_lock(&dev->struct_mutex);
-	list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list)
-		if (i915_gem_obj_is_pinned(obj))
-			pinned += i915_gem_obj_ggtt_size(obj);
+	list_for_each_entry(vma, &ggtt->base.active_list, mm_list)
+		if (vma->pin_count)
+			pinned += vma->node.size;
+	list_for_each_entry(vma, &ggtt->base.inactive_list, mm_list)
+		if (vma->pin_count)
+			pinned += vma->node.size;
 	mutex_unlock(&dev->struct_mutex);
 
 	args->aper_size = dev_priv->gtt.base.total;
@@ -5469,3 +5473,17 @@ bool i915_gem_obj_is_pinned(struct drm_i915_gem_object *obj)
 	return false;
 }
 
+unsigned long
+i915_gem_obj_total_ggtt_size(struct drm_i915_gem_object *obj)
+{
+	unsigned long size = 0;
+	struct i915_vma *vma;
+
+	list_for_each_entry(vma, &obj->vma_list, vma_link) {
+		if (i915_is_ggtt(vma->vm) &&
+		    drm_mm_node_allocated(&vma->node))
+			size += vma->node.size;
+	}
+
+	return size;
+}
Signature · 6 lines
2.4.2

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v3 1/1
#9 lore raw
Quoted 11 lines · Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

Currently only normal views were accounted which under-accounts the usage as reported in debugfs and by the GET_APERTURE ioctl.

Introduce new helper, i915_gem_obj_total_ggtt_size, and use it from call sites which want to know how much GGTT space are objects using.

v2: Single loop in i915_gem_get_aperture_ioctl. (Chris Wilson)

Quoted 7 lines

v3: Walk GGTT active/inactive lists in i915_gem_get_aperture_ioctl
for better efficiency. (Chris Wilson, Daniel Vetter)

Cc Joonas Lahtinen <[email protected]>
Cc Chris Wilson <[email protected]>
Cc Daniel Vetter <[email protected]>

One final request, and then

Please make the total_gtt_size() static to i915_debugfs.c, I don't want any new users :)

Quoted 3 lines

---
Sorry guys for a period I was convinced "mm.bound_list" is actually "vm.bound_list". :)

Sometimes I wish it were. But atm, they are used for two distinct purposes. The global list is for the shrinker, and the active/inactive list is for eviction. All other use is coincidental.
-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#10 lore raw

PATCH v4 1/1 drm/i915: Report correct GGTT space usage

From: Tvrtko Ursulin <[email protected]>

Currently only normal views were accounted which under-accounts the usage as reported in debugfs.

Introduce new helper, i915_gem_obj_total_ggtt_size, and use it from call sites which want to know how much GGTT space are objects using.

v2: Single loop in i915_gem_get_aperture_ioctl. (Chris Wilson)

v3: Walk GGTT active/inactive lists in i915_gem_get_aperture_ioctl
for better efficiency. (Chris Wilson, Daniel Vetter)

v4: Make i915_gem_obj_total_ggtt_size private to debugfs. (Chris Wilson)

Cc Joonas Lahtinen <[email protected]>
Cc Chris Wilson <[email protected]>
Cc Daniel Vetter <[email protected]>
---
 drivers/gpu/drm/i915/i915_debugfs.c | 23 +++++++++++++++++++----
 drivers/gpu/drm/i915/i915_gem.c     | 13 ++++++++-----
 2 files changed, 27 insertions(+), 9 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +19 -4
index 31d87685f3b9..16d92115c3e6 100644
@@ -117,6 +117,21 @@ static inline const char *get_global_flag(struct drm_i915_gem_object *obj)
 	return i915_gem_obj_to_ggtt(obj) ? "g" : " ";
 }
 
+static unsigned long
+i915_gem_obj_total_ggtt_size(struct drm_i915_gem_object *obj)
+{
+	unsigned long size = 0;
+	struct i915_vma *vma;
+
+	list_for_each_entry(vma, &obj->vma_list, vma_link) {
+		if (i915_is_ggtt(vma->vm) &&
+		    drm_mm_node_allocated(&vma->node))
+			size += vma->node.size;
+	}
+
+	return size;
+}
+
 static void
 describe_obj(struct seq_file *m, struct drm_i915_gem_object *obj)
 {
@@ -269,7 +284,7 @@ static int i915_gem_stolen_list_info(struct seq_file *m, void *data)
 		list_add(&obj->obj_exec_link, &stolen);
 
 		total_obj_size += obj->base.size;
-		total_gtt_size += i915_gem_obj_ggtt_size(obj);
+		total_gtt_size += i915_gem_obj_total_ggtt_size(obj);
 		count++;
 	}
 	list_for_each_entry(obj, &dev_priv->mm.unbound_list, global_list) {
@@ -299,7 +314,7 @@ static int i915_gem_stolen_list_info(struct seq_file *m, void *data)
 
 #define count_objects(list, member) do { \
 	list_for_each_entry(obj, list, member) { \
-		size += i915_gem_obj_ggtt_size(obj); \
+		size += i915_gem_obj_total_ggtt_size(obj); \
 		++count; \
 		if (obj->map_and_fenceable) { \
 			mappable_size += i915_gem_obj_ggtt_size(obj); \
@@ -405,7 +420,7 @@ static void print_batch_pool_stats(struct seq_file *m,
 
 #define count_vmas(list, member) do { \
 	list_for_each_entry(vma, list, member) { \
-		size += i915_gem_obj_ggtt_size(vma->obj); \
+		size += i915_gem_obj_total_ggtt_size(vma->obj); \
 		++count; \
 		if (vma->obj->map_and_fenceable) { \
 			mappable_size += i915_gem_obj_ggtt_size(vma->obj); \
@@ -535,7 +550,7 @@ static int i915_gem_gtt_info(struct seq_file *m, void *data)
 		describe_obj(m, obj);
 		seq_putc(m, '\n');
 		total_obj_size += obj->base.size;
-		total_gtt_size += i915_gem_obj_ggtt_size(obj);
+		total_gtt_size += i915_gem_obj_total_ggtt_size(obj);
 		count++;
 	}
 
drivers/gpu/drm/i915/i915_gem.c +8 -5
index a2a4a271555c..49016e01da6c 100644
@@ -149,14 +149,18 @@ i915_gem_get_aperture_ioctl(struct drm_device *dev, void *data,
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct drm_i915_gem_get_aperture *args = data;
-	struct drm_i915_gem_object *obj;
+	struct i915_gtt *ggtt = &dev_priv->gtt;
+	struct i915_vma *vma;
 	size_t pinned;
 
 	pinned = 0;
 	mutex_lock(&dev->struct_mutex);
-	list_for_each_entry(obj, &dev_priv->mm.bound_list, global_list)
-		if (i915_gem_obj_is_pinned(obj))
-			pinned += i915_gem_obj_ggtt_size(obj);
+	list_for_each_entry(vma, &ggtt->base.active_list, mm_list)
+		if (vma->pin_count)
+			pinned += vma->node.size;
+	list_for_each_entry(vma, &ggtt->base.inactive_list, mm_list)
+		if (vma->pin_count)
+			pinned += vma->node.size;
 	mutex_unlock(&dev->struct_mutex);
 
 	args->aper_size = dev_priv->gtt.base.total;
@@ -5468,4 +5472,3 @@ bool i915_gem_obj_is_pinned(struct drm_i915_gem_object *obj)
 
 	return false;
 }
-
Signature · 6 lines
2.4.2

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v4 1/1
#11 lore raw
Quoted 14 lines · Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

Currently only normal views were accounted which under-accounts the usage as reported in debugfs.

Introduce new helper, i915_gem_obj_total_ggtt_size, and use it from call sites which want to know how much GGTT space are objects using.

v2: Single loop in i915_gem_get_aperture_ioctl. (Chris Wilson)

v3: Walk GGTT active/inactive lists in i915_gem_get_aperture_ioctl
for better efficiency. (Chris Wilson, Daniel Vetter)

Quoted 6 lines

v4: Make i915_gem_obj_total_ggtt_size private to debugfs. (Chris Wilson)

Cc Joonas Lahtinen <[email protected]>
Cc Chris Wilson <[email protected]>
Cc Daniel Vetter <[email protected]>

s/unsigned long/u64/

-Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#12 lore raw
Quoted 15 lines · Chris Wilson
Quoted 14 lines · Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

Currently only normal views were accounted which under-accounts the usage as reported in debugfs.

Introduce new helper, i915_gem_obj_total_ggtt_size, and use it from call sites which want to know how much GGTT space are objects using.

v2: Single loop in i915_gem_get_aperture_ioctl. (Chris Wilson)

v3: Walk GGTT active/inactive lists in i915_gem_get_aperture_ioctl
for better efficiency. (Chris Wilson, Daniel Vetter)

Quoted 8 lines
Quoted 6 lines

v4: Make i915_gem_obj_total_ggtt_size private to debugfs. (Chris Wilson)

Cc Joonas Lahtinen <[email protected]>
Cc Chris Wilson <[email protected]>
Cc Daniel Vetter <[email protected]>

s/unsigned long/u64/

It's all pointless until someone makes it all consistent. But done anyway. And sent as a new thread so Daniel hopefully notices it more easily.

Quoted 1 line

Thanks,

Tvrtko

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#13 lore raw
Quoted 24 lines · Tvrtko Ursulin
Quoted 22 lines · Chris Wilson
Quoted 20 lines · Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

Currently only normal views were accounted which under-accounts the usage as reported in debugfs.

Introduce new helper, i915_gem_obj_total_ggtt_size, and use it from call sites which want to know how much GGTT space are objects using.

v2: Single loop in i915_gem_get_aperture_ioctl. (Chris Wilson)

v3: Walk GGTT active/inactive lists in i915_gem_get_aperture_ioctl
for better efficiency. (Chris Wilson, Daniel Vetter)

v4: Make i915_gem_obj_total_ggtt_size private to debugfs. (Chris Wilson)

Cc Joonas Lahtinen <[email protected]>
Cc Chris Wilson <[email protected]>
Cc Daniel Vetter <[email protected]>
Quoted 5 lines
Quoted 1 line

s/unsigned long/u64/

It's all pointless until someone makes it all consistent. But done anyway. And sent as a new thread so Daniel hopefully notices it more easily.

Mika's in the process of being repeatedly poked until the driver is clean. :) -Chris

Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Tested-by on v4 1/1
#14 lore raw
In reply to Tvrtko Ursulin

Task id: 6685 -------------------------------------Summary-------------------------------------
Platform Delta drm-intel-nightly Series Applied
ILK -1 302/302 301/302

SNB                                  312/316              312/316
IVB                                  343/343              343/343

BYT -3 287/287 284/287
HSW 380/380 380/380
-------------------------------------Detailed-------------------------------------
Platform Test drm-intel-nightly Series Applied
*ILK igt@gem_persistent_relocs@forked-interruptible-thrashing PASS(1) DMESG_WARN(1)
(dmesg patch applied)drm:i915_hangcheck_elapsed[i915]]*ERROR*Hangcheck_timer_elapsed...bsd_ring_idle@Hangcheck timer elapsed... bsd ring idle

*BYT  igt@gem_partial_pwrite_pread@reads      PASS(1)      FAIL(1)
*BYT  igt@gem_partial_pwrite_pread@reads-display      PASS(1)      FAIL(1)
*BYT  igt@gem_partial_pwrite_pread@reads-uncached      PASS(1)      FAIL(1)

Note: You need to pay more attention to line start with '*'
_______________________________________________
Intel-gfx mailing list [email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Tested-by on v3 1/1
#15 lore raw
In reply to Tvrtko Ursulin

Task id: 6680 -------------------------------------Summary-------------------------------------
Platform Delta drm-intel-nightly Series Applied

ILK                                  302/302              302/302
SNB                                  312/316              312/316
IVB                                  343/343              343/343

BYT -2 287/287 285/287
HSW 380/380 380/380
-------------------------------------Detailed-------------------------------------
Platform Test drm-intel-nightly Series Applied
*BYT igt@gem_partial_pwrite_pread@reads-display PASS(1) FAIL(1)
*BYT igt@gem_tiled_partial_pwrite_pread@reads PASS(1) FAIL(1)
Note: You need to pay more attention to line start with '*'
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Tested-by on v2 1/1
#16 lore raw
In reply to Tvrtko Ursulin

Task id: 6678 -------------------------------------Summary-------------------------------------
Platform Delta drm-intel-nightly Series Applied

ILK                                  302/302              302/302
SNB                                  312/316              312/316
IVB                                  343/343              343/343

BYT -2 287/287 285/287
HSW 380/380 380/380
-------------------------------------Detailed-------------------------------------
Platform Test drm-intel-nightly Series Applied
*BYT igt@gem_partial_pwrite_pread@reads-display PASS(1) FAIL(1)
*BYT igt@gem_tiled_partial_pwrite_pread@writes-after-reads PASS(1) FAIL(1)
Note: You need to pay more attention to line start with '*'
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Tested-by on v1 1/1
#17 lore raw
In reply to Tvrtko Ursulin

Task id: 6676 -------------------------------------Summary-------------------------------------
Platform Delta drm-intel-nightly Series Applied

ILK                                  302/302              302/302
SNB                                  312/316              312/316
IVB                                  345/345              345/345

BYT -3 287/287 284/287
HSW 382/382 382/382
-------------------------------------Detailed-------------------------------------
Platform Test drm-intel-nightly Series Applied

*BYT  igt@gem_partial_pwrite_pread@reads      PASS(1)      FAIL(1)
*BYT  igt@gem_partial_pwrite_pread@reads-display      PASS(1)      FAIL(1)
*BYT  igt@gem_partial_pwrite_pread@reads-uncached      PASS(1)      FAIL(1)

Note: You need to pay more attention to line start with '*'
_______________________________________________
Intel-gfx mailing list [email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx