All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: dri-devel@lists.freedesktop.org
Cc: intel-gfx@lists.freedesktop.org
Subject: [PATCH v2 17/40] drm: kselftest for drm_mm and range restricted eviction
Date: Fri, 16 Dec 2016 07:46:55 +0000	[thread overview]
Message-ID: <20161216074718.32500-18-chris@chris-wilson.co.uk> (raw)
In-Reply-To: <20161216074718.32500-1-chris@chris-wilson.co.uk>

Check that we add arbitrary blocks to a restrited eviction scanner in
order to find the first minimal hole that matches our request.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
---
 drivers/gpu/drm/selftests/drm_mm_selftests.h |   1 +
 drivers/gpu/drm/selftests/test-drm_mm.c      | 113 ++++++++++++++++++++++++++-
 2 files changed, 110 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/selftests/drm_mm_selftests.h b/drivers/gpu/drm/selftests/drm_mm_selftests.h
index a31b4458c7eb..965aca65c160 100644
--- a/drivers/gpu/drm/selftests/drm_mm_selftests.h
+++ b/drivers/gpu/drm/selftests/drm_mm_selftests.h
@@ -16,3 +16,4 @@ selftest(align, igt_align)
 selftest(align32, igt_align32)
 selftest(align64, igt_align64)
 selftest(evict, igt_evict)
