[RFC PATCH v6 23/25] sched/rt: Try pull task on empty server pick.

From: Yuri Andriaccio

Date: Mon Jun 08 2026 - 08:27:16 EST


Try to pull task on a server with an empty runqueue before returning NULL (and
thus shutting down).

---

When all the servers of a cgroup are throttled, work is pending, and any one of
the servers is replenished, it may happen that the runqueue is empty and thus
the replenished server is immediately shut down.

The server may try to pull a task so that the cgroup could consume its
allocated runtime as soon as it is replenished.

Signed-off-by: Yuri Andriaccio <yurand2000@xxxxxxxxx>
---
kernel/sched/rt.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index 964704d88ba1..f672ef17e5d1 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -285,14 +285,22 @@ int alloc_rt_sched_group(struct task_group *tg, struct task_group *parent)
}

static struct sched_rt_entity *pick_next_rt_entity(struct rt_rq *rt_rq);
+static void pull_rt_task(struct rq *);

static struct task_struct *rt_server_pick(struct sched_dl_entity *dl_se, struct rq_flags *rf)
{
struct rt_rq *rt_rq = &dl_se->my_q->rt;
+ struct rq *global_rq = global_rq_of_rt_rq(rt_rq);
struct task_struct *p;

- if (!sched_rt_runnable(dl_se->my_q))
- return NULL;
+ if (!sched_rt_runnable(dl_se->my_q)) {
+ rq_unpin_lock(global_rq, rf);
+ pull_rt_task(rq_of_rt_rq(rt_rq));
+ rq_repin_lock(global_rq, rf);
+
+ if (!sched_rt_runnable(dl_se->my_q))
+ return NULL;
+ }

p = rt_task_of(pick_next_rt_entity(rt_rq));

--
2.54.0