From: Frederic Weisbecker <frederic@kernel.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, "Rafael J . Wysocki" <rafael@kernel.org>
Subject: Re: [PATCH 3/4] x86: Remove __current_clr_polling() from mwait_idle()
Date: Thu, 16 Nov 2023 13:48:47 -0500 [thread overview]
Message-ID: <ZVZkD3FvmNQ39Kk9@localhost.localdomain> (raw)
In-Reply-To: <20231116151316.GH8262@noisy.programming.kicks-ass.net>
Le Thu, Nov 16, 2023 at 04:13:16PM +0100, Peter Zijlstra a écrit :
> On Wed, Nov 15, 2023 at 10:13:24AM -0500, Frederic Weisbecker wrote:
> > mwait_idle() is only ever called through by cpuidle, either from
> > default_idle_call() or from cpuidle_enter(). In any case
> > cpuidle_idle_call() sets again TIF_NR_POLLING after calling it so there
> > is no point for this atomic operation upon idle exit.
> >
> > Acked-by: Rafael J. Wysocki <rafael@kernel.org>
> > Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
> > ---
> > arch/x86/kernel/process.c | 1 -
> > 1 file changed, 1 deletion(-)
> >
> > diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
> > index b6f4e8399fca..fc7a38084606 100644
> > --- a/arch/x86/kernel/process.c
> > +++ b/arch/x86/kernel/process.c
> > @@ -930,7 +930,6 @@ static __cpuidle void mwait_idle(void)
> > raw_local_irq_disable();
> > }
> > }
> > - __current_clr_polling();
> > }
> >
> > void select_idle_routine(const struct cpuinfo_x86 *c)
>
>
> Urgh at this and the next one... That is, yes we can do this, but it
> makes these function asymmetric and doesn't actually solve the
> underlying problem that all of the polling stuff is inside-out.
>
> Idle loop sets polling, then clears polling because it assumes all
> arch/driver idle loops are non-polling, then individual drivers re-set
> polling, and to be symmetric (above) clear it again, for the generic
> code to set it again, only to clear it again when leaving idle.
>
> Follow that? ;-)
That's right :-)
>
> Anyway, drivers ought to tell up-front if they're polling and then we
> can avoid the whole dance and everything is better.
>
> Something like the very crude below.
Yeah that makes perfect sense (can I use your SoB right away?)
Though I sometimes wonder why we even bother with setting TIF_NR_POLLING
for some short parts in the generic idle loop even on !mwait and
!cpuidle-state-polling states.
Like for example why do we bother with setting TIF_NR_POLLING for just
the portion in the generic idle loop that looks up the cpuidle state
and stops the tick then clear TIF_NR_POLLING before calling wfi on ARM?
Or may be it's a frequent pattern to have a remote wake up happening while
entering the idle loop?
Thanks.
next prev parent reply other threads:[~2023-11-16 18:49 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-15 15:13 [PATCH 0/4] x86/cpuidle fixes and optimization Frederic Weisbecker
2023-11-15 15:13 ` [PATCH 1/4] x86: Add a comment about the "magic" behind shadow sti before mwait Frederic Weisbecker
2023-11-29 14:55 ` [tip: x86/core] " tip-bot2 for Frederic Weisbecker
2023-11-15 15:13 ` [PATCH 2/4] x86: Fix CPUIDLE_FLAG_IRQ_ENABLE leaking timer reprogram Frederic Weisbecker
2023-11-15 15:52 ` Peter Zijlstra
2023-11-15 15:57 ` Frederic Weisbecker
2023-11-29 14:55 ` [tip: x86/core] " tip-bot2 for Peter Zijlstra
2023-11-30 11:15 ` Peter Zijlstra
2023-12-12 13:46 ` Frederic Weisbecker
2023-11-15 15:13 ` [PATCH 3/4] x86: Remove __current_clr_polling() from mwait_idle() Frederic Weisbecker
2023-11-16 15:13 ` Peter Zijlstra
2023-11-16 18:48 ` Frederic Weisbecker [this message]
2023-11-15 15:13 ` [PATCH 4/4] x86: Remove the current_clr_polling() call upon mwait exit Frederic Weisbecker
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=ZVZkD3FvmNQ39Kk9@localhost.localdomain \
--to=frederic@kernel.org \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=peterz@infradead.org \
--cc=rafael@kernel.org \
--cc=tglx@linutronix.de \
--cc=x86@kernel.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