+selftest(evict_range, igt_evict_range)
diff --git a/drivers/gpu/drm/selftests/test-drm_mm.c b/drivers/gpu/drm/selftests/test-drm_mm.c
index 4881752d6424..6c4679304358 100644
--- a/drivers/gpu/drm/selftests/test-drm_mm.c
+++ b/drivers/gpu/drm/selftests/test-drm_mm.c
@@ -1249,6 +1249,7 @@ static bool evict_everything(struct drm_mm *mm,
 }
 
 static int evict_something(struct drm_mm *mm,
+			   u64 range_start, u64 range_end,
 			   struct evict_node *nodes,
 			   unsigned int *order,
 			   unsigned int count,
@@ -1261,7 +1262,9 @@ static int evict_something(struct drm_mm *mm,
 	struct drm_mm_node tmp;
 	int err;
 
-	drm_mm_init_scan(mm, size, alignment, 0);
+	drm_mm_init_scan_with_range(mm,
+				    size, alignment, 0,
+				    range_start, range_end);
 	if (!evict_nodes(mm,
 			 nodes, order, count,
 			 &evict_list))
@@ -1279,6 +1282,12 @@ static int evict_something(struct drm_mm *mm,
 		return err;
 	}
 
+	if (tmp.start < range_start || tmp.start + tmp.size > range_end) {
+		pr_err("Inserted [address=%llu + %llu] did not fit into the request range [%llu, %llu]\n",
+		       tmp.start, tmp.size, range_start, range_end);
+		err = -EINVAL;
+	}
+
 	if (!assert_node(&tmp, mm, size, alignment, 0) || tmp.hole_follows) {
 		pr_err("Inserted did not fill the eviction hole: size=%lld [%d], align=%d [rem=%lld], start=%llx, hole-follows?=%d\n",
 		       tmp.size, size,
@@ -1360,7 +1369,7 @@ static int igt_evict(void *ignored)
 	for (mode = evict_modes; mode->name; mode++) {
 		for (n = 1; n <= size; n <<= 1) {
 			drm_random_reorder(order, size, &prng);
-			err = evict_something(&mm,
+			err = evict_something(&mm, 0, U64_MAX,
 					      nodes, order, size,
 					      n, 1,
 					      mode);
@@ -1374,7 +1383,7 @@ static int igt_evict(void *ignored)
 
 		for (n = 1; n < size; n <<= 1) {
 			drm_random_reorder(order, size, &prng);
-			err = evict_something(&mm,
+			err = evict_something(&mm, 0, U64_MAX,
 					      nodes, order, size,
 					      size/2, n,
 					      mode);
@@ -1392,7 +1401,7 @@ static int igt_evict(void *ignored)
 			DRM_MM_BUG_ON(!nsize);
 
 			drm_random_reorder(order, size, &prng);
-			err = evict_something(&mm,
+			err = evict_something(&mm, 0, U64_MAX,
 					      nodes, order, size,
 					      nsize, n,
 					      mode);
@@ -1417,6 +1426,102 @@ static int igt_evict(void *ignored)
 	return ret;
 }
 
+static int igt_evict_range(void *ignored)
+{
+	RND_STATE(prng, random_seed);
+	const unsigned int size = 8192;
+	const unsigned int range_size = size / 2;
+	const unsigned int range_start = size / 4;
+	const unsigned int range_end = range_start + range_size;
+	const struct insert_mode *mode;
+	struct drm_mm mm;
+	struct evict_node *nodes;
+	struct drm_mm_node *node, *next;
+	unsigned int *order, n;
+	int ret, err;
+
+	/* Like igt_evict() but now we are limiting the search to a
+	 * small portion of the full drm_mm.
+	 */
+
+	ret = -ENOMEM;
+	nodes = vzalloc(size * sizeof(*nodes));
+	if (!nodes)
+		goto err;
+
+	order = drm_random_order(size, &prng);
+	if (!order)
+		goto err_nodes;
+
+	ret = -EINVAL;
+	drm_mm_init(&mm, 0, size);
+	for (n = 0; n < size; n++) {
+		err = drm_mm_insert_node(&mm, &nodes[n].node, 1, 0,
+					 DRM_MM_SEARCH_DEFAULT);
+		if (err) {
+			pr_err("insert failed, step %d\n", n);
+			ret = err;
+			goto out;
+		}
+	}
+
+	for (mode = evict_modes; mode->name; mode++) {
+		for (n = 1; n <= range_size; n <<= 1) {
+			drm_random_reorder(order, size, &prng);
+			err = evict_something(&mm, range_start, range_end,
+					      nodes, order, size,
+					      n, 1,
+					      mode);
+			if (err) {
+				pr_err("%s evict_something(size=%u) failed with range [%u, %u]\n",
+				       mode->name, n, range_start, range_end);
+				goto out;
+			}
+		}
+
+		for (n = 1; n <= range_size; n <<= 1) {
+			drm_random_reorder(order, size, &prng);
+			err = evict_something(&mm, range_start, range_end,
+					      nodes, order, size,
+					      range_size/2, n,
+					      mode);
+			if (err) {
+				pr_err("%s evict_something(size=%u, alignment=%u) failed with range [%u, %u]\n",
+				       mode->name, range_size/2, n, range_start, range_end);
+				goto out;
+			}
+		}
+
+		drm_for_each_prime(n, min(range_size, max_prime)) {
+			unsigned int nsize = (range_size - n + 1) / 2;
+
+			DRM_MM_BUG_ON(!nsize);
+
+			drm_random_reorder(order, size, &prng);
+			err = evict_something(&mm, range_start, range_end,
+					      nodes, order, size,
+					      nsize, n,
+					      mode);
+			if (err) {
+				pr_err("%s evict_something(size=%u, alignment=%u) failed with range [%u, %u]\n",
+				       mode->name, nsize/2, n, range_start, range_end);
+				goto out;
+			}
+		}
+	}
+
+	ret = 0;
+out:
+	drm_mm_for_each_node_safe(node, next, &mm)
+		drm_mm_remove_node(node);
+	drm_mm_takedown(&mm);
+	kfree(order);
+err_nodes:
+	vfree(nodes);
+err:
+	return ret;
+}
+
 #include "drm_selftest.c"
 
 static int __init test_drm_mm_init(void)
-- 
2.11.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2016-12-16  7:46 UTC|newest]

Thread overview: 79+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-16  7:46 drm_mm range manager fixes, take 2 Chris Wilson
2016-12-16  7:46 ` [PATCH v2 01/40] drm/i915: Use the MRU stack search after evicting Chris Wilson
2016-12-16  9:03   ` Joonas Lahtinen
2016-12-16  7:46 ` [PATCH v2 02/40] drm/i915: Simplify i915_gtt_color_adjust() Chris Wilson
2016-12-16  7:46 ` [PATCH v2 03/40] drm: Add drm_mm_for_each_node_safe() Chris Wilson
2016-12-16  9:06   ` Joonas Lahtinen
2016-12-16 13:32     ` Daniel Vetter
2016-12-16  7:46 ` [PATCH v2 04/40] drm: Constify the drm_mm API Chris Wilson
2016-12-16 13:45   ` Daniel Vetter
2016-12-16  7:46 ` [PATCH v2 05/40] drm: Compile time enabling for asserts in drm_mm Chris Wilson
2016-12-16  7:46 ` [PATCH v2 06/40] drm: Add some kselftests for the DRM range manager (struct drm_mm) Chris Wilson
2016-12-16  7:46 ` [PATCH v2 07/40] drm: Add a simple generator of random permutations Chris Wilson
2016-12-16  9:38   ` Joonas Lahtinen
2016-12-16  7:46 ` [PATCH v2 08/40] drm: Add a simple prime number generator Chris Wilson
2016-12-16  9:31   ` Lukas Wunner
2016-12-16  9:43     ` Chris Wilson
2016-12-16 10:08       ` Lukas Wunner
2016-12-16 10:25         ` Chris Wilson
2016-12-16 13:23   ` [PATCH] lib: " Chris Wilson
2016-12-16 13:53     ` Chris Wilson
2016-12-16 14:02     ` [PATCH v3] " Chris Wilson
2016-12-16 18:47       ` kbuild test robot
2016-12-16  7:46 ` [PATCH v2 09/40] drm: kselftest for drm_mm_init() Chris Wilson
2016-12-16  9:41   ` Joonas Lahtinen
2016-12-16  7:46 ` [PATCH v2 10/40] drm: kselftest for drm_mm_debug() Chris Wilson
2016-12-16  9:44   ` Joonas Lahtinen
2016-12-16 10:01     ` Chris Wilson
2016-12-16  7:46 ` [PATCH v2 11/40] drm: kselftest for drm_mm_reserve_node() Chris Wilson
2016-12-16  7:46 ` [PATCH v2 12/40] drm: kselftest for drm_mm_insert_node() Chris Wilson
2016-12-16 14:02   ` Joonas Lahtinen
2016-12-16 14:59     ` Chris Wilson
2016-12-16  7:46 ` [PATCH v2 13/40] drm: kselftest for drm_mm_replace_node() Chris Wilson
2016-12-16  7:46 ` [PATCH v2 14/40] drm: kselftest for drm_mm_insert_node_in_range() Chris Wilson
2016-12-16 14:08   ` Joonas Lahtinen
2016-12-16  7:46 ` [PATCH v2 15/40] drm: kselftest for drm_mm and alignment Chris Wilson
2016-12-16  7:46 ` [PATCH v2 16/40] drm: kselftest for drm_mm and eviction Chris Wilson
2016-12-16  7:46 ` Chris Wilson [this message]
2016-12-16  7:46 ` [PATCH v2 18/40] drm: kselftest for drm_mm and top-down allocation Chris Wilson
2016-12-16  7:46 ` [PATCH v2 19/40] drm: kselftest for drm_mm and color adjustment Chris Wilson
2016-12-16  7:46 ` [PATCH v2 20/40] drm: kselftest for drm_mm and color eviction Chris Wilson
2016-12-16 14:38   ` Joonas Lahtinen
2016-12-16 14:48     ` Chris Wilson
2016-12-16  7:46 ` [PATCH v2 21/40] drm: kselftest for drm_mm and restricted " Chris Wilson
2016-12-16 14:41   ` Joonas Lahtinen
2016-12-16  7:47 ` [PATCH v2 22/40] drm/i915: Build DRM range manager selftests for CI Chris Wilson
2016-12-16  7:47 ` [PATCH v2 23/40] drm: Promote drm_mm alignment to u64 Chris Wilson
2016-12-16  7:47 ` [PATCH v2 24/40] drm: Fix kerneldoc for drm_mm_scan_remove_block() Chris Wilson
2016-12-16 10:09   ` Joonas Lahtinen
2016-12-16  7:47 ` [PATCH v2 25/40] drm: Detect overflow in drm_mm_reserve_node() Chris Wilson
2016-12-16 10:11   ` Joonas Lahtinen
2016-12-16  7:47 ` [PATCH v2 26/40] drm: Simplify drm_mm_clean() Chris Wilson
2016-12-16  7:47 ` [PATCH v2 27/40] drm: Add asserts to catch overflow in drm_mm_init() and drm_mm_init_scan() Chris Wilson
2016-12-16 13:10   ` Joonas Lahtinen
2016-12-16  7:47 ` [PATCH v2 28/40] drm: Extract struct drm_mm_scan from struct drm_mm Chris Wilson
2016-12-16  7:47 ` [PATCH v2 29/40] drm: Rename prev_node to hole in drm_mm_scan_add_block() Chris Wilson
2016-12-16 14:41   ` Joonas Lahtinen
2016-12-16  7:47 ` [PATCH v2 30/40] drm: Unconditionally do the range check " Chris Wilson
2016-12-16  7:47 ` [PATCH v2 31/40] drm: Fix application of color vs range restriction when scanning drm_mm Chris Wilson
2016-12-16  7:47 ` [PATCH v2 32/40] drm: Compute tight evictions for drm_mm_scan Chris Wilson
2016-12-16  7:47 ` [PATCH v2 33/40] drm: Optimise power-of-two alignments in drm_mm_scan_add_block() Chris Wilson
2016-12-16  7:47 ` [PATCH v2 34/40] drm: Simplify drm_mm scan-list manipulation Chris Wilson
2016-12-16 13:06   ` Joonas Lahtinen
2016-12-16  7:47 ` [PATCH v2 35/40] drm: Apply tight eviction scanning to color_adjust Chris Wilson
2016-12-16 14:14   ` Joonas Lahtinen
2016-12-16 14:24     ` Chris Wilson
2016-12-16  7:47 ` [PATCH v2 36/40] drm: Wrap drm_mm_node.hole_follows Chris Wilson
2016-12-16 13:04   ` Joonas Lahtinen
2016-12-16 13:31     ` Chris Wilson
2016-12-16 13:41       ` Joonas Lahtinen
2016-12-16  7:47 ` [PATCH v2 37/40] drm: Apply range restriction after color adjustment when allocation Chris Wilson
2016-12-16 12:57   ` Joonas Lahtinen
2016-12-16  7:47 ` [PATCH v2 38/40] drm: Use drm_mm_insert_node_in_range_generic() for everyone Chris Wilson
2016-12-16 13:01   ` Joonas Lahtinen
2016-12-16  7:47 ` [PATCH v2 39/40] drm: Improve drm_mm search (and fix topdown allocation) with rbtrees Chris Wilson
2016-12-16 13:46   ` Joonas Lahtinen
2016-12-16 13:56     ` Chris Wilson
2016-12-16  7:47 ` [PATCH v2 40/40] drm: kselftest for drm_mm and bottom-up allocation Chris Wilson
2016-12-16  9:15 ` ✓ Fi.CI.BAT: success for series starting with [v2,01/40] drm/i915: Use the MRU stack search after evicting Patchwork
2016-12-16 16:31 ` ✗ Fi.CI.BAT: failure for series starting with [v2,01/40] drm/i915: Use the MRU stack search after evicting (rev3) Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161216074718.32500-18-chris@chris-wilson.co.uk \
    --to=chris@chris-wilson.co.uk \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.