[PATCH] drm/mm: add ig_frag selftest

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

 



This patch introduces fragmentation in the address range
and measures time taken by 10k insertions for each modes.

ig_frag() will fail if one of the mode takes more than 1 sec.

Output:
<snip>
[   37.326723] drm_mm: igt_sanitycheck - ok!
[   37.326727] igt_debug 0x0000000000000000-0x0000000000000200: 512: free
[   37.326728] igt_debug 0x0000000000000200-0x0000000000000600: 1024: used
[   37.326728] igt_debug 0x0000000000000600-0x0000000000000a00: 1024: free
[   37.326729] igt_debug 0x0000000000000a00-0x0000000000000e00: 1024: used
[   37.326730] igt_debug 0x0000000000000e00-0x0000000000001000: 512: free
[   37.326730] igt_debug total: 4096, used 2048 free 2048
[   56.040064] drm_mm: best fragmented insert took 504 msecs
[   56.082184] drm_mm: bottom-up fragmented insert took 40 msecs
[   56.102255] drm_mm: top-down fragmented insert took 20 msecs
[   56.107177] drm_mm: evict fragmented insert took 4 msecs
<snip>

Signed-off-by: Nirmoy Das <nirmoy.das@xxxxxxx>
---
 drivers/gpu/drm/selftests/drm_mm_selftests.h |  1 +
 drivers/gpu/drm/selftests/test-drm_mm.c      | 59 ++++++++++++++++++++
 2 files changed, 60 insertions(+)

diff --git a/drivers/gpu/drm/selftests/drm_mm_selftests.h b/drivers/gpu/drm/selftests/drm_mm_selftests.h
index 6b943ea1c57d..8c87c964176b 100644
--- a/drivers/gpu/drm/selftests/drm_mm_selftests.h
+++ b/drivers/gpu/drm/selftests/drm_mm_selftests.h
@@ -14,6 +14,7 @@ selftest(insert, igt_insert)
 selftest(replace, igt_replace)
 selftest(insert_range, igt_insert_range)
 selftest(align, igt_align)
+selftest(frag, igt_frag)
 selftest(align32, igt_align32)
 selftest(align64, igt_align64)
 selftest(evict, igt_evict)
diff --git a/drivers/gpu/drm/selftests/test-drm_mm.c b/drivers/gpu/drm/selftests/test-drm_mm.c
index 9aabe82dcd3a..4c08ca86bb86 100644
--- a/drivers/gpu/drm/selftests/test-drm_mm.c
+++ b/drivers/gpu/drm/selftests/test-drm_mm.c
@@ -1033,6 +1033,65 @@ static int igt_insert_range(void *ignored)
 	return 0;
 }
 
+static int igt_frag(void *ignored)
+{
+	const struct insert_mode *mode;
+	struct drm_mm mm;
+	struct drm_mm_node *nodes, *node, *next;
+	unsigned int size = 4096, align = 8192;
+	unsigned long start, timeout = 1000;
+	const unsigned int max_count = 10000;
+	unsigned int i;
+	int ret = -EINVAL;
+
+	/* For each of the possible insertion modes, we pass an size, alignment
+	 * value that is known to introduce fragmentation and check that it
+	 * doesn't take more than 1 sec.
+	 */
+
+	nodes = vzalloc(array_size(max_count, sizeof(*nodes)));
+	if (!nodes)
+		goto err;
+
+	drm_mm_init(&mm, 1, U64_MAX - 2);
+
+	for (mode = insert_modes; mode->name; mode++) {
+		start = jiffies;
+
+		for (i = 0; i < max_count; i++) {
+			if (jiffies_to_msecs(jiffies - start) >= timeout) {
+				pr_err("%s fragmented insert took more than %lu msecs\n",
+				       mode->name, timeout);
+				goto out;
+			}
+
+			if (!expect_insert(&mm, &nodes[i],
+					   size, align, i, mode)) {
+				pr_err("%s insert failed with alignment=%d",
+				       mode->name, align);
+				goto out;
+			}
+		}
+
+		pr_info("%s fragmented insert took %d msecs\n",
+			mode->name, jiffies_to_msecs(jiffies - start));
+		drm_mm_for_each_node_safe(node, next, &mm)
+			drm_mm_remove_node(node);
+		DRM_MM_BUG_ON(!drm_mm_clean(&mm));
+
+		cond_resched();
+	}
+
+	ret = 0;
+out:
+	drm_mm_for_each_node_safe(node, next, &mm)
+		drm_mm_remove_node(node);
+	drm_mm_takedown(&mm);
+	vfree(nodes);
+err:
+	return ret;
+}
+
 static int igt_align(void *ignored)
 {
 	const struct insert_mode *mode;
-- 
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