[PATCH] sched: pull tasks when CPU is about to run SCHED_IDLE tasks

From: ultrachin
Date: Wed Dec 23 2020 - 04:52:52 EST


From: Chen Xiaoguang <xiaoggchen@xxxxxxxxxxx>

Before a CPU switches from running SCHED_NORMAL task to
SCHED_IDLE task, trying to pull SCHED_NORMAL tasks from other
CPU by doing load_balance first.

Signed-off-by: Chen Xiaoguang <xiaoggchen@xxxxxxxxxxx>
Signed-off-by: Chen He <heddchen@xxxxxxxxxxx>
---
kernel/sched/fair.c | 5 +++++
1 file changed, 5 insertions(+)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index ae7ceba..0a26132 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -7004,6 +7004,11 @@ struct task_struct *
struct task_struct *p;
int new_tasks;

+ if (prev &&
+ fair_policy(prev->policy) &&
+ sched_idle_cpu(rq->cpu))
+ goto idle;
+
again:
if (!sched_fair_runnable(rq))
goto idle;
--
1.8.3.1