Skip to contentSkip to conversation

mm: Check if mmu notifier callbacks are allowed to fail

PATCH In review Daniel Vetter 5 participants 21 messages May 20, 2019 – Jun 19, 2019

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

PATCH 1/4 mm: Check if mmu notifier callbacks are allowed to fail

Just a bit of paranoia, since if we start pushing this deep into callchains it's hard to spot all places where an mmu notifier implementation might fail when it's not allowed to.

Inspired by some confusion we had discussing i915 mmu notifiers and whether we could use the newly-introduced return value to handle some corner cases. Until we realized that these are only for when a task has been killed by the oom reaper.

An alternative approach would be to split the callback into two versions, one with the int return value, and the other with void return value like in older kernels. But that's a lot more churn for fairly little gain I think.

Summary from the m-l discussion on why we want something at warning
level: This allows automated tooling in CI to catch bugs without humans having to look at everything. If we just upgrade the existing pr_info to a pr_warn, then we'll have false positives. And as-is, no one will ever spot the problem since it's lost in the massive amounts of overall dmesg noise.

v2: Drop the full WARN_ON backtrace in favour of just a pr_warn for the problematic case (Michal Hocko).

v3: Rebase on top of Glisse's arg rework.

v4: More rebase on top of Glisse reworking everything.

Cc Andrew Morton <[email protected]>
Cc Michal Hocko <[email protected]>
Cc "Christian König" <[email protected]>
Cc David Rientjes <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc "Jérôme Glisse" <[email protected]>
Cc Paolo Bonzini <[email protected]>
---
 mm/mmu_notifier.c | 3 +++
 1 file changed, 3 insertions(+)
mm/mmu_notifier.c +3 -0
index ee36068077b6..c05e406a7cd7 100644
@@ -181,6 +181,9 @@ int __mmu_notifier_invalidate_range_start(struct mmu_notifier_range *range)
 				pr_info("%pS callback failed with %d in %sblockable context.\n",
 					mn->ops->invalidate_range_start, _ret,
 					!mmu_notifier_range_blockable(range) ? "non-" : "");
+				if (!mmu_notifier_range_blockable(range))
+					pr_warn("%pS callback failure not allowed\n",
+						mn->ops->invalidate_range_start);
 				ret = _ret;
 			}
 		}
Signature · 1 line
2.20.1
#1 lore raw

PATCH 2/4 kernel.h: Add non_block_start/end()

In some special cases we must not block, but there's not a spinlock, preempt-off, irqs-off or similar critical section already that arms the might_sleep() debug checks. Add a non_block_start/end() pair to annotate these.

This will be used in the oom paths of mmu-notifiers, where blocking is not allowed to make sure there's forward progress. Quoting Michal:

"The notifier is called from quite a restricted context - oom_reaper - which shouldn't depend on any locks or sleepable conditionals. The code should be swift as well but we mostly do care about it to make a forward progress. Checking for sleepable context is the best thing we could come up with that would describe these demands at least partially."

Peter also asked whether we want to catch spinlocks on top, but Michal said those are less of a problem because spinlocks can't have an indirect dependency upon the page allocator and hence close the loop with the oom reaper.

Suggested by Michal Hocko.

v2:
- Improve commit message (Michal)
- Also check in schedule, not just might_sleep (Peter)

Cc Peter Zijlstra <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Michal Hocko <[email protected]>
Cc David Rientjes <[email protected]>
Cc "Christian König" <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc "Jérôme Glisse" <[email protected]>
Cc Masahiro Yamada <[email protected]>
Cc Wei Wang <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Jann Horn <[email protected]>
Cc Feng Tang <[email protected]>
Cc Kees Cook <[email protected]>
Cc Randy Dunlap <[email protected]>
---
 include/linux/kernel.h | 10 +++++++++-
 include/linux/sched.h  |  4 ++++
 kernel/sched/core.c    | 19 ++++++++++++++-----
 3 files changed, 27 insertions(+), 6 deletions(-)
include/linux/kernel.h +9 -1
index 74b1ee9027f5..b5f2c2ff0eab 100644
@@ -214,7 +214,9 @@ extern void __cant_sleep(const char *file, int line, int preempt_offset);
  * might_sleep - annotation for functions that can sleep
  *
  * this macro will print a stack trace if it is executed in an atomic
- * context (spinlock, irq-handler, ...).
+ * context (spinlock, irq-handler, ...). Additional sections where blocking is
+ * not allowed can be annotated with non_block_start() and non_block_end()
+ * pairs.
  *
  * This is a useful debugging help to be able to catch problems early and not
  * be bitten later when the calling function happens to sleep when it is not
@@ -230,6 +232,10 @@ extern void __cant_sleep(const char *file, int line, int preempt_offset);
 # define cant_sleep() \
 	do { __cant_sleep(__FILE__, __LINE__, 0); } while (0)
 # define sched_annotate_sleep()	(current->task_state_change = 0)
+# define non_block_start() \
+	do { current->non_block_count++; } while (0)
+# define non_block_end() \
+	do { WARN_ON(current->non_block_count-- == 0); } while (0)
 #else
   static inline void ___might_sleep(const char *file, int line,
 				   int preempt_offset) { }
@@ -238,6 +244,8 @@ extern void __cant_sleep(const char *file, int line, int preempt_offset);
 # define might_sleep() do { might_resched(); } while (0)
 # define cant_sleep() do { } while (0)
 # define sched_annotate_sleep() do { } while (0)
+# define non_block_start() do { } while (0)
+# define non_block_end() do { } while (0)
 #endif
 
 #define might_sleep_if(cond) do { if (cond) might_sleep(); } while (0)
