Re: [PATCH] sched/fair: Reschedule the cfs_rq when current is ineligible
From: Mike Galbraith
Date: Sat May 25 2024 - 02:42:13 EST
On Fri, 2024-05-24 at 21:40 +0800, Chunxin Zang wrote:
> I found that some tasks have been running for a long enough time and
> have become illegal, but they are still not releasing the CPU. This
> will increase the scheduling delay of other processes. Therefore, I
> tried checking the current process in wakeup_preempt and entity_tick,
> and if it is illegal, reschedule that cfs queue.
My box gave making the XXX below reality a two thumbs up when fiddling
with the original unfettered and a bit harsh RUN_TO_PARITY.
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 8a5b1ae0aa55..922834f172b0 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -8413,12 +8413,13 @@ static void check_preempt_wakeup_fair(struct rq *rq, struct task_struct *p, int
update_curr(cfs_rq);
/*
- * XXX pick_eevdf(cfs_rq) != se ?
+ * Run @curr until it is no longer our best option. Basing the preempt
+ * decision on @curr reselection puts any previous decisions back on the
+ * table in context "now", including granularity preservation decisions
+ * by RUN_TO_PARITY.
*/
- if (pick_eevdf(cfs_rq) == pse)
- goto preempt;
-
- return;
+ if (pick_eevdf(cfs_rq) == se)
+ return;
preempt:
resched_curr(rq);