[PATCH v2 3/6] sched: Extract __schedule_loop()
From: Sebastian Andrzej Siewior
Date: Fri Aug 25 2023 - 14:11:30 EST
From: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
There are currently two implementations of this basic __schedule()
loop, and there is soon to be a third.
Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Signed-off-by: "Peter Zijlstra (Intel)" <peterz@xxxxxxxxxxxxx>
Link: https://lkml.kernel.org/r/20230427111937.2745231-2-bigeasy@xxxxxxxxxxxxx
Link: https://lore.kernel.org/r/20230815111430.288063671@xxxxxxxxxxxxx
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@xxxxxxxxxxxxx>
---
kernel/sched/core.c | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index bca53ff9d8182..901766a88afc3 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -6785,16 +6785,21 @@ static void sched_update_worker(struct task_struct *tsk)
}
}
+static __always_inline void __schedule_loop(unsigned int sched_mode)
+{
+ do {
+ preempt_disable();
+ __schedule(sched_mode);
+ sched_preempt_enable_no_resched();
+ } while (need_resched());
+}
+
asmlinkage __visible void __sched schedule(void)
{
struct task_struct *tsk = current;
sched_submit_work(tsk);
- do {
- preempt_disable();
- __schedule(SM_NONE);
- sched_preempt_enable_no_resched();
- } while (need_resched());
+ __schedule_loop(SM_NONE);
sched_update_worker(tsk);
}
EXPORT_SYMBOL(schedule);
@@ -6858,11 +6863,7 @@ void __sched schedule_preempt_disabled(void)
#ifdef CONFIG_PREEMPT_RT
void __sched notrace schedule_rtlock(void)
{
- do {
- preempt_disable();
- __schedule(SM_RTLOCK_WAIT);
- sched_preempt_enable_no_resched();
- } while (need_resched());
+ __schedule_loop(SM_RTLOCK_WAIT);
}
NOKPROBE_SYMBOL(schedule_rtlock);
#endif
--
2.40.1