From: Frederic Weisbecker <frederic@kernel.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
"Rafael J . Wysocki" <rafael@kernel.org>,
Daniel Lezcano <daniel.lezcano@linaro.org>,
Thomas Gleixner <tglx@linutronix.de>,
Anna-Maria Behnsen <anna-maria@linutronix.de>
Subject: Re: [PATCH 00/10] timers/cpuidle: Fixes and cleanups
Date: Tue, 29 Aug 2023 13:28:00 +0200 [thread overview]
Message-ID: <ZO3WQJXTMw7CKhxO@lothringen> (raw)
In-Reply-To: <20230815161043.GL212435@hirez.programming.kicks-ass.net>
On Tue, Aug 15, 2023 at 06:10:43PM +0200, Peter Zijlstra wrote:
> On Fri, Aug 11, 2023 at 07:00:39PM +0200, Frederic Weisbecker wrote:
> > Hi,
> >
> > The first part of the series is cpuidle callback fixes against timers,
> > some of which haven't been Signed by Peter yet.
> >
> > Another part is removing the overhead of useless TIF_NR_POLLING clearing.
>
> So I've again forgotten why we don't simply set TIF_NEED_RESCHED if we
> need the timer re-programmed. That is by far the simplest fix.
>
> I'm sure we talked about it, but this was a long time ago and I can't
> remember :/
I don't think we did but the rationale is that with forcing setting
TIF_NEED_RESCHED, you force a needless timer restart (which is then going
to be cancelled shortly after) and a round trip to the scheduler with the
rq lock overhead, etc...
Just for the fun I just tried the following change:
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index c52c2eba7c73..ec43d135cf65 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -1132,8 +1132,10 @@ static void wake_up_idle_cpu(int cpu)
{
struct rq *rq = cpu_rq(cpu);
- if (cpu == smp_processor_id())
+ if (cpu == smp_processor_id()) {
+ set_tsk_need_resched(current);
return;
+ }
if (set_nr_and_not_polling(rq->idle))
smp_send_reschedule(cpu);
Then I computed the average of 100 runs of "make clean -C tools/perf; make -C
tools/perf/" before and after this patch.
I observed an average regression of 1.27% less time spent in C-states.
So this has a measurable impact.
>
> Anyway, the patches look good, except I think there's a whole bunch of
> architectures that still need fixing. In particular since loongson
> 'borrowed' the whole lot from MIPS, they need an identical fix. But I'm
> sure there's more architectures affected.
MIPS at least yes, I only did a quick check and it seems that most archs
use a "wfi" like instruction. I'll check for others.
Thanks.
prev parent reply other threads:[~2023-08-29 11:28 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-11 17:00 [PATCH 00/10] timers/cpuidle: Fixes and cleanups Frederic Weisbecker
2023-08-11 17:00 ` [PATCH 01/10] x86: Add a comment about the "magic" behind shadow sti before mwait Frederic Weisbecker
2023-08-11 17:44 ` Rafael J. Wysocki
2023-08-11 17:00 ` [PATCH 02/10] cpuidle: Fix CPUIDLE_FLAG_IRQ_ENABLE leaking timer reprogram Frederic Weisbecker
2023-08-11 17:35 ` Rafael J. Wysocki
2023-08-11 17:00 ` [PATCH 03/10] cpuidle: Report illegal tick stopped while polling Frederic Weisbecker
2023-08-11 17:37 ` Rafael J. Wysocki
2023-08-29 13:04 ` Frederic Weisbecker
2023-08-11 17:00 ` [PATCH 04/10] loongson: Fix idle VS timer enqueue Frederic Weisbecker
2023-08-14 2:58 ` bibo mao
2023-08-11 17:00 ` [PATCH 05/10] cpuidle: Comment about timers requirements VS idle handler Frederic Weisbecker
2023-08-11 17:38 ` Rafael J. Wysocki
2023-08-11 17:00 ` [PATCH 06/10] cpuidle: Remove unnecessary current_clr_polling_and_test() from haltpoll Frederic Weisbecker
2023-08-11 17:39 ` Rafael J. Wysocki
2023-08-11 17:00 ` [PATCH 07/10] cpuidle: Remove unnecessary current_clr_polling() on poll_idle() Frederic Weisbecker
2023-08-11 17:40 ` Rafael J. Wysocki
2023-08-11 17:00 ` [PATCH 08/10] x86: Remove __current_clr_polling() from mwait_idle() Frederic Weisbecker
2023-08-11 17:40 ` Rafael J. Wysocki
2023-08-11 17:00 ` [PATCH 09/10] x86: Remove the current_clr_polling() call upon mwait exit Frederic Weisbecker
2023-08-11 17:41 ` Rafael J. Wysocki
2023-08-11 17:00 ` [PATCH 10/10] sched/timers: Explain why idle task schedules out on remote timer enqueue Frederic Weisbecker
2023-08-11 17:43 ` Rafael J. Wysocki
2023-08-15 16:10 ` [PATCH 00/10] timers/cpuidle: Fixes and cleanups Peter Zijlstra
2023-08-29 11:28 ` Frederic Weisbecker [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=ZO3WQJXTMw7CKhxO@lothringen \
--to=frederic@kernel.org \
--cc=anna-maria@linutronix.de \
--cc=daniel.lezcano@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=rafael@kernel.org \
--cc=tglx@linutronix.de \
/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