[PATCH v2 08/17] sched/rt: Select a preferred CPU for wakeup and pulling rt task
From: Shrikanth Hegde
Date: Tue Apr 07 2026 - 15:27:18 EST
For RT class,
- During wakeup choose a preferred CPU.
- For push_rt framework, limit pushing to preferred CPUs
- Pull the rt task only if CPU is preferred.
Signed-off-by: Shrikanth Hegde <sshegde@xxxxxxxxxxxxx>
---
kernel/sched/cpupri.c | 4 ++++
kernel/sched/rt.c | 4 ++++
2 files changed, 8 insertions(+)
diff --git a/kernel/sched/cpupri.c b/kernel/sched/cpupri.c
index 8f2237e8b484..3e3106690ff3 100644
--- a/kernel/sched/cpupri.c
+++ b/kernel/sched/cpupri.c
@@ -104,6 +104,10 @@ static inline int __cpupri_find(struct cpupri *cp, struct task_struct *p,
cpumask_and(lowest_mask, &p->cpus_mask, vec->mask);
cpumask_and(lowest_mask, lowest_mask, cpu_active_mask);
+#ifdef CONFIG_PARAVIRT
+ cpumask_and(lowest_mask, lowest_mask, cpu_preferred_mask);
+#endif
+
/*
* We have to ensure that we have at least one bit
* still set in the array, since the map could have
diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index a48e86794913..0c8cc8555287 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -2262,6 +2262,10 @@ static void pull_rt_task(struct rq *this_rq)
if (likely(!rt_overload_count))
return;
+ /* No point in pulling the load, just to push it next tick again */
+ if (!cpu_preferred(this_cpu))
+ return;
+
/*
* Match the barrier from rt_set_overloaded; this guarantees that if we
* see overloaded we must also see the rto_mask bit.
--
2.47.3