lkml.org 
[lkml]   [2019]   [Mar]   [19]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    Date
    SubjectRe: [PATCH V2] cpufreq: Call transition notifier only once for each policy
    On Tue, Mar 19, 2019 at 6:50 AM Viresh Kumar <viresh.kumar@linaro.org> wrote:
    >
    > On 18-03-19, 12:49, Rafael J. Wysocki wrote:
    > > To summarize, I think that it would be sufficient to do this just for
    > > policy->cpu and, as Peter said, warn once if there are more CPUs in
    > > the policy or policy->cpu is not the CPU running this code. And mark
    > > the TSC as unstable in both of these cases.
    >
    > How about this ?

    We guarantee that this will always run on policy->cpu IIRC, so it LGTM
    overall, but the new message is missing "one".

    > diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
    > index 3fae23834069..4d3681cfb6e0 100644
    > --- a/arch/x86/kernel/tsc.c
    > +++ b/arch/x86/kernel/tsc.c
    > @@ -958,10 +958,13 @@ static int time_cpufreq_notifier(struct notifier_block *nb, unsigned long val,
    > struct cpufreq_freqs *freq = data;
    > unsigned long *lpj;
    >
    > + if (WARN_ON_ONCE(cpumask_weight(freq->policy->related_cpus) != 1))
    > + mark_tsc_unstable("cpufreq policy has more than CPU");

    Also I would check policy->cpus here. After all, we don't care about
    CPUs that are never online.

    And the message could be something like "cpufreq changes: related CPUs
    affected".

    > +
    > lpj = &boot_cpu_data.loops_per_jiffy;
    > #ifdef CONFIG_SMP
    > if (!(freq->flags & CPUFREQ_CONST_LOOPS))
    > - lpj = &cpu_data(freq->cpu).loops_per_jiffy;
    > + lpj = &cpu_data(freq->policy->cpu).loops_per_jiffy;
    > #endif
    >
    > if (!ref_freq) {
    > @@ -977,7 +980,7 @@ static int time_cpufreq_notifier(struct notifier_block *nb, unsigned long val,
    > if (!(freq->flags & CPUFREQ_CONST_LOOPS))
    > mark_tsc_unstable("cpufreq changes");
    >
    > - set_cyc2ns_scale(tsc_khz, freq->cpu, rdtsc());
    > + set_cyc2ns_scale(tsc_khz, freq->policy->cpu, rdtsc());
    > }
    >
    > return 0;

    \
     
     \ /
      Last update: 2019-03-19 10:42    [W:3.145 / U:2.728 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site