mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chaosheng Qu <chaosheng.qu.linux@gmail.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: 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: [PATCH] sched/rt: push a queued task when its priority is boosted
Date: Sat, 21 Nov 2026 19:31:27 +0800	[thread overview]
Message-ID: <179526068763.97100.12205093734161349836@gmail.com> (raw)
In-Reply-To: <20261015084615.05957ae3@gandalf.local.home>

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.

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.

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);
 	}
 }
 
-- 
2.43.0



  reply	other threads:[~2026-11-21 11:33 UTC|newest]

Thread overview: 10+ 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           ` Chaosheng Qu [this message]
2026-10-17 12:14         ` [PATCH] sched/rt: queue a push when a queued RT task is boosted 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=179526068763.97100.12205093734161349836@gmail.com \
    --to=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®