diff mbox series

[RFC,32/86] entry: handle TIF_NEED_RESCHED_LAZY

Message ID 20231107215742.363031-33-ankur.a.arora@oracle.com (mailing list archive)
State New
Headers show
Series Make the kernel preemptible | expand

Commit Message

Ankur Arora Nov. 7, 2023, 9:57 p.m. UTC
The scheduling policy for TIF_NEED_RESCHED_LAZY is to run to
completion. Scheduling in exit_to_user_mode_loop() satisfies that.

Scheduling while exiting to userspace, also guarantees that the task
being scheduled away is entirely clear of any kernel encumbrances
that cannot span across preemption.

Ordinarily we don't need this extra protection: the preempt_count
check is always available. However, cases where preempt_count might
not be wholly dependable (ARCH_NO_PREEMPT configurations) will make
use of this.

Originally-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ankur Arora <ankur.a.arora@oracle.com>
---
 include/linux/entry-common.h | 2 +-
 kernel/entry/common.c        | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/include/linux/entry-common.h b/include/linux/entry-common.h
index fb2e349a17d2..7a56440442df 100644
--- a/include/linux/entry-common.h
+++ b/include/linux/entry-common.h
@@ -59,7 +59,7 @@ 
 #define EXIT_TO_USER_MODE_WORK						\
 	(_TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_UPROBE |		\
 	 _TIF_NEED_RESCHED | _TIF_PATCH_PENDING | _TIF_NOTIFY_SIGNAL |	\
-	 ARCH_EXIT_TO_USER_MODE_WORK)
+	 _TIF_NEED_RESCHED_LAZY | ARCH_EXIT_TO_USER_MODE_WORK)
 
 /**
  * arch_enter_from_user_mode - Architecture specific sanity check for user mode regs
diff --git a/kernel/entry/common.c b/kernel/entry/common.c
index 194c349b8be7..0d055c39690b 100644
--- a/kernel/entry/common.c
+++ b/kernel/entry/common.c
@@ -154,7 +154,7 @@  static unsigned long exit_to_user_mode_loop(struct pt_regs *regs,
 
 		local_irq_enable_exit_to_user(ti_work);
 
-		if (ti_work & _TIF_NEED_RESCHED)
+		if (ti_work & (_TIF_NEED_RESCHED | _TIF_NEED_RESCHED_LAZY))
 			schedule();
 
 		if (ti_work & _TIF_UPROBE)