Re: [intel-pstate driver regression] processor frequency very high even if in idle

From: Srinivas Pandruvada
Date: Thu Mar 31 2016 - 13:58:35 EST


On Thu, 2016-03-31 at 19:27 +0200, JÃrg Otte wrote:
> 2016-03-31 17:43 GMT+02:00 Rafael J. Wysocki <rjw@xxxxxxxxxxxxx>:
> > On Thursday, March 31, 2016 05:25:18 PM JÃrg Otte wrote:
> > > 2016-03-31 13:42 GMT+02:00 Rafael J. Wysocki <rjw@xxxxxxxxxxxxx>:
> > > > On Thursday, March 31, 2016 11:05:56 AM JÃrg Otte wrote:
> > > >
> > > > [cut]
> > > >
> > > > > >
> > > > >
> > > > > Yes, works for me.
> > > > >
> > > > > CPUID(7): No-SGX
> > > > > ÂÂÂÂÂCPU Avg_MHzÂÂÂBusy% Bzy_MHz TSC_MHz
> > > > > ÂÂÂÂÂÂÂ-ÂÂÂÂÂÂ11ÂÂÂÂ0.66 1682 2494
> > > > > ÂÂÂÂÂÂÂ0ÂÂÂÂÂÂ11ÂÂÂÂ0.60 1856 2494
> > > > > ÂÂÂÂÂÂÂ1ÂÂÂÂÂÂÂ6ÂÂÂÂ0.34ÂÂÂÂ1898ÂÂÂÂ2494
> > > > > ÂÂÂÂÂÂÂ2ÂÂÂÂÂÂ13ÂÂÂÂ0.82ÂÂÂÂ1628ÂÂÂÂ2494
> > > > > ÂÂÂÂÂÂÂ3ÂÂÂÂÂÂ13ÂÂÂÂ0.87ÂÂÂÂ1528ÂÂÂÂ2494
> > > > > ÂÂÂÂÂCPU Avg_MHzÂÂÂBusy% Bzy_MHz TSC_MHz
> > > > > ÂÂÂÂÂÂÂ-ÂÂÂÂÂÂÂ6ÂÂÂÂ0.58ÂÂÂÂÂ963ÂÂÂÂ2494
> > > > > ÂÂÂÂÂÂÂ0ÂÂÂÂÂÂÂ8ÂÂÂÂ0.83ÂÂÂÂÂ957ÂÂÂÂ2494
> > > > > ÂÂÂÂÂÂÂ1ÂÂÂÂÂÂÂ1ÂÂÂÂ0.08ÂÂÂÂÂ984ÂÂÂÂ2494
> > > > > ÂÂÂÂÂÂÂ2ÂÂÂÂÂÂ10ÂÂÂÂ1.04ÂÂÂÂÂ975ÂÂÂÂ2494
> > > > > ÂÂÂÂÂÂÂ3ÂÂÂÂÂÂÂ3ÂÂÂÂ0.35ÂÂÂÂÂ934ÂÂÂÂ2494
> > > > >
> > > >
> >
> > [cut]
> >
> > > >
> > >
> > > No, this patch doesn't help.
> >
> > Well, more work to do then.
> >
> > I've just noticed a bug in this patch, which is not relevant for
> > the results,
> > but below is a new version.
> >
> > > CPUID(7): No-SGX
> > > ÂÂÂÂÂÂCPU Avg_MHzÂÂÂBusy% Bzy_MHz TSC_MHz
> > > ÂÂÂÂÂÂÂ-ÂÂÂÂÂÂÂ8ÂÂÂÂ0.32ÂÂÂÂ2507ÂÂÂÂ2495
> > > ÂÂÂÂÂÂÂ0ÂÂÂÂÂÂ13ÂÂÂÂ0.53ÂÂÂÂ2505ÂÂÂÂ2495
> > > ÂÂÂÂÂÂÂ1ÂÂÂÂÂÂÂ3ÂÂÂÂ0.11ÂÂÂÂ2523ÂÂÂÂ2495
> > > ÂÂÂÂÂÂÂ2ÂÂÂÂÂÂÂ1ÂÂÂÂ0.06ÂÂÂÂ2555ÂÂÂÂ2495
> > > ÂÂÂÂÂÂÂ3ÂÂÂÂÂÂ15ÂÂÂÂ0.59ÂÂÂÂ2500ÂÂÂÂ2495
> > > ÂÂÂÂÂCPU Avg_MHzÂÂÂBusy% Bzy_MHz TSC_MHz
> > > ÂÂÂÂÂÂÂ-ÂÂÂÂÂÂÂ8ÂÂÂÂ0.33ÂÂÂÂ2486ÂÂÂÂ2495
> > > ÂÂÂÂÂÂÂ0ÂÂÂÂÂÂ12ÂÂÂÂ0.50ÂÂÂÂ2482ÂÂÂÂ2495
> > > ÂÂÂÂÂÂÂ1ÂÂÂÂÂÂÂ5ÂÂÂÂ0.22ÂÂÂÂ2489ÂÂÂÂ2495
> > > ÂÂÂÂÂÂÂ2ÂÂÂÂÂÂÂ1ÂÂÂÂ0.04ÂÂÂÂ2492ÂÂÂÂ2495
> > > ÂÂÂÂÂÂÂ3ÂÂÂÂÂÂ15ÂÂÂÂ0.59ÂÂÂÂ2487ÂÂÂÂ2495
> >
> > Please apply the patch below and take a (1s or so) trace from the
> > pstate_sample
> > tracepoint (under /sys/kernel/debug/tracing/events/power/ on my
> > systems).
> >
> > Then please apply the revert instead of it and take a trace from
> > that tracepoint
> > again and send both of the traces to me.
> >
> > ---
> > From: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
> > Subject: [PATCH] intel_pstate: Do not set utilization update hook
> > too early
> >
> > The utilization update hook in the intel_pstate driver is set too
> > early, as it only should be set after the policy has been fully
> > initialized by the core.ÂÂThat may cause intel_pstate_update_util()
> > to use incorrect data and put the CPUs into incorrect P-states as
> > a result.
> >
> > To prevent that from happening, make intel_pstate_set_policy() set
> > the utilization update hook instead of intel_pstate_init_cpu() so
> > intel_pstate_update_util() only runs when all things have been
> > initialized as appropriate.
> >
> > Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
> > ---
> > Âdrivers/cpufreq/intel_pstate.c |ÂÂÂ27 +++++++++++++++++++--------
> > Â1 file changed, 19 insertions(+), 8 deletions(-)
> >
> > Index: linux-pm/drivers/cpufreq/intel_pstate.c
> > ===================================================================
> > --- linux-pm.orig/drivers/cpufreq/intel_pstate.c
> > +++ linux-pm/drivers/cpufreq/intel_pstate.c
> > @@ -1103,7 +1103,6 @@ static int intel_pstate_init_cpu(unsigne
> > ÂÂÂÂÂÂÂÂintel_pstate_sample(cpu, 0);
> >
> > ÂÂÂÂÂÂÂÂcpu->update_util.func = intel_pstate_update_util;
> > -ÂÂÂÂÂÂÂcpufreq_set_update_util_data(cpunum, &cpu->update_util);
> >
> > ÂÂÂÂÂÂÂÂpr_debug("intel_pstate: controlling: cpu %d\n", cpunum);
> >
> > @@ -1122,18 +1121,29 @@ static unsigned int intel_pstate_get(uns
> > ÂÂÂÂÂÂÂÂreturn get_avg_frequency(cpu);
> > Â}
> >
> > +static void intel_pstate_set_update_util_hook(unsigned int cpu)
> > +{
> > +ÂÂÂÂÂÂÂcpufreq_set_update_util_data(cpu, &all_cpu_data[cpu]-
> > >update_util);
> > +}
> > +
> > +static void intel_pstate_clear_update_util_hook(unsigned int cpu)
> > +{
> > +ÂÂÂÂÂÂÂcpufreq_set_update_util_data(cpu, NULL);
> > +ÂÂÂÂÂÂÂsynchronize_sched();
> > +}
> > +
> > Âstatic int intel_pstate_set_policy(struct cpufreq_policy *policy)
> > Â{
> > ÂÂÂÂÂÂÂÂif (!policy->cpuinfo.max_freq)
> > ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂreturn -ENODEV;
> >
> > +ÂÂÂÂÂÂÂintel_pstate_clear_update_util_hook(policy->cpu);
> > +
> > ÂÂÂÂÂÂÂÂif (policy->policy == CPUFREQ_POLICY_PERFORMANCE &&
> > ÂÂÂÂÂÂÂÂÂÂÂÂpolicy->max >= policy->cpuinfo.max_freq) {
> > ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂpr_debug("intel_pstate: set performance\n");
> > ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂlimits = &performance_limits;
> > -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂif (hwp_active)
> > -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂintel_pstate_hwp_set(policy->cpus);
> > -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂreturn 0;
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂgoto out;
> > ÂÂÂÂÂÂÂÂ}
> >
> > ÂÂÂÂÂÂÂÂpr_debug("intel_pstate: set powersave\n");
> > @@ -1163,6 +1173,9 @@ static int intel_pstate_set_policy(struc
> > ÂÂÂÂÂÂÂÂlimits->max_perf = div_fp(int_tofp(limits->max_perf_pct),
> > ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂint_tofp(100));
> >
> > + out:
> > +ÂÂÂÂÂÂÂintel_pstate_set_update_util_hook(policy->cpu);
> > +
> > ÂÂÂÂÂÂÂÂif (hwp_active)
> > ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂintel_pstate_hwp_set(policy->cpus);
> >
> > @@ -1187,8 +1200,7 @@ static void intel_pstate_stop_cpu(struct
> >
> > ÂÂÂÂÂÂÂÂpr_debug("intel_pstate: CPU %d exiting\n", cpu_num);
> >
> > -ÂÂÂÂÂÂÂcpufreq_set_update_util_data(cpu_num, NULL);
> > -ÂÂÂÂÂÂÂsynchronize_sched();
> > +ÂÂÂÂÂÂÂintel_pstate_clear_update_util_hook(cpu_num);
> >
> > ÂÂÂÂÂÂÂÂif (hwp_active)
> > ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂreturn;
> > @@ -1455,8 +1467,7 @@ out:
> > ÂÂÂÂÂÂÂÂget_online_cpus();
> > ÂÂÂÂÂÂÂÂfor_each_online_cpu(cpu) {
> > ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂif (all_cpu_data[cpu]) {
> > -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂcpufreq_set_update_util_data(cpu, NULL);
> > -ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂsynchronize_sched();
> > +ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂintel_pstate_clear_update_util_hook(cpu);
> > ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂkfree(all_cpu_data[cpu]);
> > ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ}
> > ÂÂÂÂÂÂÂÂ}
> >
>
> OK, patch is applied.
> After some configurations and compilations I'm there.
> Under pstate_sample I see:
> enableÂÂfilterÂÂformatÂÂidÂÂtrigger
>
> what to do now ? (never did tracing before)'

# cd /sys/kernel/debug/tracing/
# echo 1 > events/power/pstate_sample/enable
# echo 1 > events/power/cpu_frequency/enable
# cat trace
Send us the trace file.

Also your kernel config doesn't have many modules, Is it a custom
configuration you do for your system?

Thanks,
Srinivas

Â
>
> Thanks, JÃrg