[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20260106104911.54fac7f4@gandalf.local.home>
Date: Tue, 6 Jan 2026 10:49:11 -0500
From: Steven Rostedt <rostedt@...dmis.org>
To: K Prateek Nayak <kprateek.nayak@....com>
Cc: Chen Jinghuang <chenjinghuang2@...wei.com>, <mingo@...hat.com>,
<peterz@...radead.org>, <juri.lelli@...hat.com>,
<vincent.guittot@...aro.org>, <dietmar.eggemann@....com>,
<bsegall@...gle.com>, <mgorman@...e.de>, <vschneid@...hat.com>,
<linux-kernel@...r.kernel.org>
Subject: Re: [RESEND] sched/rt: Skip currently executing CPU in
rto_next_cpu()
On Tue, 6 Jan 2026 14:11:57 +0530
K Prateek Nayak <kprateek.nayak@....com> wrote:
> Hello Chen, Steve,
>
> On 1/5/2026 9:10 AM, Chen Jinghuang wrote:
> > @@ -2118,10 +2119,13 @@ 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);
> > + do {
> > + /* When rto_cpu is -1 this acts like cpumask_first() */
> > + cpu = cpumask_next(rd->rto_cpu, rd->rto_mask);
> >
> > - rd->rto_cpu = cpu;
> > + rd->rto_cpu = cpu;
> > + /* Do not send IPI to self */
> > + } while (cpu == this_cpu);
>
> nit.
>
> Since we are already within an infinite for-loop, can't we simply do:
>
> /* Do not send IPI to self */
> if (cpu == this_cpu)
> continue;
>
> here and go evaluate cpumask_next() again instead of adding another
> do-while? Was the nested loop intentional to highlight these bits
> explicitly?
Hmm, yeah, I think I added the loop to express this issue. But I think your
suggestion could work too. I originally had something like that, but for
some reason I thought it added an extra branch (over the added do { } while).
>
> >
> > if (cpu < nr_cpu_ids)
> > return cpu;
>
for (;;) {
/* When rto_cpu is -1 this acts like cpumask_first() */
cpu = cpumask_next(rd->rto_cpu, rd->rto_mask);
rd->rto_cpu = cpu;
+ /* Do not send IPI to self */
+ if (cpu == this_cpu)
+ continue;
+
if (cpu < nr_cpu_ids)
return cpu;
rd->rto_cpu = -1;
/*
* ACQUIRE ensures we see the @rto_mask changes
* made prior to the @next value observed.
*
* Matches WMB in rt_set_overload().
*/
next = atomic_read_acquire(&rd->rto_loop_next);
if (rd->rto_loop == next)
break;
rd->rto_loop = next;
}
Looks to be equivalent.
Chen, care to send a new version?
-- Steve
Powered by blists - more mailing lists