[PATCH 3/3] sched/fair: make tick based schedule always happen
From: Aaron Lu
Date: Thu Jul 25 2019 - 07:57:21 EST
When a hyperthread is forced idle and the other hyperthread has a single
CPU intensive task running, the running task can occupy the hyperthread
for a long time with no scheduling point and starve the other
hyperthread.
Fix this temporarily by always checking if the task has exceed its
timeslice and if so, for root cfs_rq, do a schedule.
Signed-off-by: Aaron Lu <ziqian.lzq@xxxxxxxxxx>
---
kernel/sched/fair.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 26d29126d6a5..b1f0defdad91 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -4011,6 +4011,9 @@ check_preempt_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr)
return;
}
+ if (cfs_rq->nr_running <= 1)
+ return;
+
/*
* Ensure that a task that missed wakeup preemption by a
* narrow margin doesn't have to wait for a full slice.
@@ -4179,7 +4182,7 @@ entity_tick(struct cfs_rq *cfs_rq, struct sched_entity *curr, int queued)
return;
#endif
- if (cfs_rq->nr_running > 1)
+ if (cfs_rq->nr_running > 1 || cfs_rq->tg == &root_task_group)
check_preempt_tick(cfs_rq, curr);
}
--
2.19.1.3.ge56e4f7