Re: [PATCH] sched/eevdf: Fix wakeup-preempt by checking cfs_rq->nr_running

From: K Prateek Nayak
Date: Wed Sep 25 2024 - 00:54:53 EST


Hello Chenyu,

On 9/24/2024 6:40 PM, Chen Yu wrote:
[..snip..]
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 225b31aaee55..2859fc7e2da2 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -1025,7 +1025,7 @@ static bool update_deadline(struct cfs_rq *cfs_rq, struct sched_entity *se)
/*
* The task has consumed its request, reschedule.
*/
- return true;
+ return (cfs_rq->nr_running > 1);

Was there a strong reason why Peter decided to use "rq->nr_running"
instead of "cfs_rq->nr_running" with PREEMPT_SHORT in update_curr()?

I wonder if it was to force a pick_next_task() cycle to dequeue a
possibly delayed entity
but AFAICT, "cfs_rq->nr_running" should
account for the delayed entity still on the cfs_rq and perhaps the
early return in update_curr() can just be changed to use
"cfs_rq->nr_running". Not sure if I'm missing something trivial.

85e511df3cec changes
if (cfs_rq->nr_running > 1) resched
to
if (rq->nr_running == 1) not_resched
which does lower the bar to trigger resched

Yes, I think your proposal make sense, the resched should only
be triggered between 2 cfs tasks,
and the restore to update_deadline() is not needed, something like below
in update_curr() could also work:

if (cfs_rq->nr_running == 1)
return;

That seems better IMO unless there was a strong reason for the original
change to use rq->nr_running :)


thanks,
Chenyu

--
Thanks and Regards,
Prateek