On Tue, 2020-11-10 at 10:49 +0100, Peter Zijlstra wrote:
> On Tue, Nov 10, 2020 at 09:39:34AM +0100, Giovanni Gherdovich wrote:
> 
> > +#ifdef CONFIG_ACPI
> > +void init_freq_invariance_cppc(void)
> > +{
> > +   init_freq_invariance(false, true);
> > +
> > +   if (static_branch_likely(&arch_scale_freq_key))
> > +           on_each_cpu(init_counter_refs, NULL, 0);
> > +}
> > +#endif
> > +
> >  static void disable_freq_invariance_workfn(struct work_struct *work)
> >  {
> >     static_branch_disable(&arch_scale_freq_key);
> > diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c
> > index 7a99b19bb893..e1969ff876ff 100644
> > --- a/drivers/acpi/cppc_acpi.c
> > +++ b/drivers/acpi/cppc_acpi.c
> > @@ -39,6 +39,7 @@
> >  #include <linux/ktime.h>
> >  #include <linux/rwsem.h>
> >  #include <linux/wait.h>
> > +#include <linux/topology.h>
> >  
> >  #include <acpi/cppc_acpi.h>
> >  
> > @@ -850,6 +851,10 @@ int acpi_cppc_processor_probe(struct acpi_processor 
> > *pr)
> >             goto out_free;
> >     }
> >  
> > +   /* Only needed once, so call on CPU0 */
> > +   if (pr->id == 0)
> > +           init_freq_invariance_cppc();
> > +
> 
> This seems broken vs lovely things like booting with maxcpus= or
> physical hotplug where you add logical CPUs.

Right.

> 
> Given the latter hunk limits it to one invocation (is phys_id 0
> guaranteed to exist? Can a BIOS monkey screw us over?) only to then call
> it on all CPUs, shouldn't this be changed to let
> acpi_cppc_processor_probe() call it for every CPU that comes online?

I sent a V2 that basically does that, it just makes sure that
"init_freq_invariance(secondary=false)" is called only once (the first CPU
that gets there), and init_counter_refs() instead is called by all.

Which makes me think, I could make better use of the "secondary" argument
to init_freq_invariance() and trim a couple of lines from
init_freq_invariance_cppc().


Giovanni





Reply via email to