Skip to contentSkip to conversation

drm/i915: Switch obj->mm.lock lockdep annotations on its head

PATCH In review Daniel Vetter 7 participants 19 messages Nov 4, 2019 – Nov 8, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/3 drm/i915: Switch obj->mm.lock lockdep annotations on its head

The trouble with having a plain nesting flag for locks which do not naturally nest (unlike block devices and their partitions, which is the original motivation for nesting levels) is that lockdep will never spot a true deadlock if you screw up.

This patch is an attempt at trying better, by highlighting a bit more the actual nature of the nesting that's going on. Essentially we have two kinds of objects:

- objects without pages allocated, which cannot be on any lru and are hence inaccessible to the shrinker.

- objects which have pages allocated, which are on an lru, and which the shrinker can decide to throw out.

For the former type of object, memory allcoations while holding obj->mm.lock are permissible. For the latter they are not. And get/put_pages transitions between the two types of objects.

This is still not entirely fool-proof since the rules might chance. But as long as we run such a code ever at runtime lockdep should be able to observe the inconsistency and complain (like with any other lockdep class that we've split up in multiple classes). But there are a few clear benefits:

- We can drop the nesting flag parameter from __i915_gem_object_put_pages, because that function by definition is never going allocate memory, and calling it on an object which doesn't have its pages allocated would be a bug.

- We strictly catch more bugs, since there's not only one place in the entire tree which is annotated with the special class. All the other places that had explicit lockdep nesting annotations we're now going to leave up to lockdep again.

- Specifically this catches stuff like calling get_pages from put_pages (which isn't really a good idea, if we can call put_pages so could the shrinker). I've seen patches do exactly that.

Of course I fully expect CI will show me for the fool I am with this one here :-)

v2: There can only be one (lockdep only has a cache for the first subclass, not for deeper ones, and we don't want to make these locks even slower). Still separate enums for better documentation.

Real fix: don forget about phys objs and pin_map(), and fix the shrinker to have the right annotations ... silly me.

v3: Forgot usertptr too ...

v4: Improve comment for pages_pin_count, drop the IMPORTANT comment and instead prime lockdep (Chris).

v5: Appease checkpatch, no double empty lines (Chris)

v6: More rebasing over selftest changes. Also somehow I forgot to push this patch :-/

Also format comments consistently while at it.

Cc Chris Wilson <[email protected]>
Cc "Tang, CQ" <[email protected]>
Cc Tvrtko Ursulin <[email protected]>
Cc Joonas Lahtinen <[email protected]>
---
 drivers/gpu/drm/i915/gem/i915_gem_object.c      | 12 +++++++++++-
 drivers/gpu/drm/i915/gem/i915_gem_object.h      | 17 ++++++++++++++---
 .../gpu/drm/i915/gem/i915_gem_object_types.h    |  6 +++++-
 drivers/gpu/drm/i915/gem/i915_gem_pages.c       |  9 ++++-----
 drivers/gpu/drm/i915/gem/i915_gem_phys.c        |  2 +-
 drivers/gpu/drm/i915/gem/i915_gem_shrinker.c    |  5 ++---
 drivers/gpu/drm/i915/gem/i915_gem_userptr.c     |  4 ++--
 drivers/gpu/drm/i915/gem/selftests/huge_pages.c | 14 +++++++-------
 .../drm/i915/selftests/intel_memory_region.c    |  4 ++--
 9 files changed, 48 insertions(+), 25 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_object.c +11 -1
index a50296cce0d8..078d515d72c0 100644
@@ -22,6 +22,8 @@
  *
  */
 
+#include <linux/sched/mm.h>
+
 #include "display/intel_frontbuffer.h"
 #include "gt/intel_gt.h"
 #include "i915_drv.h"
@@ -52,6 +54,14 @@ void i915_gem_object_init(struct drm_i915_gem_object *obj,
 {
 	__mutex_init(&obj->mm.lock, "obj->mm.lock", key);
 
+	if (IS_ENABLED(CONFIG_LOCKDEP)) {
+		mutex_lock_nested(&obj->mm.lock, I915_MM_GET_PAGES);
+		fs_reclaim_acquire(GFP_KERNEL);
+		might_lock(&obj->mm.lock);
+		fs_reclaim_release(GFP_KERNEL);
+		mutex_unlock(&obj->mm.lock);
+	}
+
 	spin_lock_init(&obj->vma.lock);
 	INIT_LIST_HEAD(&obj->vma.list);
 
@@ -186,7 +196,7 @@ static void __i915_gem_free_objects(struct drm_i915_private *i915,
 		GEM_BUG_ON(!list_empty(&obj->lut_list));
 
 		atomic_set(&obj->mm.pages_pin_count, 0);
-		__i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+		__i915_gem_object_put_pages(obj);
 		GEM_BUG_ON(i915_gem_object_has_pages(obj));
 		bitmap_free(obj->bit_17);
 
drivers/gpu/drm/i915/gem/i915_gem_object.h +14 -3
index 458cd51331f1..edaf7126a84d 100644
@@ -319,11 +319,22 @@ i915_gem_object_unpin_pages(struct drm_i915_gem_object *obj)
 
 enum i915_mm_subclass { /* lockdep subclass for obj->mm.lock/struct_mutex */
 	I915_MM_NORMAL = 0,
-	I915_MM_SHRINKER /* called "recursively" from direct-reclaim-esque */
+	/*
+	 * Only used by struct_mutex, when called "recursively" from
+	 * direct-reclaim-esque. Safe because there is only every one
+	 * struct_mutex in the entire system.
+	 */
+	I915_MM_SHRINKER = 1,
+	/*
+	 * Used for obj->mm.lock when allocating pages. Safe because the object
+	 * isn't yet on any LRU, and therefore the shrinker can't deadlock on
+	 * it. As soon as the object has pages, obj->mm.lock nests within
+	 * fs_reclaim.
+	 */
+	I915_MM_GET_PAGES = 1,
 };
 
-int __i915_gem_object_put_pages(struct drm_i915_gem_object *obj,
-				enum i915_mm_subclass subclass);
+int __i915_gem_object_put_pages(struct drm_i915_gem_object *obj);
 void i915_gem_object_truncate(struct drm_i915_gem_object *obj);
 void i915_gem_object_writeback(struct drm_i915_gem_object *obj);
 
drivers/gpu/drm/i915/gem/i915_gem_object_types.h +5 -1
index 96008374a412..15f8297dc34e 100644
@@ -162,7 +162,11 @@ struct drm_i915_gem_object {
 	atomic_t bind_count;
 
 	struct {
-		struct mutex lock; /* protects the pages and their use */
+		/*
+		 * Protects the pages and their use. Do not use directly, but
+		 * instead go through the pin/unpin interfaces.
+		 */
+		struct mutex lock;
 		atomic_t pages_pin_count;
 		atomic_t shrink_pin;
 
drivers/gpu/drm/i915/gem/i915_gem_pages.c +4 -5
index 29f4c2850745..f402c2c415c2 100644
@@ -106,7 +106,7 @@ int __i915_gem_object_get_pages(struct drm_i915_gem_object *obj)
 {
 	int err;
 
-	err = mutex_lock_interruptible(&obj->mm.lock);
+	err = mutex_lock_interruptible_nested(&obj->mm.lock, I915_MM_GET_PAGES);
 	if (err)
 		return err;
 
@@ -190,8 +190,7 @@ __i915_gem_object_unset_pages(struct drm_i915_gem_object *obj)
 	return pages;
 }
 
-int __i915_gem_object_put_pages(struct drm_i915_gem_object *obj,
-				enum i915_mm_subclass subclass)
+int __i915_gem_object_put_pages(struct drm_i915_gem_object *obj)
 {
 	struct sg_table *pages;
 	int err;
@@ -202,7 +201,7 @@ int __i915_gem_object_put_pages(struct drm_i915_gem_object *obj,
 	GEM_BUG_ON(atomic_read(&obj->bind_count));
 
 	/* May be called by shrinker from within get_pages() (on another bo) */
-	mutex_lock_nested(&obj->mm.lock, subclass);
+	mutex_lock(&obj->mm.lock);
 	if (unlikely(atomic_read(&obj->mm.pages_pin_count))) {
 		err = -EBUSY;
 		goto unlock;
@@ -308,7 +307,7 @@ void *i915_gem_object_pin_map(struct drm_i915_gem_object *obj,
 	if (!i915_gem_object_type_has(obj, flags))
 		return ERR_PTR(-ENXIO);
 
-	err = mutex_lock_interruptible(&obj->mm.lock);
+	err = mutex_lock_interruptible_nested(&obj->mm.lock, I915_MM_GET_PAGES);
 	if (err)
 		return ERR_PTR(err);
 
drivers/gpu/drm/i915/gem/i915_gem_phys.c +1 -1
index 8043ff63d73f..b1b7c1b3038a 100644
@@ -164,7 +164,7 @@ int i915_gem_object_attach_phys(struct drm_i915_gem_object *obj, int align)
 	if (err)
 		return err;
 
-	mutex_lock(&obj->mm.lock);
+	mutex_lock_nested(&obj->mm.lock, I915_MM_GET_PAGES);
 
 	if (obj->mm.madv != I915_MADV_WILLNEED) {
 		err = -EFAULT;
drivers/gpu/drm/i915/gem/i915_gem_shrinker.c +2 -3
index fd3ce6da8497..066b3df677e8 100644
@@ -57,7 +57,7 @@ static bool unsafe_drop_pages(struct drm_i915_gem_object *obj,
 		flags = I915_GEM_OBJECT_UNBIND_ACTIVE;
 
 	if (i915_gem_object_unbind(obj, flags) == 0)
-		__i915_gem_object_put_pages(obj, I915_MM_SHRINKER);
+		__i915_gem_object_put_pages(obj);
 
 	return !i915_gem_object_has_pages(obj);
 }
@@ -209,8 +209,7 @@ i915_gem_shrink(struct drm_i915_private *i915,
 
 			if (unsafe_drop_pages(obj, shrink)) {
 				/* May arrive from get_pages on another bo */
-				mutex_lock_nested(&obj->mm.lock,
-						  I915_MM_SHRINKER);
+				mutex_lock(&obj->mm.lock);
 				if (!i915_gem_object_has_pages(obj)) {
 					try_to_writeback(obj, shrink);
 					count += obj->base.size >> PAGE_SHIFT;
drivers/gpu/drm/i915/gem/i915_gem_userptr.c +2 -2
index 1e045c337044..ee65c6acf0e2 100644
@@ -131,7 +131,7 @@ userptr_mn_invalidate_range_start(struct mmu_notifier *_mn,
 		ret = i915_gem_object_unbind(obj,
 					     I915_GEM_OBJECT_UNBIND_ACTIVE);
 		if (ret == 0)
-			ret = __i915_gem_object_put_pages(obj, I915_MM_SHRINKER);
+			ret = __i915_gem_object_put_pages(obj);
 		i915_gem_object_put(obj);
 		if (ret)
 			return ret;
@@ -483,7 +483,7 @@ __i915_gem_userptr_get_pages_worker(struct work_struct *_work)
 		}
 	}
 
-	mutex_lock(&obj->mm.lock);
+	mutex_lock_nested(&obj->mm.lock, I915_MM_GET_PAGES);
 	if (obj->userptr.work == &work->work) {
 		struct sg_table *pages = ERR_PTR(ret);
 
drivers/gpu/drm/i915/gem/selftests/huge_pages.c +7 -7
index 688c49a24f32..5c9583349077 100644
@@ -517,7 +517,7 @@ static int igt_mock_memory_region_huge_pages(void *arg)
 			i915_vma_unpin(vma);
 			i915_vma_close(vma);
 
-			__i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+			__i915_gem_object_put_pages(obj);
 			i915_gem_object_put(obj);
 		}
 	}
@@ -650,7 +650,7 @@ static int igt_mock_ppgtt_misaligned_dma(void *arg)
 		i915_vma_close(vma);
 
 		i915_gem_object_unpin_pages(obj);
-		__i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+		__i915_gem_object_put_pages(obj);
 		i915_gem_object_put(obj);
 	}
 
@@ -678,7 +678,7 @@ static void close_object_list(struct list_head *objects,
 
 		list_del(&obj->st_link);
 		i915_gem_object_unpin_pages(obj);
-		__i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+		__i915_gem_object_put_pages(obj);
 		i915_gem_object_put(obj);
 	}
 }
@@ -948,7 +948,7 @@ static int igt_mock_ppgtt_64K(void *arg)
 			i915_vma_close(vma);
 
 			i915_gem_object_unpin_pages(obj);
-			__i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+			__i915_gem_object_put_pages(obj);
 			i915_gem_object_put(obj);
 		}
 	}
@@ -1301,7 +1301,7 @@ static int igt_ppgtt_exhaust_huge(void *arg)
 			}
 
 			i915_gem_object_unpin_pages(obj);
-			__i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+			__i915_gem_object_put_pages(obj);
 			i915_gem_object_put(obj);
 		}
 	}
@@ -1442,7 +1442,7 @@ static int igt_ppgtt_smoke_huge(void *arg)
 		}
 out_unpin:
 		i915_gem_object_unpin_pages(obj);
-		__i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+		__i915_gem_object_put_pages(obj);
 out_put:
 		i915_gem_object_put(obj);
 
@@ -1530,7 +1530,7 @@ static int igt_ppgtt_sanity_check(void *arg)
 			err = igt_write_huge(ctx, obj);
 
 			i915_gem_object_unpin_pages(obj);
-			__i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+			__i915_gem_object_put_pages(obj);
 			i915_gem_object_put(obj);
 
 			if (err) {
drivers/gpu/drm/i915/selftests/intel_memory_region.c +2 -2
index 19e1cca8f143..95d609abd39b 100644
@@ -32,7 +32,7 @@ static void close_objects(struct intel_memory_region *mem,
 		if (i915_gem_object_has_pinned_pages(obj))
 			i915_gem_object_unpin_pages(obj);
 		/* No polluting the memory region between tests */
-		__i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+		__i915_gem_object_put_pages(obj);
 		list_del(&obj->st_link);
 		i915_gem_object_put(obj);
 	}
@@ -122,7 +122,7 @@ igt_object_create(struct intel_memory_region *mem,
 static void igt_object_release(struct drm_i915_gem_object *obj)
 {
 	i915_gem_object_unpin_pages(obj);
-	__i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+	__i915_gem_object_put_pages(obj);
 	list_del(&obj->st_link);
 	i915_gem_object_put(obj);
 }
Signature · 6 lines
2.24.0.rc2

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

PATCH 2/3 lockdep: add might_lock_nested()

Necessary to annotate functions where we might acquire a mutex_lock_nested() or similar. Needed by i915.

---
 include/linux/lockdep.h | 8 ++++++++
 1 file changed, 8 insertions(+)
include/linux/lockdep.h +8 -0
index e0eca94e58c8..c4155436e6fc 100644
@@ -628,6 +628,13 @@ do {									\
 	lock_acquire(&(lock)->dep_map, 0, 0, 1, 1, NULL, _THIS_IP_);	\
 	lock_release(&(lock)->dep_map, 0, _THIS_IP_);			\
 } while (0)
+# define might_lock_nested(lock, subclass) 				\
+do {									\
+	typecheck(struct lockdep_map *, &(lock)->dep_map);		\
+	lock_acquire(&(lock)->dep_map, subclass, 0, 1, 1, NULL,		\
+		     _THIS_IP_);					\
+	lock_release(&(lock)->dep_map, 0, _THIS_IP_);		\
+} while (0)
 
 #define lockdep_assert_irqs_enabled()	do {				\
 		WARN_ONCE(debug_locks && !current->lockdep_recursion &&	\
@@ -650,6 +657,7 @@ do {									\
 #else
 # define might_lock(lock) do { } while (0)
 # define might_lock_read(lock) do { } while (0)
+# define might_lock_nested(lock, subclass) do { } while (0)
 # define lockdep_assert_irqs_enabled() do { } while (0)
 # define lockdep_assert_irqs_disabled() do { } while (0)
 # define lockdep_assert_in_irq() do { } while (0)
Signature · 1 line
2.24.0.rc2
#2 lore raw

PATCH 3/3 drm/i915: use might_lock_nested in get_pages annotation

In reply to Daniel Vetter

So strictly speaking the existing annotation is also ok, because we have a chain of

obj->mm.lock#I915_MM_GET_PAGES -> fs_reclaim -> obj->mm.lock

(the shrinker cannot get at an object while we're in get_pages, hence this is safe). But it's confusing, so try to take the right subclass of the lock.

This does a bit reduce our lockdep based checking, but then it's also less fragile, in case we ever change the nesting around.

Cc Peter Zijlstra <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Will Deacon <[email protected]>
---
 drivers/gpu/drm/i915/gem/i915_gem_object.h | 36 +++++++++++-----------
 1 file changed, 18 insertions(+), 18 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_object.h +18 -18
index edaf7126a84d..e5750d506cc9 100644
@@ -271,10 +271,27 @@ void __i915_gem_object_set_pages(struct drm_i915_gem_object *obj,
 int ____i915_gem_object_get_pages(struct drm_i915_gem_object *obj);
 int __i915_gem_object_get_pages(struct drm_i915_gem_object *obj);
 
+enum i915_mm_subclass { /* lockdep subclass for obj->mm.lock/struct_mutex */
+	I915_MM_NORMAL = 0,
+	/*
+	 * Only used by struct_mutex, when called "recursively" from
+	 * direct-reclaim-esque. Safe because there is only every one
+	 * struct_mutex in the entire system.
+	 */
+	I915_MM_SHRINKER = 1,
+	/*
+	 * Used for obj->mm.lock when allocating pages. Safe because the object
+	 * isn't yet on any LRU, and therefore the shrinker can't deadlock on
+	 * it. As soon as the object has pages, obj->mm.lock nests within
+	 * fs_reclaim.
+	 */
+	I915_MM_GET_PAGES = 1,
+};
+
 static inline int __must_check
 i915_gem_object_pin_pages(struct drm_i915_gem_object *obj)
 {
-	might_lock(&obj->mm.lock);
+	might_lock_nested(&obj->mm.lock, I915_MM_GET_PAGES);
 
 	if (atomic_inc_not_zero(&obj->mm.pages_pin_count))
 		return 0;
@@ -317,23 +334,6 @@ i915_gem_object_unpin_pages(struct drm_i915_gem_object *obj)
 	__i915_gem_object_unpin_pages(obj);
 }
 
-enum i915_mm_subclass { /* lockdep subclass for obj->mm.lock/struct_mutex */
-	I915_MM_NORMAL = 0,
-	/*
-	 * Only used by struct_mutex, when called "recursively" from
-	 * direct-reclaim-esque. Safe because there is only every one
-	 * struct_mutex in the entire system.
-	 */
-	I915_MM_SHRINKER = 1,
-	/*
-	 * Used for obj->mm.lock when allocating pages. Safe because the object
-	 * isn't yet on any LRU, and therefore the shrinker can't deadlock on
-	 * it. As soon as the object has pages, obj->mm.lock nests within
-	 * fs_reclaim.
-	 */
-	I915_MM_GET_PAGES = 1,
-};
-
 int __i915_gem_object_put_pages(struct drm_i915_gem_object *obj);
 void i915_gem_object_truncate(struct drm_i915_gem_object *obj);
 void i915_gem_object_writeback(struct drm_i915_gem_object *obj);
Signature · 6 lines
2.24.0.rc2

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
maintainer Reviewed-by on v1 3/3
#3 lore raw

Re: [Intel-gfx] [PATCH 3/3] drm/i915: use might_lock_nested in get_pages annotation

Quoting Daniel Vetter (2019-11-04 19:37:20)

Quoted 9 lines

So strictly speaking the existing annotation is also ok, because we have a chain of

obj->mm.lock#I915_MM_GET_PAGES -> fs_reclaim -> obj->mm.lock

(the shrinker cannot get at an object while we're in get_pages, hence this is safe). But it's confusing, so try to take the right subclass of the lock.

Quoted 8 lines

This does a bit reduce our lockdep based checking, but then it's also less fragile, in case we ever change the nesting around.

Cc Peter Zijlstra <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Will Deacon <[email protected]>

Regards, Joonas

#4 lore raw

✗ Fi.CI.CHECKPATCH: warning for series starting with [1/3] drm/i915: Switch obj->mm.lock lockdep annotations on its head

In reply to Daniel Vetter
== Series Details ==

== Series Details ==

Series: series starting with [1/3] drm/i915: Switch obj->mm.lock lockdep annotations on its head
URL : https://patchwork.freedesktop.org/series/68956/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
c495bd921770 drm/i915: Switch obj->mm.lock lockdep annotations on its head
-:345: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <[email protected]>'

total: 0 errors, 1 warnings, 0 checks, 213 lines checked ffcadad25d96 lockdep: add might_lock_nested() -:24: WARNING:SPACE_BEFORE_TAB: please, no space before tabs #24: FILE: include/linux/lockdep.h:631:
+# define might_lock_nested(lock, subclass) ^I^I^I^I\$

-:24: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'lock' - possible side-effects? #24: FILE: include/linux/lockdep.h:631:
+# define might_lock_nested(lock, subclass) \
+do { \
+ typecheck(struct lockdep_map *, &(lock)->dep_map); \
+ lock_acquire(&(lock)->dep_map, subclass, 0, 1, 1, NULL, \
+ _THIS_IP_); \
+ lock_release(&(lock)->dep_map, 0, _THIS_IP_); \
+} while (0)

-:41: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <[email protected]>'

total: 0 errors, 2 warnings, 1 checks, 20 lines checked
db49a54b7b5c drm/i915: use might_lock_nested in get_pages annotation
-:80: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <[email protected]>'

total: 0 errors, 1 warnings, 0 checks, 51 lines checked

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

#5 lore raw

✓ Fi.CI.BAT: success for series starting with [1/3] drm/i915: Switch obj->mm.lock lockdep annotations on its head

In reply to Daniel Vetter
== Series Details ==

== Series Details ==

Series: series starting with [1/3] drm/i915: Switch obj->mm.lock lockdep annotations on its head
URL : https://patchwork.freedesktop.org/series/68956/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_7258 -> Patchwork_15123
====================================================

Summary
-------

**SUCCESS**

No regressions found.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/index.html

Known issues
------------

Here are the changes found in Patchwork_15123 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@gem_flink_basic@double-flink:
- fi-icl-u3: [PASS][1] -> [DMESG-WARN][2] ([fdo#107724]) +1 similar issue
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/fi-icl-u3/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/fi-icl-u3/igt@[email protected]

* igt@i915_selftest@live_blt:
- fi-bsw-n3050: [PASS][3] -> [DMESG-FAIL][4] ([fdo#112176])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/fi-bsw-n3050/igt@i915_selftest@live_blt.html
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/fi-bsw-n3050/igt@i915_selftest@live_blt.html

* igt@i915_selftest@live_gem_contexts:
- fi-bsw-nick: [PASS][5] -> [INCOMPLETE][6] ([fdo# 111542])
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/fi-bsw-nick/igt@i915_selftest@live_gem_contexts.html
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/fi-bsw-nick/igt@i915_selftest@live_gem_contexts.html

* igt@i915_selftest@live_hangcheck:
- fi-hsw-4770r: [PASS][7] -> [DMESG-FAIL][8] ([fdo#111991])
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/fi-hsw-4770r/igt@i915_selftest@live_hangcheck.html
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/fi-hsw-4770r/igt@i915_selftest@live_hangcheck.html

* igt@kms_frontbuffer_tracking@basic:
- fi-hsw-peppy: [PASS][9] -> [DMESG-WARN][10] ([fdo#102614])
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/fi-hsw-peppy/igt@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/fi-hsw-peppy/igt@[email protected]

#### Possible fixes ####

* {igt@gem_exec_suspend@basic-s0}:
- fi-bsw-kefka: [DMESG-WARN][11] ([fdo#112120]) -> [PASS][12]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/fi-bsw-kefka/igt@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/fi-bsw-kefka/igt@[email protected]

* igt@gem_flink_basic@basic:
- fi-icl-u3: [DMESG-WARN][13] ([fdo#107724] / [fdo#112052 ]) -> [PASS][14]
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/fi-icl-u3/igt@[email protected]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/fi-icl-u3/igt@[email protected]

* igt@prime_busy@basic-before-default:
- fi-icl-u3: [DMESG-WARN][15] ([fdo#107724]) -> [PASS][16]
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/fi-icl-u3/igt@[email protected]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/fi-icl-u3/igt@[email protected]

#### Warnings ####

* igt@kms_chamelium@hdmi-hpd-fast:
- fi-kbl-7500u: [FAIL][17] ([fdo#111407]) -> [FAIL][18] ([fdo#111045] / [fdo#111096])
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/fi-kbl-7500u/igt@[email protected]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/fi-kbl-7500u/igt@[email protected]

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[fdo# 111542]: https://bugs.freedesktop.org/show_bug.cgi?id= 111542 [fdo#102505]: https://bugs.freedesktop.org/show_bug.cgi?id=102505
[fdo#102614]: https://bugs.freedesktop.org/show_bug.cgi?id=102614
[fdo#105602]: https://bugs.freedesktop.org/show_bug.cgi?id=105602
[fdo#106107]: https://bugs.freedesktop.org/show_bug.cgi?id=106107
[fdo#106350]: https://bugs.freedesktop.org/show_bug.cgi?id=106350
[fdo#107724]: https://bugs.freedesktop.org/show_bug.cgi?id=107724
[fdo#111045]: https://bugs.freedesktop.org/show_bug.cgi?id=111045
[fdo#111096]: https://bugs.freedesktop.org/show_bug.cgi?id=111096
[fdo#111154]: https://bugs.freedesktop.org/show_bug.cgi?id=111154
[fdo#111407]: https://bugs.freedesktop.org/show_bug.cgi?id=111407
[fdo#111991]: https://bugs.freedesktop.org/show_bug.cgi?id=111991
[fdo#112052 ]: https://bugs.freedesktop.org/show_bug.cgi?id=112052
[fdo#112057]: https://bugs.freedesktop.org/show_bug.cgi?id=112057
[fdo#112120]: https://bugs.freedesktop.org/show_bug.cgi?id=112120
[fdo#112176]: https://bugs.freedesktop.org/show_bug.cgi?id=112176

Participating hosts (52 -> 43)
------------------------------

Missing (9): fi-ilk-m540 fi-hsw-4200u fi-skl-guc fi-byt-squawks fi-bsw-cyan fi-bwr-2160 fi-ctg-p8600 fi-gdg-551 fi-byt-clapper

Build changes
-------------

* CI: CI-20190529 -> None
* Linux: CI_DRM_7258 -> Patchwork_15123

CI-20190529: 20190529
CI_DRM_7258: 51b92cc0826a46a2b6de4abee3edecb216bf0419 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_5261: 6c3bae1455c373c49fe744ea037e33b11e8daf1e @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_15123: db49a54b7b5c9d33c874e9f069b0a03ff7ef6cd1 @ git://anongit.freedesktop.org/gfx-ci/linux

== Linux commits ==

db49a54b7b5c drm/i915: use might_lock_nested in get_pages annotation ffcadad25d96 lockdep: add might_lock_nested()
c495bd921770 drm/i915: Switch obj->mm.lock lockdep annotations on its head

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/index.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#6 lore raw

✗ Fi.CI.IGT: failure for series starting with [1/3] drm/i915: Switch obj->mm.lock lockdep annotations on its head

In reply to Daniel Vetter
== Series Details ==

== Series Details ==

Series: series starting with [1/3] drm/i915: Switch obj->mm.lock lockdep annotations on its head
URL : https://patchwork.freedesktop.org/series/68956/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_7258_full -> Patchwork_15123_full
====================================================

Summary
-------

**FAILURE**

Serious unknown changes coming with Patchwork_15123_full absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in Patchwork_15123_full, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.

Possible new issues
-------------------

Here are the unknown changes that may have been introduced in Patchwork_15123_full:

### IGT changes ###

#### Possible regressions ####

* igt@i915_selftest@mock_hugepages:
- shard-kbl: [PASS][1] -> [DMESG-WARN][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-kbl6/igt@i915_selftest@mock_hugepages.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-kbl3/igt@i915_selftest@mock_hugepages.html
- shard-skl: [PASS][3] -> [DMESG-WARN][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-skl7/igt@i915_selftest@mock_hugepages.html
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-skl9/igt@i915_selftest@mock_hugepages.html
- shard-glk: [PASS][5] -> [DMESG-WARN][6]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-glk6/igt@i915_selftest@mock_hugepages.html
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-glk5/igt@i915_selftest@mock_hugepages.html
- shard-iclb: [PASS][7] -> [DMESG-WARN][8]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-iclb7/igt@i915_selftest@mock_hugepages.html
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-iclb3/igt@i915_selftest@mock_hugepages.html

#### Suppressed ####

The following results come from untrusted machines, tests, or statuses. They do not affect the overall result.

* igt@i915_selftest@mock_hugepages:
- {shard-tglb}: [PASS][9] -> [DMESG-WARN][10]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-tglb5/igt@i915_selftest@mock_hugepages.html
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-tglb2/igt@i915_selftest@mock_hugepages.html

Known issues
------------

Here are the changes found in Patchwork_15123_full that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@gem_busy@busy-vcs1:
- shard-iclb: [PASS][11] -> [SKIP][12] ([fdo#112080]) +15 similar issues
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-iclb2/igt@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-iclb7/igt@[email protected]

* igt@gem_ctx_isolation@vcs1-dirty-create:
- shard-iclb: [PASS][13] -> [SKIP][14] ([fdo#109276] / [fdo#112080]) +2 similar issues
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-iclb4/igt@[email protected]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-iclb3/igt@[email protected]

* igt@gem_eio@in-flight-suspend:
- shard-kbl: [PASS][15] -> [DMESG-WARN][16] ([fdo#108566]) +1 similar issue
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-kbl2/igt@[email protected]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-kbl2/igt@[email protected]

* igt@gem_exec_balancer@smoke:
- shard-iclb: [PASS][17] -> [SKIP][18] ([fdo#110854])
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-iclb2/igt@[email protected]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-iclb6/igt@[email protected]

* igt@gem_exec_schedule@in-order-bsd:
- shard-iclb: [PASS][19] -> [SKIP][20] ([fdo#112146]) +5 similar issues
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-iclb5/igt@[email protected]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-iclb4/igt@[email protected]

* igt@gem_exec_schedule@independent-bsd2:
- shard-iclb: [PASS][21] -> [SKIP][22] ([fdo#109276]) +21 similar issues
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-iclb4/igt@[email protected]
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-iclb3/igt@[email protected]

* igt@gem_mmap_gtt@hang:
- shard-snb: [PASS][23] -> [INCOMPLETE][24] ([fdo#105411])
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-snb4/igt@[email protected]
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-snb5/igt@[email protected]

* igt@gem_persistent_relocs@forked-interruptible-thrashing:
- shard-hsw: [PASS][25] -> [TIMEOUT][26] ([fdo#112068 ])
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-hsw8/igt@[email protected]
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-hsw1/igt@[email protected]

* igt@gem_userptr_blits@dmabuf-unsync:
- shard-hsw: [PASS][27] -> [DMESG-WARN][28] ([fdo#111870])
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-hsw5/igt@[email protected]
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-hsw1/igt@[email protected]

* igt@i915_selftest@mock_hugepages:
- shard-apl: [PASS][29] -> [DMESG-WARN][30] ([fdo#109385])
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-apl2/igt@i915_selftest@mock_hugepages.html
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-apl3/igt@i915_selftest@mock_hugepages.html

* igt@kms_flip@flip-vs-suspend-interruptible:
- shard-apl: [PASS][31] -> [DMESG-WARN][32] ([fdo#108566]) +1 similar issue
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-apl4/igt@[email protected]
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-apl4/igt@[email protected]
- shard-hsw: [PASS][33] -> [INCOMPLETE][34] ([fdo#103540])
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-hsw4/igt@[email protected]
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-hsw5/igt@[email protected]

* igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-cur-indfb-draw-mmap-gtt:
- shard-iclb: [PASS][35] -> [FAIL][36] ([fdo#103167]) +5 similar issues
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-iclb7/igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-cur-indfb-draw-mmap-gtt.html
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-iclb2/igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-cur-indfb-draw-mmap-gtt.html

* igt@kms_psr@psr2_sprite_mmap_cpu:
- shard-iclb: [PASS][37] -> [SKIP][38] ([fdo#109441])
[37]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-iclb2/igt@kms_psr@psr2_sprite_mmap_cpu.html
[38]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-iclb7/igt@kms_psr@psr2_sprite_mmap_cpu.html

* igt@kms_setmode@basic:
- shard-apl: [PASS][39] -> [FAIL][40] ([fdo#99912])
[39]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-apl1/igt@[email protected]
[40]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-apl3/igt@[email protected]

#### Possible fixes ####

* igt@gem_ctx_isolation@rcs0-s3:
- shard-kbl: [DMESG-WARN][41] ([fdo#108566]) -> [PASS][42] +9 similar issues
[41]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-kbl7/igt@[email protected]
[42]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-kbl7/igt@[email protected]

* igt@gem_ctx_isolation@vecs0-s3:
- {shard-tglb}: [INCOMPLETE][43] ([fdo#111832]) -> [PASS][44]
[43]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-tglb7/igt@[email protected]
[44]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-tglb7/igt@[email protected]

* {igt@gem_ctx_persistence@vcs1-mixed-process}:
- shard-iclb: [SKIP][45] ([fdo#109276] / [fdo#112080]) -> [PASS][46] +2 similar issues
[45]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-iclb6/igt@[email protected]
[46]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-iclb1/igt@[email protected]

* igt@gem_ctx_shared@exec-single-timeline-bsd:
- shard-iclb: [SKIP][47] ([fdo#110841]) -> [PASS][48]
[47]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-iclb1/igt@[email protected]
[48]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-iclb8/igt@[email protected]

* igt@gem_ctx_shared@q-smoketest-blt:
- {shard-tglb}: [INCOMPLETE][49] ([fdo#111735]) -> [PASS][50]
[49]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-tglb6/igt@[email protected]
[50]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-tglb1/igt@[email protected]

* igt@gem_ctx_switch@queue-light:
- {shard-tglb}: [INCOMPLETE][51] ([fdo#111672]) -> [PASS][52]
[51]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-tglb6/igt@[email protected]
[52]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-tglb4/igt@[email protected]

* igt@gem_exec_parallel@vcs1-fds:
- shard-iclb: [SKIP][53] ([fdo#112080]) -> [PASS][54] +10 similar issues
[53]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-iclb6/igt@[email protected]
[54]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-iclb1/igt@[email protected]

* igt@gem_exec_schedule@preempt-other-chain-bsd:
- shard-iclb: [SKIP][55] ([fdo#112146]) -> [PASS][56] +9 similar issues
[55]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-iclb4/igt@[email protected]
[56]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-iclb5/igt@[email protected]

* igt@gem_exec_suspend@basic-s3:
- {shard-tglb}: [INCOMPLETE][57] ([fdo#111736] / [fdo#111850]) -> [PASS][58]
[57]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-tglb2/igt@[email protected]
[58]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-tglb6/igt@[email protected]

* igt@gem_softpin@noreloc-s3:
- shard-skl: [INCOMPLETE][59] ([fdo#104108]) -> [PASS][60]
[59]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-skl10/igt@[email protected]
[60]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-skl9/igt@[email protected]

* igt@gem_sync@basic-each:
- {shard-tglb}: [INCOMPLETE][61] ([fdo#111647] / [fdo#111998]) -> [PASS][62]
[61]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-tglb5/igt@[email protected]
[62]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-tglb4/igt@[email protected]

* igt@gem_userptr_blits@sync-unmap:
- shard-hsw: [DMESG-WARN][63] ([fdo#111870]) -> [PASS][64] +1 similar issue
[63]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-hsw1/igt@[email protected]
[64]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-hsw7/igt@[email protected]

* igt@i915_pm_rc6_residency@rc6-accuracy:
- shard-kbl: [SKIP][65] ([fdo#109271]) -> [PASS][66]
[65]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-kbl1/igt@[email protected]
[66]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-kbl3/igt@[email protected]

* igt@kms_color@pipe-b-ctm-0-25:
- shard-skl: [DMESG-WARN][67] ([fdo#106107]) -> [PASS][68] +1 similar issue
[67]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-skl3/igt@[email protected]
[68]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-skl5/igt@[email protected]

* igt@kms_cursor_crc@pipe-b-cursor-256x85-offscreen:
- shard-skl: [FAIL][69] ([fdo#103232]) -> [PASS][70]
[69]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-skl6/igt@[email protected]
[70]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-skl8/igt@[email protected]

* igt@kms_cursor_edge_walk@pipe-b-256x256-left-edge:
- shard-snb: [SKIP][71] ([fdo#109271]) -> [PASS][72]
[71]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-snb4/igt@[email protected]
[72]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-snb5/igt@[email protected]

* igt@kms_flip@flip-vs-expired-vblank:
- shard-skl: [FAIL][73] ([fdo#105363]) -> [PASS][74]
[73]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-skl7/igt@[email protected]
[74]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-skl10/igt@[email protected]

* igt@kms_flip@flip-vs-expired-vblank-interruptible:
- shard-glk: [FAIL][75] ([fdo#105363]) -> [PASS][76]
[75]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-glk6/igt@[email protected]
[76]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-glk6/igt@[email protected]

* igt@kms_frontbuffer_tracking@fbc-rgb565-draw-blt:
- shard-iclb: [FAIL][77] ([fdo#103167]) -> [PASS][78] +4 similar issues
[77]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-iclb2/igt@[email protected]
[78]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-iclb6/igt@[email protected]

* igt@kms_frontbuffer_tracking@fbcpsr-1p-offscren-pri-shrfb-draw-pwrite:
- {shard-tglb}: [FAIL][79] ([fdo#103167]) -> [PASS][80] +2 similar issues
[79]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-tglb2/igt@kms_frontbuffer_tracking@fbcpsr-1p-offscren-pri-shrfb-draw-pwrite.html
[80]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-tglb6/igt@kms_frontbuffer_tracking@fbcpsr-1p-offscren-pri-shrfb-draw-pwrite.html

* igt@kms_plane_alpha_blend@pipe-b-constant-alpha-min:
- shard-skl: [FAIL][81] ([fdo#108145]) -> [PASS][82]
[81]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-skl9/igt@[email protected]
[82]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-skl3/igt@[email protected]

* igt@kms_plane_alpha_blend@pipe-c-coverage-7efc:
- shard-skl: [FAIL][83] ([fdo#108145] / [fdo#110403]) -> [PASS][84] +1 similar issue
[83]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-skl6/igt@[email protected]
[84]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-skl5/igt@[email protected]

* igt@kms_plane_lowres@pipe-a-tiling-x:
- shard-iclb: [FAIL][85] ([fdo#103166]) -> [PASS][86]
[85]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-iclb8/igt@[email protected]
[86]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-iclb7/igt@[email protected]

* igt@kms_psr@no_drrs:
- shard-iclb: [FAIL][87] ([fdo#108341]) -> [PASS][88]
[87]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-iclb1/igt@kms_psr@no_drrs.html
[88]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-iclb8/igt@kms_psr@no_drrs.html

* igt@kms_psr@psr2_primary_page_flip:
- shard-iclb: [SKIP][89] ([fdo#109441]) -> [PASS][90] +1 similar issue
[89]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-iclb7/igt@kms_psr@psr2_primary_page_flip.html
[90]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-iclb2/igt@kms_psr@psr2_primary_page_flip.html

* igt@kms_psr@suspend:
- {shard-tglb}: [INCOMPLETE][91] ([fdo#111832] / [fdo#111850]) -> [PASS][92] +4 similar issues
[91]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-tglb8/igt@[email protected]
[92]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-tglb4/igt@[email protected]

* igt@kms_vblank@pipe-a-ts-continuation-dpms-suspend:
- {shard-tglb}: [INCOMPLETE][93] ([fdo#111850]) -> [PASS][94]
[93]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-tglb7/igt@[email protected]
[94]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-tglb5/igt@[email protected]

* igt@prime_busy@hang-bsd2:
- shard-iclb: [SKIP][95] ([fdo#109276]) -> [PASS][96] +20 similar issues
[95]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-iclb7/igt@[email protected]
[96]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-iclb2/igt@[email protected]

#### Warnings ####

* igt@gem_ctx_isolation@vcs1-nonpriv:
- shard-iclb: [FAIL][97] ([fdo#111329]) -> [SKIP][98] ([fdo#109276] / [fdo#112080])
[97]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-iclb1/igt@[email protected]
[98]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-iclb8/igt@[email protected]

* igt@gem_mocs_settings@mocs-reset-bsd2:
- shard-iclb: [SKIP][99] ([fdo#109276]) -> [FAIL][100] ([fdo#111330]) +1 similar issue
[99]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-iclb6/igt@[email protected]
[100]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-iclb1/igt@[email protected]

* igt@gem_mocs_settings@mocs-settings-bsd2:
- shard-iclb: [FAIL][101] ([fdo#111330]) -> [SKIP][102] ([fdo#109276]) +1 similar issue
[101]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7258/shard-iclb4/igt@[email protected]
[102]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/shard-iclb3/igt@[email protected]

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[fdo#103166]: https://bugs.freedesktop.org/show_bug.cgi?id=103166
[fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
[fdo#103232]: https://bugs.freedesktop.org/show_bug.cgi?id=103232
[fdo#103540]: https://bugs.freedesktop.org/show_bug.cgi?id=103540
[fdo#104108]: https://bugs.freedesktop.org/show_bug.cgi?id=104108
[fdo#105363]: https://bugs.freedesktop.org/show_bug.cgi?id=105363
[fdo#105411]: https://bugs.freedesktop.org/show_bug.cgi?id=105411
[fdo#106107]: https://bugs.freedesktop.org/show_bug.cgi?id=106107
[fdo#108145]: https://bugs.freedesktop.org/show_bug.cgi?id=108145
[fdo#108341]: https://bugs.freedesktop.org/show_bug.cgi?id=108341
[fdo#108566]: https://bugs.freedesktop.org/show_bug.cgi?id=108566
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fd

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15123/index.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

maintainer Reviewed-by on v1 1/3
#7 lore raw
In reply to Daniel Vetter

Quoting Daniel Vetter (2019-11-04 19:37:18)

Quoted 30 lines

The trouble with having a plain nesting flag for locks which do not naturally nest (unlike block devices and their partitions, which is the original motivation for nesting levels) is that lockdep will never spot a true deadlock if you screw up.

This patch is an attempt at trying better, by highlighting a bit more the actual nature of the nesting that's going on. Essentially we have two kinds of objects:

- objects without pages allocated, which cannot be on any lru and are hence inaccessible to the shrinker.

- objects which have pages allocated, which are on an lru, and which the shrinker can decide to throw out.

For the former type of object, memory allcoations while holding obj->mm.lock are permissible. For the latter they are not. And get/put_pages transitions between the two types of objects.

This is still not entirely fool-proof since the rules might chance. But as long as we run such a code ever at runtime lockdep should be able to observe the inconsistency and complain (like with any other lockdep class that we've split up in multiple classes). But there are a few clear benefits:

- We can drop the nesting flag parameter from __i915_gem_object_put_pages, because that function by definition is never going allocate memory, and calling it on an object which doesn't have its pages allocated would be a bug.

Quoted 7 lines

- We strictly catch more bugs, since there's not only one place in the entire tree which is annotated with the special class. All the other places that had explicit lockdep nesting annotations we're now going to leave up to lockdep again.

- Specifically this catches stuff like calling get_pages from put_pages (which isn't really a good idea, if we can call put_pages

get_pages?

Quoted 22 lines

so could the shrinker). I've seen patches do exactly that.

Of course I fully expect CI will show me for the fool I am with this one here :-)

v2: There can only be one (lockdep only has a cache for the first subclass, not for deeper ones, and we don't want to make these locks even slower). Still separate enums for better documentation.

Real fix: don forget about phys objs and pin_map(), and fix the shrinker to have the right annotations ... silly me.

v3: Forgot usertptr too ...

v4: Improve comment for pages_pin_count, drop the IMPORTANT comment and instead prime lockdep (Chris).

v5: Appease checkpatch, no double empty lines (Chris)

v6: More rebasing over selftest changes. Also somehow I forgot to push this patch :-/

Quoted 8 lines

Also format comments consistently while at it.

Cc Chris Wilson <[email protected]>
Cc "Tang, CQ" <[email protected]>
Cc Tvrtko Ursulin <[email protected]>
Cc Joonas Lahtinen <[email protected]>

Other than the below comment;

Regards, Joonas
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#8 lore raw

PATCH 1/1 drm/i915: Switch obj->mm.lock lockdep annotations on its head

In reply to Daniel Vetter

The trouble with having a plain nesting flag for locks which do not naturally nest (unlike block devices and their partitions, which is the original motivation for nesting levels) is that lockdep will never spot a true deadlock if you screw up.

This patch is an attempt at trying better, by highlighting a bit more the actual nature of the nesting that's going on. Essentially we have two kinds of objects:

- objects without pages allocated, which cannot be on any lru and are hence inaccessible to the shrinker.

- objects which have pages allocated, which are on an lru, and which the shrinker can decide to throw out.

For the former type of object, memory allcoations while holding obj->mm.lock are permissible. For the latter they are not. And get/put_pages transitions between the two types of objects.

This is still not entirely fool-proof since the rules might chance. But as long as we run such a code ever at runtime lockdep should be able to observe the inconsistency and complain (like with any other lockdep class that we've split up in multiple classes). But there are a few clear benefits:

- We can drop the nesting flag parameter from __i915_gem_object_put_pages, because that function by definition is never going allocate memory, and calling it on an object which doesn't have its pages allocated would be a bug.

- We strictly catch more bugs, since there's not only one place in the entire tree which is annotated with the special class. All the other places that had explicit lockdep nesting annotations we're now going to leave up to lockdep again.

- Specifically this catches stuff like calling get_pages from put_pages (which isn't really a good idea, if we can call get_pages so could the shrinker). I've seen patches do exactly that.

Of course I fully expect CI will show me for the fool I am with this one here :-)

v2: There can only be one (lockdep only has a cache for the first subclass, not for deeper ones, and we don't want to make these locks even slower). Still separate enums for better documentation.

Real fix: don forget about phys objs and pin_map(), and fix the shrinker to have the right annotations ... silly me.

v3: Forgot usertptr too ...

v4: Improve comment for pages_pin_count, drop the IMPORTANT comment and instead prime lockdep (Chris).

v5: Appease checkpatch, no double empty lines (Chris)

v6: More rebasing over selftest changes. Also somehow I forgot to push this patch :-/

Also format comments consistently while at it.

v7: Fix typo in commit message (Joonas)

Also drop the priming, with the lmem merge we now have allocations while holding the lmem lock, which wreaks the generic priming I've done in earlier patches. Should probably be resurrected when lmem is fixed. See

commit 232a6ebae419193f5b8da4fa869ae5089ab105c2

Author: Matthew Auld <[email protected]>
Date:   Tue Oct 8 17:01:14 2019 +0100

drm/i915: introduce intel_memory_region

I'm keeping the priming patch locally so it wont get lost.

---
 drivers/gpu/drm/i915/gem/i915_gem_object.c      |  4 +++-
 drivers/gpu/drm/i915/gem/i915_gem_object.h      | 17 ++++++++++++++---
 .../gpu/drm/i915/gem/i915_gem_object_types.h    |  6 +++++-
 drivers/gpu/drm/i915/gem/i915_gem_pages.c       |  9 ++++-----
 drivers/gpu/drm/i915/gem/i915_gem_phys.c        |  2 +-
 drivers/gpu/drm/i915/gem/i915_gem_shrinker.c    |  5 ++---
 drivers/gpu/drm/i915/gem/i915_gem_userptr.c     |  4 ++--
 drivers/gpu/drm/i915/gem/selftests/huge_pages.c | 14 +++++++-------
 .../drm/i915/selftests/intel_memory_region.c    |  4 ++--
 9 files changed, 40 insertions(+), 25 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_object.c +3 -1
index a50296cce0d8..db103d3c8760 100644
@@ -22,6 +22,8 @@
  *
  */
 
+#include <linux/sched/mm.h>
+
 #include "display/intel_frontbuffer.h"
 #include "gt/intel_gt.h"
 #include "i915_drv.h"
@@ -186,7 +188,7 @@ static void __i915_gem_free_objects(struct drm_i915_private *i915,
 		GEM_BUG_ON(!list_empty(&obj->lut_list));
 
 		atomic_set(&obj->mm.pages_pin_count, 0);
-		__i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+		__i915_gem_object_put_pages(obj);
 		GEM_BUG_ON(i915_gem_object_has_pages(obj));
 		bitmap_free(obj->bit_17);
 
drivers/gpu/drm/i915/gem/i915_gem_object.h +14 -3
index 458cd51331f1..edaf7126a84d 100644
@@ -319,11 +319,22 @@ i915_gem_object_unpin_pages(struct drm_i915_gem_object *obj)
 
 enum i915_mm_subclass { /* lockdep subclass for obj->mm.lock/struct_mutex */
 	I915_MM_NORMAL = 0,
-	I915_MM_SHRINKER /* called "recursively" from direct-reclaim-esque */
+	/*
+	 * Only used by struct_mutex, when called "recursively" from
+	 * direct-reclaim-esque. Safe because there is only every one
+	 * struct_mutex in the entire system.
+	 */
+	I915_MM_SHRINKER = 1,
+	/*
+	 * Used for obj->mm.lock when allocating pages. Safe because the object
+	 * isn't yet on any LRU, and therefore the shrinker can't deadlock on
+	 * it. As soon as the object has pages, obj->mm.lock nests within
+	 * fs_reclaim.
+	 */
+	I915_MM_GET_PAGES = 1,
 };
 
-int __i915_gem_object_put_pages(struct drm_i915_gem_object *obj,
-				enum i915_mm_subclass subclass);
+int __i915_gem_object_put_pages(struct drm_i915_gem_object *obj);
 void i915_gem_object_truncate(struct drm_i915_gem_object *obj);
 void i915_gem_object_writeback(struct drm_i915_gem_object *obj);
 
drivers/gpu/drm/i915/gem/i915_gem_object_types.h +5 -1
index 96008374a412..15f8297dc34e 100644
@@ -162,7 +162,11 @@ struct drm_i915_gem_object {
 	atomic_t bind_count;
 
 	struct {
-		struct mutex lock; /* protects the pages and their use */
+		/*
+		 * Protects the pages and their use. Do not use directly, but
+		 * instead go through the pin/unpin interfaces.
+		 */
+		struct mutex lock;
 		atomic_t pages_pin_count;
 		atomic_t shrink_pin;
 
drivers/gpu/drm/i915/gem/i915_gem_pages.c +4 -5
index 29f4c2850745..f402c2c415c2 100644
@@ -106,7 +106,7 @@ int __i915_gem_object_get_pages(struct drm_i915_gem_object *obj)
 {
 	int err;
 
-	err = mutex_lock_interruptible(&obj->mm.lock);
+	err = mutex_lock_interruptible_nested(&obj->mm.lock, I915_MM_GET_PAGES);
 	if (err)
 		return err;
 
@@ -190,8 +190,7 @@ __i915_gem_object_unset_pages(struct drm_i915_gem_object *obj)
 	return pages;
 }
 
-int __i915_gem_object_put_pages(struct drm_i915_gem_object *obj,
-				enum i915_mm_subclass subclass)
+int __i915_gem_object_put_pages(struct drm_i915_gem_object *obj)
 {
 	struct sg_table *pages;
 	int err;
@@ -202,7 +201,7 @@ int __i915_gem_object_put_pages(struct drm_i915_gem_object *obj,
 	GEM_BUG_ON(atomic_read(&obj->bind_count));
 
 	/* May be called by shrinker from within get_pages() (on another bo) */
-	mutex_lock_nested(&obj->mm.lock, subclass);
+	mutex_lock(&obj->mm.lock);
 	if (unlikely(atomic_read(&obj->mm.pages_pin_count))) {
 		err = -EBUSY;
 		goto unlock;
@@ -308,7 +307,7 @@ void *i915_gem_object_pin_map(struct drm_i915_gem_object *obj,
 	if (!i915_gem_object_type_has(obj, flags))
 		return ERR_PTR(-ENXIO);
 
-	err = mutex_lock_interruptible(&obj->mm.lock);
+	err = mutex_lock_interruptible_nested(&obj->mm.lock, I915_MM_GET_PAGES);
 	if (err)
 		return ERR_PTR(err);
 
drivers/gpu/drm/i915/gem/i915_gem_phys.c +1 -1
index 8043ff63d73f..b1b7c1b3038a 100644
@@ -164,7 +164,7 @@ int i915_gem_object_attach_phys(struct drm_i915_gem_object *obj, int align)
 	if (err)
 		return err;
 
-	mutex_lock(&obj->mm.lock);
+	mutex_lock_nested(&obj->mm.lock, I915_MM_GET_PAGES);
 
 	if (obj->mm.madv != I915_MADV_WILLNEED) {
 		err = -EFAULT;
drivers/gpu/drm/i915/gem/i915_gem_shrinker.c +2 -3
index fd3ce6da8497..066b3df677e8 100644
@@ -57,7 +57,7 @@ static bool unsafe_drop_pages(struct drm_i915_gem_object *obj,
 		flags = I915_GEM_OBJECT_UNBIND_ACTIVE;
 
 	if (i915_gem_object_unbind(obj, flags) == 0)
-		__i915_gem_object_put_pages(obj, I915_MM_SHRINKER);
+		__i915_gem_object_put_pages(obj);
 
 	return !i915_gem_object_has_pages(obj);
 }
@@ -209,8 +209,7 @@ i915_gem_shrink(struct drm_i915_private *i915,
 
 			if (unsafe_drop_pages(obj, shrink)) {
 				/* May arrive from get_pages on another bo */
-				mutex_lock_nested(&obj->mm.lock,
-						  I915_MM_SHRINKER);
+				mutex_lock(&obj->mm.lock);
 				if (!i915_gem_object_has_pages(obj)) {
 					try_to_writeback(obj, shrink);
 					count += obj->base.size >> PAGE_SHIFT;
drivers/gpu/drm/i915/gem/i915_gem_userptr.c +2 -2
index 1e045c337044..ee65c6acf0e2 100644
@@ -131,7 +131,7 @@ userptr_mn_invalidate_range_start(struct mmu_notifier *_mn,
 		ret = i915_gem_object_unbind(obj,
 					     I915_GEM_OBJECT_UNBIND_ACTIVE);
 		if (ret == 0)
-			ret = __i915_gem_object_put_pages(obj, I915_MM_SHRINKER);
+			ret = __i915_gem_object_put_pages(obj);
 		i915_gem_object_put(obj);
 		if (ret)
 			return ret;
@@ -483,7 +483,7 @@ __i915_gem_userptr_get_pages_worker(struct work_struct *_work)
 		}
 	}
 
-	mutex_lock(&obj->mm.lock);
+	mutex_lock_nested(&obj->mm.lock, I915_MM_GET_PAGES);
 	if (obj->userptr.work == &work->work) {
 		struct sg_table *pages = ERR_PTR(ret);
 
drivers/gpu/drm/i915/gem/selftests/huge_pages.c +7 -7
index 688c49a24f32..5c9583349077 100644
@@ -517,7 +517,7 @@ static int igt_mock_memory_region_huge_pages(void *arg)
 			i915_vma_unpin(vma);
 			i915_vma_close(vma);
 
-			__i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+			__i915_gem_object_put_pages(obj);
 			i915_gem_object_put(obj);
 		}
 	}
@@ -650,7 +650,7 @@ static int igt_mock_ppgtt_misaligned_dma(void *arg)
 		i915_vma_close(vma);
 
 		i915_gem_object_unpin_pages(obj);
-		__i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+		__i915_gem_object_put_pages(obj);
 		i915_gem_object_put(obj);
 	}
 
@@ -678,7 +678,7 @@ static void close_object_list(struct list_head *objects,
 
 		list_del(&obj->st_link);
 		i915_gem_object_unpin_pages(obj);
-		__i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+		__i915_gem_object_put_pages(obj);
 		i915_gem_object_put(obj);
 	}
 }
@@ -948,7 +948,7 @@ static int igt_mock_ppgtt_64K(void *arg)
 			i915_vma_close(vma);
 
 			i915_gem_object_unpin_pages(obj);
-			__i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+			__i915_gem_object_put_pages(obj);
 			i915_gem_object_put(obj);
 		}
 	}
@@ -1301,7 +1301,7 @@ static int igt_ppgtt_exhaust_huge(void *arg)
 			}
 
 			i915_gem_object_unpin_pages(obj);
-			__i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+			__i915_gem_object_put_pages(obj);
 			i915_gem_object_put(obj);
 		}
 	}
@@ -1442,7 +1442,7 @@ static int igt_ppgtt_smoke_huge(void *arg)
 		}
 out_unpin:
 		i915_gem_object_unpin_pages(obj);
-		__i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+		__i915_gem_object_put_pages(obj);
 out_put:
 		i915_gem_object_put(obj);
 
@@ -1530,7 +1530,7 @@ static int igt_ppgtt_sanity_check(void *arg)
 			err = igt_write_huge(ctx, obj);
 
 			i915_gem_object_unpin_pages(obj);
-			__i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+			__i915_gem_object_put_pages(obj);
 			i915_gem_object_put(obj);
 
 			if (err) {
drivers/gpu/drm/i915/selftests/intel_memory_region.c +2 -2
index 19e1cca8f143..95d609abd39b 100644
@@ -32,7 +32,7 @@ static void close_objects(struct intel_memory_region *mem,
 		if (i915_gem_object_has_pinned_pages(obj))
 			i915_gem_object_unpin_pages(obj);
 		/* No polluting the memory region between tests */
-		__i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+		__i915_gem_object_put_pages(obj);
 		list_del(&obj->st_link);
 		i915_gem_object_put(obj);
 	}
@@ -122,7 +122,7 @@ igt_object_create(struct intel_memory_region *mem,
 static void igt_object_release(struct drm_i915_gem_object *obj)
 {
 	i915_gem_object_unpin_pages(obj);
-	__i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+	__i915_gem_object_put_pages(obj);
 	list_del(&obj->st_link);
 	i915_gem_object_put(obj);
 }
Signature · 6 lines
2.24.0.rc2

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#9 lore raw
Quoted 69 lines · Daniel Vetter

The trouble with having a plain nesting flag for locks which do not naturally nest (unlike block devices and their partitions, which is the original motivation for nesting levels) is that lockdep will never spot a true deadlock if you screw up.

This patch is an attempt at trying better, by highlighting a bit more the actual nature of the nesting that's going on. Essentially we have two kinds of objects:

- objects without pages allocated, which cannot be on any lru and are hence inaccessible to the shrinker.

- objects which have pages allocated, which are on an lru, and which the shrinker can decide to throw out.

For the former type of object, memory allcoations while holding obj->mm.lock are permissible. For the latter they are not. And get/put_pages transitions between the two types of objects.

This is still not entirely fool-proof since the rules might chance. But as long as we run such a code ever at runtime lockdep should be able to observe the inconsistency and complain (like with any other lockdep class that we've split up in multiple classes). But there are a few clear benefits:

- We can drop the nesting flag parameter from __i915_gem_object_put_pages, because that function by definition is never going allocate memory, and calling it on an object which doesn't have its pages allocated would be a bug.

- We strictly catch more bugs, since there's not only one place in the entire tree which is annotated with the special class. All the other places that had explicit lockdep nesting annotations we're now going to leave up to lockdep again.

- Specifically this catches stuff like calling get_pages from put_pages (which isn't really a good idea, if we can call get_pages so could the shrinker). I've seen patches do exactly that.

Of course I fully expect CI will show me for the fool I am with this one here :-)

v2: There can only be one (lockdep only has a cache for the first subclass, not for deeper ones, and we don't want to make these locks even slower). Still separate enums for better documentation.

Real fix: don forget about phys objs and pin_map(), and fix the shrinker to have the right annotations ... silly me.

v3: Forgot usertptr too ...

v4: Improve comment for pages_pin_count, drop the IMPORTANT comment and instead prime lockdep (Chris).

v5: Appease checkpatch, no double empty lines (Chris)

v6: More rebasing over selftest changes. Also somehow I forgot to push this patch :-/

Also format comments consistently while at it.

v7: Fix typo in commit message (Joonas)

Also drop the priming, with the lmem merge we now have allocations while holding the lmem lock, which wreaks the generic priming I've done in earlier patches. Should probably be resurrected when lmem is fixed. See

Quoted 7 lines

commit 232a6ebae419193f5b8da4fa869ae5089ab105c2

Author: Matthew Auld <[email protected]>
Date:   Tue Oct 8 17:01:14 2019 +0100

drm/i915: introduce intel_memory_region

I'm keeping the priming patch locally so it wont get lost.

Any idea how we can fix this? AFAIK for something like LMEM, its objects are always marked as !shrinkable, and so shouldn't be accessible from the shrinker.
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#10 lore raw
Quoted 74 lines · Matthew Auld
Quoted 73 lines · Daniel Vetter

The trouble with having a plain nesting flag for locks which do not naturally nest (unlike block devices and their partitions, which is the original motivation for nesting levels) is that lockdep will never spot a true deadlock if you screw up.

This patch is an attempt at trying better, by highlighting a bit more the actual nature of the nesting that's going on. Essentially we have two kinds of objects:

- objects without pages allocated, which cannot be on any lru and are hence inaccessible to the shrinker.

- objects which have pages allocated, which are on an lru, and which the shrinker can decide to throw out.

For the former type of object, memory allcoations while holding obj->mm.lock are permissible. For the latter they are not. And get/put_pages transitions between the two types of objects.

This is still not entirely fool-proof since the rules might chance. But as long as we run such a code ever at runtime lockdep should be able to observe the inconsistency and complain (like with any other lockdep class that we've split up in multiple classes). But there are a few clear benefits:

- We can drop the nesting flag parameter from __i915_gem_object_put_pages, because that function by definition is never going allocate memory, and calling it on an object which doesn't have its pages allocated would be a bug.

- We strictly catch more bugs, since there's not only one place in the entire tree which is annotated with the special class. All the other places that had explicit lockdep nesting annotations we're now going to leave up to lockdep again.

- Specifically this catches stuff like calling get_pages from put_pages (which isn't really a good idea, if we can call get_pages so could the shrinker). I've seen patches do exactly that.

Of course I fully expect CI will show me for the fool I am with this one here :-)

v2: There can only be one (lockdep only has a cache for the first subclass, not for deeper ones, and we don't want to make these locks even slower). Still separate enums for better documentation.

Real fix: don forget about phys objs and pin_map(), and fix the shrinker to have the right annotations ... silly me.

v3: Forgot usertptr too ...

v4: Improve comment for pages_pin_count, drop the IMPORTANT comment and instead prime lockdep (Chris).

v5: Appease checkpatch, no double empty lines (Chris)

v6: More rebasing over selftest changes. Also somehow I forgot to push this patch :-/

Also format comments consistently while at it.

v7: Fix typo in commit message (Joonas)

Also drop the priming, with the lmem merge we now have allocations while holding the lmem lock, which wreaks the generic priming I've done in earlier patches. Should probably be resurrected when lmem is fixed. See

commit 232a6ebae419193f5b8da4fa869ae5089ab105c2

Author: Matthew Auld <[email protected]>
Date:   Tue Oct 8 17:01:14 2019 +0100
Quoted 7 lines
Quoted 3 lines

drm/i915: introduce intel_memory_region

I'm keeping the priming patch locally so it wont get lost.

Any idea how we can fix this? AFAIK for something like LMEM, its objects are always marked as !shrinkable, and so shouldn't be accessible from the shrinker.

On one hand I don't think you need to fix this, since it works.

Otoh I think it's generally good practice to not allocate memory (or at least be very conscious about it) when holding memory manager locks. Because sooner or later you somehow create a dependency from one memory manager to the next, or something else, and then you end up with the shrinker in your dependencies. In the locking rules for the new lmem locking we've discussed this a bit, and agreed to just encode it as best practice. Including lockdep priming (i.e. tell lockdep that we might get at mm_lock from fs_reclaim, to make sure no one can allocate anything while holding mm_lock).

Wrt fixing: preallocate, then take lock, is the standard pattern. -Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#11 lore raw
In reply to Daniel Vetter

Just some nits/typos that made this a little difficult for me to read.

I am still trying to understand what is going on, so unfortunately I have no comments on the patch.

Quoted 10 lines

-----Original Message-----
From: Intel-gfx <[email protected]> On Behalf Of Daniel Vetter
Sent: Tuesday, November 5, 2019 4:02 AM
To: Intel Graphics Development <[email protected]>
Cc: Daniel Vetter <[email protected]>; Auld, Matthew <[email protected]>; Vetter, Daniel <[email protected]>
Subject: [Intel-gfx] [PATCH] drm/i915: Switch obj->mm.lock lockdep annotations on its head

Quoted 6 lines

The trouble with having a plain nesting flag for locks which do not naturally nest (unlike block devices and their partitions, which is the original motivation for nesting levels) is that lockdep will never spot a true deadlock if you screw up.

This patch is an attempt at trying better, by highlighting a bit more

"a bit more of the"

Quoted 10 lines

the actual nature of the nesting that's going on. Essentially we have two kinds of objects:

- objects without pages allocated, which cannot be on any lru and are hence inaccessible to the shrinker.

- objects which have pages allocated, which are on an lru, and which the shrinker can decide to throw out.

For the former type of object, memory allcoations while holding

s/allcoations/allocations

Quoted 2 lines

obj->mm.lock are permissible. For the latter they are not. And get/put_pages transitions between the two types of objects.

I am not sure what the sentence,

"And get/put_page transitions between the two types of objects."

means. Can you clarify?

Quoted 2 lines

This is still not entirely fool-proof since the rules might chance.

s/chance/change/

Quoted 2 lines

But as long as we run such a code ever at runtime lockdep should be able to observe the inconsistency and complain (like with any other

I am having difficulty with "But as long as we run such a code ever at".

Should this be, "With this code, runtime lockdep should be able to..."?

Quoted 17 lines

lockdep class that we've split up in multiple classes). But there are a few clear benefits:

- We can drop the nesting flag parameter from __i915_gem_object_put_pages, because that function by definition is never going allocate memory, and calling it on an object which doesn't have its pages allocated would be a bug.

- We strictly catch more bugs, since there's not only one place in the entire tree which is annotated with the special class. All the other places that had explicit lockdep nesting annotations we're now going to leave up to lockdep again.

- Specifically this catches stuff like calling get_pages from put_pages (which isn't really a good idea, if we can call get_pages so could the shrinker). I've seen patches do exactly that.

Quoted 8 lines

Of course I fully expect CI will show me for the fool I am with this one here :-)

v2: There can only be one (lockdep only has a cache for the first subclass, not for deeper ones, and we don't want to make these locks even slower). Still separate enums for better documentation.

Real fix: don forget about phys objs and pin_map(), and fix the

s/don/don't/

Thanks,

Mike

Quoted 344 lines

shrinker to have the right annotations ... silly me.

v3: Forgot usertptr too ...

v4: Improve comment for pages_pin_count, drop the IMPORTANT comment and instead prime lockdep (Chris).

v5: Appease checkpatch, no double empty lines (Chris)

v6: More rebasing over selftest changes. Also somehow I forgot to push this patch :-/

Also format comments consistently while at it.

v7: Fix typo in commit message (Joonas)

Also drop the priming, with the lmem merge we now have allocations while holding the lmem lock, which wreaks the generic priming I've done in earlier patches. Should probably be resurrected when lmem is fixed. See

commit 232a6ebae419193f5b8da4fa869ae5089ab105c2

Author: Matthew Auld <[email protected]>
Date:   Tue Oct 8 17:01:14 2019 +0100

drm/i915: introduce intel_memory_region

I'm keeping the priming patch locally so it wont get lost.

---

drivers/gpu/drm/i915/gem/i915_gem_object.c      |  4 +++-
drivers/gpu/drm/i915/gem/i915_gem_object.h      | 17 ++++++++++++++---
.../gpu/drm/i915/gem/i915_gem_object_types.h    |  6 +++++-
drivers/gpu/drm/i915/gem/i915_gem_pages.c       |  9 ++++-----
drivers/gpu/drm/i915/gem/i915_gem_phys.c        |  2 +-
drivers/gpu/drm/i915/gem/i915_gem_shrinker.c    |  5 ++---
drivers/gpu/drm/i915/gem/i915_gem_userptr.c     |  4 ++--
drivers/gpu/drm/i915/gem/selftests/huge_pages.c | 14 +++++++-------
.../drm/i915/selftests/intel_memory_region.c    |  4 ++--
9 files changed, 40 insertions(+), 25 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_object.c +3 -1
index a50296cce0d8..db103d3c8760 100644
@@ -22,6 +22,8 @@
 *
 */
 
+#include <linux/sched/mm.h>
+
 #include "display/intel_frontbuffer.h"
 #include "gt/intel_gt.h"
 #include "i915_drv.h"
@@ -186,7 +188,7 @@ static void __i915_gem_free_objects(struct
 drm_i915_private *i915,
 		GEM_BUG_ON(!list_empty(&obj->lut_list));
 
 		atomic_set(&obj->mm.pages_pin_count, 0);
-		__i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+		__i915_gem_object_put_pages(obj);
 		GEM_BUG_ON(i915_gem_object_has_pages(obj));
 		bitmap_free(obj->bit_17);
drivers/gpu/drm/i915/gem/i915_gem_object.h +0 -0
index 458cd51331f1..edaf7126a84d 100644
@@ -319,11 +319,22 @@ i915_gem_object_unpin_pages(struct
 drm_i915_gem_object *obj)
 

enum i915_mm_subclass { /* lockdep subclass for obj-

Quoted 1 line

mm.lock/struct_mutex */

	I915_MM_NORMAL = 0,
drivers/gpu/drm/i915/gem/i915_gem_object.h +0 -1
-	I915_MM_SHRINKER /* called "recursively" from direct-reclaim-esque

*/

drivers/gpu/drm/i915/gem/i915_gem_object.h +8 -0
+	/*
+	 * Only used by struct_mutex, when called "recursively" from
+	 * direct-reclaim-esque. Safe because there is only every one
+	 * struct_mutex in the entire system.
+	 */
+	I915_MM_SHRINKER = 1,
+	/*
+	 * Used for obj->mm.lock when allocating pages. Safe because the

object

drivers/gpu/drm/i915/gem/i915_gem_object.h +5 -0
+	 * isn't yet on any LRU, and therefore the shrinker can't deadlock on
+	 * it. As soon as the object has pages, obj->mm.lock nests within
+	 * fs_reclaim.
+	 */
+	I915_MM_GET_PAGES = 1,

};

drivers/gpu/drm/i915/gem/i915_gem_object.h +1 -2
-int __i915_gem_object_put_pages(struct drm_i915_gem_object *obj,
-				enum i915_mm_subclass subclass);
+int __i915_gem_object_put_pages(struct drm_i915_gem_object *obj);

void i915_gem_object_truncate(struct drm_i915_gem_object *obj); void i915_gem_object_writeback(struct drm_i915_gem_object *obj);

drivers/gpu/drm/i915/gem/i915_gem_object_types.h +5 -1
index 96008374a412..15f8297dc34e 100644
@@ -162,7 +162,11 @@ struct drm_i915_gem_object {
 	atomic_t bind_count;
 
 	struct {
-		struct mutex lock; /* protects the pages and their use */
+		/*
+		 * Protects the pages and their use. Do not use directly, but
+		 * instead go through the pin/unpin interfaces.
+		 */
+		struct mutex lock;
 		atomic_t pages_pin_count;
 		atomic_t shrink_pin;
 
drivers/gpu/drm/i915/gem/i915_gem_pages.c +1 -1
index 29f4c2850745..f402c2c415c2 100644
@@ -106,7 +106,7 @@ int __i915_gem_object_get_pages(struct
 drm_i915_gem_object *obj)
 {
 	int err;
 
-	err = mutex_lock_interruptible(&obj->mm.lock);
+	err = mutex_lock_interruptible_nested(&obj->mm.lock,
 I915_MM_GET_PAGES);
 	if (err)
		return err;
drivers/gpu/drm/i915/gem/i915_gem_pages.c +1 -2
@@ -190,8 +190,7 @@ __i915_gem_object_unset_pages(struct
 drm_i915_gem_object *obj)
 	return pages;
 }
 
-int __i915_gem_object_put_pages(struct drm_i915_gem_object *obj,
-				enum i915_mm_subclass subclass)
+int __i915_gem_object_put_pages(struct drm_i915_gem_object *obj)
 {
 	struct sg_table *pages;
	int err;
drivers/gpu/drm/i915/gem/i915_gem_pages.c +1 -1
@@ -202,7 +201,7 @@ int __i915_gem_object_put_pages(struct
 drm_i915_gem_object *obj,
 	GEM_BUG_ON(atomic_read(&obj->bind_count));
 
 	/* May be called by shrinker from within get_pages() (on another bo)
 */
-	mutex_lock_nested(&obj->mm.lock, subclass);
+	mutex_lock(&obj->mm.lock);
 	if (unlikely(atomic_read(&obj->mm.pages_pin_count))) {
		err = -EBUSY;
		goto unlock;
drivers/gpu/drm/i915/gem/i915_gem_pages.c +1 -1
@@ -308,7 +307,7 @@ void *i915_gem_object_pin_map(struct
 drm_i915_gem_object *obj,
 	if (!i915_gem_object_type_has(obj, flags))
 		return ERR_PTR(-ENXIO);
 
-	err = mutex_lock_interruptible(&obj->mm.lock);
+	err = mutex_lock_interruptible_nested(&obj->mm.lock,
 I915_MM_GET_PAGES);
 	if (err)
		return ERR_PTR(err);
drivers/gpu/drm/i915/gem/i915_gem_phys.c +1 -1
index 8043ff63d73f..b1b7c1b3038a 100644
@@ -164,7 +164,7 @@ int i915_gem_object_attach_phys(struct
 drm_i915_gem_object *obj, int align)
 	if (err)
 		return err;
 
-	mutex_lock(&obj->mm.lock);
+	mutex_lock_nested(&obj->mm.lock, I915_MM_GET_PAGES);
 
 	if (obj->mm.madv != I915_MADV_WILLNEED) {
		err = -EFAULT;
drivers/gpu/drm/i915/gem/i915_gem_shrinker.c +1 -1
index fd3ce6da8497..066b3df677e8 100644
@@ -57,7 +57,7 @@ static bool unsafe_drop_pages(struct
 drm_i915_gem_object *obj,
 		flags = I915_GEM_OBJECT_UNBIND_ACTIVE;
 
 	if (i915_gem_object_unbind(obj, flags) == 0)
-		__i915_gem_object_put_pages(obj, I915_MM_SHRINKER);
+		__i915_gem_object_put_pages(obj);
 
 	return !i915_gem_object_has_pages(obj);

}

drivers/gpu/drm/i915/gem/i915_gem_shrinker.c +1 -2
@@ -209,8 +209,7 @@ i915_gem_shrink(struct drm_i915_private *i915,
 
 			if (unsafe_drop_pages(obj, shrink)) {
 				/* May arrive from get_pages on another bo
 */
-				mutex_lock_nested(&obj->mm.lock,
-						  I915_MM_SHRINKER);
+				mutex_lock(&obj->mm.lock);
 				if (!i915_gem_object_has_pages(obj)) {
 					try_to_writeback(obj, shrink);
					count += obj->base.size >>

PAGE_SHIFT;

drivers/gpu/drm/i915/gem/i915_gem_userptr.c +1 -1
index 1e045c337044..ee65c6acf0e2 100644
@@ -131,7 +131,7 @@ userptr_mn_invalidate_range_start(struct
 mmu_notifier *_mn,
 		ret = i915_gem_object_unbind(obj,
 
 I915_GEM_OBJECT_UNBIND_ACTIVE);
 		if (ret == 0)
-			ret = __i915_gem_object_put_pages(obj,
 I915_MM_SHRINKER);
+			ret = __i915_gem_object_put_pages(obj);
		i915_gem_object_put(obj);
		if (ret)
			return ret;
drivers/gpu/drm/i915/gem/i915_gem_userptr.c +1 -1
@@ -483,7 +483,7 @@ __i915_gem_userptr_get_pages_worker(struct
 work_struct *_work)
 		}
 	}
 
-	mutex_lock(&obj->mm.lock);
+	mutex_lock_nested(&obj->mm.lock, I915_MM_GET_PAGES);
 	if (obj->userptr.work == &work->work) {
 		struct sg_table *pages = ERR_PTR(ret);
drivers/gpu/drm/i915/gem/selftests/huge_pages.c +1 -1
index 688c49a24f32..5c9583349077 100644
@@ -517,7 +517,7 @@ static int igt_mock_memory_region_huge_pages(void
 *arg)
 			i915_vma_unpin(vma);
 			i915_vma_close(vma);
 
-			__i915_gem_object_put_pages(obj,
 I915_MM_NORMAL);
+			__i915_gem_object_put_pages(obj);
 			i915_gem_object_put(obj);
		}
	}
drivers/gpu/drm/i915/gem/selftests/huge_pages.c +3 -3
@@ -650,7 +650,7 @@ static int igt_mock_ppgtt_misaligned_dma(void *arg)
 		i915_vma_close(vma);
 
 		i915_gem_object_unpin_pages(obj);
-		__i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+		__i915_gem_object_put_pages(obj);
 		i915_gem_object_put(obj);
 	}
 
@@ -678,7 +678,7 @@ static void close_object_list(struct list_head *objects,
 
 		list_del(&obj->st_link);
 		i915_gem_object_unpin_pages(obj);
-		__i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+		__i915_gem_object_put_pages(obj);
 		i915_gem_object_put(obj);
 	}
 }
@@ -948,7 +948,7 @@ static int igt_mock_ppgtt_64K(void *arg)
 			i915_vma_close(vma);
 
 			i915_gem_object_unpin_pages(obj);
-			__i915_gem_object_put_pages(obj,
 I915_MM_NORMAL);
+			__i915_gem_object_put_pages(obj);
 			i915_gem_object_put(obj);
 		}
	}
drivers/gpu/drm/i915/gem/selftests/huge_pages.c +1 -1
@@ -1301,7 +1301,7 @@ static int igt_ppgtt_exhaust_huge(void *arg)
 			}
 
 			i915_gem_object_unpin_pages(obj);
-			__i915_gem_object_put_pages(obj,
 I915_MM_NORMAL);
+			__i915_gem_object_put_pages(obj);
 			i915_gem_object_put(obj);
 		}
	}
drivers/gpu/drm/i915/gem/selftests/huge_pages.c +0 -0
@@ -1442,7 +1442,7 @@ static int igt_ppgtt_smoke_huge(void *arg)
 		}

out_unpin:

		i915_gem_object_unpin_pages(obj);
drivers/gpu/drm/i915/gem/selftests/huge_pages.c +1 -1
-		__i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+		__i915_gem_object_put_pages(obj);

out_put:

		i915_gem_object_put(obj);
drivers/gpu/drm/i915/gem/selftests/huge_pages.c +1 -1
@@ -1530,7 +1530,7 @@ static int igt_ppgtt_sanity_check(void *arg)
 			err = igt_write_huge(ctx, obj);
 
 			i915_gem_object_unpin_pages(obj);
-			__i915_gem_object_put_pages(obj,
 I915_MM_NORMAL);
+			__i915_gem_object_put_pages(obj);
 			i915_gem_object_put(obj);
 
			if (err) {
drivers/gpu/drm/i915/selftests/intel_memory_region.c +1 -1
index 19e1cca8f143..95d609abd39b 100644
@@ -32,7 +32,7 @@ static void close_objects(struct intel_memory_region
 *mem,
 		if (i915_gem_object_has_pinned_pages(obj))
 			i915_gem_object_unpin_pages(obj);
 		/* No polluting the memory region between tests */
-		__i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+		__i915_gem_object_put_pages(obj);
 		list_del(&obj->st_link);
 		i915_gem_object_put(obj);
	}
drivers/gpu/drm/i915/selftests/intel_memory_region.c +1 -2
@@ -122,7 +122,7 @@ igt_object_create(struct intel_memory_region *mem,
 static void igt_object_release(struct drm_i915_gem_object *obj)
 {
 	i915_gem_object_unpin_pages(obj);
-	__i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+	__i915_gem_object_put_pages(obj);
 	list_del(&obj->st_link);
 	i915_gem_object_put(obj);
 }
--

2.24.0.rc2

Quoted 4 lines

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

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

#12 lore raw
In reply to Daniel Vetter
Quoted 43 lines

-----Original Message-----
From: Daniel Vetter <[email protected]>
Sent: Tuesday, November 5, 2019 2:02 AM
To: Intel Graphics Development <[email protected]>
Cc: Daniel Vetter <[email protected]>; Auld, Matthew <[email protected]>; Chris Wilson <[email protected]>; Tang, CQ <[email protected]>; Ursulin, Tvrtko <[email protected]>; Joonas Lahtinen <[email protected]>; Vetter, Daniel <[email protected]>
Subject: [PATCH] drm/i915: Switch obj->mm.lock lockdep annotations on its head

The trouble with having a plain nesting flag for locks which do not naturally nest (unlike block devices and their partitions, which is the original motivation for nesting levels) is that lockdep will never spot a true deadlock if you screw up.

This patch is an attempt at trying better, by highlighting a bit more the actual nature of the nesting that's going on. Essentially we have two kinds of objects:

- objects without pages allocated, which cannot be on any lru and are hence inaccessible to the shrinker.

- objects which have pages allocated, which are on an lru, and which the shrinker can decide to throw out.

For the former type of object, memory allcoations while holding obj->mm.lock are permissible. For the latter they are not. And get/put_pages transitions between the two types of objects.

This is still not entirely fool-proof since the rules might chance. But as long as we run such a code ever at runtime lockdep should be able to observe the inconsistency and complain (like with any other lockdep class that we've split up in multiple classes). But there are a few clear benefits:

- We can drop the nesting flag parameter from __i915_gem_object_put_pages, because that function by definition is never going allocate memory, and calling it on an object which doesn't have its pages allocated would be a bug.

Quoted 8 lines

- We strictly catch more bugs, since there's not only one place in the entire tree which is annotated with the special class. All the other places that had explicit lockdep nesting annotations we're now going to leave up to lockdep again.

- Specifically this catches stuff like calling get_pages from put_pages (which isn't really a good idea, if we can call get_pages so could the shrinker). I've seen patches do exactly that.

If we don't allow get_pages from put_pages, then we need to think a new way to swap the pages freed by put_pages. In the lmem swapping case, put_pages can't just free the pages, it needs to save the pages to somewhere else.

The saving operation requires to call get_pages because we need temp objects for blitter engine to do the copying.

Can we use another thread to do the async copying?

--CQ

Quoted 345 lines

Of course I fully expect CI will show me for the fool I am with this one here :-)

v2: There can only be one (lockdep only has a cache for the first subclass, not for deeper ones, and we don't want to make these locks even slower). Still separate enums for better documentation.

Real fix: don forget about phys objs and pin_map(), and fix the shrinker to have the right annotations ... silly me.

v3: Forgot usertptr too ...

v4: Improve comment for pages_pin_count, drop the IMPORTANT comment and instead prime lockdep (Chris).

v5: Appease checkpatch, no double empty lines (Chris)

v6: More rebasing over selftest changes. Also somehow I forgot to push this patch :-/

Also format comments consistently while at it.

v7: Fix typo in commit message (Joonas)

Also drop the priming, with the lmem merge we now have allocations while holding the lmem lock, which wreaks the generic priming I've done in earlier patches. Should probably be resurrected when lmem is fixed. See

commit 232a6ebae419193f5b8da4fa869ae5089ab105c2

Author: Matthew Auld <[email protected]>
Date:   Tue Oct 8 17:01:14 2019 +0100

drm/i915: introduce intel_memory_region

I'm keeping the priming patch locally so it wont get lost.

---
 drivers/gpu/drm/i915/gem/i915_gem_object.c      |  4 +++-
 drivers/gpu/drm/i915/gem/i915_gem_object.h      | 17 ++++++++++++++---
 .../gpu/drm/i915/gem/i915_gem_object_types.h    |  6 +++++-
 drivers/gpu/drm/i915/gem/i915_gem_pages.c       |  9 ++++-----
 drivers/gpu/drm/i915/gem/i915_gem_phys.c        |  2 +-
 drivers/gpu/drm/i915/gem/i915_gem_shrinker.c    |  5 ++---
 drivers/gpu/drm/i915/gem/i915_gem_userptr.c     |  4 ++--
 drivers/gpu/drm/i915/gem/selftests/huge_pages.c | 14 +++++++-------
 .../drm/i915/selftests/intel_memory_region.c    |  4 ++--
 9 files changed, 40 insertions(+), 25 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_object.c +3 -1
index a50296cce0d8..db103d3c8760 100644
@@ -22,6 +22,8 @@
  *
  */
 
+#include <linux/sched/mm.h>
+
 #include "display/intel_frontbuffer.h"
 #include "gt/intel_gt.h"
 #include "i915_drv.h"
@@ -186,7 +188,7 @@ static void __i915_gem_free_objects(struct
 drm_i915_private *i915,
 		GEM_BUG_ON(!list_empty(&obj->lut_list));
 
 		atomic_set(&obj->mm.pages_pin_count, 0);
-		__i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+		__i915_gem_object_put_pages(obj);
 		GEM_BUG_ON(i915_gem_object_has_pages(obj));
 		bitmap_free(obj->bit_17);
drivers/gpu/drm/i915/gem/i915_gem_object.h +0 -0
index 458cd51331f1..edaf7126a84d 100644
@@ -319,11 +319,22 @@ i915_gem_object_unpin_pages(struct
 drm_i915_gem_object *obj)
 
 enum i915_mm_subclass { /* lockdep subclass for obj-
Quoted 1 line

mm.lock/struct_mutex */

drivers/gpu/drm/i915/gem/i915_gem_object.h +0 -1
 	I915_MM_NORMAL = 0,
-	I915_MM_SHRINKER /* called "recursively" from direct-reclaim-

esque */

drivers/gpu/drm/i915/gem/i915_gem_object.h +8 -0
+	/*
+	 * Only used by struct_mutex, when called "recursively" from
+	 * direct-reclaim-esque. Safe because there is only every one
+	 * struct_mutex in the entire system.
+	 */
+	I915_MM_SHRINKER = 1,
+	/*
+	 * Used for obj->mm.lock when allocating pages. Safe because the

object

drivers/gpu/drm/i915/gem/i915_gem_object.h +6 -2
+	 * isn't yet on any LRU, and therefore the shrinker can't deadlock on
+	 * it. As soon as the object has pages, obj->mm.lock nests within
+	 * fs_reclaim.
+	 */
+	I915_MM_GET_PAGES = 1,
 };
 
-int __i915_gem_object_put_pages(struct drm_i915_gem_object *obj,
-				enum i915_mm_subclass subclass);
+int __i915_gem_object_put_pages(struct drm_i915_gem_object *obj);
 void i915_gem_object_truncate(struct drm_i915_gem_object *obj);  void

i915_gem_object_writeback(struct drm_i915_gem_object *obj);

drivers/gpu/drm/i915/gem/i915_gem_object_types.h +5 -1
index 96008374a412..15f8297dc34e 100644
@@ -162,7 +162,11 @@ struct drm_i915_gem_object {
 	atomic_t bind_count;
 
 	struct {
-		struct mutex lock; /* protects the pages and their use */
+		/*
+		 * Protects the pages and their use. Do not use directly, but
+		 * instead go through the pin/unpin interfaces.
+		 */
+		struct mutex lock;
 		atomic_t pages_pin_count;
 		atomic_t shrink_pin;
 
drivers/gpu/drm/i915/gem/i915_gem_pages.c +3 -3
index 29f4c2850745..f402c2c415c2 100644
@@ -106,7 +106,7 @@ int __i915_gem_object_get_pages(struct
 drm_i915_gem_object *obj)  {
 	int err;
 
-	err = mutex_lock_interruptible(&obj->mm.lock);
+	err = mutex_lock_interruptible_nested(&obj->mm.lock,
+I915_MM_GET_PAGES);
 	if (err)
 		return err;
@@ -190,8 +190,7 @@ __i915_gem_object_unset_pages(struct
 drm_i915_gem_object *obj)
 	return pages;
 }
 
-int __i915_gem_object_put_pages(struct drm_i915_gem_object *obj,
-				enum i915_mm_subclass subclass)
+int __i915_gem_object_put_pages(struct drm_i915_gem_object *obj)
 {
 	struct sg_table *pages;
drivers/gpu/drm/i915/gem/i915_gem_pages.c +1 -1
 	int err;
@@ -202,7 +201,7 @@ int __i915_gem_object_put_pages(struct
 drm_i915_gem_object *obj,
 	GEM_BUG_ON(atomic_read(&obj->bind_count));
 
 	/* May be called by shrinker from within get_pages() (on another bo)
 */
-	mutex_lock_nested(&obj->mm.lock, subclass);
+	mutex_lock(&obj->mm.lock);
 	if (unlikely(atomic_read(&obj->mm.pages_pin_count))) {
drivers/gpu/drm/i915/gem/i915_gem_pages.c +2 -1
 		err = -EBUSY;
 		goto unlock;
@@ -308,7 +307,7 @@ void *i915_gem_object_pin_map(struct
 drm_i915_gem_object *obj,
 	if (!i915_gem_object_type_has(obj, flags))
 		return ERR_PTR(-ENXIO);
 
-	err = mutex_lock_interruptible(&obj->mm.lock);
+	err = mutex_lock_interruptible_nested(&obj->mm.lock,
+I915_MM_GET_PAGES);
 	if (err)
 		return ERR_PTR(err);
drivers/gpu/drm/i915/gem/i915_gem_phys.c +1 -1
index 8043ff63d73f..b1b7c1b3038a 100644
@@ -164,7 +164,7 @@ int i915_gem_object_attach_phys(struct
 drm_i915_gem_object *obj, int align)
 	if (err)
 		return err;
 
-	mutex_lock(&obj->mm.lock);
+	mutex_lock_nested(&obj->mm.lock, I915_MM_GET_PAGES);
 
 	if (obj->mm.madv != I915_MADV_WILLNEED) {
drivers/gpu/drm/i915/gem/i915_gem_phys.c +0 -0
 		err = -EFAULT;
drivers/gpu/drm/i915/gem/i915_gem_shrinker.c +1 -1
index fd3ce6da8497..066b3df677e8 100644
@@ -57,7 +57,7 @@ static bool unsafe_drop_pages(struct
 drm_i915_gem_object *obj,
 		flags = I915_GEM_OBJECT_UNBIND_ACTIVE;
 
 	if (i915_gem_object_unbind(obj, flags) == 0)
-		__i915_gem_object_put_pages(obj, I915_MM_SHRINKER);
+		__i915_gem_object_put_pages(obj);
 
 	return !i915_gem_object_has_pages(obj);  } @@ -209,8 +209,7 @@

i915_gem_shrink(struct drm_i915_private *i915,

drivers/gpu/drm/i915/gem/i915_gem_shrinker.c +0 -0
 			if (unsafe_drop_pages(obj, shrink)) {
 				/* May arrive from get_pages on another bo

*/

drivers/gpu/drm/i915/gem/i915_gem_shrinker.c +1 -2
-				mutex_lock_nested(&obj->mm.lock,
-						  I915_MM_SHRINKER);
+				mutex_lock(&obj->mm.lock);
 				if (!i915_gem_object_has_pages(obj)) {
 					try_to_writeback(obj, shrink);
 					count += obj->base.size >>

PAGE_SHIFT; diff --git a/drivers/gpu/drm/i915/gem/i915_gem_userptr.c b/drivers/gpu/drm/i915/gem/i915_gem_userptr.c
index 1e045c337044..ee65c6acf0e2 100644

drivers/gpu/drm/i915/gem/i915_gem_userptr.c +1 -1
@@ -131,7 +131,7 @@ userptr_mn_invalidate_range_start(struct
 mmu_notifier *_mn,
 		ret = i915_gem_object_unbind(obj,
 
 I915_GEM_OBJECT_UNBIND_ACTIVE);
 		if (ret == 0)
-			ret = __i915_gem_object_put_pages(obj,
 I915_MM_SHRINKER);
+			ret = __i915_gem_object_put_pages(obj);
drivers/gpu/drm/i915/gem/i915_gem_userptr.c +1 -1
 		i915_gem_object_put(obj);
 		if (ret)
 			return ret;
@@ -483,7 +483,7 @@ __i915_gem_userptr_get_pages_worker(struct
 work_struct *_work)
 		}
 	}
 
-	mutex_lock(&obj->mm.lock);
+	mutex_lock_nested(&obj->mm.lock, I915_MM_GET_PAGES);
 	if (obj->userptr.work == &work->work) {
 		struct sg_table *pages = ERR_PTR(ret);
drivers/gpu/drm/i915/gem/selftests/huge_pages.c +1 -1
index 688c49a24f32..5c9583349077 100644
@@ -517,7 +517,7 @@ static int
 igt_mock_memory_region_huge_pages(void *arg)
 			i915_vma_unpin(vma);
 			i915_vma_close(vma);
 
-			__i915_gem_object_put_pages(obj,
 I915_MM_NORMAL);
+			__i915_gem_object_put_pages(obj);
 			i915_gem_object_put(obj);
drivers/gpu/drm/i915/gem/selftests/huge_pages.c +3 -3
 		}
 	}
@@ -650,7 +650,7 @@ static int igt_mock_ppgtt_misaligned_dma(void *arg)
 		i915_vma_close(vma);
 
 		i915_gem_object_unpin_pages(obj);
-		__i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+		__i915_gem_object_put_pages(obj);
 		i915_gem_object_put(obj);
 	}
 
@@ -678,7 +678,7 @@ static void close_object_list(struct list_head *objects,
 
 		list_del(&obj->st_link);
 		i915_gem_object_unpin_pages(obj);
-		__i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+		__i915_gem_object_put_pages(obj);
 		i915_gem_object_put(obj);
 	}
 }
@@ -948,7 +948,7 @@ static int igt_mock_ppgtt_64K(void *arg)
 			i915_vma_close(vma);
 
 			i915_gem_object_unpin_pages(obj);
-			__i915_gem_object_put_pages(obj,
 I915_MM_NORMAL);
+			__i915_gem_object_put_pages(obj);
 			i915_gem_object_put(obj);
 		}
drivers/gpu/drm/i915/gem/selftests/huge_pages.c +1 -1
 	}
@@ -1301,7 +1301,7 @@ static int igt_ppgtt_exhaust_huge(void *arg)
 			}
 
 			i915_gem_object_unpin_pages(obj);
-			__i915_gem_object_put_pages(obj,
 I915_MM_NORMAL);
+			__i915_gem_object_put_pages(obj);
 			i915_gem_object_put(obj);
 		}
drivers/gpu/drm/i915/gem/selftests/huge_pages.c +2 -2
 	}
@@ -1442,7 +1442,7 @@ static int igt_ppgtt_smoke_huge(void *arg)
 		}
 out_unpin:
 		i915_gem_object_unpin_pages(obj);
-		__i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+		__i915_gem_object_put_pages(obj);
 out_put:
 		i915_gem_object_put(obj);
 
@@ -1530,7 +1530,7 @@ static int igt_ppgtt_sanity_check(void *arg)
 			err = igt_write_huge(ctx, obj);
 
 			i915_gem_object_unpin_pages(obj);
-			__i915_gem_object_put_pages(obj,
 I915_MM_NORMAL);
+			__i915_gem_object_put_pages(obj);
 			i915_gem_object_put(obj);
 
drivers/gpu/drm/i915/gem/selftests/huge_pages.c +0 -0
 			if (err) {
drivers/gpu/drm/i915/selftests/intel_memory_region.c +1 -1
index 19e1cca8f143..95d609abd39b 100644
@@ -32,7 +32,7 @@ static void close_objects(struct intel_memory_region
 *mem,
 		if (i915_gem_object_has_pinned_pages(obj))
 			i915_gem_object_unpin_pages(obj);
 		/* No polluting the memory region between tests */
-		__i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+		__i915_gem_object_put_pages(obj);
 		list_del(&obj->st_link);
 		i915_gem_object_put(obj);
drivers/gpu/drm/i915/selftests/intel_memory_region.c +1 -2
 	}
@@ -122,7 +122,7 @@ igt_object_create(struct intel_memory_region *mem,
 static void igt_object_release(struct drm_i915_gem_object *obj)  {
 	i915_gem_object_unpin_pages(obj);
-	__i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+	__i915_gem_object_put_pages(obj);
 	list_del(&obj->st_link);
 	i915_gem_object_put(obj);
 }
--
Quoted 1 line

2.24.0.rc2

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

#13 lore raw
Quoted 53 lines · CQ
Quoted 44 lines

-----Original Message-----
From: Daniel Vetter <[email protected]>
Sent: Tuesday, November 5, 2019 2:02 AM
To: Intel Graphics Development <[email protected]>
Cc: Daniel Vetter <[email protected]>; Auld, Matthew <[email protected]>; Chris Wilson <[email protected]>; Tang, CQ <[email protected]>; Ursulin, Tvrtko <[email protected]>; Joonas Lahtinen <[email protected]>; Vetter, Daniel <[email protected]>
Subject: [PATCH] drm/i915: Switch obj->mm.lock lockdep annotations on its head

The trouble with having a plain nesting flag for locks which do not naturally nest (unlike block devices and their partitions, which is the original motivation for nesting levels) is that lockdep will never spot a true deadlock if you screw up.

This patch is an attempt at trying better, by highlighting a bit more the actual nature of the nesting that's going on. Essentially we have two kinds of objects:

- objects without pages allocated, which cannot be on any lru and are hence inaccessible to the shrinker.

- objects which have pages allocated, which are on an lru, and which the shrinker can decide to throw out.

For the former type of object, memory allcoations while holding obj->mm.lock are permissible. For the latter they are not. And get/put_pages transitions between the two types of objects.

This is still not entirely fool-proof since the rules might chance. But as long as we run such a code ever at runtime lockdep should be able to observe the inconsistency and complain (like with any other lockdep class that we've split up in multiple classes). But there are a few clear benefits:

- We can drop the nesting flag parameter from __i915_gem_object_put_pages, because that function by definition is never going allocate memory, and calling it on an object which doesn't have its pages allocated would be a bug.

Quoted 8 lines

- We strictly catch more bugs, since there's not only one place in the entire tree which is annotated with the special class. All the other places that had explicit lockdep nesting annotations we're now going to leave up to lockdep again.

- Specifically this catches stuff like calling get_pages from put_pages (which isn't really a good idea, if we can call get_pages so could the shrinker). I've seen patches do exactly that.

Quoted 6 lines

If we don't allow get_pages from put_pages, then we need to think a new way to swap the pages freed by put_pages. In the lmem swapping case, put_pages can't just free the pages, it needs to save the pages to somewhere else.

The saving operation requires to call get_pages because we need temp objects for blitter engine to do the copying.

Can we use another thread to do the async copying?

Nah, it's a lot simpler.
- roll out dma_resv locking
- remove the obj->mm.lock locking for lmem

With ww_mutex you can nest however you want to, as long as there's no other locks in between it's all going to work out. Some of the recently added new locks (like the vma->mutex or whatever it was exactly) might also need to be switched over. But that's details we still need to figure out.

Only downside to all this it's a lot of to switch the locking around. -Daniel

Quoted 352 lines

--CQ

Quoted 346 lines

Of course I fully expect CI will show me for the fool I am with this one here :-)

v2: There can only be one (lockdep only has a cache for the first subclass, not for deeper ones, and we don't want to make these locks even slower). Still separate enums for better documentation.

Real fix: don forget about phys objs and pin_map(), and fix the shrinker to have the right annotations ... silly me.

v3: Forgot usertptr too ...

v4: Improve comment for pages_pin_count, drop the IMPORTANT comment and instead prime lockdep (Chris).

v5: Appease checkpatch, no double empty lines (Chris)

v6: More rebasing over selftest changes. Also somehow I forgot to push this patch :-/

Also format comments consistently while at it.

v7: Fix typo in commit message (Joonas)

Also drop the priming, with the lmem merge we now have allocations while holding the lmem lock, which wreaks the generic priming I've done in earlier patches. Should probably be resurrected when lmem is fixed. See

commit 232a6ebae419193f5b8da4fa869ae5089ab105c2

Author: Matthew Auld <[email protected]>
Date:   Tue Oct 8 17:01:14 2019 +0100

drm/i915: introduce intel_memory_region

I'm keeping the priming patch locally so it wont get lost.

---
 drivers/gpu/drm/i915/gem/i915_gem_object.c      |  4 +++-
 drivers/gpu/drm/i915/gem/i915_gem_object.h      | 17 ++++++++++++++---
 .../gpu/drm/i915/gem/i915_gem_object_types.h    |  6 +++++-
 drivers/gpu/drm/i915/gem/i915_gem_pages.c       |  9 ++++-----
 drivers/gpu/drm/i915/gem/i915_gem_phys.c        |  2 +-
 drivers/gpu/drm/i915/gem/i915_gem_shrinker.c    |  5 ++---
 drivers/gpu/drm/i915/gem/i915_gem_userptr.c     |  4 ++--
 drivers/gpu/drm/i915/gem/selftests/huge_pages.c | 14 +++++++-------
 .../drm/i915/selftests/intel_memory_region.c    |  4 ++--
 9 files changed, 40 insertions(+), 25 deletions(-)
drivers/gpu/drm/i915/gem/i915_gem_object.c +3 -1
index a50296cce0d8..db103d3c8760 100644
@@ -22,6 +22,8 @@
  *
  */
 
+#include <linux/sched/mm.h>
+
 #include "display/intel_frontbuffer.h"
 #include "gt/intel_gt.h"
 #include "i915_drv.h"
@@ -186,7 +188,7 @@ static void __i915_gem_free_objects(struct
 drm_i915_private *i915,
              GEM_BUG_ON(!list_empty(&obj->lut_list));
 
              atomic_set(&obj->mm.pages_pin_count, 0);
-             __i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+             __i915_gem_object_put_pages(obj);
              GEM_BUG_ON(i915_gem_object_has_pages(obj));
              bitmap_free(obj->bit_17);
drivers/gpu/drm/i915/gem/i915_gem_object.h +0 -0
index 458cd51331f1..edaf7126a84d 100644
@@ -319,11 +319,22 @@ i915_gem_object_unpin_pages(struct
 drm_i915_gem_object *obj)
 
 enum i915_mm_subclass { /* lockdep subclass for obj-
Quoted 1 line

mm.lock/struct_mutex */

      I915_MM_NORMAL = 0,

- I915_MM_SHRINKER /* called "recursively" from direct-reclaim-
esque */

drivers/gpu/drm/i915/gem/i915_gem_object.h +8 -0
+     /*
+      * Only used by struct_mutex, when called "recursively" from
+      * direct-reclaim-esque. Safe because there is only every one
+      * struct_mutex in the entire system.
+      */
+     I915_MM_SHRINKER = 1,
+     /*
+      * Used for obj->mm.lock when allocating pages. Safe because the

object

drivers/gpu/drm/i915/gem/i915_gem_object.h +6 -2
+      * isn't yet on any LRU, and therefore the shrinker can't deadlock on
+      * it. As soon as the object has pages, obj->mm.lock nests within
+      * fs_reclaim.
+      */
+     I915_MM_GET_PAGES = 1,
 };
 
-int __i915_gem_object_put_pages(struct drm_i915_gem_object *obj,
-                             enum i915_mm_subclass subclass);
+int __i915_gem_object_put_pages(struct drm_i915_gem_object *obj);
 void i915_gem_object_truncate(struct drm_i915_gem_object *obj);  void

i915_gem_object_writeback(struct drm_i915_gem_object *obj);

drivers/gpu/drm/i915/gem/i915_gem_object_types.h +5 -1
index 96008374a412..15f8297dc34e 100644
@@ -162,7 +162,11 @@ struct drm_i915_gem_object {
      atomic_t bind_count;
 
      struct {
-             struct mutex lock; /* protects the pages and their use */
+             /*
+              * Protects the pages and their use. Do not use directly, but
+              * instead go through the pin/unpin interfaces.
+              */
+             struct mutex lock;
              atomic_t pages_pin_count;
              atomic_t shrink_pin;
 
drivers/gpu/drm/i915/gem/i915_gem_pages.c +3 -3
index 29f4c2850745..f402c2c415c2 100644
@@ -106,7 +106,7 @@ int __i915_gem_object_get_pages(struct
 drm_i915_gem_object *obj)  {
      int err;
 
-     err = mutex_lock_interruptible(&obj->mm.lock);
+     err = mutex_lock_interruptible_nested(&obj->mm.lock,
+I915_MM_GET_PAGES);
      if (err)
              return err;
@@ -190,8 +190,7 @@ __i915_gem_object_unset_pages(struct
 drm_i915_gem_object *obj)
      return pages;
 }
 
-int __i915_gem_object_put_pages(struct drm_i915_gem_object *obj,
-                             enum i915_mm_subclass subclass)
+int __i915_gem_object_put_pages(struct drm_i915_gem_object *obj)
 {
      struct sg_table *pages;
      int err;
drivers/gpu/drm/i915/gem/i915_gem_pages.c +1 -1
@@ -202,7 +201,7 @@ int __i915_gem_object_put_pages(struct
 drm_i915_gem_object *obj,
      GEM_BUG_ON(atomic_read(&obj->bind_count));
 
      /* May be called by shrinker from within get_pages() (on another bo)
 */
-     mutex_lock_nested(&obj->mm.lock, subclass);
+     mutex_lock(&obj->mm.lock);
      if (unlikely(atomic_read(&obj->mm.pages_pin_count))) {
              err = -EBUSY;
              goto unlock;
drivers/gpu/drm/i915/gem/i915_gem_pages.c +2 -1
@@ -308,7 +307,7 @@ void *i915_gem_object_pin_map(struct
 drm_i915_gem_object *obj,
      if (!i915_gem_object_type_has(obj, flags))
              return ERR_PTR(-ENXIO);
 
-     err = mutex_lock_interruptible(&obj->mm.lock);
+     err = mutex_lock_interruptible_nested(&obj->mm.lock,
+I915_MM_GET_PAGES);
      if (err)
              return ERR_PTR(err);
drivers/gpu/drm/i915/gem/i915_gem_phys.c +1 -1
index 8043ff63d73f..b1b7c1b3038a 100644
@@ -164,7 +164,7 @@ int i915_gem_object_attach_phys(struct
 drm_i915_gem_object *obj, int align)
      if (err)
              return err;
 
-     mutex_lock(&obj->mm.lock);
+     mutex_lock_nested(&obj->mm.lock, I915_MM_GET_PAGES);
 
      if (obj->mm.madv != I915_MADV_WILLNEED) {
              err = -EFAULT;
drivers/gpu/drm/i915/gem/i915_gem_shrinker.c +1 -1
index fd3ce6da8497..066b3df677e8 100644
@@ -57,7 +57,7 @@ static bool unsafe_drop_pages(struct
 drm_i915_gem_object *obj,
              flags = I915_GEM_OBJECT_UNBIND_ACTIVE;
 
      if (i915_gem_object_unbind(obj, flags) == 0)
-             __i915_gem_object_put_pages(obj, I915_MM_SHRINKER);
+             __i915_gem_object_put_pages(obj);
 
      return !i915_gem_object_has_pages(obj);  } @@ -209,8 +209,7 @@

i915_gem_shrink(struct drm_i915_private *i915,

                      if (unsafe_drop_pages(obj, shrink)) {
                              /* May arrive from get_pages on another bo

*/

drivers/gpu/drm/i915/gem/i915_gem_shrinker.c +1 -2
-                             mutex_lock_nested(&obj->mm.lock,
-                                               I915_MM_SHRINKER);
+                             mutex_lock(&obj->mm.lock);
                              if (!i915_gem_object_has_pages(obj)) {
                                      try_to_writeback(obj, shrink);
                                      count += obj->base.size >>

PAGE_SHIFT; diff --git a/drivers/gpu/drm/i915/gem/i915_gem_userptr.c b/drivers/gpu/drm/i915/gem/i915_gem_userptr.c
index 1e045c337044..ee65c6acf0e2 100644

drivers/gpu/drm/i915/gem/i915_gem_userptr.c +1 -1
@@ -131,7 +131,7 @@ userptr_mn_invalidate_range_start(struct
 mmu_notifier *_mn,
              ret = i915_gem_object_unbind(obj,
 
 I915_GEM_OBJECT_UNBIND_ACTIVE);
              if (ret == 0)
-                     ret = __i915_gem_object_put_pages(obj,
 I915_MM_SHRINKER);
+                     ret = __i915_gem_object_put_pages(obj);
              i915_gem_object_put(obj);
              if (ret)
                      return ret;
drivers/gpu/drm/i915/gem/i915_gem_userptr.c +1 -1
@@ -483,7 +483,7 @@ __i915_gem_userptr_get_pages_worker(struct
 work_struct *_work)
              }
      }
 
-     mutex_lock(&obj->mm.lock);
+     mutex_lock_nested(&obj->mm.lock, I915_MM_GET_PAGES);
      if (obj->userptr.work == &work->work) {
              struct sg_table *pages = ERR_PTR(ret);
drivers/gpu/drm/i915/gem/selftests/huge_pages.c +1 -1
index 688c49a24f32..5c9583349077 100644
@@ -517,7 +517,7 @@ static int
 igt_mock_memory_region_huge_pages(void *arg)
                      i915_vma_unpin(vma);
                      i915_vma_close(vma);
 
-                     __i915_gem_object_put_pages(obj,
 I915_MM_NORMAL);
+                     __i915_gem_object_put_pages(obj);
                      i915_gem_object_put(obj);
              }
      }
drivers/gpu/drm/i915/gem/selftests/huge_pages.c +3 -3
@@ -650,7 +650,7 @@ static int igt_mock_ppgtt_misaligned_dma(void *arg)
              i915_vma_close(vma);
 
              i915_gem_object_unpin_pages(obj);
-             __i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+             __i915_gem_object_put_pages(obj);
              i915_gem_object_put(obj);
      }
 
@@ -678,7 +678,7 @@ static void close_object_list(struct list_head *objects,
 
              list_del(&obj->st_link);
              i915_gem_object_unpin_pages(obj);
-             __i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+             __i915_gem_object_put_pages(obj);
              i915_gem_object_put(obj);
      }
 }
@@ -948,7 +948,7 @@ static int igt_mock_ppgtt_64K(void *arg)
                      i915_vma_close(vma);
 
                      i915_gem_object_unpin_pages(obj);
-                     __i915_gem_object_put_pages(obj,
 I915_MM_NORMAL);
+                     __i915_gem_object_put_pages(obj);
                      i915_gem_object_put(obj);
              }
      }
drivers/gpu/drm/i915/gem/selftests/huge_pages.c +1 -1
@@ -1301,7 +1301,7 @@ static int igt_ppgtt_exhaust_huge(void *arg)
                      }
 
                      i915_gem_object_unpin_pages(obj);
-                     __i915_gem_object_put_pages(obj,
 I915_MM_NORMAL);
+                     __i915_gem_object_put_pages(obj);
                      i915_gem_object_put(obj);
              }
      }
drivers/gpu/drm/i915/gem/selftests/huge_pages.c +2 -2
@@ -1442,7 +1442,7 @@ static int igt_ppgtt_smoke_huge(void *arg)
              }
 out_unpin:
              i915_gem_object_unpin_pages(obj);
-             __i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+             __i915_gem_object_put_pages(obj);
 out_put:
              i915_gem_object_put(obj);
 
@@ -1530,7 +1530,7 @@ static int igt_ppgtt_sanity_check(void *arg)
                      err = igt_write_huge(ctx, obj);
 
                      i915_gem_object_unpin_pages(obj);
-                     __i915_gem_object_put_pages(obj,
 I915_MM_NORMAL);
+                     __i915_gem_object_put_pages(obj);
                      i915_gem_object_put(obj);
 
                      if (err) {
drivers/gpu/drm/i915/selftests/intel_memory_region.c +1 -1
index 19e1cca8f143..95d609abd39b 100644
@@ -32,7 +32,7 @@ static void close_objects(struct intel_memory_region
 *mem,
              if (i915_gem_object_has_pinned_pages(obj))
                      i915_gem_object_unpin_pages(obj);
              /* No polluting the memory region between tests */
-             __i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+             __i915_gem_object_put_pages(obj);
              list_del(&obj->st_link);
              i915_gem_object_put(obj);
      }
drivers/gpu/drm/i915/selftests/intel_memory_region.c +1 -2
@@ -122,7 +122,7 @@ igt_object_create(struct intel_memory_region *mem,
 static void igt_object_release(struct drm_i915_gem_object *obj)  {
      i915_gem_object_unpin_pages(obj);
-     __i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+     __i915_gem_object_put_pages(obj);
      list_del(&obj->st_link);
      i915_gem_object_put(obj);
 }
--

2.24.0.rc2

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#14 lore raw

✗ Fi.CI.CHECKPATCH: warning for series starting with drm/i915: Switch obj->mm.lock lockdep annotations on its head (rev2)

In reply to Daniel Vetter
== Series Details ==

== Series Details ==

Series: series starting with drm/i915: Switch obj->mm.lock lockdep annotations on its head (rev2)
URL : https://patchwork.freedesktop.org/series/68956/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
c1f4ce7bcff4 drm/i915: Switch obj->mm.lock lockdep annotations on its head
-:74: ERROR:GIT_COMMIT_ID: Please use git commit description style 'commit <12+ chars of sha1> ("<title line>")' - ie: 'commit 232a6ebae419 ("drm/i915: introduce intel_memory_region")'
#74: 
commit 232a6ebae419193f5b8da4fa869ae5089ab105c2

-:347: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <[email protected]>'

total: 1 errors, 1 warnings, 0 checks, 199 lines checked 71463ddc096d lockdep: add might_lock_nested() -:24: WARNING:SPACE_BEFORE_TAB: please, no space before tabs #24: FILE: include/linux/lockdep.h:631:
+# define might_lock_nested(lock, subclass) ^I^I^I^I\$

-:24: CHECK:MACRO_ARG_REUSE: Macro argument reuse 'lock' - possible side-effects? #24: FILE: include/linux/lockdep.h:631:
+# define might_lock_nested(lock, subclass) \
+do { \
+ typecheck(struct lockdep_map *, &(lock)->dep_map); \
+ lock_acquire(&(lock)->dep_map, subclass, 0, 1, 1, NULL, \
+ _THIS_IP_); \
+ lock_release(&(lock)->dep_map, 0, _THIS_IP_); \
+} while (0)

-:41: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <[email protected]>'

total: 0 errors, 2 warnings, 1 checks, 20 lines checked
57feff531c8e drm/i915: use might_lock_nested in get_pages annotation
-:81: WARNING:NO_AUTHOR_SIGN_OFF: Missing Signed-off-by: line by nominal patch author 'Daniel Vetter <[email protected]>'

total: 0 errors, 1 warnings, 0 checks, 51 lines checked

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

#15 lore raw

✓ Fi.CI.BAT: success for series starting with drm/i915: Switch obj->mm.lock lockdep annotations on its head (rev2)

In reply to Daniel Vetter
== Series Details ==

== Series Details ==

Series: series starting with drm/i915: Switch obj->mm.lock lockdep annotations on its head (rev2)
URL : https://patchwork.freedesktop.org/series/68956/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_7260 -> Patchwork_15125
====================================================

Summary
-------

**SUCCESS**

No regressions found.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/index.html

Known issues
------------

Here are the changes found in Patchwork_15125 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@gem_mmap_gtt@basic-write-gtt:
- fi-icl-u3: [PASS][1] -> [DMESG-WARN][2] ([fdo#107724])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/fi-icl-u3/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/fi-icl-u3/igt@[email protected]

* igt@kms_chamelium@hdmi-hpd-fast:
- fi-kbl-7500u: [PASS][3] -> [FAIL][4] ([fdo#111407])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/fi-kbl-7500u/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/fi-kbl-7500u/igt@[email protected]

#### Possible fixes ####

* igt@gem_mmap_gtt@basic-write-read-distinct:
- fi-icl-u3: [DMESG-WARN][5] ([fdo#107724]) -> [PASS][6]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/fi-icl-u3/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/fi-icl-u3/igt@[email protected]

* igt@i915_selftest@live_gem_contexts:
- fi-bsw-nick: [INCOMPLETE][7] ([fdo# 111542]) -> [PASS][8]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/fi-bsw-nick/igt@i915_selftest@live_gem_contexts.html
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/fi-bsw-nick/igt@i915_selftest@live_gem_contexts.html
- fi-bsw-kefka: [INCOMPLETE][9] ([fdo# 111542]) -> [PASS][10]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/fi-bsw-kefka/igt@i915_selftest@live_gem_contexts.html
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/fi-bsw-kefka/igt@i915_selftest@live_gem_contexts.html

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[fdo# 111542]: https://bugs.freedesktop.org/show_bug.cgi?id= 111542 [fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
[fdo#107724]: https://bugs.freedesktop.org/show_bug.cgi?id=107724
[fdo#111407]: https://bugs.freedesktop.org/show_bug.cgi?id=111407
[fdo#111880]: https://bugs.freedesktop.org/show_bug.cgi?id=111880
[fdo#111998]: https://bugs.freedesktop.org/show_bug.cgi?id=111998

Participating hosts (52 -> 44)
------------------------------

Missing (8): fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-bwr-2160 fi-ctg-p8600 fi-gdg-551 fi-byt-clapper

Build changes
-------------

* CI: CI-20190529 -> None
* Linux: CI_DRM_7260 -> Patchwork_15125

CI-20190529: 20190529
CI_DRM_7260: 14a672b77aed0ec7e7ae273750d80c261017f505 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_5262: 2d2fd6ce47b2eac83732c5c88cd0d7e5f13013a2 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_15125: 57feff531c8e72d9b4b2ceadfce2c0c968fd86cb @ git://anongit.freedesktop.org/gfx-ci/linux

== Linux commits ==

57feff531c8e drm/i915: use might_lock_nested in get_pages annotation 71463ddc096d lockdep: add might_lock_nested()
c1f4ce7bcff4 drm/i915: Switch obj->mm.lock lockdep annotations on its head

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/index.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#16 lore raw

✗ Fi.CI.IGT: failure for series starting with drm/i915: Switch obj->mm.lock lockdep annotations on its head (rev2)

In reply to Daniel Vetter
== Series Details ==

== Series Details ==

Series: series starting with drm/i915: Switch obj->mm.lock lockdep annotations on its head (rev2)
URL : https://patchwork.freedesktop.org/series/68956/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_7260_full -> Patchwork_15125_full
====================================================

Summary
-------

**FAILURE**

Serious unknown changes coming with Patchwork_15125_full absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in Patchwork_15125_full, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.

Possible new issues
-------------------

Here are the unknown changes that may have been introduced in Patchwork_15125_full:

### IGT changes ###

#### Possible regressions ####

* igt@debugfs_test@read_all_entries_display_on:
- shard-skl: [PASS][1] -> [DMESG-WARN][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-skl1/igt@debugfs_test@read_all_entries_display_on.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-skl2/igt@debugfs_test@read_all_entries_display_on.html

#### Suppressed ####

The following results come from untrusted machines, tests, or statuses. They do not affect the overall result.

* igt@kms_chamelium@hdmi-crc-bgr565:
- {shard-tglb}: [SKIP][3] ([fdo#111827 ]) -> [SKIP][4] +4 similar issues
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-tglb4/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-tglb9/igt@[email protected]

* igt@kms_content_protection@srm:
- {shard-tglb}: [SKIP][5] ([fdo#111828]) -> [SKIP][6] +1 similar issue
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-tglb7/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-tglb9/igt@[email protected]

* igt@kms_frontbuffer_tracking@fbc-2p-primscrn-cur-indfb-draw-mmap-cpu:
- {shard-tglb}: NOTRUN -> [SKIP][7] +2 similar issues
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-tglb9/igt@kms_frontbuffer_tracking@fbc-2p-primscrn-cur-indfb-draw-mmap-cpu.html

* igt@kms_frontbuffer_tracking@fbcpsr-2p-primscrn-cur-indfb-onoff:
- {shard-tglb}: [SKIP][8] ([fdo#111825]) -> [SKIP][9] +27 similar issues
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-tglb4/igt@[email protected]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-tglb9/igt@[email protected]

Known issues
------------

Here are the changes found in Patchwork_15125_full that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@gem_ctx_isolation@vcs1-none:
- shard-iclb: [PASS][10] -> [SKIP][11] ([fdo#109276] / [fdo#112080]) +2 similar issues
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-iclb1/igt@[email protected]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-iclb7/igt@[email protected]

* igt@gem_ctx_shared@exec-single-timeline-bsd:
- shard-iclb: [PASS][12] -> [SKIP][13] ([fdo#110841])
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-iclb3/igt@[email protected]
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-iclb4/igt@[email protected]

* igt@gem_ctx_switch@vcs1-heavy:
- shard-iclb: [PASS][14] -> [SKIP][15] ([fdo#112080]) +17 similar issues
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-iclb2/igt@[email protected]
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-iclb5/igt@[email protected]

* igt@gem_exec_schedule@preempt-other-chain-bsd:
- shard-iclb: [PASS][16] -> [SKIP][17] ([fdo#112146]) +4 similar issues
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-iclb6/igt@[email protected]
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-iclb2/igt@[email protected]

* igt@gem_exec_schedule@preempt-queue-bsd2:
- shard-iclb: [PASS][18] -> [SKIP][19] ([fdo#109276]) +16 similar issues
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-iclb2/igt@[email protected]
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-iclb5/igt@[email protected]

* igt@gem_exec_schedule@smoketest-all:
- shard-glk: [PASS][20] -> [INCOMPLETE][21] ([fdo#103359] / [k.org#198133])
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-glk4/igt@[email protected]
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-glk5/igt@[email protected]

* igt@gem_persistent_relocs@forked-interruptible-faulting-reloc-thrashing:
- shard-snb: [PASS][22] -> [TIMEOUT][23] ([fdo#112068 ])
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-snb2/igt@gem_persistent_relocs@forked-interruptible-faulting-reloc-thrashing.html
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-snb4/igt@gem_persistent_relocs@forked-interruptible-faulting-reloc-thrashing.html

* igt@gem_userptr_blits@map-fixed-invalidate-overlap-busy:
- shard-hsw: [PASS][24] -> [DMESG-WARN][25] ([fdo#111870])
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-hsw5/igt@[email protected]
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-hsw1/igt@[email protected]

* igt@gem_userptr_blits@sync-unmap-after-close:
- shard-snb: [PASS][26] -> [DMESG-WARN][27] ([fdo#111870]) +1 similar issue
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-snb6/igt@[email protected]
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-snb1/igt@[email protected]

* igt@gem_workarounds@suspend-resume:
- shard-skl: [PASS][28] -> [INCOMPLETE][29] ([fdo#104108])
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-skl10/igt@[email protected]
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-skl4/igt@[email protected]

* igt@gem_workarounds@suspend-resume-context:
- shard-apl: [PASS][30] -> [DMESG-WARN][31] ([fdo#108566]) +2 similar issues
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-apl3/igt@[email protected]
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-apl6/igt@[email protected]

* igt@i915_selftest@live_hangcheck:
- shard-hsw: [PASS][32] -> [DMESG-FAIL][33] ([fdo#111991])
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-hsw6/igt@i915_selftest@live_hangcheck.html
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-hsw1/igt@i915_selftest@live_hangcheck.html

* igt@kms_flip@flip-vs-expired-vblank-interruptible:
- shard-glk: [PASS][34] -> [FAIL][35] ([fdo#105363])
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-glk7/igt@[email protected]
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-glk6/igt@[email protected]

* igt@kms_flip@flip-vs-suspend-interruptible:
- shard-snb: [PASS][36] -> [INCOMPLETE][37] ([fdo#105411])
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-snb4/igt@[email protected]
[37]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-snb1/igt@[email protected]

* igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-cur-indfb-draw-render:
- shard-iclb: [PASS][38] -> [FAIL][39] ([fdo#103167]) +3 similar issues
[38]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-iclb7/igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-cur-indfb-draw-render.html
[39]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-iclb6/igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-cur-indfb-draw-render.html

* igt@kms_plane_alpha_blend@pipe-c-constant-alpha-min:
- shard-skl: [PASS][40] -> [FAIL][41] ([fdo#108145])
[40]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-skl10/igt@[email protected]
[41]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-skl9/igt@[email protected]

* igt@kms_psr2_su@page_flip:
- shard-iclb: [PASS][42] -> [SKIP][43] ([fdo#109642] / [fdo#111068])
[42]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-iclb2/igt@kms_psr2_su@page_flip.html
[43]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-iclb1/igt@kms_psr2_su@page_flip.html

* igt@kms_psr@psr2_primary_mmap_gtt:
- shard-iclb: [PASS][44] -> [SKIP][45] ([fdo#109441])
[44]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-iclb2/igt@kms_psr@psr2_primary_mmap_gtt.html
[45]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-iclb6/igt@kms_psr@psr2_primary_mmap_gtt.html

* igt@kms_setmode@basic:
- shard-hsw: [PASS][46] -> [FAIL][47] ([fdo#99912])
[46]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-hsw1/igt@[email protected]
[47]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-hsw4/igt@[email protected]

* igt@kms_vblank@pipe-a-ts-continuation-suspend:
- shard-kbl: [PASS][48] -> [DMESG-WARN][49] ([fdo#108566]) +5 similar issues
[48]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-kbl1/igt@[email protected]
[49]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-kbl4/igt@[email protected]

* igt@tools_test@tools_test:
- shard-skl: [PASS][50] -> [SKIP][51] ([fdo#109271])
[50]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-skl5/igt@tools_test@tools_test.html
[51]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-skl5/igt@tools_test@tools_test.html

#### Possible fixes ####

* igt@gem_ctx_exec@basic-invalid-context-vcs1:
- shard-iclb: [SKIP][52] ([fdo#112080]) -> [PASS][53] +11 similar issues
[52]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-iclb6/igt@[email protected]
[53]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-iclb2/igt@[email protected]

* {igt@gem_ctx_persistence@vcs1-mixed}:
- shard-iclb: [SKIP][54] ([fdo#109276] / [fdo#112080]) -> [PASS][55] +3 similar issues
[54]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-iclb6/igt@[email protected]
[55]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-iclb2/igt@[email protected]

* igt@gem_exec_balancer@smoke:
- shard-iclb: [SKIP][56] ([fdo#110854]) -> [PASS][57]
[56]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-iclb5/igt@[email protected]
[57]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-iclb1/igt@[email protected]

* igt@gem_exec_create@madvise:
- {shard-tglb}: [INCOMPLETE][58] ([fdo#111747]) -> [PASS][59]
[58]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-tglb9/igt@[email protected]
[59]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-tglb5/igt@[email protected]

* igt@gem_exec_schedule@in-order-bsd:
- shard-iclb: [SKIP][60] ([fdo#112146]) -> [PASS][61] +6 similar issues
[60]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-iclb4/igt@[email protected]
[61]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-iclb6/igt@[email protected]

* igt@gem_exec_schedule@independent-bsd2:
- shard-iclb: [SKIP][62] ([fdo#109276]) -> [PASS][63] +18 similar issues
[62]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-iclb6/igt@[email protected]
[63]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-iclb2/igt@[email protected]

* igt@gem_exec_schedule@preempt-queue-chain-blt:
- {shard-tglb}: [INCOMPLETE][64] ([fdo#111606] / [fdo#111677]) -> [PASS][65]
[64]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-tglb6/igt@[email protected]
[65]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-tglb3/igt@[email protected]

* igt@gem_exec_schedule@preempt-queue-contexts-chain-render:
- {shard-tglb}: [INCOMPLETE][66] ([fdo#111677]) -> [PASS][67]
[66]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-tglb6/igt@[email protected]
[67]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-tglb1/igt@[email protected]

* igt@gem_sync@basic-each:
- {shard-tglb}: [INCOMPLETE][68] ([fdo#111647] / [fdo#111998]) -> [PASS][69]
[68]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-tglb6/igt@[email protected]
[69]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-tglb3/igt@[email protected]

* igt@gem_userptr_blits@map-fixed-invalidate-busy:
- shard-snb: [DMESG-WARN][70] ([fdo#111870]) -> [PASS][71]
[70]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-snb4/igt@[email protected]
[71]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-snb2/igt@[email protected]

* igt@i915_selftest@live_requests:
- {shard-tglb}: [INCOMPLETE][72] ([fdo#112057]) -> [PASS][73]
[72]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-tglb6/igt@i915_selftest@live_requests.html
[73]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-tglb4/igt@i915_selftest@live_requests.html

* igt@kms_flip@flip-vs-expired-vblank-interruptible:
- shard-skl: [FAIL][74] ([fdo#105363]) -> [PASS][75]
[74]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-skl9/igt@[email protected]
[75]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-skl3/igt@[email protected]

* igt@kms_frontbuffer_tracking@fbc-1p-pri-indfb-multidraw:
- shard-iclb: [FAIL][76] ([fdo#103167]) -> [PASS][77] +4 similar issues
[76]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-iclb7/igt@[email protected]
[77]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-iclb4/igt@[email protected]

* igt@kms_frontbuffer_tracking@fbc-1p-primscrn-indfb-msflip-blt:
- {shard-tglb}: [FAIL][78] ([fdo#103167]) -> [PASS][79] +3 similar issues
[78]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-tglb6/igt@[email protected]
[79]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-tglb3/igt@[email protected]

* igt@kms_frontbuffer_tracking@fbc-suspend:
- shard-kbl: [DMESG-WARN][80] ([fdo#108566]) -> [PASS][81] +8 similar issues
[80]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-kbl4/igt@[email protected]
[81]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-kbl1/igt@[email protected]
- {shard-tglb}: [INCOMPLETE][82] ([fdo#111832] / [fdo#111850] / [fdo#111884]) -> [PASS][83]
[82]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-tglb4/igt@[email protected]
[83]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-tglb9/igt@[email protected]

* igt@kms_frontbuffer_tracking@psr-suspend:
- shard-iclb: [INCOMPLETE][84] ([fdo#106978] / [fdo#107713]) -> [PASS][85]
[84]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-iclb3/igt@[email protected]
[85]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-iclb3/igt@[email protected]

* igt@kms_plane@plane-panning-bottom-right-suspend-pipe-b-planes:
- shard-apl: [DMESG-WARN][86] ([fdo#108566]) -> [PASS][87] +1 similar issue
[86]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-apl6/igt@[email protected]
[87]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-apl8/igt@[email protected]

* igt@kms_plane_alpha_blend@pipe-a-coverage-7efc:
- shard-skl: [FAIL][88] ([fdo#108145]) -> [PASS][89]
[88]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-skl5/igt@[email protected]
[89]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-skl4/igt@[email protected]

* igt@kms_plane_alpha_blend@pipe-b-coverage-7efc:
- shard-skl: [FAIL][90] ([fdo#108145] / [fdo#110403]) -> [PASS][91]
[90]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-skl2/igt@[email protected]
[91]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-skl3/igt@[email protected]

* igt@kms_psr@psr2_primary_mmap_cpu:
- shard-iclb: [SKIP][92] ([fdo#109441]) -> [PASS][93] +2 similar issues
[92]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-iclb3/igt@kms_psr@psr2_primary_mmap_cpu.html
[93]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-iclb2/igt@kms_psr@psr2_primary_mmap_cpu.html

* igt@kms_vblank@pipe-a-ts-continuation-suspend:
- {shard-tglb}: [INCOMPLETE][94] ([fdo#111832] / [fdo#111850]) -> [PASS][95] +4 similar issues
[94]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-tglb7/igt@[email protected]
[95]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-tglb5/igt@[email protected]

#### Warnings ####

* igt@gem_ctx_isolation@vcs1-nonpriv:
- shard-iclb: [SKIP][96] ([fdo#109276] / [fdo#112080]) -> [FAIL][97] ([fdo#111329])
[96]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-iclb3/igt@[email protected]
[97]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-iclb2/igt@[email protected]

* igt@gem_mocs_settings@mocs-isolation-bsd2:
- shard-iclb: [SKIP][98] ([fdo#109276]) -> [FAIL][99] ([fdo#111330]) +1 similar issue
[98]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-iclb3/igt@[email protected]
[99]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-iclb4/igt@[email protected]

* igt@gem_mocs_settings@mocs-reset-bsd2:
- shard-iclb: [FAIL][100] ([fdo#111330]) -> [SKIP][101] ([fdo#109276])
[100]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7260/shard-iclb4/igt@[email protected]
[101]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/shard-iclb6/igt@[email protected]

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_15125/index.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#17 lore raw
In reply to Daniel Vetter
Quoted 14 lines
drivers/gpu/drm/i915/gem/i915_gem_object.c +2 -0
@@ -22,6 +22,8 @@
  *
  */
 
+#include <linux/sched/mm.h>
+
 #include "display/intel_frontbuffer.h"
 #include "gt/intel_gt.h"
 #include "i915_drv.h"
@@ -52,6 +54,14 @@ void i915_gem_object_init(struct
 drm_i915_gem_object *obj,  {
 	__mutex_init(&obj->mm.lock, "obj->mm.lock", key);

drivers/gpu/drm/i915/gem/i915_gem_object.c void i915_gem_object_init(struct · line 65

Quoted 10 lines
drivers/gpu/drm/i915/gem/i915_gem_object.c +8 -0
 
+	if (IS_ENABLED(CONFIG_LOCKDEP)) {
+		mutex_lock_nested(&obj->mm.lock,
 I915_MM_GET_PAGES);
+		fs_reclaim_acquire(GFP_KERNEL);
+		might_lock(&obj->mm.lock);
+		fs_reclaim_release(GFP_KERNEL);
+		mutex_unlock(&obj->mm.lock);
+	}
+

I looked the upstream code in drm-tip, I see other changes but not above. Is this correct?

--CQ

Quoted 278 lines
drivers/gpu/drm/i915/gem/i915_gem_object.c +1 -1
 	spin_lock_init(&obj->vma.lock);
 	INIT_LIST_HEAD(&obj->vma.list);
@@ -186,7 +196,7 @@ static void __i915_gem_free_objects(struct
 drm_i915_private *i915,
 		GEM_BUG_ON(!list_empty(&obj->lut_list));
 
 		atomic_set(&obj->mm.pages_pin_count, 0);
-		__i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+		__i915_gem_object_put_pages(obj);
 		GEM_BUG_ON(i915_gem_object_has_pages(obj));
 		bitmap_free(obj->bit_17);
drivers/gpu/drm/i915/gem/i915_gem_object.h +0 -0
index 458cd51331f1..edaf7126a84d 100644
@@ -319,11 +319,22 @@ i915_gem_object_unpin_pages(struct
 drm_i915_gem_object *obj)
 
 enum i915_mm_subclass { /* lockdep subclass for obj-
Quoted 1 line

mm.lock/struct_mutex */

drivers/gpu/drm/i915/gem/i915_gem_object.h +0 -1
 	I915_MM_NORMAL = 0,
-	I915_MM_SHRINKER /* called "recursively" from direct-reclaim-

esque */

drivers/gpu/drm/i915/gem/i915_gem_object.h +8 -0
+	/*
+	 * Only used by struct_mutex, when called "recursively" from
+	 * direct-reclaim-esque. Safe because there is only every one
+	 * struct_mutex in the entire system.
+	 */
+	I915_MM_SHRINKER = 1,
+	/*
+	 * Used for obj->mm.lock when allocating pages. Safe because the

object

drivers/gpu/drm/i915/gem/i915_gem_object.h +6 -2
+	 * isn't yet on any LRU, and therefore the shrinker can't deadlock on
+	 * it. As soon as the object has pages, obj->mm.lock nests within
+	 * fs_reclaim.
+	 */
+	I915_MM_GET_PAGES = 1,
 };
 
-int __i915_gem_object_put_pages(struct drm_i915_gem_object *obj,
-				enum i915_mm_subclass subclass);
+int __i915_gem_object_put_pages(struct drm_i915_gem_object *obj);
 void i915_gem_object_truncate(struct drm_i915_gem_object *obj);  void

i915_gem_object_writeback(struct drm_i915_gem_object *obj);

drivers/gpu/drm/i915/gem/i915_gem_object_types.h +5 -1
index 96008374a412..15f8297dc34e 100644
@@ -162,7 +162,11 @@ struct drm_i915_gem_object {
 	atomic_t bind_count;
 
 	struct {
-		struct mutex lock; /* protects the pages and their use */
+		/*
+		 * Protects the pages and their use. Do not use directly, but
+		 * instead go through the pin/unpin interfaces.
+		 */
+		struct mutex lock;
 		atomic_t pages_pin_count;
 		atomic_t shrink_pin;
 
drivers/gpu/drm/i915/gem/i915_gem_pages.c +3 -3
index 29f4c2850745..f402c2c415c2 100644
@@ -106,7 +106,7 @@ int __i915_gem_object_get_pages(struct
 drm_i915_gem_object *obj)  {
 	int err;
 
-	err = mutex_lock_interruptible(&obj->mm.lock);
+	err = mutex_lock_interruptible_nested(&obj->mm.lock,
+I915_MM_GET_PAGES);
 	if (err)
 		return err;
@@ -190,8 +190,7 @@ __i915_gem_object_unset_pages(struct
 drm_i915_gem_object *obj)
 	return pages;
 }
 
-int __i915_gem_object_put_pages(struct drm_i915_gem_object *obj,
-				enum i915_mm_subclass subclass)
+int __i915_gem_object_put_pages(struct drm_i915_gem_object *obj)
 {
 	struct sg_table *pages;
drivers/gpu/drm/i915/gem/i915_gem_pages.c +1 -1
 	int err;
@@ -202,7 +201,7 @@ int __i915_gem_object_put_pages(struct
 drm_i915_gem_object *obj,
 	GEM_BUG_ON(atomic_read(&obj->bind_count));
 
 	/* May be called by shrinker from within get_pages() (on another bo)
 */
-	mutex_lock_nested(&obj->mm.lock, subclass);
+	mutex_lock(&obj->mm.lock);
 	if (unlikely(atomic_read(&obj->mm.pages_pin_count))) {
drivers/gpu/drm/i915/gem/i915_gem_pages.c +2 -1
 		err = -EBUSY;
 		goto unlock;
@@ -308,7 +307,7 @@ void *i915_gem_object_pin_map(struct
 drm_i915_gem_object *obj,
 	if (!i915_gem_object_type_has(obj, flags))
 		return ERR_PTR(-ENXIO);
 
-	err = mutex_lock_interruptible(&obj->mm.lock);
+	err = mutex_lock_interruptible_nested(&obj->mm.lock,
+I915_MM_GET_PAGES);
 	if (err)
 		return ERR_PTR(err);
drivers/gpu/drm/i915/gem/i915_gem_phys.c +1 -1
index 8043ff63d73f..b1b7c1b3038a 100644
@@ -164,7 +164,7 @@ int i915_gem_object_attach_phys(struct
 drm_i915_gem_object *obj, int align)
 	if (err)
 		return err;
 
-	mutex_lock(&obj->mm.lock);
+	mutex_lock_nested(&obj->mm.lock, I915_MM_GET_PAGES);
 
 	if (obj->mm.madv != I915_MADV_WILLNEED) {
drivers/gpu/drm/i915/gem/i915_gem_phys.c +0 -0
 		err = -EFAULT;
drivers/gpu/drm/i915/gem/i915_gem_shrinker.c +1 -1
index fd3ce6da8497..066b3df677e8 100644
@@ -57,7 +57,7 @@ static bool unsafe_drop_pages(struct
 drm_i915_gem_object *obj,
 		flags = I915_GEM_OBJECT_UNBIND_ACTIVE;
 
 	if (i915_gem_object_unbind(obj, flags) == 0)
-		__i915_gem_object_put_pages(obj, I915_MM_SHRINKER);
+		__i915_gem_object_put_pages(obj);
 
 	return !i915_gem_object_has_pages(obj);  } @@ -209,8 +209,7 @@

i915_gem_shrink(struct drm_i915_private *i915,

drivers/gpu/drm/i915/gem/i915_gem_shrinker.c +0 -0
 			if (unsafe_drop_pages(obj, shrink)) {
 				/* May arrive from get_pages on another bo

*/

drivers/gpu/drm/i915/gem/i915_gem_shrinker.c +1 -2
-				mutex_lock_nested(&obj->mm.lock,
-						  I915_MM_SHRINKER);
+				mutex_lock(&obj->mm.lock);
 				if (!i915_gem_object_has_pages(obj)) {
 					try_to_writeback(obj, shrink);
 					count += obj->base.size >>

PAGE_SHIFT; diff --git a/drivers/gpu/drm/i915/gem/i915_gem_userptr.c b/drivers/gpu/drm/i915/gem/i915_gem_userptr.c
index 1e045c337044..ee65c6acf0e2 100644

drivers/gpu/drm/i915/gem/i915_gem_userptr.c +1 -1
@@ -131,7 +131,7 @@ userptr_mn_invalidate_range_start(struct
 mmu_notifier *_mn,
 		ret = i915_gem_object_unbind(obj,
 
 I915_GEM_OBJECT_UNBIND_ACTIVE);
 		if (ret == 0)
-			ret = __i915_gem_object_put_pages(obj,
 I915_MM_SHRINKER);
+			ret = __i915_gem_object_put_pages(obj);
drivers/gpu/drm/i915/gem/i915_gem_userptr.c +1 -1
 		i915_gem_object_put(obj);
 		if (ret)
 			return ret;
@@ -483,7 +483,7 @@ __i915_gem_userptr_get_pages_worker(struct
 work_struct *_work)
 		}
 	}
 
-	mutex_lock(&obj->mm.lock);
+	mutex_lock_nested(&obj->mm.lock, I915_MM_GET_PAGES);
 	if (obj->userptr.work == &work->work) {
 		struct sg_table *pages = ERR_PTR(ret);
drivers/gpu/drm/i915/gem/selftests/huge_pages.c +1 -1
index 688c49a24f32..5c9583349077 100644
@@ -517,7 +517,7 @@ static int
 igt_mock_memory_region_huge_pages(void *arg)
 			i915_vma_unpin(vma);
 			i915_vma_close(vma);
 
-			__i915_gem_object_put_pages(obj,
 I915_MM_NORMAL);
+			__i915_gem_object_put_pages(obj);
 			i915_gem_object_put(obj);
drivers/gpu/drm/i915/gem/selftests/huge_pages.c +3 -3
 		}
 	}
@@ -650,7 +650,7 @@ static int igt_mock_ppgtt_misaligned_dma(void *arg)
 		i915_vma_close(vma);
 
 		i915_gem_object_unpin_pages(obj);
-		__i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+		__i915_gem_object_put_pages(obj);
 		i915_gem_object_put(obj);
 	}
 
@@ -678,7 +678,7 @@ static void close_object_list(struct list_head *objects,
 
 		list_del(&obj->st_link);
 		i915_gem_object_unpin_pages(obj);
-		__i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+		__i915_gem_object_put_pages(obj);
 		i915_gem_object_put(obj);
 	}
 }
@@ -948,7 +948,7 @@ static int igt_mock_ppgtt_64K(void *arg)
 			i915_vma_close(vma);
 
 			i915_gem_object_unpin_pages(obj);
-			__i915_gem_object_put_pages(obj,
 I915_MM_NORMAL);
+			__i915_gem_object_put_pages(obj);
 			i915_gem_object_put(obj);
 		}
drivers/gpu/drm/i915/gem/selftests/huge_pages.c +1 -1
 	}
@@ -1301,7 +1301,7 @@ static int igt_ppgtt_exhaust_huge(void *arg)
 			}
 
 			i915_gem_object_unpin_pages(obj);
-			__i915_gem_object_put_pages(obj,
 I915_MM_NORMAL);
+			__i915_gem_object_put_pages(obj);
 			i915_gem_object_put(obj);
 		}
drivers/gpu/drm/i915/gem/selftests/huge_pages.c +2 -2
 	}
@@ -1442,7 +1442,7 @@ static int igt_ppgtt_smoke_huge(void *arg)
 		}
 out_unpin:
 		i915_gem_object_unpin_pages(obj);
-		__i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+		__i915_gem_object_put_pages(obj);
 out_put:
 		i915_gem_object_put(obj);
 
@@ -1530,7 +1530,7 @@ static int igt_ppgtt_sanity_check(void *arg)
 			err = igt_write_huge(ctx, obj);
 
 			i915_gem_object_unpin_pages(obj);
-			__i915_gem_object_put_pages(obj,
 I915_MM_NORMAL);
+			__i915_gem_object_put_pages(obj);
 			i915_gem_object_put(obj);
 
drivers/gpu/drm/i915/gem/selftests/huge_pages.c +0 -0
 			if (err) {
drivers/gpu/drm/i915/selftests/intel_memory_region.c +1 -1
index 19e1cca8f143..95d609abd39b 100644
@@ -32,7 +32,7 @@ static void close_objects(struct intel_memory_region
 *mem,
 		if (i915_gem_object_has_pinned_pages(obj))
 			i915_gem_object_unpin_pages(obj);
 		/* No polluting the memory region between tests */
-		__i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+		__i915_gem_object_put_pages(obj);
 		list_del(&obj->st_link);
 		i915_gem_object_put(obj);
drivers/gpu/drm/i915/selftests/intel_memory_region.c +1 -2
 	}
@@ -122,7 +122,7 @@ igt_object_create(struct intel_memory_region *mem,
 static void igt_object_release(struct drm_i915_gem_object *obj)  {
 	i915_gem_object_unpin_pages(obj);
-	__i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+	__i915_gem_object_put_pages(obj);
 	list_del(&obj->st_link);
 	i915_gem_object_put(obj);
 }
--
Quoted 1 line

2.24.0.rc2

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

#18 lore raw
Quoted 16 lines · CQ
Quoted 16 lines
drivers/gpu/drm/i915/gem/i915_gem_object.c +2 -0
@@ -22,6 +22,8 @@
  *
  */
 
+#include <linux/sched/mm.h>
+
 #include "display/intel_frontbuffer.h"
 #include "gt/intel_gt.h"
 #include "i915_drv.h"
@@ -52,6 +54,14 @@ void i915_gem_object_init(struct
 drm_i915_gem_object *obj,  {
      __mutex_init(&obj->mm.lock, "obj->mm.lock", key);
 
Quoted 11 lines

drivers/gpu/drm/i915/gem/i915_gem_object.c void i915_gem_object_init(struct drm_i915_gem_object *obj, · line 64

Quoted 9 lines
drivers/gpu/drm/i915/gem/i915_gem_object.c +8 -0
+     if (IS_ENABLED(CONFIG_LOCKDEP)) {
+             mutex_lock_nested(&obj->mm.lock,
 I915_MM_GET_PAGES);
+             fs_reclaim_acquire(GFP_KERNEL);
+             might_lock(&obj->mm.lock);
+             fs_reclaim_release(GFP_KERNEL);
+             mutex_unlock(&obj->mm.lock);
+     }
+

I looked the upstream code in drm-tip, I see other changes but not above. Is this correct?

Yeah I had to drop this because the lmem code breaks this. It allocates memory while holding memory manager locks, which in turn depend upon obj->mm.lock. That already blew up a bit, and got papered over by splitting up the lock classes. As a temporary measure only (I hope at least). I still have this as a patch locally, so once the lmem locking is sorted I can submit it, so it's not lost. -Daniel

Quoted 284 lines

--CQ

Quoted 279 lines
drivers/gpu/drm/i915/gem/i915_gem_object.c +1 -1
      spin_lock_init(&obj->vma.lock);
      INIT_LIST_HEAD(&obj->vma.list);
@@ -186,7 +196,7 @@ static void __i915_gem_free_objects(struct
 drm_i915_private *i915,
              GEM_BUG_ON(!list_empty(&obj->lut_list));
 
              atomic_set(&obj->mm.pages_pin_count, 0);
-             __i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+             __i915_gem_object_put_pages(obj);
              GEM_BUG_ON(i915_gem_object_has_pages(obj));
              bitmap_free(obj->bit_17);
drivers/gpu/drm/i915/gem/i915_gem_object.h +0 -0
index 458cd51331f1..edaf7126a84d 100644
@@ -319,11 +319,22 @@ i915_gem_object_unpin_pages(struct
 drm_i915_gem_object *obj)
 
 enum i915_mm_subclass { /* lockdep subclass for obj-
Quoted 1 line

mm.lock/struct_mutex */

      I915_MM_NORMAL = 0,

- I915_MM_SHRINKER /* called "recursively" from direct-reclaim-
esque */

drivers/gpu/drm/i915/gem/i915_gem_object.h +8 -0
+     /*
+      * Only used by struct_mutex, when called "recursively" from
+      * direct-reclaim-esque. Safe because there is only every one
+      * struct_mutex in the entire system.
+      */
+     I915_MM_SHRINKER = 1,
+     /*
+      * Used for obj->mm.lock when allocating pages. Safe because the

object

drivers/gpu/drm/i915/gem/i915_gem_object.h +6 -2
+      * isn't yet on any LRU, and therefore the shrinker can't deadlock on
+      * it. As soon as the object has pages, obj->mm.lock nests within
+      * fs_reclaim.
+      */
+     I915_MM_GET_PAGES = 1,
 };
 
-int __i915_gem_object_put_pages(struct drm_i915_gem_object *obj,
-                             enum i915_mm_subclass subclass);
+int __i915_gem_object_put_pages(struct drm_i915_gem_object *obj);
 void i915_gem_object_truncate(struct drm_i915_gem_object *obj);  void

i915_gem_object_writeback(struct drm_i915_gem_object *obj);

drivers/gpu/drm/i915/gem/i915_gem_object_types.h +5 -1
index 96008374a412..15f8297dc34e 100644
@@ -162,7 +162,11 @@ struct drm_i915_gem_object {
      atomic_t bind_count;
 
      struct {
-             struct mutex lock; /* protects the pages and their use */
+             /*
+              * Protects the pages and their use. Do not use directly, but
+              * instead go through the pin/unpin interfaces.
+              */
+             struct mutex lock;
              atomic_t pages_pin_count;
              atomic_t shrink_pin;
 
drivers/gpu/drm/i915/gem/i915_gem_pages.c +3 -3
index 29f4c2850745..f402c2c415c2 100644
@@ -106,7 +106,7 @@ int __i915_gem_object_get_pages(struct
 drm_i915_gem_object *obj)  {
      int err;
 
-     err = mutex_lock_interruptible(&obj->mm.lock);
+     err = mutex_lock_interruptible_nested(&obj->mm.lock,
+I915_MM_GET_PAGES);
      if (err)
              return err;
@@ -190,8 +190,7 @@ __i915_gem_object_unset_pages(struct
 drm_i915_gem_object *obj)
      return pages;
 }
 
-int __i915_gem_object_put_pages(struct drm_i915_gem_object *obj,
-                             enum i915_mm_subclass subclass)
+int __i915_gem_object_put_pages(struct drm_i915_gem_object *obj)
 {
      struct sg_table *pages;
      int err;
drivers/gpu/drm/i915/gem/i915_gem_pages.c +1 -1
@@ -202,7 +201,7 @@ int __i915_gem_object_put_pages(struct
 drm_i915_gem_object *obj,
      GEM_BUG_ON(atomic_read(&obj->bind_count));
 
      /* May be called by shrinker from within get_pages() (on another bo)
 */
-     mutex_lock_nested(&obj->mm.lock, subclass);
+     mutex_lock(&obj->mm.lock);
      if (unlikely(atomic_read(&obj->mm.pages_pin_count))) {
              err = -EBUSY;
              goto unlock;
drivers/gpu/drm/i915/gem/i915_gem_pages.c +2 -1
@@ -308,7 +307,7 @@ void *i915_gem_object_pin_map(struct
 drm_i915_gem_object *obj,
      if (!i915_gem_object_type_has(obj, flags))
              return ERR_PTR(-ENXIO);
 
-     err = mutex_lock_interruptible(&obj->mm.lock);
+     err = mutex_lock_interruptible_nested(&obj->mm.lock,
+I915_MM_GET_PAGES);
      if (err)
              return ERR_PTR(err);
drivers/gpu/drm/i915/gem/i915_gem_phys.c +1 -1
index 8043ff63d73f..b1b7c1b3038a 100644
@@ -164,7 +164,7 @@ int i915_gem_object_attach_phys(struct
 drm_i915_gem_object *obj, int align)
      if (err)
              return err;
 
-     mutex_lock(&obj->mm.lock);
+     mutex_lock_nested(&obj->mm.lock, I915_MM_GET_PAGES);
 
      if (obj->mm.madv != I915_MADV_WILLNEED) {
              err = -EFAULT;
drivers/gpu/drm/i915/gem/i915_gem_shrinker.c +1 -1
index fd3ce6da8497..066b3df677e8 100644
@@ -57,7 +57,7 @@ static bool unsafe_drop_pages(struct
 drm_i915_gem_object *obj,
              flags = I915_GEM_OBJECT_UNBIND_ACTIVE;
 
      if (i915_gem_object_unbind(obj, flags) == 0)
-             __i915_gem_object_put_pages(obj, I915_MM_SHRINKER);
+             __i915_gem_object_put_pages(obj);
 
      return !i915_gem_object_has_pages(obj);  } @@ -209,8 +209,7 @@

i915_gem_shrink(struct drm_i915_private *i915,

                      if (unsafe_drop_pages(obj, shrink)) {
                              /* May arrive from get_pages on another bo

*/

drivers/gpu/drm/i915/gem/i915_gem_shrinker.c +1 -2
-                             mutex_lock_nested(&obj->mm.lock,
-                                               I915_MM_SHRINKER);
+                             mutex_lock(&obj->mm.lock);
                              if (!i915_gem_object_has_pages(obj)) {
                                      try_to_writeback(obj, shrink);
                                      count += obj->base.size >>

PAGE_SHIFT; diff --git a/drivers/gpu/drm/i915/gem/i915_gem_userptr.c b/drivers/gpu/drm/i915/gem/i915_gem_userptr.c
index 1e045c337044..ee65c6acf0e2 100644

drivers/gpu/drm/i915/gem/i915_gem_userptr.c +1 -1
@@ -131,7 +131,7 @@ userptr_mn_invalidate_range_start(struct
 mmu_notifier *_mn,
              ret = i915_gem_object_unbind(obj,
 
 I915_GEM_OBJECT_UNBIND_ACTIVE);
              if (ret == 0)
-                     ret = __i915_gem_object_put_pages(obj,
 I915_MM_SHRINKER);
+                     ret = __i915_gem_object_put_pages(obj);
              i915_gem_object_put(obj);
              if (ret)
                      return ret;
drivers/gpu/drm/i915/gem/i915_gem_userptr.c +1 -1
@@ -483,7 +483,7 @@ __i915_gem_userptr_get_pages_worker(struct
 work_struct *_work)
              }
      }
 
-     mutex_lock(&obj->mm.lock);
+     mutex_lock_nested(&obj->mm.lock, I915_MM_GET_PAGES);
      if (obj->userptr.work == &work->work) {
              struct sg_table *pages = ERR_PTR(ret);
drivers/gpu/drm/i915/gem/selftests/huge_pages.c +1 -1
index 688c49a24f32..5c9583349077 100644
@@ -517,7 +517,7 @@ static int
 igt_mock_memory_region_huge_pages(void *arg)
                      i915_vma_unpin(vma);
                      i915_vma_close(vma);
 
-                     __i915_gem_object_put_pages(obj,
 I915_MM_NORMAL);
+                     __i915_gem_object_put_pages(obj);
                      i915_gem_object_put(obj);
              }
      }
drivers/gpu/drm/i915/gem/selftests/huge_pages.c +3 -3
@@ -650,7 +650,7 @@ static int igt_mock_ppgtt_misaligned_dma(void *arg)
              i915_vma_close(vma);
 
              i915_gem_object_unpin_pages(obj);
-             __i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+             __i915_gem_object_put_pages(obj);
              i915_gem_object_put(obj);
      }
 
@@ -678,7 +678,7 @@ static void close_object_list(struct list_head *objects,
 
              list_del(&obj->st_link);
              i915_gem_object_unpin_pages(obj);
-             __i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+             __i915_gem_object_put_pages(obj);
              i915_gem_object_put(obj);
      }
 }
@@ -948,7 +948,7 @@ static int igt_mock_ppgtt_64K(void *arg)
                      i915_vma_close(vma);
 
                      i915_gem_object_unpin_pages(obj);
-                     __i915_gem_object_put_pages(obj,
 I915_MM_NORMAL);
+                     __i915_gem_object_put_pages(obj);
                      i915_gem_object_put(obj);
              }
      }
drivers/gpu/drm/i915/gem/selftests/huge_pages.c +1 -1
@@ -1301,7 +1301,7 @@ static int igt_ppgtt_exhaust_huge(void *arg)
                      }
 
                      i915_gem_object_unpin_pages(obj);
-                     __i915_gem_object_put_pages(obj,
 I915_MM_NORMAL);
+                     __i915_gem_object_put_pages(obj);
                      i915_gem_object_put(obj);
              }
      }
drivers/gpu/drm/i915/gem/selftests/huge_pages.c +2 -2
@@ -1442,7 +1442,7 @@ static int igt_ppgtt_smoke_huge(void *arg)
              }
 out_unpin:
              i915_gem_object_unpin_pages(obj);
-             __i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+             __i915_gem_object_put_pages(obj);
 out_put:
              i915_gem_object_put(obj);
 
@@ -1530,7 +1530,7 @@ static int igt_ppgtt_sanity_check(void *arg)
                      err = igt_write_huge(ctx, obj);
 
                      i915_gem_object_unpin_pages(obj);
-                     __i915_gem_object_put_pages(obj,
 I915_MM_NORMAL);
+                     __i915_gem_object_put_pages(obj);
                      i915_gem_object_put(obj);
 
                      if (err) {
drivers/gpu/drm/i915/selftests/intel_memory_region.c +1 -1
index 19e1cca8f143..95d609abd39b 100644
@@ -32,7 +32,7 @@ static void close_objects(struct intel_memory_region
 *mem,
              if (i915_gem_object_has_pinned_pages(obj))
                      i915_gem_object_unpin_pages(obj);
              /* No polluting the memory region between tests */
-             __i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+             __i915_gem_object_put_pages(obj);
              list_del(&obj->st_link);
              i915_gem_object_put(obj);
      }
drivers/gpu/drm/i915/selftests/intel_memory_region.c +1 -2
@@ -122,7 +122,7 @@ igt_object_create(struct intel_memory_region *mem,
 static void igt_object_release(struct drm_i915_gem_object *obj)  {
      i915_gem_object_unpin_pages(obj);
-     __i915_gem_object_put_pages(obj, I915_MM_NORMAL);
+     __i915_gem_object_put_pages(obj);
      list_del(&obj->st_link);
      i915_gem_object_put(obj);
 }
--

2.24.0.rc2

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx