All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] lib/rbtree,drm/mm: Add rbtree_replace_node_cached()
@ 2017-11-09 21:24 Chris Wilson
  2017-11-09 21:24 ` [PATCH 2/2] drm/selftests/mm: Add callsite indicator to common asserts Chris Wilson
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: Chris Wilson @ 2017-11-09 21:24 UTC (permalink / raw)
  To: dri-devel
  Cc: Davidlohr Bueso, Daniel Vetter, intel-gfx, Joonas Lahtinen,
	Jérôme Glisse, Andrew Morton

Add a variant of rbtree_replace_node() that maintains the leftmost
cached of struct rbtree_root_cached when replacing nodes within the
rbtree.

As drm_mm is the only rb_replace_node() being used on an interval tree,
the mistake looks fairly self-contained. Furthermore the only user of
drm_mm_replace_node() is its testsuite...

Fixes: f808c13fd373 ("lib/interval_tree: fast overlap detection")
Testcase: igt/drm_mm/replace
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Davidlohr Bueso <dbueso@suse.de>
Cc: Jérôme Glisse <jglisse@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_mm.c |  8 +++++---
 include/linux/rbtree.h   |  2 ++
 lib/rbtree.c             | 10 ++++++++++
 3 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c
index eb86bc3f753b..186c4e90cc1c 100644
--- a/drivers/gpu/drm/drm_mm.c
+++ b/drivers/gpu/drm/drm_mm.c
@@ -575,21 +575,23 @@ EXPORT_SYMBOL(drm_mm_remove_node);
  */
 void drm_mm_replace_node(struct drm_mm_node *old, struct drm_mm_node *new)
 {
+	struct drm_mm *mm = old->mm;
+
 	DRM_MM_BUG_ON(!old->allocated);
 
 	*new = *old;
 
 	list_replace(&old->node_list, &new->node_list);
-	rb_replace_node(&old->rb, &new->rb, &old->mm->interval_tree.rb_root);
+	rb_replace_node_cached(&old->rb, &new->rb, &mm->interval_tree);
 
 	if (drm_mm_hole_follows(old)) {
 		list_replace(&old->hole_stack, &new->hole_stack);
 		rb_replace_node(&old->rb_hole_size,
 				&new->rb_hole_size,
-				&old->mm->holes_size);
+				&mm->holes_size);
 		rb_replace_node(&old->rb_hole_addr,
 				&new->rb_hole_addr,
-				&old->mm->holes_addr);
+				&mm->holes_addr);
 	}
 
 	old->allocated = false;
diff --git a/include/linux/rbtree.h b/include/linux/rbtree.h
index d574361943ea..fcbeed4053ef 100644
--- a/include/linux/rbtree.h
+++ b/include/linux/rbtree.h
@@ -99,6 +99,8 @@ extern void rb_replace_node(struct rb_node *victim, struct rb_node *new,
 			    struct rb_root *root);
 extern void rb_replace_node_rcu(struct rb_node *victim, struct rb_node *new,
 				struct rb_root *root);
+extern void rb_replace_node_cached(struct rb_node *victim, struct rb_node *new,
+				   struct rb_root_cached *root);
 
 static inline void rb_link_node(struct rb_node *node, struct rb_node *parent,
 				struct rb_node **rb_link)
diff --git a/lib/rbtree.c b/lib/rbtree.c
index ba4a9d165f1b..d3ff682fd4b8 100644
--- a/lib/rbtree.c
+++ b/lib/rbtree.c
@@ -603,6 +603,16 @@ void rb_replace_node(struct rb_node *victim, struct rb_node *new,
 }
 EXPORT_SYMBOL(rb_replace_node);
 
+void rb_replace_node_cached(struct rb_node *victim, struct rb_node *new,
+			    struct rb_root_cached *root)
+{
+	rb_replace_node(victim, new, &root->rb_root);
+
+	if (root->rb_leftmost == victim)
+		root->rb_leftmost = new;
+}
+EXPORT_SYMBOL(rb_replace_node_cached);
+
 void rb_replace_node_rcu(struct rb_node *victim, struct rb_node *new,
 			 struct rb_root *root)
 {
-- 
2.15.0

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH 2/2] drm/selftests/mm: Add callsite indicator to common asserts
  2017-11-09 21:24 [PATCH 1/2] lib/rbtree,drm/mm: Add rbtree_replace_node_cached() Chris Wilson
@ 2017-11-09 21:24 ` Chris Wilson
  2017-11-21  8:07   ` Joonas Lahtinen
  2017-11-09 21:46 ` ✗ Fi.CI.BAT: warning for series starting with [1/2] lib/rbtree, drm/mm: Add rbtree_replace_node_cached() Patchwork
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 10+ messages in thread
From: Chris Wilson @ 2017-11-09 21:24 UTC (permalink / raw)
  To: dri-devel; +Cc: Daniel Vetter, intel-gfx

The majority of the asserts (validating nodes and ranges) are shared
amongst several subtests. This makes identification of which caller
failed hard; but we uniquely identify them if we include the callsite
into the assertion error message (a single frame stacktrace).

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/selftests/test-drm_mm.c | 46 +++++++++++++++++++++++----------
 1 file changed, 32 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/selftests/test-drm_mm.c b/drivers/gpu/drm/selftests/test-drm_mm.c
index 7cc935d7b7aa..5f1477329bee 100644
--- a/drivers/gpu/drm/selftests/test-drm_mm.c
+++ b/drivers/gpu/drm/selftests/test-drm_mm.c
@@ -59,13 +59,16 @@ static bool assert_no_holes(const struct drm_mm *mm)
 	drm_mm_for_each_hole(hole, mm, hole_start, hole_end)
 		count++;
 	if (count) {
-		pr_err("Expected to find no holes (after reserve), found %lu instead\n", count);
+		pr_err("%pS: Expected to find no holes (after reserve), found %lu instead\n",
+		       __builtin_return_address(0),
+		       count);
 		return false;
 	}
 
 	drm_mm_for_each_node(hole, mm) {
 		if (drm_mm_hole_follows(hole)) {
-			pr_err("Hole follows node, expected none!\n");
+			pr_err("%pS: Hole follows node, expected none!\n",
+			       __builtin_return_address(0));
 			return false;
 		}
 	}
@@ -87,7 +90,8 @@ static bool assert_one_hole(const struct drm_mm *mm, u64 start, u64 end)
 	drm_mm_for_each_hole(hole, mm, hole_start, hole_end) {
 		if (start != hole_start || end != hole_end) {
 			if (ok)
-				pr_err("empty mm has incorrect hole, found (%llx, %llx), expect (%llx, %llx)\n",
+				pr_err("%pS: empty mm has incorrect hole, found (%llx, %llx), expect (%llx, %llx)\n",
+				       __builtin_return_address(0),
 				       hole_start, hole_end,
 				       start, end);
 			ok = false;
@@ -95,7 +99,9 @@ static bool assert_one_hole(const struct drm_mm *mm, u64 start, u64 end)
 		count++;
 	}
 	if (count != 1) {
-		pr_err("Expected to find one hole, found %lu instead\n", count);
+		pr_err("%pS: Expected to find one hole, found %lu instead\n",
+		       __builtin_return_address(0),
+		       count);
 		ok = false;
 	}
 
@@ -108,40 +114,48 @@ static bool assert_continuous(const struct drm_mm *mm, u64 size)
 	unsigned long n;
 	u64 addr;
 
-	if (!assert_no_holes(mm))
+	if (!assert_no_holes(mm)) {
+		pr_err("%pS: expected no holes!\n",
+		       __builtin_return_address(0));
 		return false;
+	}
 
 	n = 0;
 	addr = 0;
 	drm_mm_for_each_node(node, mm) {
 		if (node->start != addr) {
-			pr_err("node[%ld] list out of order, expected %llx found %llx\n",
+			pr_err("%pS: node[%ld] list out of order, expected %llx found %llx\n",
+			       __builtin_return_address(0),
 			       n, addr, node->start);
 			return false;
 		}
 
 		if (node->size != size) {
-			pr_err("node[%ld].size incorrect, expected %llx, found %llx\n",
+			pr_err("%pS: node[%ld].size incorrect, expected %llx, found %llx\n",
+			       __builtin_return_address(0),
 			       n, size, node->size);
 			return false;
 		}
 
 		if (drm_mm_hole_follows(node)) {
-			pr_err("node[%ld] is followed by a hole!\n", n);
+			pr_err("%pS: node[%ld] is followed by a hole!\n",
+			       __builtin_return_address(0), n);
 			return false;
 		}
 
 		found = NULL;
 		drm_mm_for_each_node_in_range(check, mm, addr, addr + size) {
 			if (node != check) {
-				pr_err("lookup return wrong node, expected start %llx, found %llx\n",
+				pr_err("%pS: lookup return wrong node, expected start %llx, found %llx\n",
+				       __builtin_return_address(0),
 				       node->start, check->start);
 				return false;
 			}
 			found = check;
 		}
 		if (!found) {
-			pr_err("lookup failed for node %llx + %llx\n",
+			pr_err("%pS: lookup failed for node %llx + %llx\n",
+			       __builtin_return_address(0),
 			       addr, size);
 			return false;
 		}
@@ -170,24 +184,28 @@ static bool assert_node(struct drm_mm_node *node, struct drm_mm *mm,
 	bool ok = true;
 
 	if (!drm_mm_node_allocated(node) || node->mm != mm) {
-		pr_err("node not allocated\n");
+		pr_err("%pS: node not allocated\n",
+		       __builtin_return_address(0));
 		ok = false;
 	}
 
 	if (node->size != size) {
-		pr_err("node has wrong size, found %llu, expected %llu\n",
+		pr_err("%pS: node has wrong size, found %llu, expected %llu\n",
+		       __builtin_return_address(0),
 		       node->size, size);
 		ok = false;
 	}
 
 	if (misalignment(node, alignment)) {
-		pr_err("node is misaligned, start %llx rem %llu, expected alignment %llu\n",
+		pr_err("%pS: node is misaligned, start %llx rem %llu, expected alignment %llu\n",
+		       __builtin_return_address(0),
 		       node->start, misalignment(node, alignment), alignment);
 		ok = false;
 	}
 
 	if (node->color != color) {
-		pr_err("node has wrong color, found %lu, expected %lu\n",
+		pr_err("%pS: node has wrong color, found %lu, expected %lu\n",
+		       __builtin_return_address(0),
 		       node->color, color);
 		ok = false;
 	}
-- 
2.15.0

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* ✗ Fi.CI.BAT: warning for series starting with [1/2] lib/rbtree, drm/mm: Add rbtree_replace_node_cached()
  2017-11-09 21:24 [PATCH 1/2] lib/rbtree,drm/mm: Add rbtree_replace_node_cached() Chris Wilson
  2017-11-09 21:24 ` [PATCH 2/2] drm/selftests/mm: Add callsite indicator to common asserts Chris Wilson
@ 2017-11-09 21:46 ` Patchwork
  2017-11-10 14:26 ` [PATCH 1/2] " Davidlohr Bueso
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Patchwork @ 2017-11-09 21:46 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: series starting with [1/2] lib/rbtree, drm/mm: Add rbtree_replace_node_cached()
URL   : https://patchwork.freedesktop.org/series/33554/
State : warning

== Summary ==

Series 33554v1 series starting with [1/2] lib/rbtree, drm/mm: Add rbtree_replace_node_cached()
https://patchwork.freedesktop.org/api/1.0/series/33554/revisions/1/mbox/

Test chamelium:
        Subgroup dp-crc-fast:
                fail       -> PASS       (fi-kbl-7500u) fdo#102514
Test kms_force_connector_basic:
        Subgroup prune-stale-modes:
                pass       -> SKIP       (fi-snb-2600)
Test kms_frontbuffer_tracking:
        Subgroup basic:
                pass       -> DMESG-WARN (fi-bdw-5557u) fdo#102473
Test kms_pipe_crc_basic:
        Subgroup read-crc-pipe-a-frame-sequence:
                skip       -> PASS       (fi-hsw-4770r)

fdo#102514 https://bugs.freedesktop.org/show_bug.cgi?id=102514
fdo#102473 https://bugs.freedesktop.org/show_bug.cgi?id=102473

fi-bdw-5557u     total:289  pass:267  dwarn:1   dfail:0   fail:0   skip:21  time:445s
fi-bdw-gvtdvm    total:289  pass:265  dwarn:0   dfail:0   fail:0   skip:24  time:455s
fi-blb-e6850     total:289  pass:223  dwarn:1   dfail:0   fail:0   skip:65  time:379s
fi-bsw-n3050     total:289  pass:243  dwarn:0   dfail:0   fail:0   skip:46  time:535s
fi-bwr-2160      total:289  pass:183  dwarn:0   dfail:0   fail:0   skip:106 time:274s
fi-bxt-dsi       total:289  pass:259  dwarn:0   dfail:0   fail:0   skip:30  time:501s
fi-bxt-j4205     total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:507s
fi-byt-j1900     total:289  pass:254  dwarn:0   dfail:0   fail:0   skip:35  time:499s
fi-byt-n2820     total:289  pass:250  dwarn:0   dfail:0   fail:0   skip:39  time:487s
fi-elk-e7500     total:289  pass:229  dwarn:0   dfail:0   fail:0   skip:60  time:420s
fi-gdg-551       total:289  pass:178  dwarn:1   dfail:0   fail:1   skip:109 time:263s
fi-glk-1         total:289  pass:261  dwarn:0   dfail:0   fail:0   skip:28  time:544s
fi-hsw-4770      total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:433s
fi-hsw-4770r     total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:437s
fi-ilk-650       total:289  pass:228  dwarn:0   dfail:0   fail:0   skip:61  time:425s
fi-ivb-3520m     total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:473s
fi-ivb-3770      total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:459s
fi-kbl-7500u     total:289  pass:264  dwarn:1   dfail:0   fail:0   skip:24  time:480s
fi-kbl-7560u     total:289  pass:270  dwarn:0   dfail:0   fail:0   skip:19  time:523s
fi-kbl-7567u     total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:476s
fi-kbl-r         total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:537s
fi-pnv-d510      total:289  pass:222  dwarn:1   dfail:0   fail:0   skip:66  time:572s
fi-skl-6260u     total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:453s
fi-skl-6600u     total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:542s
fi-skl-6700hq    total:289  pass:263  dwarn:0   dfail:0   fail:0   skip:26  time:560s
fi-skl-6700k     total:289  pass:265  dwarn:0   dfail:0   fail:0   skip:24  time:525s
fi-skl-6770hq    total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:492s
fi-skl-gvtdvm    total:289  pass:266  dwarn:0   dfail:0   fail:0   skip:23  time:462s
fi-snb-2520m     total:289  pass:250  dwarn:0   dfail:0   fail:0   skip:39  time:561s
fi-snb-2600      total:289  pass:248  dwarn:0   dfail:0   fail:0   skip:41  time:415s
Blacklisted hosts:
fi-cfl-s         total:289  pass:254  dwarn:3   dfail:0   fail:0   skip:32  time:533s
fi-cnl-y         total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:548s
fi-glk-dsi       total:289  pass:259  dwarn:0   dfail:0   fail:0   skip:30  time:488s

bd1f3f04014b597b479785e6125d8bde41939c8c drm-tip: 2017y-11m-09d-18h-20m-22s UTC integration manifest
80ab3331fc87 drm/selftests/mm: Add callsite indicator to common asserts
caa59fe88557 lib/rbtree, drm/mm: Add rbtree_replace_node_cached()

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_7044/
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] lib/rbtree, drm/mm: Add rbtree_replace_node_cached()
  2017-11-09 21:24 [PATCH 1/2] lib/rbtree,drm/mm: Add rbtree_replace_node_cached() Chris Wilson
  2017-11-09 21:24 ` [PATCH 2/2] drm/selftests/mm: Add callsite indicator to common asserts Chris Wilson
  2017-11-09 21:46 ` ✗ Fi.CI.BAT: warning for series starting with [1/2] lib/rbtree, drm/mm: Add rbtree_replace_node_cached() Patchwork
@ 2017-11-10 14:26 ` Davidlohr Bueso
  2017-11-21  8:49   ` [PATCH 1/2] lib/rbtree,drm/mm: " Joonas Lahtinen
  2017-11-22 10:07   ` Chris Wilson
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 10+ messages in thread
From: Davidlohr Bueso @ 2017-11-10 14:26 UTC (permalink / raw)
  To: Chris Wilson
  Cc: Daniel Vetter, intel-gfx, dri-devel, Jérôme Glisse,
	Andrew Morton

On 2017-11-09 13:24, Chris Wilson wrote:
> Add a variant of rbtree_replace_node() that maintains the leftmost
> cached of struct rbtree_root_cached when replacing nodes within the
> rbtree.
> 
> As drm_mm is the only rb_replace_node() being used on an interval tree,
> the mistake looks fairly self-contained. Furthermore the only user of
> drm_mm_replace_node() is its testsuite...
> 
> Fixes: f808c13fd373 ("lib/interval_tree: fast overlap detection")
> Testcase: igt/drm_mm/replace
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Davidlohr Bueso <dbueso@suse.de>
> Cc: Jérôme Glisse <jglisse@redhat.com>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>

Thanks!

Acked-by: Davidlohr Bueso <dbueso@suse.de>
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 2/2] drm/selftests/mm: Add callsite indicator to common asserts
  2017-11-09 21:24 ` [PATCH 2/2] drm/selftests/mm: Add callsite indicator to common asserts Chris Wilson
@ 2017-11-21  8:07   ` Joonas Lahtinen
  0 siblings, 0 replies; 10+ messages in thread
From: Joonas Lahtinen @ 2017-11-21  8:07 UTC (permalink / raw)
  To: Chris Wilson, dri-devel; +Cc: Daniel Vetter, intel-gfx

On Thu, 2017-11-09 at 21:24 +0000, Chris Wilson wrote:
> The majority of the asserts (validating nodes and ranges) are shared
> amongst several subtests. This makes identification of which caller
> failed hard; but we uniquely identify them if we include the callsite
> into the assertion error message (a single frame stacktrace).
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>

Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>

Regards, Joonas
-- 
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH 1/2] lib/rbtree,drm/mm: Add rbtree_replace_node_cached()
  2017-11-10 14:26 ` [PATCH 1/2] " Davidlohr Bueso
@ 2017-11-21  8:49   ` Joonas Lahtinen
  0 siblings, 0 replies; 10+ messages in thread
From: Joonas Lahtinen @ 2017-11-21  8:49 UTC (permalink / raw)
  To: Davidlohr Bueso, Chris Wilson
  Cc: Andrew Morton, Daniel Vetter, intel-gfx, Jérôme Glisse,
	dri-devel

On Fri, 2017-11-10 at 06:26 -0800, Davidlohr Bueso wrote:
> On 2017-11-09 13:24, Chris Wilson wrote:
> > Add a variant of rbtree_replace_node() that maintains the leftmost
> > cached of struct rbtree_root_cached when replacing nodes within the
> > rbtree.
> > 
> > As drm_mm is the only rb_replace_node() being used on an interval tree,
> > the mistake looks fairly self-contained. Furthermore the only user of
> > drm_mm_replace_node() is its testsuite...
> > 
> > Fixes: f808c13fd373 ("lib/interval_tree: fast overlap detection")
> > Testcase: igt/drm_mm/replace
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > Cc: Davidlohr Bueso <dbueso@suse.de>
> > Cc: Jérôme Glisse <jglisse@redhat.com>
> > Cc: Andrew Morton <akpm@linux-foundation.org>
> > Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> 
> Thanks!
> 
> Acked-by: Davidlohr Bueso <dbueso@suse.de>

Would you like us to merge this patch through the DRM tree or how would
you like us to proceed?

Regards, Joonas
-- 
Joonas Lahtinen
Open Source Technology Center
Intel Corporation
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH] lib/rbtree,drm/mm: Add rbtree_replace_node_cached()
  2017-11-09 21:24 [PATCH 1/2] lib/rbtree,drm/mm: Add rbtree_replace_node_cached() Chris Wilson
@ 2017-11-22 10:07   ` Chris Wilson
  2017-11-09 21:46 ` ✗ Fi.CI.BAT: warning for series starting with [1/2] lib/rbtree, drm/mm: Add rbtree_replace_node_cached() Patchwork
                     ` (4 subsequent siblings)
  5 siblings, 0 replies; 10+ messages in thread
From: Chris Wilson @ 2017-11-22 10:07 UTC (permalink / raw)
  To: akpm
  Cc: linux-kernel, dri-devel, intel-gfx, Chris Wilson,
	Davidlohr Bueso, Jérôme Glisse, Joonas Lahtinen,
	Daniel Vetter

Add a variant of rbtree_replace_node() that maintains the leftmost
cache of struct rbtree_root_cached when replacing nodes within the
rbtree.

As drm_mm is the only rb_replace_node() being used on an interval tree,
the mistake looks fairly self-contained. Furthermore the only user of
drm_mm_replace_node() is its testsuite...

Fixes: f808c13fd373 ("lib/interval_tree: fast overlap detection")
Testcase: igt/drm_mm/replace
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Davidlohr Bueso <dbueso@suse.de>
Cc: Jérôme Glisse <jglisse@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20171109212435.9265-1-chris@chris-wilson.co.uk
Acked-by: Davidlohr Bueso <dbueso@suse.de>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
---
 drivers/gpu/drm/drm_mm.c |  8 +++++---
 include/linux/rbtree.h   |  2 ++
 lib/rbtree.c             | 10 ++++++++++
 3 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c
index 61a1c8ea74bc..c3c79ee6119e 100644
--- a/drivers/gpu/drm/drm_mm.c
+++ b/drivers/gpu/drm/drm_mm.c
@@ -575,21 +575,23 @@ EXPORT_SYMBOL(drm_mm_remove_node);
  */
 void drm_mm_replace_node(struct drm_mm_node *old, struct drm_mm_node *new)
 {
+	struct drm_mm *mm = old->mm;
+
 	DRM_MM_BUG_ON(!old->allocated);
 
 	*new = *old;
 
 	list_replace(&old->node_list, &new->node_list);
-	rb_replace_node(&old->rb, &new->rb, &old->mm->interval_tree.rb_root);
+	rb_replace_node_cached(&old->rb, &new->rb, &mm->interval_tree);
 
 	if (drm_mm_hole_follows(old)) {
 		list_replace(&old->hole_stack, &new->hole_stack);
 		rb_replace_node(&old->rb_hole_size,
 				&new->rb_hole_size,
-				&old->mm->holes_size);
+				&mm->holes_size);
 		rb_replace_node(&old->rb_hole_addr,
 				&new->rb_hole_addr,
-				&old->mm->holes_addr);
+				&mm->holes_addr);
 	}
 
 	old->allocated = false;
diff --git a/include/linux/rbtree.h b/include/linux/rbtree.h
index d574361943ea..fcbeed4053ef 100644
--- a/include/linux/rbtree.h
+++ b/include/linux/rbtree.h
@@ -99,6 +99,8 @@ extern void rb_replace_node(struct rb_node *victim, struct rb_node *new,
 			    struct rb_root *root);
 extern void rb_replace_node_rcu(struct rb_node *victim, struct rb_node *new,
 				struct rb_root *root);
+extern void rb_replace_node_cached(struct rb_node *victim, struct rb_node *new,
+				   struct rb_root_cached *root);
 
 static inline void rb_link_node(struct rb_node *node, struct rb_node *parent,
 				struct rb_node **rb_link)
diff --git a/lib/rbtree.c b/lib/rbtree.c
index ba4a9d165f1b..d3ff682fd4b8 100644
--- a/lib/rbtree.c
+++ b/lib/rbtree.c
@@ -603,6 +603,16 @@ void rb_replace_node(struct rb_node *victim, struct rb_node *new,
 }
 EXPORT_SYMBOL(rb_replace_node);
 
+void rb_replace_node_cached(struct rb_node *victim, struct rb_node *new,
+			    struct rb_root_cached *root)
+{
+	rb_replace_node(victim, new, &root->rb_root);
+
+	if (root->rb_leftmost == victim)
+		root->rb_leftmost = new;
+}
+EXPORT_SYMBOL(rb_replace_node_cached);
+
 void rb_replace_node_rcu(struct rb_node *victim, struct rb_node *new,
 			 struct rb_root *root)
 {
-- 
2.15.0

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH] lib/rbtree,drm/mm: Add rbtree_replace_node_cached()
@ 2017-11-22 10:07   ` Chris Wilson
  0 siblings, 0 replies; 10+ messages in thread
From: Chris Wilson @ 2017-11-22 10:07 UTC (permalink / raw)
  To: akpm
  Cc: Davidlohr Bueso, Daniel Vetter, intel-gfx, Joonas Lahtinen,
	linux-kernel, dri-devel, Jérôme Glisse

Add a variant of rbtree_replace_node() that maintains the leftmost
cache of struct rbtree_root_cached when replacing nodes within the
rbtree.

As drm_mm is the only rb_replace_node() being used on an interval tree,
the mistake looks fairly self-contained. Furthermore the only user of
drm_mm_replace_node() is its testsuite...

Fixes: f808c13fd373 ("lib/interval_tree: fast overlap detection")
Testcase: igt/drm_mm/replace
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Davidlohr Bueso <dbueso@suse.de>
Cc: Jérôme Glisse <jglisse@redhat.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/20171109212435.9265-1-chris@chris-wilson.co.uk
Acked-by: Davidlohr Bueso <dbueso@suse.de>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
---
 drivers/gpu/drm/drm_mm.c |  8 +++++---
 include/linux/rbtree.h   |  2 ++
 lib/rbtree.c             | 10 ++++++++++
 3 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c
index 61a1c8ea74bc..c3c79ee6119e 100644
--- a/drivers/gpu/drm/drm_mm.c
+++ b/drivers/gpu/drm/drm_mm.c
@@ -575,21 +575,23 @@ EXPORT_SYMBOL(drm_mm_remove_node);
  */
 void drm_mm_replace_node(struct drm_mm_node *old, struct drm_mm_node *new)
 {
+	struct drm_mm *mm = old->mm;
+
 	DRM_MM_BUG_ON(!old->allocated);
 
 	*new = *old;
 
 	list_replace(&old->node_list, &new->node_list);
-	rb_replace_node(&old->rb, &new->rb, &old->mm->interval_tree.rb_root);
+	rb_replace_node_cached(&old->rb, &new->rb, &mm->interval_tree);
 
 	if (drm_mm_hole_follows(old)) {
 		list_replace(&old->hole_stack, &new->hole_stack);
 		rb_replace_node(&old->rb_hole_size,
 				&new->rb_hole_size,
-				&old->mm->holes_size);
+				&mm->holes_size);
 		rb_replace_node(&old->rb_hole_addr,
 				&new->rb_hole_addr,
-				&old->mm->holes_addr);
+				&mm->holes_addr);
 	}
 
 	old->allocated = false;
diff --git a/include/linux/rbtree.h b/include/linux/rbtree.h
index d574361943ea..fcbeed4053ef 100644
--- a/include/linux/rbtree.h
+++ b/include/linux/rbtree.h
@@ -99,6 +99,8 @@ extern void rb_replace_node(struct rb_node *victim, struct rb_node *new,
 			    struct rb_root *root);
 extern void rb_replace_node_rcu(struct rb_node *victim, struct rb_node *new,
 				struct rb_root *root);
+extern void rb_replace_node_cached(struct rb_node *victim, struct rb_node *new,
+				   struct rb_root_cached *root);
 
 static inline void rb_link_node(struct rb_node *node, struct rb_node *parent,
 				struct rb_node **rb_link)
diff --git a/lib/rbtree.c b/lib/rbtree.c
index ba4a9d165f1b..d3ff682fd4b8 100644
--- a/lib/rbtree.c
+++ b/lib/rbtree.c
@@ -603,6 +603,16 @@ void rb_replace_node(struct rb_node *victim, struct rb_node *new,
 }
 EXPORT_SYMBOL(rb_replace_node);
 
+void rb_replace_node_cached(struct rb_node *victim, struct rb_node *new,
+			    struct rb_root_cached *root)
+{
+	rb_replace_node(victim, new, &root->rb_root);
+
+	if (root->rb_leftmost == victim)
+		root->rb_leftmost = new;
+}
+EXPORT_SYMBOL(rb_replace_node_cached);
+
 void rb_replace_node_rcu(struct rb_node *victim, struct rb_node *new,
 			 struct rb_root *root)
 {
-- 
2.15.0

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* ✓ Fi.CI.BAT: success for series starting with lib/rbtree, drm/mm: Add rbtree_replace_node_cached() (rev2)
  2017-11-09 21:24 [PATCH 1/2] lib/rbtree,drm/mm: Add rbtree_replace_node_cached() Chris Wilson
                   ` (3 preceding siblings ...)
  2017-11-22 10:07   ` Chris Wilson
@ 2017-11-22 10:32 ` Patchwork
  2017-11-22 11:53 ` ✓ Fi.CI.IGT: " Patchwork
  5 siblings, 0 replies; 10+ messages in thread
From: Patchwork @ 2017-11-22 10:32 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: series starting with lib/rbtree, drm/mm: Add rbtree_replace_node_cached() (rev2)
URL   : https://patchwork.freedesktop.org/series/33554/
State : success

== Summary ==

Series 33554v2 series starting with lib/rbtree, drm/mm: Add rbtree_replace_node_cached()
https://patchwork.freedesktop.org/api/1.0/series/33554/revisions/2/mbox/

Test gem_ringfill:
        Subgroup basic-default-hang:
                dmesg-warn -> PASS       (fi-blb-e6850) fdo#101600
Test kms_chamelium:
        Subgroup dp-crc-fast:
                dmesg-fail -> PASS       (fi-kbl-7500u) fdo#103841
Test kms_pipe_crc_basic:
        Subgroup suspend-read-crc-pipe-b:
                pass       -> INCOMPLETE (fi-snb-2520m) fdo#103713

fdo#101600 https://bugs.freedesktop.org/show_bug.cgi?id=101600
fdo#103841 https://bugs.freedesktop.org/show_bug.cgi?id=103841
fdo#103713 https://bugs.freedesktop.org/show_bug.cgi?id=103713

fi-bdw-5557u     total:289  pass:268  dwarn:0   dfail:0   fail:0   skip:21  time:444s
fi-bdw-gvtdvm    total:289  pass:265  dwarn:0   dfail:0   fail:0   skip:24  time:455s
fi-blb-e6850     total:289  pass:224  dwarn:0   dfail:0   fail:0   skip:65  time:382s
fi-bsw-n3050     total:289  pass:243  dwarn:0   dfail:0   fail:0   skip:46  time:533s
fi-bwr-2160      total:289  pass:183  dwarn:0   dfail:0   fail:0   skip:106 time:280s
fi-bxt-dsi       total:289  pass:259  dwarn:0   dfail:0   fail:0   skip:30  time:509s
fi-bxt-j4205     total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:514s
fi-byt-j1900     total:289  pass:254  dwarn:0   dfail:0   fail:0   skip:35  time:507s
fi-byt-n2820     total:289  pass:250  dwarn:0   dfail:0   fail:0   skip:39  time:492s
fi-cfl-s2        total:289  pass:263  dwarn:0   dfail:0   fail:0   skip:26  time:605s
fi-elk-e7500     total:289  pass:229  dwarn:0   dfail:0   fail:0   skip:60  time:435s
fi-gdg-551       total:289  pass:178  dwarn:1   dfail:0   fail:1   skip:109 time:265s
fi-glk-1         total:289  pass:261  dwarn:0   dfail:0   fail:0   skip:28  time:548s
fi-hsw-4770      total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:432s
fi-hsw-4770r     total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:437s
fi-ilk-650       total:289  pass:228  dwarn:0   dfail:0   fail:0   skip:61  time:430s
fi-ivb-3520m     total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:485s
fi-ivb-3770      total:289  pass:260  dwarn:0   dfail:0   fail:0   skip:29  time:463s
fi-kbl-7500u     total:289  pass:264  dwarn:1   dfail:0   fail:0   skip:24  time:480s
fi-kbl-7560u     total:289  pass:270  dwarn:0   dfail:0   fail:0   skip:19  time:530s
fi-kbl-7567u     total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:478s
fi-kbl-r         total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:533s
fi-pnv-d510      total:289  pass:222  dwarn:1   dfail:0   fail:0   skip:66  time:577s
fi-skl-6260u     total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:455s
fi-skl-6600u     total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:546s
fi-skl-6700hq    total:289  pass:263  dwarn:0   dfail:0   fail:0   skip:26  time:565s
fi-skl-6700k     total:289  pass:265  dwarn:0   dfail:0   fail:0   skip:24  time:522s
fi-skl-6770hq    total:289  pass:269  dwarn:0   dfail:0   fail:0   skip:20  time:505s
fi-skl-gvtdvm    total:289  pass:266  dwarn:0   dfail:0   fail:0   skip:23  time:459s
fi-snb-2520m     total:246  pass:212  dwarn:0   dfail:0   fail:0   skip:33 
fi-snb-2600      total:289  pass:249  dwarn:0   dfail:0   fail:0   skip:40  time:427s
Blacklisted hosts:
fi-cnl-y         total:289  pass:262  dwarn:0   dfail:0   fail:0   skip:27  time:546s
fi-glk-dsi       total:289  pass:132  dwarn:0   dfail:10  fail:2   skip:145 time:307s

07a70d6dc2979f5c86dc347cc03d87ceaf42f642 drm-tip: 2017y-11m-21d-21h-46m-40s UTC integration manifest
2aaf8c757a56 drm/selftests/mm: Add callsite indicator to common asserts
9b655f32b54f lib/rbtree, drm/mm: Add rbtree_replace_node_cached()

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_7229/
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 10+ messages in thread

* ✓ Fi.CI.IGT: success for series starting with lib/rbtree, drm/mm: Add rbtree_replace_node_cached() (rev2)
  2017-11-09 21:24 [PATCH 1/2] lib/rbtree,drm/mm: Add rbtree_replace_node_cached() Chris Wilson
                   ` (4 preceding siblings ...)
  2017-11-22 10:32 ` ✓ Fi.CI.BAT: success for series starting with lib/rbtree, drm/mm: Add rbtree_replace_node_cached() (rev2) Patchwork
@ 2017-11-22 11:53 ` Patchwork
  5 siblings, 0 replies; 10+ messages in thread
From: Patchwork @ 2017-11-22 11:53 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: series starting with lib/rbtree, drm/mm: Add rbtree_replace_node_cached() (rev2)
URL   : https://patchwork.freedesktop.org/series/33554/
State : success

== Summary ==

Test perf:
        Subgroup blocking:
                pass       -> FAIL       (shard-hsw) fdo#102252
Test kms_flip:
        Subgroup modeset-vs-vblank-race-interruptible:
                pass       -> FAIL       (shard-hsw) fdo#103060
Test kms_frontbuffer_tracking:
        Subgroup fbc-1p-offscren-pri-shrfb-draw-render:
                pass       -> FAIL       (shard-snb) fdo#101623 +1
Test drv_module_reload:
        Subgroup basic-no-display:
                dmesg-warn -> PASS       (shard-snb) fdo#102707

fdo#102252 https://bugs.freedesktop.org/show_bug.cgi?id=102252
fdo#103060 https://bugs.freedesktop.org/show_bug.cgi?id=103060
fdo#101623 https://bugs.freedesktop.org/show_bug.cgi?id=101623
fdo#102707 https://bugs.freedesktop.org/show_bug.cgi?id=102707

shard-hsw        total:2585 pass:1473 dwarn:1   dfail:0   fail:12  skip:1099 time:9524s
shard-snb        total:2585 pass:1259 dwarn:1   dfail:0   fail:12  skip:1313 time:8087s
Blacklisted hosts:
shard-apl        total:2563 pass:1600 dwarn:2   dfail:0   fail:23  skip:937 time:13334s
shard-kbl        total:2114 pass:1396 dwarn:6   dfail:1   fail:15  skip:693 time:8555s

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_7229/shards.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-11-22 11:53 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-11-09 21:24 [PATCH 1/2] lib/rbtree,drm/mm: Add rbtree_replace_node_cached() Chris Wilson
2017-11-09 21:24 ` [PATCH 2/2] drm/selftests/mm: Add callsite indicator to common asserts Chris Wilson
2017-11-21  8:07   ` Joonas Lahtinen
2017-11-09 21:46 ` ✗ Fi.CI.BAT: warning for series starting with [1/2] lib/rbtree, drm/mm: Add rbtree_replace_node_cached() Patchwork
2017-11-10 14:26 ` [PATCH 1/2] " Davidlohr Bueso
2017-11-21  8:49   ` [PATCH 1/2] lib/rbtree,drm/mm: " Joonas Lahtinen
2017-11-22 10:07 ` [PATCH] " Chris Wilson
2017-11-22 10:07   ` Chris Wilson
2017-11-22 10:32 ` ✓ Fi.CI.BAT: success for series starting with lib/rbtree, drm/mm: Add rbtree_replace_node_cached() (rev2) Patchwork
2017-11-22 11:53 ` ✓ Fi.CI.IGT: " Patchwork

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.