Re: [PATCH] sched/stats: Fix run_delay over-count for proxy-migrated blocked donors
From: K Prateek Nayak
Date: Mon Oct 26 2026 - 01:48:44 EST
On 10/25/2026 6:37 PM, albin_yang@xxxxxxx wrote:
> diff --git a/kernel/sched/stats.h b/kernel/sched/stats.h
> index dc626f99ffd9..ef52fbe86bba 100644
> --- a/kernel/sched/stats.h
> +++ b/kernel/sched/stats.h
> @@ -290,7 +290,7 @@ static void sched_info_arrive(struct rq *rq, struct task_struct *t)
> */
> static inline void sched_info_enqueue(struct rq *rq, struct task_struct *t)
> {
> - if (!t->sched_info.last_queued && !t->se.sched_delayed)
> + if (!t->sched_info.last_queued && !t->se.sched_delayed && !task_is_blocked(t))
I think the sched info bits should be adapted to use the p->is_blocked
indicator instead of adding these endless exceptions.
Could you see if something like below works:
(Only build tested; Prepared on top of sched-core-2026-10-18)
diff --git a/kernel/sched/stats.h b/kernel/sched/stats.h
index ebe0a7765f98..bd8c5cdfd12a 100644
--- a/kernel/sched/stats.h
+++ b/kernel/sched/stats.h
@@ -233,16 +233,13 @@ static inline void psi_account_irqtime(struct rq *rq, struct task_struct *curr,
/*
* We are interested in knowing how long it was from the *first* time a
* task was queued to the time that it finally hit a CPU, we call this routine
- * from dequeue_task() to account for possible rq->clock skew across CPUs. The
- * delta taken on each CPU would annul the skew.
+ * from dequeue_task() / __schedule() to account for possible rq->clock skew
+ * across CPUs. The delta taken on each CPU would annul the skew.
*/
-static inline void sched_info_dequeue(struct rq *rq, struct task_struct *t)
+static inline void __sched_info_dequeue(struct rq *rq, struct task_struct *t)
{
unsigned long long delta = 0;
- if (!t->sched_info.last_queued)
- return;
-
delta = rq_clock(rq) - t->sched_info.last_queued;
t->sched_info.last_queued = 0;
t->sched_info.run_delay += delta;
@@ -255,6 +252,15 @@ static inline void sched_info_dequeue(struct rq *rq, struct task_struct *t)
rq_sched_info_dequeue(rq, delta);
}
+static inline void sched_info_dequeue(struct rq *rq, struct task_struct *t)
+{
+ /* blocked tasks are handled at sched_info_depart() */
+ if (t->is_blocked)
+ return;
+
+ __sched_info_dequeue(rq, t);
+}
+
/*
* Called when a task finally hits the CPU. We can now calculate how
* long it was waiting to run. We also note when it began so that we
@@ -290,7 +296,7 @@ static void sched_info_arrive(struct rq *rq, struct task_struct *t)
*/
static inline void sched_info_enqueue(struct rq *rq, struct task_struct *t)
{
- if (!t->sched_info.last_queued)
+ if (t->is_blocked)
t->sched_info.last_queued = rq_clock(rq);
}
@@ -310,6 +316,9 @@ static inline void sched_info_depart(struct rq *rq, struct task_struct *t)
if (task_is_running(t))
sched_info_enqueue(rq, t);
+
+ if (t->is_blocked)
+ __sched_info_dequeue(rq, t);
}
/*
---
It is similar to how we handle PSI signals.
> t->sched_info.last_queued = rq_clock(rq);
> }
>
--
Thanks and Regards,
Prateek