[RFC PATCH 141/162] drm/i915: Lmem eviction statistics by category

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Ramalingam C <ramalingam.c@xxxxxxxxx>

Number of bytes swapped in and out are captured for both blitter and
memcpy based evictions with time taken for the process.

Debugfs is extended to provide the eviction statistics through both
methods with rate of transfer.

Signed-off-by: Ramalingam C <ramalingam.c@xxxxxxxxx>
Cc: Matthew Auld <matthew.auld@xxxxxxxxx>
Cc: CQ Tang <cq.tang@xxxxxxxxx>
---
 drivers/gpu/drm/i915/gem/i915_gem_region.c | 32 +++++++++++++---
 drivers/gpu/drm/i915/i915_debugfs.c        | 43 +++++++++++++++++++---
 drivers/gpu/drm/i915/i915_drv.h            |  5 +++
 3 files changed, 68 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_region.c b/drivers/gpu/drm/i915/gem/i915_gem_region.c
index f9ff0aa31752..1ec6528498c8 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_region.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_region.c
@@ -16,6 +16,7 @@ i915_gem_object_swapout_pages(struct drm_i915_gem_object *obj,
 	struct drm_i915_private *i915 = to_i915(obj->base.dev);
 	struct drm_i915_gem_object *dst, *src;
 	unsigned long start, diff, msec;
+	bool blt_completed = false;
 	int err = -EINVAL;
 
 	GEM_BUG_ON(obj->swapto);
@@ -54,8 +55,11 @@ i915_gem_object_swapout_pages(struct drm_i915_gem_object *obj,
 	__i915_gem_object_pin_pages(src);
 
 	/* copying the pages */
-	if (i915->params.enable_eviction >= 2)
+	if (i915->params.enable_eviction >= 2) {
 		err = i915_window_blt_copy(dst, src);
+		if (!err)
+			blt_completed = true;
+	}
 	if (err && i915->params.enable_eviction != 2)
 		err = i915_gem_object_memcpy(dst, src);
 
@@ -72,8 +76,14 @@ i915_gem_object_swapout_pages(struct drm_i915_gem_object *obj,
 	if (!err) {
 		diff = jiffies - start;
 		msec = diff * 1000 / HZ;
-		atomic_long_add(msec, &i915->time_swap_out_ms);
-		atomic_long_add(sizes, &i915->num_bytes_swapped_out);
+		if (blt_completed) {
+			atomic_long_add(sizes, &i915->num_bytes_swapped_out);
+			atomic_long_add(msec, &i915->time_swap_out_ms);
+		} else {
+			atomic_long_add(sizes,
+					&i915->num_bytes_swapped_out_memcpy);
+			atomic_long_add(msec, &i915->time_swap_out_ms_memcpy);
+		}
 	}
 
 	return err;
@@ -86,6 +96,7 @@ i915_gem_object_swapin_pages(struct drm_i915_gem_object *obj,
 	struct drm_i915_private *i915 = to_i915(obj->base.dev);
 	struct drm_i915_gem_object *dst, *src;
 	unsigned long start, diff, msec;
+	bool blt_completed = false;
 	int err = -EINVAL;
 
 	GEM_BUG_ON(!obj->swapto);
@@ -120,8 +131,11 @@ i915_gem_object_swapin_pages(struct drm_i915_gem_object *obj,
 	__i915_gem_object_pin_pages(dst);
 
 	/* copying the pages */
-	if (i915->params.enable_eviction >= 2)
+	if (i915->params.enable_eviction >= 2) {
 		err = i915_window_blt_copy(dst, src);
+		if (!err)
+			blt_completed = true;
+	}
 	if (err && i915->params.enable_eviction != 2)
 		err = i915_gem_object_memcpy(dst, src);
 
@@ -138,8 +152,14 @@ i915_gem_object_swapin_pages(struct drm_i915_gem_object *obj,
 	if (!err) {
 		diff = jiffies - start;
 		msec = diff * 1000 / HZ;
-		atomic_long_add(msec, &i915->time_swap_in_ms);
-		atomic_long_add(sizes, &i915->num_bytes_swapped_in);
+		if (blt_completed) {
+			atomic_long_add(sizes, &i915->num_bytes_swapped_in);
+			atomic_long_add(msec, &i915->time_swap_in_ms);
+		} else {
+			atomic_long_add(sizes,
+					&i915->num_bytes_swapped_in_memcpy);
+			atomic_long_add(msec, &i915->time_swap_in_ms_memcpy);
+		}
 	}
 
 	return err;
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 2bf51dd9de7c..983030ac39e1 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -364,6 +364,7 @@ static int i915_gem_object_info(struct seq_file *m, void *data)
 	struct drm_i915_private *i915 = node_to_i915(m->private);
 	struct intel_memory_region *mr;
 	enum intel_region_id id;
+	u64 time, bytes, rate;
 
 	seq_printf(m, "%u shrinkable [%u free] objects, %llu bytes\n",
 		   i915->mm.shrink_count,
@@ -372,12 +373,42 @@ static int i915_gem_object_info(struct seq_file *m, void *data)
 	for_each_memory_region(mr, i915, id)
 		seq_printf(m, "%s: total:%pa, available:%pa bytes\n",
 			   mr->name, &mr->total, &mr->avail);
-	seq_printf(m, "num_bytes_swapped_out %ld num_bytes_swapped_in %ld\n",
-		   atomic_long_read(&i915->num_bytes_swapped_out),
-		   atomic_long_read(&i915->num_bytes_swapped_in));
-	seq_printf(m, "time_swap_out_msec %ld time_swap_in_msec %ld\n",
-		   atomic_long_read(&i915->time_swap_out_ms),
-		   atomic_long_read(&i915->time_swap_in_ms));
+
+	time = atomic_long_read(&i915->time_swap_out_ms);
+	bytes = atomic_long_read(&i915->num_bytes_swapped_out);
+	if (time)
+		rate = div64_u64(bytes * 1000, time * 1024 * 1024);
+	else
+		rate = 0;
+	seq_printf(m, "BLT: swapout %llu Bytes in %llu mSec(%llu MB/Sec)\n",
+		   bytes, time, rate);
+
+	time = atomic_long_read(&i915->time_swap_in_ms);
+	bytes = atomic_long_read(&i915->num_bytes_swapped_in);
+	if (time)
+		rate = div64_u64(bytes * 1000, time * 1024 * 1024);
+	else
+		rate = 0;
+	seq_printf(m, "BLT: swapin %llu Bytes in %llu mSec(%llu MB/Sec)\n",
+		   bytes, time, rate);
+
+	time = atomic_long_read(&i915->time_swap_out_ms_memcpy);
+	bytes = atomic_long_read(&i915->num_bytes_swapped_out_memcpy);
+	if (time)
+		rate = div64_u64(bytes * 1000, time * 1024 * 1024);
+	else
+		rate = 0;
+	seq_printf(m, "Memcpy: swapout %llu Bytes in %llu mSec(%llu MB/Sec)\n",
+		   bytes, time, rate);
+
+	time = atomic_long_read(&i915->time_swap_in_ms_memcpy);
+	bytes = atomic_long_read(&i915->num_bytes_swapped_in_memcpy);
+	if (time)
+		rate = div64_u64(bytes * 1000, time * 1024 * 1024);
+	else
+		rate = 0;
+	seq_printf(m, "Memcpy: swapin %llu Bytes in %llu mSec(%llu MB/Sec)\n",
+		   bytes, time, rate);
 	seq_putc(m, '\n');
 
 	print_context_stats(m, i915);
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 82f431cc38cd..6f0ab363bdee 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1225,6 +1225,11 @@ struct drm_i915_private {
 	atomic_long_t num_bytes_swapped_in;
 	atomic_long_t time_swap_out_ms;
 	atomic_long_t time_swap_in_ms;
+
+	atomic_long_t num_bytes_swapped_out_memcpy;
+	atomic_long_t num_bytes_swapped_in_memcpy;
+	atomic_long_t time_swap_out_ms_memcpy;
+	atomic_long_t time_swap_in_ms_memcpy;
 };
 
 static inline struct drm_i915_private *to_i915(const struct drm_device *dev)
-- 
2.26.2

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel



[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux