From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: Chaosheng Qu <chaosheng.qu.linux@gmail.com>
Cc: Steven Rostedt <rostedt@goodmis.org>,
Martin King <martin3kx@gmail.com>,
Peter Zijlstra <peterz@infradead.org>,
Juri Lelli <juri.lelli@redhat.com>,
Thorsten Leemhuis <regressions@leemhuis.info>,
regressions@lists.linux.dev, linux-kernel@vger.kernel.org,
linux-rt-users@vger.kernel.org
Subject: Re: [PATCH] sched/rt: push a queued task when its priority is boosted
Date: Tue, 24 Nov 2026 13:08:29 +0100 [thread overview]
Message-ID: <20261124120829.53F8ppqc@linutronix.de> (raw)
In-Reply-To: <179526068763.97100.12205093734161349836@gmail.com>
Martin, can you check if this solves your problem?
On 2026-11-21 19:31:27 [+0800], Chaosheng Qu wrote:
> A PI boost can raise a queued task above everything that is runnable on
> other CPUs while it still cannot run on its own rq, because the task
> currently running there has equal or higher priority. prio_changed_rt()
> only calls resched_curr() in that case. The task then waits for the
> current task to schedule out.
It only calls resched_curr() if the boosted task has a higher priority
and is not running. Then it will force a scheduling event by calling
resched_curr().
If it has a lower priority than the currently running task will remain
on CPU and the boosted will remain waiting.
> The pull side does not necessarily rescue it: pull_rt_task() only picks a
> task whose affinity includes the pulling CPU, so a task whose mask
> excludes the CPUs that just became idle is unreachable until the running
> task leaves on its own. With RT_PUSH_IPI off this is the difference
> between a millisecond migration and a wait for the hog to finish.
While browsing through the code, the task should be added to the
pushable_tasks list once blocked. A PI-boost seems not to do anything if
it did not become highest priority on the local CPU.
A push as suggested below will try to move it to another CPU if
possible. What I don't get why does it work with RT_PUSH_IPI enabled?
This means there is a scheduling event (or something else) doing
pull_rt_task() and the IPI feature causes to iterate over all CPUs und
find the boosted task on a matching CPU.
Without RT_PUSH_IPI, it is limited to a CPU which might not to be suited
for the task (due to different affinity). Did I get it right?
> Queue a push when the priority of a queued, non-current RT task goes up.
> push_rt_task() already declines to move a task that is not pushable and
> skips the reschedule path when the task is higher priority than the
> current one, so the extra callback only acts when a migration target
> exists.
>
> Signed-off-by: Chaosheng Qu <chaosheng.qu.linux@gmail.com>
> ---
> Steve,
>
> This is the fix we discussed in October. The case that matters is the
> queued task that the pull side cannot reach because its mask excludes the
> CPUs that just became idle.
>
> Numbers from a 4-vCPU QEMU guest (TCG; KVM is not available here), non-RT
> kernel, RT_PUSH_IPI off. L is FIFO 10 with mask {cpu1,cpu3}, X is FIFO 99
> hogging cpu1, W is FIFO 90 on cpu2 and blocks on L's PI mutex, R is FIFO 60
> on cpu3:
>
> baseline: 1/5 rescued, 802.8 / 1161.0 / 1311.8 / 30.2 / 1280.0 ms
> patched: 5/5 rescued, 13.8 / 1.1 / 0.2 / 0.2 / 0.8 ms
>
> The reproducer is a small static C program; I can post it if useful.
>
> kernel/sched/rt.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
> index 85303add7..db93bfff7 100644
> --- a/kernel/sched/rt.c
> +++ b/kernel/sched/rt.c
> @@ -2499,6 +2499,19 @@ prio_changed_rt(struct rq *rq, struct task_struct *p, u64 oldprio)
> */
> if (p->prio < rq->donor->prio)
> resched_curr(rq);
> +
> + /*
> + * A (PI) boost can make @p the highest priority
> + * pushable task on this rq while it still cannot run
> + * here, because the running task is of equal or higher
> + * priority. If @p's affinity excludes the CPUs that
> + * become idle, the pull side cannot pick it and it may
> + * stay queued until the current task schedules out.
> + * Trigger a push for the new priority.
> + */
> + if (oldprio > p->prio && p->nr_cpus_allowed > 1 &&
> + p->prio >= rq->donor->prio)
> + rt_queue_push_tasks(rq);
> }
> }
>
Sebastian
next prev parent reply other threads:[~2026-11-24 12:08 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-14 21:12 [REGRESSION] sched/rt: NO_RT_PUSH_IPI causes multi-second PI-boost starvation in pro-audio workloads (dd29c017aed6) Martin King
2026-08-14 22:36 ` Steven Rostedt
2026-09-03 11:27 ` Thorsten Leemhuis
2026-09-03 13:20 ` Steven Rostedt
2026-10-15 6:19 ` Chaosheng Qu
2026-10-15 12:46 ` Steven Rostedt
2026-11-21 11:31 ` [PATCH] sched/rt: push a queued task when its priority is boosted Chaosheng Qu
2026-11-24 12:08 ` Sebastian Andrzej Siewior [this message]
2026-10-17 12:14 ` [PATCH] sched/rt: queue a push when a queued RT task " Chaosheng Qu
2026-10-17 14:44 ` Kayra Cizmeci
2026-10-18 3:42 ` Chaosheng Qu
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=20261124120829.53F8ppqc@linutronix.de \
--to=bigeasy@linutronix.de \
--cc=chaosheng.qu.linux@gmail.com \
--cc=juri.lelli@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=martin3kx@gmail.com \
--cc=peterz@infradead.org \
--cc=regressions@leemhuis.info \
--cc=regressions@lists.linux.dev \
--cc=rostedt@goodmis.org \
/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®