From: "Paul E. McKenney" <paulmck@kernel.org>
To: Feng Tang <feng.tang@intel.com>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
Doug Smythies <dsmythies@telus.net>,
"Rafael J. Wysocki" <rjw@rjwysocki.net>,
srinivas pandruvada <srinivas.pandruvada@linux.intel.com>,
"Zhang, Rui" <rui.zhang@intel.com>,
Thomas Gleixner <tglx@linutronix.de>,
"stable@vger.kernel.org" <stable@vger.kernel.org>,
"x86@kernel.org" <x86@kernel.org>,
"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
tim.c.chen@intel.com
Subject: Re: CPU excessively long times between frequency scaling driver calls - bisected
Date: Fri, 4 Mar 2022 08:23:23 -0800 [thread overview]
Message-ID: <20220304162323.GN4285@paulmck-ThinkPad-P17-Gen-1> (raw)
In-Reply-To: <20220304051344.GA72462@shbuild999.sh.intel.com>
On Fri, Mar 04, 2022 at 01:13:44PM +0800, Feng Tang wrote:
> On Thu, Mar 03, 2022 at 01:02:01PM +0100, Rafael J. Wysocki wrote:
> > On Thu, Mar 3, 2022 at 6:27 AM Feng Tang <feng.tang@intel.com> wrote:
> > >
> > > On Tue, Mar 01, 2022 at 08:06:24PM -0800, Doug Smythies wrote:
> > > > On Tue, Mar 1, 2022 at 9:34 AM Rafael J. Wysocki <rafael@kernel.org> wrote:
> > > > >
> > > > > I guess the numbers above could be reduced still by using a P-state
> > > > > below the max non-turbo one as a limit.
> > > >
> > > > Yes, and for a test I did "rjw-3".
> > > >
> > > > > > overruns: 1042.
> > > > > > max overrun time: 9,769 uSec.
> > > > >
> > > > > This would probably get worse then, though.
> > > >
> > > > Yes, that was my expectation, but not what happened.
> > > >
> > > > rjw-3:
> > > > ave: 3.09 watts
> > > > min: 3.01 watts
> > > > max: 31.7 watts
> > > > ave freq: 2.42 GHz.
> > > > overruns: 12. (I did not expect this.)
> > > > Max overruns time: 621 uSec.
> > > >
> > > > Note 1: IRQ's increased by 74%. i.e. it was going in
> > > > and out of idle a lot more.
> > > >
> > > > Note 2: We know that processor package power
> > > > is highly temperature dependent. I forgot to let my
> > > > coolant cool adequately after the kernel compile,
> > > > and so had to throw out the first 4 power samples
> > > > (20 minutes).
> > > >
> > > > I retested both rjw-2 and rjw-3, but shorter tests
> > > > and got 0 overruns in both cases.
> > >
> > > One thought is can we consider trying the previous debug patch of
> > > calling the util_update when entering idle (time limited).
> > >
> > > In current code, the RT/CFS/Deadline class all have places to call
> > > cpufreq_update_util(), the patch will make sure it is called in all
> > > four classes, also it follows the principle of 'schedutil' of not
> > > introducing more system cost. And surely I could be missing some
> > > details here.
> > >
> > > Following is a cleaner version of the patch, and the code could be
> > > moved down to the internal loop of
> > >
> > > while (!need_resched()) {
> > >
> > > }
> > >
> > > Which will make it get called more frequently.
> >
> > It will, but it's not necessary in all cases. It only is necessary if
> > the tick is going to be stopped (because the tick will update the
> > P-state governor anyway if it runs). However, at this point you don't
> > know what's going to happen to the tick.
> >
> > Moreover, updating the P-state governor before going idle doesn't
> > really help,
>
> >From Doug's previous test, the power consumption and the delay
> both improved with the debug patch.
>
> > because the P-state programmed by it at this point may
> > very well be stale after getting out of the idle state, so instead of
> > doing a full update at this point, it should force a low P-state on
> > the way from idle.
>
> Makes sense.
>
> Paul has asked about the timer interupts, and here is some more info,
> when there is no active load in system, the longest interval of 4
> seconds between 2 timer interrupts comes from the kernel watchdog
> for hardware/software lockup detector, and every CPU will have this
> timer, which limits the maximum cpu idle duration to be 4 seconds.
And thank you for the info! One way to reduce this overhead is to boot
with the watchdog_thresh kernel-boot parameter set to some value greater
than 10. The downside is that HW/FW/NMI catastrophes will need to last
for more than 10 seconds before the system complains. One approach
is to run with a small watchdog_thresh during testing and a larger one
in production.
Thanx, Paul
> > > ---
> > >
> > > diff --git a/kernel/sched/idle.c b/kernel/sched/idle.c
> > > index d17b0a5ce6ac..e12688036725 100644
> > > --- a/kernel/sched/idle.c
> > > +++ b/kernel/sched/idle.c
> > > @@ -258,15 +258,23 @@ static void cpuidle_idle_call(void)
> > > *
> > > * Called with polling cleared.
> > > */
> > > +DEFINE_PER_CPU(u64, last_util_update_time); /* in jiffies */
> > > static void do_idle(void)
> > > {
> > > int cpu = smp_processor_id();
> > > + u64 expire;
> > >
> > > /*
> > > * Check if we need to update blocked load
> > > */
> > > nohz_run_idle_balance(cpu);
> > >
> > > + expire = __this_cpu_read(last_util_update_time) + HZ * 3;
> > > + if (unlikely(time_is_before_jiffies((unsigned long)expire))) {
> > > + cpufreq_update_util(this_rq(), 0);
> >
> > And quite frankly I'm not sure if running cpufreq_update_util() from
> > here is safe.
>
> I had that concern too :). Do you mean this is called when the local
> irq is enabled, and could be interrupted causing some issue?
>
> Thanks,
> Feng
>
> > > + __this_cpu_write(last_util_update_time, get_jiffies_64());
> > > + }
> > > +
> > > /*
> > > * If the arch has a polling bit, we maintain an invariant:
> > > *
> > >
next prev parent reply other threads:[~2022-03-04 16:23 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <003f01d81c8c$d20ee3e0$762caba0$@telus.net>
2022-02-08 2:39 ` CPU excessively long times between frequency scaling driver calls - bisected Feng Tang
2022-02-08 7:13 ` Doug Smythies
2022-02-08 9:15 ` Feng Tang
2022-02-09 6:23 ` Doug Smythies
2022-02-10 7:45 ` Zhang, Rui
2022-02-13 18:54 ` Doug Smythies
2022-02-14 15:17 ` srinivas pandruvada
2022-02-15 21:35 ` Doug Smythies
2022-02-22 7:34 ` Feng Tang
2022-02-22 18:04 ` Rafael J. Wysocki
2022-02-23 0:07 ` Doug Smythies
2022-02-23 0:32 ` srinivas pandruvada
2022-02-23 0:40 ` Feng Tang
2022-02-23 14:23 ` Rafael J. Wysocki
2022-02-24 8:08 ` Feng Tang
2022-02-24 14:44 ` Paul E. McKenney
2022-02-24 16:29 ` Doug Smythies
2022-02-24 16:58 ` Paul E. McKenney
2022-02-25 0:29 ` Feng Tang
2022-02-25 1:06 ` Paul E. McKenney
2022-02-25 17:45 ` Rafael J. Wysocki
2022-02-26 0:36 ` Doug Smythies
2022-02-28 4:12 ` Feng Tang
2022-02-28 19:36 ` Rafael J. Wysocki
2022-03-01 5:52 ` Feng Tang
2022-03-01 11:58 ` Rafael J. Wysocki
2022-03-01 17:18 ` Doug Smythies
2022-03-01 17:34 ` Rafael J. Wysocki
2022-03-02 4:06 ` Doug Smythies
2022-03-02 19:00 ` Rafael J. Wysocki
2022-03-03 23:00 ` Doug Smythies
2022-03-04 6:59 ` Doug Smythies
2022-03-16 15:54 ` Doug Smythies
2022-03-17 12:30 ` Rafael J. Wysocki
2022-03-17 13:58 ` Doug Smythies
2022-03-24 14:04 ` Doug Smythies
2022-03-24 18:17 ` Rafael J. Wysocki
2022-03-25 0:03 ` Doug Smythies
2022-03-03 5:27 ` Feng Tang
2022-03-03 12:02 ` Rafael J. Wysocki
2022-03-04 5:13 ` Feng Tang
2022-03-04 16:23 ` Paul E. McKenney [this message]
2022-02-23 2:49 ` Feng Tang
2022-02-23 14:11 ` Rafael J. Wysocki
2022-02-23 9:40 ` Thomas Gleixner
2022-02-23 14:23 ` Rafael J. Wysocki
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=20220304162323.GN4285@paulmck-ThinkPad-P17-Gen-1 \
--to=paulmck@kernel.org \
--cc=dsmythies@telus.net \
--cc=feng.tang@intel.com \
--cc=linux-pm@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=rjw@rjwysocki.net \
--cc=rui.zhang@intel.com \
--cc=srinivas.pandruvada@linux.intel.com \
--cc=stable@vger.kernel.org \
--cc=tglx@linutronix.de \
--cc=tim.c.chen@intel.com \
--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