[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20230612200229.GN4253@hirez.programming.kicks-ass.net>
Date: Mon, 12 Jun 2023 22:02:29 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Boqun Feng <boqun.feng@...il.com>
Cc: torvalds@...ux-foundation.org, keescook@...omium.org,
gregkh@...uxfoundation.org, pbonzini@...hat.com,
masahiroy@...nel.org, nathan@...nel.org, ndesaulniers@...gle.com,
nicolas@...sle.eu, catalin.marinas@....com, will@...nel.org,
vkoul@...nel.org, trix@...hat.com, ojeda@...nel.org,
mingo@...hat.com, longman@...hat.com, dennis@...nel.org,
tj@...nel.org, cl@...ux.com, acme@...nel.org, mark.rutland@....com,
alexander.shishkin@...ux.intel.com, jolsa@...nel.org,
namhyung@...nel.org, irogers@...gle.com, adrian.hunter@...el.com,
juri.lelli@...hat.com, vincent.guittot@...aro.org,
dietmar.eggemann@....com, rostedt@...dmis.org, bsegall@...gle.com,
mgorman@...e.de, bristot@...hat.com, vschneid@...hat.com,
paulmck@...nel.org, frederic@...nel.org, quic_neeraju@...cinc.com,
joel@...lfernandes.org, josh@...htriplett.org,
mathieu.desnoyers@...icios.com, jiangshanlai@...il.com,
rientjes@...gle.com, vbabka@...e.cz, roman.gushchin@...ux.dev,
42.hyeyoo@...il.com, apw@...onical.com, joe@...ches.com,
dwaipayanray1@...il.com, lukas.bulwahn@...il.com,
john.johansen@...onical.com, paul@...l-moore.com,
jmorris@...ei.org, serge@...lyn.com, linux-kbuild@...r.kernel.org,
linux-kernel@...r.kernel.org, dmaengine@...r.kernel.org,
llvm@...ts.linux.dev, linux-perf-users@...r.kernel.org,
rcu@...r.kernel.org, linux-security-module@...r.kernel.org,
tglx@...utronix.de, ravi.bangoria@....com, error27@...il.com,
luc.vanoostenryck@...il.com
Subject: Re: [PATCH v3 08/57] sched: Simplify wake_up_if_idle()
On Mon, Jun 12, 2023 at 11:02:28AM -0700, Boqun Feng wrote:
> On Mon, Jun 12, 2023 at 11:07:21AM +0200, Peter Zijlstra wrote:
> > Use guards to reduce gotos and simplify control flow.
> >
> > Signed-off-by: Peter Zijlstra (Intel) <peterz@...radead.org>
> > ---
> > kernel/sched/core.c | 20 ++++++--------------
> > kernel/sched/sched.h | 15 +++++++++++++++
> > 2 files changed, 21 insertions(+), 14 deletions(-)
> >
> > --- a/kernel/sched/core.c
> > +++ b/kernel/sched/core.c
> > @@ -3872,21 +3872,13 @@ static void __ttwu_queue_wakelist(struct
> > void wake_up_if_idle(int cpu)
> > {
> > struct rq *rq = cpu_rq(cpu);
> > - struct rq_flags rf;
> >
> > - rcu_read_lock();
> > -
> > - if (!is_idle_task(rcu_dereference(rq->curr)))
> > - goto out;
> > -
> > - rq_lock_irqsave(rq, &rf);
> > - if (is_idle_task(rq->curr))
> > - resched_curr(rq);
> > - /* Else CPU is not idle, do nothing here: */
> > - rq_unlock_irqrestore(rq, &rf);
> > -
> > -out:
> > - rcu_read_unlock();
> > + guard(rcu)();
> > + if (is_idle_task(rcu_dereference(rq->curr))) {
> > + guard(rq_lock)(rq);
>
> We assume that irq must be disabled when this function called?
> Otherwise, I don't understand why this is not
>
> guard(rq_lock_irqsave)(rq);
>
You're quite right, I messed that up.
Powered by blists - more mailing lists