From: albin_yang@163.com
To: kayracizmeci@gmail.com, peterz@infradead.org, kprateek.nayak@amd.com
Cc: albin_yang@163.com, albinwyang@tencent.com, bsegall@google.com,
chen.yu@linux.dev, dietmar.eggemann@arm.com, jstultz@google.com,
juri.lelli@redhat.com, linux-kernel@vger.kernel.org,
mgorman@suse.de, mingo@redhat.com, rostedt@goodmis.org,
vincent.guittot@linaro.org, vschneid@redhat.com
Subject: Re: [PATCH] sched/stats: Fix run_delay over-count for proxy-migrated blocked donors
Date: Sun, 1 Nov 2026 22:31:01 +0800 [thread overview]
Message-ID: <20261101143101.353033-1-albin_yang@163.com> (raw)
In-Reply-To: <0d9bce4b-0d50-46df-b865-76511b2670f6@amd.com>
On Wed, Oct 28, 2026 at 09:10:20AM +0530, K Prateek Nayak wrote:
> Yup! on_cpu / task_current() gets dealt at sched_info_switch()
> which will enqueue the signal if the task is preempted.
Prateek, Kayra, Peter -- thanks for the reviews and suggestions.
I tested the full diff below (comments stripped for brevity).
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
@@ static int ttwu_runnable(struct task_struct *p, int wake_flags) @@
if (!task_on_cpu(rq, p)) {
wakeup_preempt(rq, p, wake_flags | WF_TTWU_RQ);
+ sched_info_enqueue(rq, p);
}
ttwu_do_wakeup(p);
return 1;
diff --git a/kernel/sched/stats.h b/kernel/sched/stats.h
@@ static inline void sched_info_dequeue(struct rq *rq, struct task_struct *t) @@
unsigned long long delta = 0;
+ if (t->is_blocked)
+ t->sched_info.last_queued = 0;
if (!t->sched_info.last_queued)
return;
@@ static inline void sched_info_enqueue(struct rq *rq, struct task_struct *t) @@
- if (!t->sched_info.last_queued)
+ if (!t->sched_info.last_queued || t->is_blocked)
t->sched_info.last_queued = rq_clock(rq);
Results -- run_delay is field 2 of /proc/<tid>/schedstat:
proxy exec, donor migrated to the owner's CPU (~170 ms block)
unpatched 167.07-167.09 ms 5/5 migrated
patched 0.00 ms 20/20 migrated
same-cpu 0.00 ms 0/5 not migrated
DELAY_DEQUEUE, sleeper migrated across CPUs (~150 ms sleep)
unpatched 147.94-147.99 ms 5/20
patched 0.00 ms 0/100
Accounting stays alive in both: the proxy reproducer's sanity check
still gains ~39 ms per 80 ms contention window in every run, and the
DELAY_DEQUEUE one shows run_delay growing ~40 ms per round. The latter
also self-checks -- it has to reproduce unpatched, and it does.
Agreed with Kayra and Prateek that p==current needs no call:
try_to_wake_up() WARN_ON_ONCE()s on both se.sched_delayed and
is_blocked there, so that task is running, not waiting.
One ask, about the split rather than the code: keep the DELAY_DEQUEUE
fix as its own patch on se.sched_delayed. p->is_blocked arrived in
4c2a20413d7f and first appears in v7.2-rc1, while that over-count goes
back to v6.12 (152e11f6df29) -- folded in, it cannot be built or
backported for v6.12.y..v7.1.y. It already exists as v4, already
reviewed and tested:
https://lore.kernel.org/all/20261024042753.2276779-1-albin_yang@163.com/
Happy to be overruled.
On the proxy gate itself, dropping my own !task_is_blocked():
Prateek's covers at least the same ground, and I could not measure a
difference.
Still unmeasured: the donor already being back on p->wake_cpu -- the
case that motivated the ttwu_runnable() call. Every round I measured
ended up with task_cpu(p) != p->wake_cpu, so proxy_needs_return() did
the dequeue and the call was never reached. Forcing that path needs
the owner to migrate mid-hold and the donor to follow it, which is
timing sensitive -- I'll report if I get it, but don't hold the patch
on it.
I'm happy to post this as a series if that helps -- how would you
suggest splitting it?
Thanks,
Wei Yang
next prev parent reply other threads:[~2026-11-01 14:32 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-25 13:07 albin_yang
2026-10-25 19:28 ` Kayra Cizmeci
2026-10-26 13:53 ` albin_yang
2026-10-26 14:48 ` Kayra Cizmeci
2026-10-26 5:46 ` K Prateek Nayak
2026-10-26 13:38 ` albin_yang
2026-10-27 4:11 ` K Prateek Nayak
2026-10-27 6:11 ` Kayra Cizmeci
2026-10-27 6:24 ` K Prateek Nayak
2026-10-27 6:52 ` Kayra Cizmeci
2026-10-27 9:45 ` K Prateek Nayak
2026-10-27 9:53 ` Kayra Cizmeci
2026-10-27 9:58 ` K Prateek Nayak
2026-10-27 12:09 ` Peter Zijlstra
2026-10-27 12:13 ` Kayra Cizmeci
2026-10-28 3:40 ` K Prateek Nayak
2026-10-28 9:22 ` Peter Zijlstra
2026-11-01 14:31 ` albin_yang [this message]
2026-11-01 15:19 ` Kayra Cizmeci
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261101143101.353033-1-albin_yang@163.com \
--to=albin_yang@163.com \
--cc=albinwyang@tencent.com \
--cc=bsegall@google.com \
--cc=chen.yu@linux.dev \
--cc=dietmar.eggemann@arm.com \
--cc=jstultz@google.com \
--cc=juri.lelli@redhat.com \
--cc=kayracizmeci@gmail.com \
--cc=kprateek.nayak@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®