[PATCH] sched: Make preempt_enable_no_resched() behave like preempt_enable() on PREEMPT_RT

From: Sebastian Andrzej Siewior
Date: Tue Mar 01 2022 - 13:30:39 EST


From: Thomas Gleixner <tglx@xxxxxxxxxxxxx>

Use the distinction that has been made earlier between
preempt_enable_no_resched() and sched_preempt_enable_no_resched().
sched_preempt_enable_no_resched() is used within the scheduler where an
immediate schedule() follows. preempt_enable_no_resched() is used
outside of the scheduler and an immediate schedule() invocation may not
follow for other reasons.

The lack of an immediate schedule() invocation matters on PREEMPT_RT
where it will introduce latencies while the scheduler expects a context
switch.

Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
---
include/linux/preempt.h | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/include/linux/preempt.h b/include/linux/preempt.h
index b4381f255a5ca..582e43856a532 100644
--- a/include/linux/preempt.h
+++ b/include/linux/preempt.h
@@ -210,7 +210,11 @@ do { \
preempt_count_dec(); \
} while (0)

-#define preempt_enable_no_resched() sched_preempt_enable_no_resched()
+#ifdef CONFIG_PREEMPT_RT
+# define preempt_enable_no_resched() preempt_enable()
+#else
+# define preempt_enable_no_resched() sched_preempt_enable_no_resched()
+#endif

#define preemptible() (preempt_count() == 0 && !irqs_disabled())

--
2.35.1