Re: [REGRESSION] core scheduling latency with idle load
From: K Prateek Nayak
Date: Tue Nov 17 2026 - 05:22:40 EST
Hello Mihail,
On 11/17/2026 3:52 AM, Mihail Mihov wrote:
> On Fri, Jun 05, 2026 at 02:40:20PM +0200, Peter Zijlstra wrote:
>> @@ -14893,30 +14803,8 @@ bool cfs_prio_less(const struct task_str
> [...]
>> - se_fi_update(sea, rq->core->core_forceidle_seq, in_fi);
>> - se_fi_update(seb, rq->core->core_forceidle_seq, in_fi);
>
> In case it helps: adding these two calls back on v7.3.4 brought the
> cookie p99 back to 55 us.
I can confirm I see skipped cfs_rq->zero_vruntime_fi updates for root from
cfs_prio_less() which would have previously bumped up the zero_vruntime_fi
at common ancestor.
> I don't know whether that is the right thing
> to do, only that it changes this result.
It might be since cfs_prio_less() would have compared the zero_vruntime_fi
at common ancestor but now, everything is driven at root cfs_rq.
That said, perhaps se_fi_update() could itself be optimized now with
flattened pick. Could you try below changes a try:
(Prepared on top of v7.4-rc3; Lightly tested)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 0c8af1cac2d5..3935693bdf2f 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -15278,30 +15278,21 @@ static inline void task_tick_core(struct rq *rq, struct task_struct *curr)
/*
* se_fi_update - Update the cfs_rq->zero_vruntime_fi in a CFS hierarchy if needed.
*/
-static void se_fi_update(const struct sched_entity *se, unsigned int fi_seq,
- bool forceidle)
+static void cfs_rq_fi_update(struct cfs_rq *cfs_rq, unsigned int fi_seq, bool forceidle)
{
- for_each_sched_entity(se) {
- struct cfs_rq *cfs_rq = cfs_rq_of(se);
-
- if (forceidle) {
- if (cfs_rq->forceidle_seq == fi_seq)
- break;
- cfs_rq->forceidle_seq = fi_seq;
- }
+ if (forceidle && cfs_rq->forceidle_seq == fi_seq)
+ return;
- cfs_rq->zero_vruntime_fi = cfs_rq->zero_vruntime;
- }
+ cfs_rq->forceidle_seq = fi_seq;
+ cfs_rq->zero_vruntime_fi = cfs_rq->zero_vruntime;
}
void task_vruntime_update(struct rq *rq, struct task_struct *p, bool in_fi)
{
- struct sched_entity *se = &p->se;
-
if (p->sched_class != &fair_sched_class)
return;
- se_fi_update(se, rq->core->core_forceidle_seq, in_fi);
+ cfs_rq_fi_update(&rq->cfs, rq->core->core_forceidle_seq, in_fi);
}
bool cfs_prio_less(const struct task_struct *a, const struct task_struct *b,
@@ -15319,6 +15310,9 @@ bool cfs_prio_less(const struct task_struct *a, const struct task_struct *b,
cfs_rqa = &task_rq(a)->cfs;
cfs_rqb = &task_rq(b)->cfs;
+ cfs_rq_fi_update(cfs_rqa, rq->core->core_forceidle_seq, in_fi);
+ cfs_rq_fi_update(cfs_rqb, rq->core->core_forceidle_seq, in_fi);
+
/*
* Find delta after normalizing se's vruntime with its cfs_rq's
* zero_vruntime_fi, which would have been updated in prior calls
--
Thanks and Regards,
Prateek