[RFC PATCH 7/8] entry: Report local wake up on resched blind zone while resuming to user

From: Frederic Weisbecker
Date: Fri Jan 08 2021 - 21:07:09 EST


The last rescheduling opportunity while resuming to user is in
exit_to_user_mode_loop(). This means that any wake up performed on
the local runqueue after this point is going to have its rescheduling
silently ignored.

Perform sanity checks to report these situations.

Signed-off-by: Frederic Weisbecker <frederic@xxxxxxxxxx>
Cc: Peter Zijlstra <peterz@xxxxxxxxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: Ingo Molnar<mingo@xxxxxxxxxx>
Cc: Paul E. McKenney <paulmck@xxxxxxxxxx>
Cc: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
---
kernel/entry/common.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/kernel/entry/common.c b/kernel/entry/common.c
index 8f3292b5f9b7..1dfb97762336 100644
--- a/kernel/entry/common.c
+++ b/kernel/entry/common.c
@@ -5,6 +5,7 @@
#include <linux/highmem.h>
#include <linux/livepatch.h>
#include <linux/audit.h>
+#include <linux/sched.h>

#include "common.h"

@@ -23,6 +24,8 @@ static __always_inline void __enter_from_user_mode(struct pt_regs *regs)
instrumentation_begin();
trace_hardirqs_off_finish();
instrumentation_end();
+
+ sched_resched_local_allow();
}

void noinstr enter_from_user_mode(struct pt_regs *regs)
@@ -206,6 +209,7 @@ static void exit_to_user_mode_prepare(struct pt_regs *regs)
if (unlikely(ti_work & EXIT_TO_USER_MODE_WORK))
ti_work = exit_to_user_mode_loop(regs, ti_work);

+ sched_resched_local_forbid();
arch_exit_to_user_mode_prepare(regs, ti_work);

/* Ensure that the address limit is intact and no locks are held */
--
2.25.1