include/linux/sched.h +4 -0
index 11837410690f..7f5b293e72df 100644
@@ -908,6 +908,10 @@ struct task_struct {
 	struct mutex_waiter		*blocked_on;
 #endif
 
+#ifdef CONFIG_DEBUG_ATOMIC_SLEEP
+	int				non_block_count;
+#endif
+
 #ifdef CONFIG_TRACE_IRQFLAGS
 	unsigned int			irq_events;
 	unsigned long			hardirq_enable_ip;
kernel/sched/core.c +14 -5
index 102dfcf0a29a..dd08d423947d 100644
@@ -3264,13 +3264,22 @@ static noinline void __schedule_bug(struct task_struct *prev)
 /*
  * Various schedule()-time debugging checks and statistics:
  */
-static inline void schedule_debug(struct task_struct *prev)
+static inline void schedule_debug(struct task_struct *prev, bool preempt)
 {
 #ifdef CONFIG_SCHED_STACK_END_CHECK
 	if (task_stack_end_corrupted(prev))
 		panic("corrupted stack end detected inside scheduler\n");
 #endif
 
+#ifdef CONFIG_DEBUG_ATOMIC_SLEEP
+	if (!preempt && prev->state && prev->non_block_count) {
+		printk(KERN_ERR "BUG: scheduling in a non-blocking section: %s/%d/%i\n",
+			prev->comm, prev->pid, prev->non_blocking_count);
+		dump_stack();
+		add_taint(TAINT_WARN, LOCKDEP_STILL_OK);
+	}
+#endif
+
 	if (unlikely(in_atomic_preempt_off())) {
 		__schedule_bug(prev);
 		preempt_count_set(PREEMPT_DISABLED);
@@ -3377,7 +3386,7 @@ static void __sched notrace __schedule(bool preempt)
 	rq = cpu_rq(cpu);
 	prev = rq->curr;
 
-	schedule_debug(prev);
+	schedule_debug(prev, preempt);
 
 	if (sched_feat(HRTICK))
 		hrtick_clear(rq);
@@ -6102,7 +6111,7 @@ void ___might_sleep(const char *file, int line, int preempt_offset)
 	rcu_sleep_check();
 
 	if ((preempt_count_equals(preempt_offset) && !irqs_disabled() &&
-	     !is_idle_task(current)) ||
+	     !is_idle_task(current) && !current->non_block_count) ||
 	    system_state == SYSTEM_BOOTING || system_state > SYSTEM_RUNNING ||
 	    oops_in_progress)
 		return;
@@ -6118,8 +6127,8 @@ void ___might_sleep(const char *file, int line, int preempt_offset)
 		"BUG: sleeping function called from invalid context at %s:%d\n",
 			file, line);
 	printk(KERN_ERR
-		"in_atomic(): %d, irqs_disabled(): %d, pid: %d, name: %s\n",
-			in_atomic(), irqs_disabled(),
+		"in_atomic(): %d, irqs_disabled(): %d, non_block: %d, pid: %d, name: %s\n",
+			in_atomic(), irqs_disabled(), current->non_block_count,
 			current->pid, current->comm);
 
 	if (task_stack_end_corrupted(current))
Signature · 1 line
2.20.1
#2 lore raw

PATCH 1/1 kernel.h: Add non_block_start/end()

In some special cases we must not block, but there's not a spinlock, preempt-off, irqs-off or similar critical section already that arms the might_sleep() debug checks. Add a non_block_start/end() pair to annotate these.

This will be used in the oom paths of mmu-notifiers, where blocking is not allowed to make sure there's forward progress. Quoting Michal:

"The notifier is called from quite a restricted context - oom_reaper - which shouldn't depend on any locks or sleepable conditionals. The code should be swift as well but we mostly do care about it to make a forward progress. Checking for sleepable context is the best thing we could come up with that would describe these demands at least partially."

Peter also asked whether we want to catch spinlocks on top, but Michal said those are less of a problem because spinlocks can't have an indirect dependency upon the page allocator and hence close the loop with the oom reaper.

Suggested by Michal Hocko.

v2:
- Improve commit message (Michal)
- Also check in schedule, not just might_sleep (Peter)

v3: It works better when I actually squash in the fixup I had lying around :-/

Cc Peter Zijlstra <[email protected]>
Cc Ingo Molnar <[email protected]>
Cc Andrew Morton <[email protected]>
Cc Michal Hocko <[email protected]>
Cc David Rientjes <[email protected]>
Cc "Christian König" <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc "Jérôme Glisse" <[email protected]>
Cc Masahiro Yamada <[email protected]>
Cc Wei Wang <[email protected]>
Cc Andy Shevchenko <[email protected]>
Cc Thomas Gleixner <[email protected]>
Cc Jann Horn <[email protected]>
Cc Feng Tang <[email protected]>
Cc Kees Cook <[email protected]>
Cc Randy Dunlap <[email protected]>
---
 include/linux/kernel.h | 10 +++++++++-
 include/linux/sched.h  |  4 ++++
 kernel/sched/core.c    | 19 ++++++++++++++-----
 3 files changed, 27 insertions(+), 6 deletions(-)
include/linux/kernel.h +9 -1
index 74b1ee9027f5..b5f2c2ff0eab 100644
@@ -214,7 +214,9 @@ extern void __cant_sleep(const char *file, int line, int preempt_offset);
  * might_sleep - annotation for functions that can sleep
  *
  * this macro will print a stack trace if it is executed in an atomic
- * context (spinlock, irq-handler, ...).
+ * context (spinlock, irq-handler, ...). Additional sections where blocking is
+ * not allowed can be annotated with non_block_start() and non_block_end()
+ * pairs.
  *
  * This is a useful debugging help to be able to catch problems early and not
  * be bitten later when the calling function happens to sleep when it is not
@@ -230,6 +232,10 @@ extern void __cant_sleep(const char *file, int line, int preempt_offset);
 # define cant_sleep() \
 	do { __cant_sleep(__FILE__, __LINE__, 0); } while (0)
 # define sched_annotate_sleep()	(current->task_state_change = 0)
+# define non_block_start() \
+	do { current->non_block_count++; } while (0)
+# define non_block_end() \
+	do { WARN_ON(current->non_block_count-- == 0); } while (0)
 #else
   static inline void ___might_sleep(const char *file, int line,
 				   int preempt_offset) { }
@@ -238,6 +244,8 @@ extern void __cant_sleep(const char *file, int line, int preempt_offset);
 # define might_sleep() do { might_resched(); } while (0)
 # define cant_sleep() do { } while (0)
 # define sched_annotate_sleep() do { } while (0)
+# define non_block_start() do { } while (0)
+# define non_block_end() do { } while (0)
 #endif
 
 #define might_sleep_if(cond) do { if (cond) might_sleep(); } while (0)
include/linux/sched.h +4 -0
index 11837410690f..7f5b293e72df 100644
@@ -908,6 +908,10 @@ struct task_struct {
 	struct mutex_waiter		*blocked_on;
 #endif
 
+#ifdef CONFIG_DEBUG_ATOMIC_SLEEP
+	int				non_block_count;
+#endif
+
 #ifdef CONFIG_TRACE_IRQFLAGS
 	unsigned int			irq_events;
 	unsigned long			hardirq_enable_ip;
kernel/sched/core.c +14 -5
index 102dfcf0a29a..ed7755a28465 100644
@@ -3264,13 +3264,22 @@ static noinline void __schedule_bug(struct task_struct *prev)
 /*
  * Various schedule()-time debugging checks and statistics:
  */
-static inline void schedule_debug(struct task_struct *prev)
+static inline void schedule_debug(struct task_struct *prev, bool preempt)
 {
 #ifdef CONFIG_SCHED_STACK_END_CHECK
 	if (task_stack_end_corrupted(prev))
 		panic("corrupted stack end detected inside scheduler\n");
 #endif
 
+#ifdef CONFIG_DEBUG_ATOMIC_SLEEP
+	if (!preempt && prev->state && prev->non_block_count) {
+		printk(KERN_ERR "BUG: scheduling in a non-blocking section: %s/%d/%i\n",
+			prev->comm, prev->pid, prev->non_block_count);
+		dump_stack();
+		add_taint(TAINT_WARN, LOCKDEP_STILL_OK);
+	}
+#endif
+
 	if (unlikely(in_atomic_preempt_off())) {
 		__schedule_bug(prev);
 		preempt_count_set(PREEMPT_DISABLED);
@@ -3377,7 +3386,7 @@ static void __sched notrace __schedule(bool preempt)
 	rq = cpu_rq(cpu);
 	prev = rq->curr;
 
-	schedule_debug(prev);
+	schedule_debug(prev, preempt);
 
 	if (sched_feat(HRTICK))
 		hrtick_clear(rq);
@@ -6102,7 +6111,7 @@ void ___might_sleep(const char *file, int line, int preempt_offset)
 	rcu_sleep_check();
 
 	if ((preempt_count_equals(preempt_offset) && !irqs_disabled() &&
-	     !is_idle_task(current)) ||
+	     !is_idle_task(current) && !current->non_block_count) ||
 	    system_state == SYSTEM_BOOTING || system_state > SYSTEM_RUNNING ||
 	    oops_in_progress)
 		return;
@@ -6118,8 +6127,8 @@ void ___might_sleep(const char *file, int line, int preempt_offset)
 		"BUG: sleeping function called from invalid context at %s:%d\n",
 			file, line);
 	printk(KERN_ERR
-		"in_atomic(): %d, irqs_disabled(): %d, pid: %d, name: %s\n",
-			in_atomic(), irqs_disabled(),
+		"in_atomic(): %d, irqs_disabled(): %d, non_block: %d, pid: %d, name: %s\n",
+			in_atomic(), irqs_disabled(), current->non_block_count,
 			current->pid, current->comm);
 
 	if (task_stack_end_corrupted(current))
Signature · 6 lines
2.20.1

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

PATCH 3/4 mm, notifier: Catch sleeping/blocking for !blockable

In reply to Daniel Vetter

We need to make sure implementations don't cheat and don't have a possible schedule/blocking point deeply burried where review can't catch it.

I'm not sure whether this is the best way to make sure all the might_sleep() callsites trigger, and it's a bit ugly in the code flow. But it gets the job done.

Inspired by an i915 patch series which did exactly that, because the rules haven't been entirely clear to us.

v2: Use the shiny new non_block_start/end annotations instead of abusing preempt_disable/enable.

v3: Rebase on top of Glisse's arg rework.

v4: Rebase on top of more Glisse rework.

Cc Andrew Morton <[email protected]>
Cc Michal Hocko <[email protected]>
Cc David Rientjes <[email protected]>
Cc "Christian König" <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc "Jérôme Glisse" <[email protected]>
---
 mm/mmu_notifier.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
mm/mmu_notifier.c +7 -1
index c05e406a7cd7..a09e737711d5 100644
@@ -176,7 +176,13 @@ int __mmu_notifier_invalidate_range_start(struct mmu_notifier_range *range)
 	id = srcu_read_lock(&srcu);
 	hlist_for_each_entry_rcu(mn, &range->mm->mmu_notifier_mm->list, hlist) {
 		if (mn->ops->invalidate_range_start) {
-			int _ret = mn->ops->invalidate_range_start(mn, range);
+			int _ret;
+
+			if (!mmu_notifier_range_blockable(range))
+				non_block_start();
+			_ret = mn->ops->invalidate_range_start(mn, range);
+			if (!mmu_notifier_range_blockable(range))
+				non_block_end();
 			if (_ret) {
 				pr_info("%pS callback failed with %d in %sblockable context.\n",
 					mn->ops->invalidate_range_start, _ret,
Signature · 1 line
2.20.1
Reviewed-by on v1 3/4
#4 lore raw

Re: [PATCH 3/4] mm, notifier: Catch sleeping/blocking for !blockable

Quoted 37 lines · Daniel Vetter

We need to make sure implementations don't cheat and don't have a possible schedule/blocking point deeply burried where review can't catch it.

I'm not sure whether this is the best way to make sure all the might_sleep() callsites trigger, and it's a bit ugly in the code flow. But it gets the job done.

Inspired by an i915 patch series which did exactly that, because the rules haven't been entirely clear to us.

v2: Use the shiny new non_block_start/end annotations instead of abusing preempt_disable/enable.

v3: Rebase on top of Glisse's arg rework.

v4: Rebase on top of more Glisse rework.

Cc Andrew Morton <[email protected]>
Cc Michal Hocko <[email protected]>
Cc David Rientjes <[email protected]>
Cc "Christian König" <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc "Jérôme Glisse" <[email protected]>
---
 mm/mmu_notifier.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
mm/mmu_notifier.c +0 -0
index c05e406a7cd7..a09e737711d5 100644
@@ -176,7 +176,13 @@ int __mmu_notifier_invalidate_range_start(struct mmu_notifier_range *range)
 	id = srcu_read_lock(&srcu);

mm/mmu_notifier.c int __mmu_notifier_invalidate_range_start(struct mmu_notifier_range *range) · line 185

Quoted 10 lines
mm/mmu_notifier.c +7 -1
 	hlist_for_each_entry_rcu(mn, &range->mm->mmu_notifier_mm->list, hlist) {
 		if (mn->ops->invalidate_range_start) {
-			int _ret = mn->ops->invalidate_range_start(mn, range);
+			int _ret;
+
+			if (!mmu_notifier_range_blockable(range))
+				non_block_start();
+			_ret = mn->ops->invalidate_range_start(mn, range);
+			if (!mmu_notifier_range_blockable(range))
+				non_block_end();

This is a taste thing so feel free to ignore it as maybe other will dislike more what i prefer:

+ if (!mmu_notifier_range_blockable(range)) {
+ non_block_start();
+ _ret = mn->ops->invalidate_range_start(mn, range);
+ non_block_end();
+ } else
+ _ret = mn->ops->invalidate_range_start(mn, range);

If only we had predicate on CPU like on GPU :)

In any case:

Quoted 6 lines
mm/mmu_notifier.c +0 -0
 			if (_ret) {
 				pr_info("%pS callback failed with %d in %sblockable context.\n",
 					mn->ops->invalidate_range_start, _ret,
Signature · 1 line
2.20.1
#5 lore raw

PATCH 4/4 mm, notifier: Add a lockdep map for invalidate_range_start

In reply to Daniel Vetter

This is a similar idea to the fs_reclaim fake lockdep lock. It's fairly easy to provoke a specific notifier to be run on a specific
range: Just prep it, and then munmap() it.

A bit harder, but still doable, is to provoke the mmu notifiers for all the various callchains that might lead to them. But both at the same time is really hard to reliable hit, especially when you want to exercise paths like direct reclaim or compaction, where it's not easy to control what exactly will be unmapped.

By introducing a lockdep map to tie them all together we allow lockdep to see a lot more dependencies, without having to actually hit them in a single challchain while testing.

Aside: Since I typed this to test i915 mmu notifiers I've only rolled this out for the invaliate_range_start callback. If there's interest, we should probably roll this out to all of them. But my undestanding of core mm is seriously lacking, and I'm not clear on whether we need a lockdep map for each callback, or whether some can be shared.

v2: Use lock_map_acquire/release() like fs_reclaim, to avoid confusion with this being a real mutex (Chris Wilson).

v3: Rebase on top of Glisse's arg rework.

Cc Chris Wilson <[email protected]>
Cc Andrew Morton <[email protected]>
Cc David Rientjes <[email protected]>
Cc "Jérôme Glisse" <[email protected]>
Cc Michal Hocko <[email protected]>
Cc "Christian König" <[email protected]>
Cc Greg Kroah-Hartman <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Mike Rapoport <[email protected]>
---
 include/linux/mmu_notifier.h | 6 ++++++
 mm/mmu_notifier.c            | 7 +++++++
 2 files changed, 13 insertions(+)
include/linux/mmu_notifier.h +6 -0
index b6c004bd9f6a..9dd38c32fc53 100644
@@ -42,6 +42,10 @@ enum mmu_notifier_event {
 
 #ifdef CONFIG_MMU_NOTIFIER
 
+#ifdef CONFIG_LOCKDEP
+extern struct lockdep_map __mmu_notifier_invalidate_range_start_map;
+#endif
+
 /*
  * The mmu notifier_mm structure is allocated and installed in
  * mm->mmu_notifier_mm inside the mm_take_all_locks() protected
@@ -310,10 +314,12 @@ static inline void mmu_notifier_change_pte(struct mm_struct *mm,
 static inline void
 mmu_notifier_invalidate_range_start(struct mmu_notifier_range *range)
 {
+	lock_map_acquire(&__mmu_notifier_invalidate_range_start_map);
 	if (mm_has_notifiers(range->mm)) {
 		range->flags |= MMU_NOTIFIER_RANGE_BLOCKABLE;
 		__mmu_notifier_invalidate_range_start(range);
 	}
+	lock_map_release(&__mmu_notifier_invalidate_range_start_map);
 }
 
 static inline int
mm/mmu_notifier.c +7 -0
index a09e737711d5..33bdaddfb9b1 100644
@@ -23,6 +23,13 @@
 /* global SRCU for all MMs */
 DEFINE_STATIC_SRCU(srcu);
 
+#ifdef CONFIG_LOCKDEP
+struct lockdep_map __mmu_notifier_invalidate_range_start_map = {
+	.name = "mmu_notifier_invalidate_range_start"
+};
+EXPORT_SYMBOL_GPL(__mmu_notifier_invalidate_range_start_map);
+#endif
+
 /*
  * This function allows mmu_notifier::release callback to delay a call to
  * a function that will free appropriate resources. The function must be
Signature · 1 line
2.20.1
#6 lore raw

Re: [PATCH 4/4] mm, notifier: Add a lockdep map for invalidate_range_start

Quoted 14 lines · Daniel Vetter

This is a similar idea to the fs_reclaim fake lockdep lock. It's fairly easy to provoke a specific notifier to be run on a specific
range: Just prep it, and then munmap() it.

A bit harder, but still doable, is to provoke the mmu notifiers for all the various callchains that might lead to them. But both at the same time is really hard to reliable hit, especially when you want to exercise paths like direct reclaim or compaction, where it's not easy to control what exactly will be unmapped.

By introducing a lockdep map to tie them all together we allow lockdep to see a lot more dependencies, without having to actually hit them in a single challchain while testing.

Quoted 6 lines

Aside: Since I typed this to test i915 mmu notifiers I've only rolled this out for the invaliate_range_start callback. If there's interest, we should probably roll this out to all of them. But my undestanding of core mm is seriously lacking, and I'm not clear on whether we need a lockdep map for each callback, or whether some can be shared.

I need to read more on lockdep but it is legal to have mmu notifier invalidation within each other. For instance when you munmap you might split a huge pmd and it will trigger a second invalidate range while the munmap one is not done yet. Would that trigger the lockdep here ?

Worst case i can think of is 2 invalidate_range_start chain one after the other. I don't think you can triggers a 3 levels nesting but maybe.

Cheers,
Jérôme

#7 lore raw

Re: [PATCH 4/4] mm, notifier: Add a lockdep map for invalidate_range_start

Quoted 23 lines · Jerome Glisse
Quoted 14 lines · Daniel Vetter

This is a similar idea to the fs_reclaim fake lockdep lock. It's fairly easy to provoke a specific notifier to be run on a specific
range: Just prep it, and then munmap() it.

A bit harder, but still doable, is to provoke the mmu notifiers for all the various callchains that might lead to them. But both at the same time is really hard to reliable hit, especially when you want to exercise paths like direct reclaim or compaction, where it's not easy to control what exactly will be unmapped.

By introducing a lockdep map to tie them all together we allow lockdep to see a lot more dependencies, without having to actually hit them in a single challchain while testing.

Quoted 6 lines

Aside: Since I typed this to test i915 mmu notifiers I've only rolled this out for the invaliate_range_start callback. If there's interest, we should probably roll this out to all of them. But my undestanding of core mm is seriously lacking, and I'm not clear on whether we need a lockdep map for each callback, or whether some can be shared.

Quoted 5 lines

I need to read more on lockdep but it is legal to have mmu notifier invalidation within each other. For instance when you munmap you might split a huge pmd and it will trigger a second invalidate range while the munmap one is not done yet. Would that trigger the lockdep here ?

Depends how it's nesting. I'm wrapping the annotation only just around the individual mmu notifier callback, so if the nesting is just
- munmap starts
- invalidate_range_start #1
- we noticed that there's a huge pmd we need to split
- invalidate_range_start #2
- invalidate_reange_end #2
- invalidate_range_end #1
- munmap is done

But if otoh it's ok to trigger the 2nd invalidate range from within an mmu_notifier->invalidate_range_start callback, then lockdep will be pissed about that.

Quoted 2 lines

Worst case i can think of is 2 invalidate_range_start chain one after the other. I don't think you can triggers a 3 levels nesting but maybe.

Lockdep has special nesting annotations. I think it'd be more an issue of getting those funneled through the entire call chain, assuming we really need that.
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
Reviewed-by
#8 lore raw

Re: [PATCH 4/4] mm, notifier: Add a lockdep map for invalidate_range_start

Quoted 30 lines · Daniel Vetter
Quoted 23 lines · Jerome Glisse
Quoted 14 lines · Daniel Vetter

This is a similar idea to the fs_reclaim fake lockdep lock. It's fairly easy to provoke a specific notifier to be run on a specific
range: Just prep it, and then munmap() it.

A bit harder, but still doable, is to provoke the mmu notifiers for all the various callchains that might lead to them. But both at the same time is really hard to reliable hit, especially when you want to exercise paths like direct reclaim or compaction, where it's not easy to control what exactly will be unmapped.

By introducing a lockdep map to tie them all together we allow lockdep to see a lot more dependencies, without having to actually hit them in a single challchain while testing.

Quoted 6 lines

Aside: Since I typed this to test i915 mmu notifiers I've only rolled this out for the invaliate_range_start callback. If there's interest, we should probably roll this out to all of them. But my undestanding of core mm is seriously lacking, and I'm not clear on whether we need a lockdep map for each callback, or whether some can be shared.

Quoted 5 lines

I need to read more on lockdep but it is legal to have mmu notifier invalidation within each other. For instance when you munmap you might split a huge pmd and it will trigger a second invalidate range while the munmap one is not done yet. Would that trigger the lockdep here ?

Quoted 9 lines

Depends how it's nesting. I'm wrapping the annotation only just around the individual mmu notifier callback, so if the nesting is just
- munmap starts
- invalidate_range_start #1
- we noticed that there's a huge pmd we need to split
- invalidate_range_start #2
- invalidate_reange_end #2
- invalidate_range_end #1
- munmap is done

Yeah this is how it looks. All the callback from range_start #1 would happens before range_start #2 happens so we should be fine.

Quoted 4 lines

But if otoh it's ok to trigger the 2nd invalidate range from within an mmu_notifier->invalidate_range_start callback, then lockdep will be pissed about that.

No that would be illegal for a callback to do that. There is no existing callback that would do that at least AFAIK. So we can just say that it is illegal. I would not see the point.

Quoted 7 lines
Quoted 3 lines

Worst case i can think of is 2 invalidate_range_start chain one after the other. I don't think you can triggers a 3 levels nesting but maybe.

Lockdep has special nesting annotations. I think it'd be more an issue of getting those funneled through the entire call chain, assuming we really need that.

I think we are fine. So this patch looks good.

#9 lore raw

✗ Fi.CI.BAT: failure for series starting with [1/4] mm: Check if mmu notifier callbacks are allowed to fail

In reply to Daniel Vetter
== Series Details ==

== Series Details ==

Series: series starting with [1/4] mm: Check if mmu notifier callbacks are allowed to fail
URL : https://patchwork.freedesktop.org/series/60874/
State : failure

== Summary ==

CALL scripts/checksyscalls.sh
CALL scripts/atomic/check-atomics.sh
DESCEND objtool
CHK include/generated/compile.h
CC kernel/sched/core.o
kernel/sched/core.c: In function ‘schedule_debug’:
kernel/sched/core.c:3277:33: error: ‘struct task_struct’ has no member named ‘non_blocking_count’; did you mean ‘non_block_count’?

    prev->comm, prev->pid, prev->non_blocking_count);
                                 ^~~~~~~~~~~~~~~~~~
                                 non_block_count

scripts/Makefile.build:278: recipe for target 'kernel/sched/core.o' failed make[2]: *** [kernel/sched/core.o] Error 1 scripts/Makefile.build:489: recipe for target 'kernel/sched' failed make[1]: *** [kernel/sched] Error 2
Makefile:1071: recipe for target 'kernel' failed
make: *** [kernel] Error 2

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

Reviewed-by on v1 1/4
#10 lore raw
In reply to Daniel Vetter
Quoted 28 lines · Daniel Vetter

Just a bit of paranoia, since if we start pushing this deep into callchains it's hard to spot all places where an mmu notifier implementation might fail when it's not allowed to.

Inspired by some confusion we had discussing i915 mmu notifiers and whether we could use the newly-introduced return value to handle some corner cases. Until we realized that these are only for when a task has been killed by the oom reaper.

An alternative approach would be to split the callback into two versions, one with the int return value, and the other with void return value like in older kernels. But that's a lot more churn for fairly little gain I think.

Summary from the m-l discussion on why we want something at warning
level: This allows automated tooling in CI to catch bugs without humans having to look at everything. If we just upgrade the existing pr_info to a pr_warn, then we'll have false positives. And as-is, no one will ever spot the problem since it's lost in the massive amounts of overall dmesg noise.

v2: Drop the full WARN_ON backtrace in favour of just a pr_warn for the problematic case (Michal Hocko).

v3: Rebase on top of Glisse's arg rework.

v4: More rebase on top of Glisse reworking everything.

Quoted 10 lines
Cc Andrew Morton <[email protected]>
Cc Michal Hocko <[email protected]>
Cc "Christian König" <[email protected]>
Cc David Rientjes <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc "Jérôme Glisse" <[email protected]>
Cc Paolo Bonzini <[email protected]>
Quoted 21 lines
---
 mm/mmu_notifier.c | 3 +++
 1 file changed, 3 insertions(+)
mm/mmu_notifier.c +3 -0
index ee36068077b6..c05e406a7cd7 100644
@@ -181,6 +181,9 @@ int __mmu_notifier_invalidate_range_start(struct mmu_notifier_range *range)
 				pr_info("%pS callback failed with %d in %sblockable context.\n",
 					mn->ops->invalidate_range_start, _ret,
 					!mmu_notifier_range_blockable(range) ? "non-" : "");
+				if (!mmu_notifier_range_blockable(range))
+					pr_warn("%pS callback failure not allowed\n",
+						mn->ops->invalidate_range_start);
 				ret = _ret;
 			}
 		}
Signature · 1 line
2.20.1
#11 lore raw
Quoted 40 lines · Jerome Glisse
Quoted 28 lines · Daniel Vetter

Just a bit of paranoia, since if we start pushing this deep into callchains it's hard to spot all places where an mmu notifier implementation might fail when it's not allowed to.

Inspired by some confusion we had discussing i915 mmu notifiers and whether we could use the newly-introduced return value to handle some corner cases. Until we realized that these are only for when a task has been killed by the oom reaper.

An alternative approach would be to split the callback into two versions, one with the int return value, and the other with void return value like in older kernels. But that's a lot more churn for fairly little gain I think.

Summary from the m-l discussion on why we want something at warning
level: This allows automated tooling in CI to catch bugs without humans having to look at everything. If we just upgrade the existing pr_info to a pr_warn, then we'll have false positives. And as-is, no one will ever spot the problem since it's lost in the massive amounts of overall dmesg noise.

v2: Drop the full WARN_ON backtrace in favour of just a pr_warn for the problematic case (Michal Hocko).

v3: Rebase on top of Glisse's arg rework.

v4: More rebase on top of Glisse reworking everything.

Quoted 10 lines
Cc Andrew Morton <[email protected]>
Cc Michal Hocko <[email protected]>
Cc "Christian König" <[email protected]>
Cc David Rientjes <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc "Jérôme Glisse" <[email protected]>
Cc Paolo Bonzini <[email protected]>
Quoted 1 line

-mm folks, is this (entire series of 4 patches) planned to land in the 5.3 merge window? Or do you want more reviews/testing/polish?

I think with all the hmm rework going on, a bit more validation and checks in this tricky area would help.

Thanks, Daniel

Quoted 26 lines
Quoted 22 lines
---
 mm/mmu_notifier.c | 3 +++
 1 file changed, 3 insertions(+)
mm/mmu_notifier.c +3 -0
index ee36068077b6..c05e406a7cd7 100644
@@ -181,6 +181,9 @@ int __mmu_notifier_invalidate_range_start(struct mmu_notifier_range *range)
 				pr_info("%pS callback failed with %d in %sblockable context.\n",
 					mn->ops->invalidate_range_start, _ret,
 					!mmu_notifier_range_blockable(range) ? "non-" : "");
+				if (!mmu_notifier_range_blockable(range))
+					pr_warn("%pS callback failure not allowed\n",
+						mn->ops->invalidate_range_start);
 				ret = _ret;
 			}
 		}
Signature · 1 line
2.20.1

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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
#12 lore raw
Quoted 23 lines · Daniel Vetter
Quoted 22 lines · Jerome Glisse
Quoted 21 lines · Daniel Vetter

Just a bit of paranoia, since if we start pushing this deep into callchains it's hard to spot all places where an mmu notifier implementation might fail when it's not allowed to.

Inspired by some confusion we had discussing i915 mmu notifiers and whether we could use the newly-introduced return value to handle some corner cases. Until we realized that these are only for when a task has been killed by the oom reaper.

An alternative approach would be to split the callback into two versions, one with the int return value, and the other with void return value like in older kernels. But that's a lot more churn for fairly little gain I think.

Summary from the m-l discussion on why we want something at warning
level: This allows automated tooling in CI to catch bugs without humans having to look at everything. If we just upgrade the existing pr_info to a pr_warn, then we'll have false positives. And as-is, no one will ever spot the problem since it's lost in the massive amounts of overall dmesg noise.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

v2: Drop the full WARN_ON backtrace in favour of just a pr_warn for the problematic case (Michal Hocko).

I disagree with this v2 note, the WARN_ON/WARN will trigger checkers like syzkaller to report a bug, while a random pr_warn probably will not.

I do agree the backtrace is not useful here, but we don't have a warn-no-backtrace version..

IMHO, kernel/driver bugs should always be reported by WARN & friends. We never expect to see the print, so why do we care how big it is?

Also note that WARN integrates an unlikely() into it so the codegen is automatically a bit more optimal that the if & pr_warn combination.

Jason

#13 lore raw
Quoted 34 lines · Jason Gunthorpe
Quoted 23 lines · Daniel Vetter
Quoted 22 lines · Jerome Glisse
Quoted 21 lines · Daniel Vetter

Just a bit of paranoia, since if we start pushing this deep into callchains it's hard to spot all places where an mmu notifier implementation might fail when it's not allowed to.

Inspired by some confusion we had discussing i915 mmu notifiers and whether we could use the newly-introduced return value to handle some corner cases. Until we realized that these are only for when a task has been killed by the oom reaper.

An alternative approach would be to split the callback into two versions, one with the int return value, and the other with void return value like in older kernels. But that's a lot more churn for fairly little gain I think.

Summary from the m-l discussion on why we want something at warning
level: This allows automated tooling in CI to catch bugs without humans having to look at everything. If we just upgrade the existing pr_info to a pr_warn, then we'll have false positives. And as-is, no one will ever spot the problem since it's lost in the massive amounts of overall dmesg noise.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

v2: Drop the full WARN_ON backtrace in favour of just a pr_warn for the problematic case (Michal Hocko).

I disagree with this v2 note, the WARN_ON/WARN will trigger checkers like syzkaller to report a bug, while a random pr_warn probably will not.

I do agree the backtrace is not useful here, but we don't have a warn-no-backtrace version..

Quoted 6 lines

IMHO, kernel/driver bugs should always be reported by WARN & friends. We never expect to see the print, so why do we care how big it is?

Also note that WARN integrates an unlikely() into it so the codegen is automatically a bit more optimal that the if & pr_warn combination.

Where do you make a difference between a WARN without backtrace and a pr_warn? They're both dumped at the same log-level ...

I can easily throw an unlikely around this here if that's the only thing that's blocking the merge.
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#14 lore raw
Quoted 39 lines · Daniel Vetter
Quoted 38 lines · Jason Gunthorpe
Quoted 23 lines · Daniel Vetter
Quoted 22 lines · Jerome Glisse
Quoted 21 lines · Daniel Vetter

Just a bit of paranoia, since if we start pushing this deep into callchains it's hard to spot all places where an mmu notifier implementation might fail when it's not allowed to.

Inspired by some confusion we had discussing i915 mmu notifiers and whether we could use the newly-introduced return value to handle some corner cases. Until we realized that these are only for when a task has been killed by the oom reaper.

An alternative approach would be to split the callback into two versions, one with the int return value, and the other with void return value like in older kernels. But that's a lot more churn for fairly little gain I think.

Summary from the m-l discussion on why we want something at warning
level: This allows automated tooling in CI to catch bugs without humans having to look at everything. If we just upgrade the existing pr_info to a pr_warn, then we'll have false positives. And as-is, no one will ever spot the problem since it's lost in the massive amounts of overall dmesg noise.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

v2: Drop the full WARN_ON backtrace in favour of just a pr_warn for the problematic case (Michal Hocko).

I disagree with this v2 note, the WARN_ON/WARN will trigger checkers like syzkaller to report a bug, while a random pr_warn probably will not.

I do agree the backtrace is not useful here, but we don't have a warn-no-backtrace version..

IMHO, kernel/driver bugs should always be reported by WARN & friends. We never expect to see the print, so why do we care how big it is?

Quoted 5 lines
Quoted 2 lines

Also note that WARN integrates an unlikely() into it so the codegen is automatically a bit more optimal that the if & pr_warn combination.

Where do you make a difference between a WARN without backtrace and a pr_warn? They're both dumped at the same log-level ...

WARN panics the kernel when you set

/proc/sys/kernel/panic_on_warn

So auto testing tools can set that and get a clean detection that the kernel has failed the test in some way.

Otherwise you are left with frail/ugly grepping of dmesg.

Jason

#15 lore raw
Quoted 46 lines · Jason Gunthorpe
Quoted 39 lines · Daniel Vetter
Quoted 38 lines · Jason Gunthorpe
Quoted 23 lines · Daniel Vetter
Quoted 22 lines · Jerome Glisse
Quoted 21 lines · Daniel Vetter

Just a bit of paranoia, since if we start pushing this deep into callchains it's hard to spot all places where an mmu notifier implementation might fail when it's not allowed to.

Inspired by some confusion we had discussing i915 mmu notifiers and whether we could use the newly-introduced return value to handle some corner cases. Until we realized that these are only for when a task has been killed by the oom reaper.

An alternative approach would be to split the callback into two versions, one with the int return value, and the other with void return value like in older kernels. But that's a lot more churn for fairly little gain I think.

Summary from the m-l discussion on why we want something at warning
level: This allows automated tooling in CI to catch bugs without humans having to look at everything. If we just upgrade the existing pr_info to a pr_warn, then we'll have false positives. And as-is, no one will ever spot the problem since it's lost in the massive amounts of overall dmesg noise.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

v2: Drop the full WARN_ON backtrace in favour of just a pr_warn for the problematic case (Michal Hocko).

I disagree with this v2 note, the WARN_ON/WARN will trigger checkers like syzkaller to report a bug, while a random pr_warn probably will not.

I do agree the backtrace is not useful here, but we don't have a warn-no-backtrace version..

IMHO, kernel/driver bugs should always be reported by WARN & friends. We never expect to see the print, so why do we care how big it is?

Quoted 5 lines
Quoted 2 lines

Also note that WARN integrates an unlikely() into it so the codegen is automatically a bit more optimal that the if & pr_warn combination.

Where do you make a difference between a WARN without backtrace and a pr_warn? They're both dumped at the same log-level ...

Quoted 8 lines

WARN panics the kernel when you set

/proc/sys/kernel/panic_on_warn

So auto testing tools can set that and get a clean detection that the kernel has failed the test in some way.

Otherwise you are left with frail/ugly grepping of dmesg.

Hm right.

Anyway, I'm happy to repaint the bikeshed in any color that's desired, if that helps with landing it. WARN_WITHOUT_BACKTRACE might take a bit longer (need to find a bit of time, plus it'll definitely attract more comments).

Michal?
-Daniel

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#16 lore raw
Quoted 54 lines · Daniel Vetter
Quoted 53 lines · Jason Gunthorpe
Quoted 39 lines · Daniel Vetter
Quoted 38 lines · Jason Gunthorpe
Quoted 23 lines · Daniel Vetter
Quoted 22 lines · Jerome Glisse
Quoted 21 lines · Daniel Vetter

Just a bit of paranoia, since if we start pushing this deep into callchains it's hard to spot all places where an mmu notifier implementation might fail when it's not allowed to.

Inspired by some confusion we had discussing i915 mmu notifiers and whether we could use the newly-introduced return value to handle some corner cases. Until we realized that these are only for when a task has been killed by the oom reaper.

An alternative approach would be to split the callback into two versions, one with the int return value, and the other with void return value like in older kernels. But that's a lot more churn for fairly little gain I think.

Summary from the m-l discussion on why we want something at warning
level: This allows automated tooling in CI to catch bugs without humans having to look at everything. If we just upgrade the existing pr_info to a pr_warn, then we'll have false positives. And as-is, no one will ever spot the problem since it's lost in the massive amounts of overall dmesg noise.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

v2: Drop the full WARN_ON backtrace in favour of just a pr_warn for the problematic case (Michal Hocko).

I disagree with this v2 note, the WARN_ON/WARN will trigger checkers like syzkaller to report a bug, while a random pr_warn probably will not.

I do agree the backtrace is not useful here, but we don't have a warn-no-backtrace version..

IMHO, kernel/driver bugs should always be reported by WARN & friends. We never expect to see the print, so why do we care how big it is?

Quoted 5 lines
Quoted 2 lines

Also note that WARN integrates an unlikely() into it so the codegen is automatically a bit more optimal that the if & pr_warn combination.

Where do you make a difference between a WARN without backtrace and a pr_warn? They're both dumped at the same log-level ...

WARN panics the kernel when you set

/proc/sys/kernel/panic_on_warn

So auto testing tools can set that and get a clean detection that the kernel has failed the test in some way.

Quoted 8 lines
Quoted 1 line

Otherwise you are left with frail/ugly grepping of dmesg.

Hm right.

Anyway, I'm happy to repaint the bikeshed in any color that's desired, if that helps with landing it. WARN_WITHOUT_BACKTRACE might take a bit longer (need to find a bit of time, plus it'll definitely attract more comments).

I was actually just writing something very similar when looking at the hmm things..

Also, is the test backwards?

mmu_notifier_range_blockable() == true means the callback must return zero

mmu_notififer_range_blockable() == false means the callback can return 0 or -EAGAIN.

Suggest this:

                                pr_info("%pS callback failed with %d in %sblockable context.\n",
                                        mn->ops->invalidate_range_start, _ret,
                                        !mmu_notifier_range_blockable(range) ? "non-" : "");
+                               WARN_ON(mmu_notifier_range_blockable(range) ||
+                                       _ret != -EAGAIN);
                                ret = _ret;
                        }
                }

To express the API invariant.

Jason

#17 lore raw
Quoted 65 lines · Jason Gunthorpe
Quoted 54 lines · Daniel Vetter
Quoted 53 lines · Jason Gunthorpe
Quoted 39 lines · Daniel Vetter
Quoted 38 lines · Jason Gunthorpe
Quoted 23 lines · Daniel Vetter
Quoted 22 lines · Jerome Glisse
Quoted 21 lines · Daniel Vetter

Just a bit of paranoia, since if we start pushing this deep into callchains it's hard to spot all places where an mmu notifier implementation might fail when it's not allowed to.

Inspired by some confusion we had discussing i915 mmu notifiers and whether we could use the newly-introduced return value to handle some corner cases. Until we realized that these are only for when a task has been killed by the oom reaper.

An alternative approach would be to split the callback into two versions, one with the int return value, and the other with void return value like in older kernels. But that's a lot more churn for fairly little gain I think.

Summary from the m-l discussion on why we want something at warning
level: This allows automated tooling in CI to catch bugs without humans having to look at everything. If we just upgrade the existing pr_info to a pr_warn, then we'll have false positives. And as-is, no one will ever spot the problem since it's lost in the massive amounts of overall dmesg noise.

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

v2: Drop the full WARN_ON backtrace in favour of just a pr_warn for the problematic case (Michal Hocko).

I disagree with this v2 note, the WARN_ON/WARN will trigger checkers like syzkaller to report a bug, while a random pr_warn probably will not.

I do agree the backtrace is not useful here, but we don't have a warn-no-backtrace version..

IMHO, kernel/driver bugs should always be reported by WARN & friends. We never expect to see the print, so why do we care how big it is?

Quoted 5 lines
Quoted 2 lines

Also note that WARN integrates an unlikely() into it so the codegen is automatically a bit more optimal that the if & pr_warn combination.

Where do you make a difference between a WARN without backtrace and a pr_warn? They're both dumped at the same log-level ...

WARN panics the kernel when you set

/proc/sys/kernel/panic_on_warn

So auto testing tools can set that and get a clean detection that the kernel has failed the test in some way.

Quoted 8 lines
Quoted 1 line

Otherwise you are left with frail/ugly grepping of dmesg.

Hm right.

Anyway, I'm happy to repaint the bikeshed in any color that's desired, if that helps with landing it. WARN_WITHOUT_BACKTRACE might take a bit longer (need to find a bit of time, plus it'll definitely attract more comments).

Quoted 4 lines

I was actually just writing something very similar when looking at the hmm things..

Also, is the test backwards?

Yes, in the last rebase I screwed things up :-/
-Daniel

Quoted 20 lines

mmu_notifier_range_blockable() == true means the callback must return zero

mmu_notififer_range_blockable() == false means the callback can return 0 or -EAGAIN.

Suggest this:

                                pr_info("%pS callback failed with %d in %sblockable context.\n",
                                        mn->ops->invalidate_range_start, _ret,
                                        !mmu_notifier_range_blockable(range) ? "non-" : "");
(quoted diff) +2 -0
+                               WARN_ON(mmu_notifier_range_blockable(range) ||
+                                       _ret != -EAGAIN);
                                ret = _ret;
                        }
                }

To express the API invariant.

Jason

Signature · 3 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
#18 lore raw

✗ Fi.CI.CHECKPATCH: warning for series starting with [1/4] mm: Check if mmu notifier callbacks are allowed to fail (rev2)

In reply to Daniel Vetter
== Series Details ==

== Series Details ==

Series: series starting with [1/4] mm: Check if mmu notifier callbacks are allowed to fail (rev2)
URL : https://patchwork.freedesktop.org/series/60874/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
b2f1812e79cc mm: Check if mmu notifier callbacks are allowed to fail
-:62: 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, 9 lines checked
936dc2598132 kernel.h: Add non_block_start/end()
-:77: WARNING:SINGLE_STATEMENT_DO_WHILE_MACRO: Single statement macros should not use a do {} while (0) loop #77: FILE: include/linux/kernel.h:235:
+# define non_block_start() \
+ do { current->non_block_count++; } while (0)

-:79: WARNING:SINGLE_STATEMENT_DO_WHILE_MACRO: Single statement macros should not use a do {} while (0) loop #79: FILE: include/linux/kernel.h:237:
+# define non_block_end() \
+ do { WARN_ON(current->non_block_count-- == 0); } while (0)

-:126: WARNING:PREFER_PR_LEVEL: Prefer [subsystem eg: netdev]_err([subsystem]dev, ... then dev_err(dev, ... then pr_err(... to printk(KERN_ERR ... #126: FILE: kernel/sched/core.c:3276:
+ printk(KERN_ERR "BUG: scheduling in a non-blocking section: %s/%d/%i\n",

-:127: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis #127: FILE: kernel/sched/core.c:3277:
+ printk(KERN_ERR "BUG: scheduling in a non-blocking section: %s/%d/%i\n",
+ prev->comm, prev->pid, prev->non_block_count);

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

total: 0 errors, 4 warnings, 1 checks, 87 lines checked
dc416a4cf4e5 mm, notifier: Catch sleeping/blocking for !blockable
-:56: 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, 14 lines checked
1cb5f3d169c7 mm, notifier: Add a lockdep map for invalidate_range_start
-:93: 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, 35 lines checked

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

#19 lore raw

✓ Fi.CI.BAT: success for series starting with [1/4] mm: Check if mmu notifier callbacks are allowed to fail (rev2)

In reply to Daniel Vetter
== Series Details ==

== Series Details ==

Series: series starting with [1/4] mm: Check if mmu notifier callbacks are allowed to fail (rev2)
URL : https://patchwork.freedesktop.org/series/60874/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_6114 -> Patchwork_13063
====================================================

Summary
-------

**SUCCESS**

No regressions found.

External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13063/

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

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

### IGT changes ###

#### Issues hit ####

* igt@i915_selftest@live_hangcheck:
- fi-skl-iommu: [PASS][1] -> [INCOMPLETE][2] ([fdo#108602] / [fdo#108744])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6114/fi-skl-iommu/igt@i915_selftest@live_hangcheck.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13063/fi-skl-iommu/igt@i915_selftest@live_hangcheck.html

* igt@kms_flip@basic-flip-vs-wf_vblank:
- fi-bsw-n3050: [PASS][3] -> [FAIL][4] ([fdo#100368])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6114/fi-bsw-n3050/igt@kms_flip@basic-flip-vs-wf_vblank.html
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13063/fi-bsw-n3050/igt@kms_flip@basic-flip-vs-wf_vblank.html

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

[fdo#100368]: https://bugs.freedesktop.org/show_bug.cgi?id=100368
[fdo#107713]: https://bugs.freedesktop.org/show_bug.cgi?id=107713
[fdo#108569]: https://bugs.freedesktop.org/show_bug.cgi?id=108569
[fdo#108602]: https://bugs.freedesktop.org/show_bug.cgi?id=108602
[fdo#108744]: https://bugs.freedesktop.org/show_bug.cgi?id=108744

Participating hosts (53 -> 44)
------------------------------

Missing (9): fi-kbl-soraka fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-icl-u3 fi-icl-y fi-byt-clapper fi-bdw-samus

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

* Linux: CI_DRM_6114 -> Patchwork_13063

CI_DRM_6114: 8691fe536e41c852d3d420ed09b1d5f9916031e7 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_5000: f9961d14d76b3a0fa1296e547f7c065e2f93955c @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_13063: 1cb5f3d169c7c2aca5296e1aa883222ba925e393 @ git://anongit.freedesktop.org/gfx-ci/linux

== Linux commits ==

1cb5f3d169c7 mm, notifier: Add a lockdep map for invalidate_range_start dc416a4cf4e5 mm, notifier: Catch sleeping/blocking for !blockable 936dc2598132 kernel.h: Add non_block_start/end() b2f1812e79cc mm: Check if mmu notifier callbacks are allowed to fail

== Logs ==

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

#20 lore raw

✗ Fi.CI.IGT: failure for series starting with [1/4] mm: Check if mmu notifier callbacks are allowed to fail (rev2)

In reply to Daniel Vetter
== Series Details ==

== Series Details ==

Series: series starting with [1/4] mm: Check if mmu notifier callbacks are allowed to fail (rev2)
URL : https://patchwork.freedesktop.org/series/60874/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_6114_full -> Patchwork_13063_full
====================================================

Summary
-------

**FAILURE**

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

If you think the reported changes have nothing to do with the changes introduced in Patchwork_13063_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_13063_full:

### IGT changes ###

#### Possible regressions ####

* igt@gem_persistent_relocs@forked-interruptible-faulting-reloc-thrashing:
- shard-skl: [PASS][1] -> [DMESG-WARN][2] +2 similar issues
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6114/shard-skl10/igt@gem_persistent_relocs@forked-interruptible-faulting-reloc-thrashing.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13063/shard-skl6/igt@gem_persistent_relocs@forked-interruptible-faulting-reloc-thrashing.html

* igt@gem_userptr_blits@dmabuf-sync:
- shard-snb: [PASS][3] -> [DMESG-WARN][4] +1 similar issue
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6114/shard-snb2/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13063/shard-snb2/igt@[email protected]

* igt@gem_userptr_blits@dmabuf-unsync:
- shard-kbl: [PASS][5] -> [DMESG-WARN][6] +1 similar issue
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6114/shard-kbl4/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13063/shard-kbl1/igt@[email protected]
- shard-hsw: [PASS][7] -> [DMESG-WARN][8] +2 similar issues
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6114/shard-hsw6/igt@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13063/shard-hsw6/igt@[email protected]

* igt@gem_userptr_blits@map-fixed-invalidate-overlap-busy:
- shard-apl: [PASS][9] -> [DMESG-WARN][10] +1 similar issue
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6114/shard-apl6/igt@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13063/shard-apl4/igt@[email protected]

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

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

### IGT changes ###

#### Issues hit ####

* igt@gem_ctx_isolation@bcs0-s3:
- shard-apl: [PASS][11] -> [DMESG-WARN][12] ([fdo#108566]) +4 similar issues
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6114/shard-apl4/igt@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13063/shard-apl6/igt@[email protected]

* igt@kms_plane@plane-panning-bottom-right-suspend-pipe-a-planes:
- shard-skl: [PASS][13] -> [INCOMPLETE][14] ([fdo#104108])
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6114/shard-skl2/igt@[email protected]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13063/shard-skl4/igt@[email protected]

* igt@kms_plane_alpha_blend@pipe-b-constant-alpha-min:
- shard-skl: [PASS][15] -> [FAIL][16] ([fdo#108145])
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6114/shard-skl6/igt@[email protected]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13063/shard-skl4/igt@[email protected]

* igt@perf@short-reads:
- shard-kbl: [PASS][17] -> [FAIL][18] ([fdo#103183])
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6114/shard-kbl4/igt@[email protected]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13063/shard-kbl2/igt@[email protected]

* igt@tools_test@tools_test:
- shard-skl: [PASS][19] -> [SKIP][20] ([fdo#109271])
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6114/shard-skl9/igt@tools_test@tools_test.html
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13063/shard-skl8/igt@tools_test@tools_test.html

#### Possible fixes ####

* igt@gem_eio@in-flight-suspend:
- shard-apl: [FAIL][21] -> [PASS][22]
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6114/shard-apl7/igt@[email protected]
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13063/shard-apl2/igt@[email protected]

* igt@gem_pwrite@big-gtt-forwards:
- shard-glk: [INCOMPLETE][23] ([fdo#103359] / [k.org#198133]) -> [PASS][24]
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6114/shard-glk5/igt@[email protected]
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13063/shard-glk1/igt@[email protected]

* igt@gem_workarounds@suspend-resume:
- shard-apl: [DMESG-WARN][25] ([fdo#108566]) -> [PASS][26] +2 similar issues
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6114/shard-apl5/igt@[email protected]
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13063/shard-apl7/igt@[email protected]

* igt@i915_pm_rpm@fences:
- shard-skl: [INCOMPLETE][27] ([fdo#107807]) -> [PASS][28]
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6114/shard-skl4/igt@[email protected]
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13063/shard-skl8/igt@[email protected]

* igt@kms_atomic_interruptible@universal-setplane-primary:
- shard-apl: [INCOMPLETE][29] ([fdo#103927]) -> [PASS][30] +1 similar issue
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6114/shard-apl5/igt@[email protected]
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13063/shard-apl4/igt@[email protected]

* igt@kms_cursor_legacy@flip-vs-cursor-atomic-transitions-varying-size:
- shard-skl: [FAIL][31] ([fdo#102670]) -> [PASS][32]
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6114/shard-skl4/igt@kms_cursor_legacy@flip-vs-cursor-atomic-transitions-varying-size.html
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13063/shard-skl8/igt@kms_cursor_legacy@flip-vs-cursor-atomic-transitions-varying-size.html

* igt@kms_frontbuffer_tracking@psr-1p-primscrn-pri-indfb-draw-mmap-wc:
- shard-skl: [FAIL][33] ([fdo#103167]) -> [PASS][34]
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6114/shard-skl2/igt@kms_frontbuffer_tracking@psr-1p-primscrn-pri-indfb-draw-mmap-wc.html
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13063/shard-skl10/igt@kms_frontbuffer_tracking@psr-1p-primscrn-pri-indfb-draw-mmap-wc.html

* igt@kms_plane_alpha_blend@pipe-a-coverage-7efc:
- shard-skl: [FAIL][35] ([fdo#108145]) -> [PASS][36]
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6114/shard-skl2/igt@[email protected]
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13063/shard-skl10/igt@[email protected]

* igt@kms_plane_alpha_blend@pipe-c-coverage-7efc:
- shard-skl: [FAIL][37] ([fdo#108145] / [fdo#110403]) -> [PASS][38]
[37]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6114/shard-skl10/igt@[email protected]
[38]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13063/shard-skl4/igt@[email protected]

* igt@kms_setmode@basic:
- shard-kbl: [FAIL][39] ([fdo#99912]) -> [PASS][40]
[39]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6114/shard-kbl7/igt@[email protected]
[40]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13063/shard-kbl1/igt@[email protected]

[fdo#102670]: https://bugs.freedesktop.org/show_bug.cgi?id=102670
[fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
[fdo#103183]: https://bugs.freedesktop.org/show_bug.cgi?id=103183
[fdo#103359]: https://bugs.freedesktop.org/show_bug.cgi?id=103359
[fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
[fdo#104108]: https://bugs.freedesktop.org/show_bug.cgi?id=104108
[fdo#107807]: https://bugs.freedesktop.org/show_bug.cgi?id=107807
[fdo#108145]: https://bugs.freedesktop.org/show_bug.cgi?id=108145
[fdo#108566]: https://bugs.freedesktop.org/show_bug.cgi?id=108566
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#110403]: https://bugs.freedesktop.org/show_bug.cgi?id=110403
[fdo#99912]: https://bugs.freedesktop.org/show_bug.cgi?id=99912
[k.org#198133]: https://bugzilla.kernel.org/show_bug.cgi?id=198133

Participating hosts (10 -> 9)
------------------------------

Missing (1): shard-iclb

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

* Linux: CI_DRM_6114 -> Patchwork_13063

CI_DRM_6114: 8691fe536e41c852d3d420ed09b1d5f9916031e7 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_5000: f9961d14d76b3a0fa1296e547f7c065e2f93955c @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_13063: 1cb5f3d169c7c2aca5296e1aa883222ba925e393 @ git://anongit.freedesktop.org/gfx-ci/linux
piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit

== Logs ==

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