* [PATCH] sched/core: Call wq_worker_tick() for the execution context
@ 2026-09-02 15:02 Hui Su
2026-09-02 18:21 ` Tejun Heo
2026-09-10 9:02 ` [tip: sched/urgent] " tip-bot2 for Hui Su
0 siblings, 2 replies; 4+ messages in thread
From: Hui Su @ 2026-09-02 15:02 UTC (permalink / raw)
To: linux-kernel
Cc: mingo, peterz, juri.lelli, vincent.guittot, dietmar.eggemann,
rostedt, bsegall, mgorman, vschneid, kprateek.nayak, tj, jstultz,
Hui Su
wq_worker_tick() accounts CPU time and detects CPU-intensive work for
the kworker that is actually running. With proxy execution, rq->donor
is the scheduling context while rq->curr is the execution context.
Calling the hook with rq->donor can skip workqueue accounting when a
kworker is executing on behalf of a donor task. It can also account a
blocked kworker when the donor is a worker but rq->curr is the task
actually executing. The former can delay WORKER_CPU_INTENSIVE handling
and pool concurrency management, which can delay pending kernel work
and userspace operations depending on it.
Use rq->curr for the workqueue tick hook while retaining rq->donor for
scheduler accounting.
Fixes: af0c8b2bf67b ("sched: Split scheduler and execution contexts")
Signed-off-by: Hui Su <sh_def@163.com>
---
kernel/sched/core.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index f78275192036..a86fd3d88714 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -5770,8 +5770,8 @@ void sched_tick(void)
{
int cpu = smp_processor_id();
struct rq *rq = cpu_rq(cpu);
- /* accounting goes to the donor task */
- struct task_struct *donor;
+ /* scheduler accounting goes to the donor task */
+ struct task_struct *curr, *donor;
struct rq_flags rf;
unsigned long hw_pressure;
u64 resched_latency;
@@ -5782,6 +5782,7 @@ void sched_tick(void)
sched_clock_tick();
rq_lock(rq, &rf);
+ curr = rq->curr;
donor = rq->donor;
psi_account_irqtime(rq, donor, NULL);
@@ -5807,8 +5808,8 @@ void sched_tick(void)
perf_event_task_tick();
- if (donor->flags & PF_WQ_WORKER)
- wq_worker_tick(donor);
+ if (curr->flags & PF_WQ_WORKER)
+ wq_worker_tick(curr);
if (!scx_switched_all()) {
rq->idle_balance = idle_cpu(cpu);
base-commit: 89a312991dc6e638a36adc43ccb91dbc25504c04
--
2.54.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] sched/core: Call wq_worker_tick() for the execution context
2026-09-02 15:02 [PATCH] sched/core: Call wq_worker_tick() for the execution context Hui Su
@ 2026-09-02 18:21 ` Tejun Heo
2026-09-10 8:15 ` Peter Zijlstra
2026-09-10 9:02 ` [tip: sched/urgent] " tip-bot2 for Hui Su
1 sibling, 1 reply; 4+ messages in thread
From: Tejun Heo @ 2026-09-02 18:21 UTC (permalink / raw)
To: Hui Su
Cc: linux-kernel, mingo, peterz, juri.lelli, vincent.guittot,
dietmar.eggemann, rostedt, bsegall, mgorman, vschneid,
kprateek.nayak, jstultz
On Wed, Sep 02, 2026 at 11:02:09PM +0800, Hui Su wrote:
> wq_worker_tick() accounts CPU time and detects CPU-intensive work for
> the kworker that is actually running. With proxy execution, rq->donor
> is the scheduling context while rq->curr is the execution context.
>
> Calling the hook with rq->donor can skip workqueue accounting when a
> kworker is executing on behalf of a donor task. It can also account a
> blocked kworker when the donor is a worker but rq->curr is the task
> actually executing. The former can delay WORKER_CPU_INTENSIVE handling
> and pool concurrency management, which can delay pending kernel work
> and userspace operations depending on it.
>
> Use rq->curr for the workqueue tick hook while retaining rq->donor for
> scheduler accounting.
>
> Fixes: af0c8b2bf67b ("sched: Split scheduler and execution contexts")
> Signed-off-by: Hui Su <sh_def@163.com>
Acked-by: Tejun Heo <tj@kernel.org>
Peter, how do you want to route this patch? It can go through either sched
or wq.
Thanks.
--
tejun
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] sched/core: Call wq_worker_tick() for the execution context
2026-09-02 18:21 ` Tejun Heo
@ 2026-09-10 8:15 ` Peter Zijlstra
0 siblings, 0 replies; 4+ messages in thread
From: Peter Zijlstra @ 2026-09-10 8:15 UTC (permalink / raw)
To: Tejun Heo
Cc: Hui Su, linux-kernel, mingo, juri.lelli, vincent.guittot,
dietmar.eggemann, rostedt, bsegall, mgorman, vschneid,
kprateek.nayak, jstultz
On Wed, Sep 02, 2026 at 08:21:38AM -1000, Tejun Heo wrote:
> On Wed, Sep 02, 2026 at 11:02:09PM +0800, Hui Su wrote:
> > wq_worker_tick() accounts CPU time and detects CPU-intensive work for
> > the kworker that is actually running. With proxy execution, rq->donor
> > is the scheduling context while rq->curr is the execution context.
> >
> > Calling the hook with rq->donor can skip workqueue accounting when a
> > kworker is executing on behalf of a donor task. It can also account a
> > blocked kworker when the donor is a worker but rq->curr is the task
> > actually executing. The former can delay WORKER_CPU_INTENSIVE handling
> > and pool concurrency management, which can delay pending kernel work
> > and userspace operations depending on it.
> >
> > Use rq->curr for the workqueue tick hook while retaining rq->donor for
> > scheduler accounting.
> >
> > Fixes: af0c8b2bf67b ("sched: Split scheduler and execution contexts")
> > Signed-off-by: Hui Su <sh_def@163.com>
>
> Acked-by: Tejun Heo <tj@kernel.org>
>
> Peter, how do you want to route this patch? It can go through either sched
> or wq.
Sorry, seems this got lost in the email deluge :/ I can take it through
sched/urgent.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [tip: sched/urgent] sched/core: Call wq_worker_tick() for the execution context
2026-09-02 15:02 [PATCH] sched/core: Call wq_worker_tick() for the execution context Hui Su
2026-09-02 18:21 ` Tejun Heo
@ 2026-09-10 9:02 ` tip-bot2 for Hui Su
1 sibling, 0 replies; 4+ messages in thread
From: tip-bot2 for Hui Su @ 2026-09-10 9:02 UTC (permalink / raw)
To: linux-tip-commits
Cc: Hui Su, Peter Zijlstra (Intel), Tejun Heo, x86, linux-kernel
The following commit has been merged into the sched/urgent branch of tip:
Commit-ID: f5741d2b34519d387edf6e9798fc7030c20a35f3
Gitweb: https://git.kernel.org/tip/f5741d2b34519d387edf6e9798fc7030c20a35f3
Author: Hui Su <sh_def@163.com>
AuthorDate: Wed, 02 Sep 2026 23:02:09 +08:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Thu, 10 Sep 2026 10:22:52 +02:00
sched/core: Call wq_worker_tick() for the execution context
wq_worker_tick() accounts CPU time and detects CPU-intensive work for
the kworker that is actually running. With proxy execution, rq->donor
is the scheduling context while rq->curr is the execution context.
Calling the hook with rq->donor can skip workqueue accounting when a
kworker is executing on behalf of a donor task. It can also account a
blocked kworker when the donor is a worker but rq->curr is the task
actually executing. The former can delay WORKER_CPU_INTENSIVE handling
and pool concurrency management, which can delay pending kernel work
and userspace operations depending on it.
Use rq->curr for the workqueue tick hook while retaining rq->donor for
scheduler accounting.
Fixes: af0c8b2bf67b ("sched: Split scheduler and execution contexts")
Signed-off-by: Hui Su <sh_def@163.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Tejun Heo <tj@kernel.org>
Link: https://patch.msgid.link/20260902150208.1209922-2-sh_def@163.com
---
kernel/sched/core.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index b998ef6..7885ff7 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -5776,8 +5776,8 @@ void sched_tick(void)
{
int cpu = smp_processor_id();
struct rq *rq = cpu_rq(cpu);
- /* accounting goes to the donor task */
- struct task_struct *donor;
+ /* scheduler accounting goes to the donor task */
+ struct task_struct *curr, *donor;
struct rq_flags rf;
unsigned long hw_pressure;
u64 resched_latency;
@@ -5788,6 +5788,7 @@ void sched_tick(void)
sched_clock_tick();
rq_lock(rq, &rf);
+ curr = rq->curr;
donor = rq->donor;
psi_account_irqtime(rq, donor, NULL);
@@ -5813,8 +5814,8 @@ void sched_tick(void)
perf_event_task_tick();
- if (donor->flags & PF_WQ_WORKER)
- wq_worker_tick(donor);
+ if (curr->flags & PF_WQ_WORKER)
+ wq_worker_tick(curr);
if (!scx_switched_all()) {
rq->idle_balance = idle_cpu(cpu);
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-09-10 9:02 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-02 15:02 [PATCH] sched/core: Call wq_worker_tick() for the execution context Hui Su
2026-09-02 18:21 ` Tejun Heo
2026-09-10 8:15 ` Peter Zijlstra
2026-09-10 9:02 ` [tip: sched/urgent] " tip-bot2 for Hui Su
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.