From: Qais Yousef <qyousef@layalina.io>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Xuewen Yan <xuewen.yan@unisoc.com>,
peterz@infradead.org, mingo@redhat.com, juri.lelli@redhat.com,
vincent.guittot@linaro.org, dietmar.eggemann@arm.com,
bsegall@google.com, mgorman@suse.de, bristot@redhat.com,
vschneid@redhat.com, ke.wang@unisoc.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] sched/rt: Use cpu_active_mask to prevent rto_push_irq_work's dead loop
Date: Sun, 20 Nov 2022 23:35:43 +0000 [thread overview]
Message-ID: <20221120233543.yerjypgym7laxe42@airbuntu> (raw)
In-Reply-To: <20221117170028.04fd7013@gandalf.local.home>
On 11/17/22 17:00, Steven Rostedt wrote:
> On Mon, 14 Nov 2022 20:04:53 +0800
> Xuewen Yan <xuewen.yan@unisoc.com> wrote:
>
> > +++ b/kernel/sched/rt.c
> > @@ -2219,6 +2219,7 @@ static int rto_next_cpu(struct root_domain *rd)
> > {
> > int next;
> > int cpu;
> > + struct cpumask tmp_cpumask;
>
> If you have a machine with thousands of CPUs, this will likely kill the
> stack.
>
> >
> > /*
> > * When starting the IPI RT pushing, the rto_cpu is set to -1,
> > @@ -2238,6 +2239,11 @@ static int rto_next_cpu(struct root_domain *rd)
> > /* When rto_cpu is -1 this acts like cpumask_first() */
> > cpu = cpumask_next(rd->rto_cpu, rd->rto_mask);
> >
> > + cpumask_and(&tmp_cpumask, rd->rto_mask, cpu_active_mask);
> > + if (rd->rto_cpu == -1 && cpumask_weight(&tmp_cpumask) == 1 &&
> > + cpumask_test_cpu(smp_processor_id(), &tmp_cpumask))
> > + break;
> > +
>
> Kill the above.
>
> > rd->rto_cpu = cpu;
> >
> > if (cpu < nr_cpu_ids) {
>
> Why not just add here:
>
> if (!cpumask_test_cpu(cpu, cpu_active_mask))
> continue;
> return cpu;
> }
>
> ?
Or this?
diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index ed2a47e4ddae..5073e06e34c3 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -2236,7 +2236,7 @@ static int rto_next_cpu(struct root_domain *rd)
for (;;) {
/* When rto_cpu is -1 this acts like cpumask_first() */
- cpu = cpumask_next(rd->rto_cpu, rd->rto_mask);
+ cpu = cpumask_next_and(rd->rto_cpu, rd->rto_mask, cpu_active_mask);
rd->rto_cpu = cpu;
I think we might be circumventing the root cause though. It looks like that
there are only 2 cpus online in the system and one of them going offline (cpu1)
while the other is being overloaded (cpu0), ending in ping-ponging the tasks?
If that's the case, it seems to me the rto state needs to be cleared for cpu0
and stop attempting to push tasks. Which I'd assume it usually happens but
there's a race that prevents it from realizing this.
Maybe something like this would be better? Assuming I understood the problem
correctly of course.
diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index ed2a47e4ddae..d80072cc2596 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -334,6 +334,10 @@ static inline void rt_set_overload(struct rq *rq)
if (!rq->online)
return;
+ /* Overload is meaningless if we shrank to become a UP system */
+ if (cpumask_weight(cpu_online_mask) == 1)
+ return;
+
cpumask_set_cpu(rq->cpu, rq->rd->rto_mask);
/*
* Make sure the mask is visible before we set
This could be working around the problem too, not sure. But the bug IMHO is
that if we shrink to a UP system, the whole push-pull mechanism should retire
temporarily. Which I assume this usually happens, but there's a race somewhere.
Thanks
--
Qais Yousef
prev parent reply other threads:[~2022-11-20 23:35 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-14 12:04 Xuewen Yan
2022-11-17 22:00 ` Steven Rostedt
2022-11-18 12:08 ` Xuewen Yan
2022-11-20 19:27 ` Steven Rostedt
2022-11-20 23:35 ` Qais Yousef [this message]
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=20221120233543.yerjypgym7laxe42@airbuntu \
--to=qyousef@layalina.io \
--cc=bristot@redhat.com \
--cc=bsegall@google.com \
--cc=dietmar.eggemann@arm.com \
--cc=juri.lelli@redhat.com \
--cc=ke.wang@unisoc.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mgorman@suse.de \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=vincent.guittot@linaro.org \
--cc=vschneid@redhat.com \
--cc=xuewen.yan@unisoc.com \
/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®