From: Kayra Cizmeci <kayracizmeci@gmail.com>
To: Qais Yousef <qyousef@layalina.io>
Cc: Ingo Molnar <mingo@kernel.org>,
Peter Zijlstra <peterz@infradead.org>,
Vincent Guittot <vincent.guittot@linaro.org>,
Christian Loehle <christian.loehle@arm.com>,
Dietmar Eggemann <dietmar.eggemann@arm.com>,
Steven Rostedt <rostedt@goodmis.org>,
John Stultz <jstultz@google.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH RFC v5 3/4] Revert "sched/rt: Substract number of tasks of throttled queues from rq->nr_running"
Date: Thu, 5 Nov 2026 18:54:58 +0300 [thread overview]
Message-ID: <auyR6v0tKagzo986@scheduler.schedules> (raw)
In-Reply-To: <8401ef7a-de1a-4cb2-a3eb-be02a8436360@layalina.io>
On Thu, Nov 05, 2026 at 01:31:37AM +0000, Qais Yousef wrote:
> On 11/3/26 18:51, Kayra Cizmeci wrote:
>
> > So, as I was saying above I gave this a run. Did some tests:
> >
> > In my base a RT task can only get a CPU's %95.5, with the series %99.9.
> > Even when rt_throttled is 1, task doesn't stop running. I opened
> > CONFIG_RT_GROUP_SCHED and set cpu.rt_runtime_us to 950000. cgroup v1.
> >
> >
> > And AFAICT from the code and my tests, nr_running is handled
> > differently/wrong with this patch.
> >
> > When there is a RT group while throttling is enabled, with 2 tasks when
> > the group throttles nr_running should be 0. Since, there is nothing to
> > run. (If the group is alone in the rq tho :>) But with the patch series,
> > it stays 2. I think it's because dec_rt_tasks() does not call
> > sub_nr_running() in the group_rt_rq() case of se.
> >
> >
> > Or am I missing something :-)?
>
> This is an RFC as I was looking for potential historical context why it had to
> be done this way. I did call out in the cover letter that I am not sure about
> the implementation of inc/dec_rt_tasks() and was looking for advise too.
>
> I might have just missed that we have rt_task_is_entity(), does things get
> better with the below? Otherwise I'll just need to find the time to figure out
> the code and test it properly. Thanks!
>
> --->8---
>
> diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
> index 96d37a1ccc2a8..520273086134d 100644
> --- a/kernel/sched/rt.c
> +++ b/kernel/sched/rt.c
> @@ -1132,7 +1132,7 @@ void inc_rt_tasks(struct sched_rt_entity *rt_se, struct
> rt_rq *rt_rq)
> inc_rt_prio(rt_rq, prio);
> inc_rt_group(rt_se, rt_rq);
>
> - if (!group_rt_rq(rt_se)) {
> + if (rt_entity_is_task(rt_se)) {
> struct rq *rq = rq_of_rt_rq(rt_rq);
>
> add_nr_running(rq, 1);
> @@ -1151,7 +1151,7 @@ void dec_rt_tasks(struct sched_rt_entity *rt_se, struct
> rt_rq *rt_rq)
> dec_rt_prio(rt_rq, rt_se_prio(rt_se));
> dec_rt_group(rt_se, rt_rq);
>
> - if (!group_rt_rq(rt_se)) {
> + if (rt_entity_is_task(rt_se)) {
> struct rq *rq = rq_of_rt_rq(rt_rq);
>
> sub_nr_running(rq, 1);
>
Well I'm *thinking* it's the same thing :/, no?
#define rt_entity_is_task(rt_se) (!(rt_se)->my_q)
And look at this:
static inline struct rt_rq *group_rt_rq(struct sched_rt_entity *rt_se)
{
return rt_se->my_q;
}
Also, my other test was for this case that you said:
"It also had a confusing call in sched_rt_rq_dequeue() to
dequeue_top_rt_rq() when it is essentially a dead code - in existing
code base at least."
It's not dead. My other test was just for that case. Normally it
should, but when we change root's cgroup cpu.rt_runtime_us to 950000, it runs.
Because of two things:
1. We remove dequeue_top_rt_rq() calls, and in root throttle path that is
the thing that preventing root from being selected with reseting
rt_queued.
2. We remove rt_queued itself AND remove the rt_queued check from
rt_rq_is_runnable().
So when we come to pick_task_rt() sched_rt_runnable() returns true,
and we don't return NULL.
Or, is my brain oopsed?
BTW, fixing both of these AFAICT requires bit of
doing the same thing as the commit we are trying to revert. So may be
dropping the revert would be better. Its up to you tho.
What ya think?
Cheers,
Kayra
next prev parent reply other threads:[~2026-11-05 15:55 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 0:59 [PATCH v5 0/4] Fix uclamp race against non atomic static key enable Qais Yousef
2026-11-03 0:59 ` [PATCH v5 1/4] sched/uclamp: Fix race condition leading to imbalanced uclamp_rq Qais Yousef
2026-11-03 0:59 ` [PATCH v5 2/4] sched/uclamp: Use wrappers instead of open coding UCLAMP_FLAG_IDLE Qais Yousef
2026-11-03 0:59 ` [PATCH RFC v5 3/4] Revert "sched/rt: Substract number of tasks of throttled queues from rq->nr_running" Qais Yousef
2026-11-03 18:51 ` Kayra Cizmeci
2026-11-05 1:31 ` Qais Yousef
2026-11-05 15:54 ` Kayra Cizmeci [this message]
2026-11-03 0:59 ` [PATCH v5 4/4] sched/uclamp: Move uclamp_rq_{inc, dec}() from core.c Qais Yousef
2026-11-03 1:35 ` Qais Yousef
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=auyR6v0tKagzo986@scheduler.schedules \
--to=kayracizmeci@gmail.com \
--cc=christian.loehle@arm.com \
--cc=dietmar.eggemann@arm.com \
--cc=jstultz@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=qyousef@layalina.io \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.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®