Re: [PATCH 1/3] x86, sched: Calculate frequency invariance for AMD systems
From: Peter Zijlstra
Date: Tue Nov 10 2020 - 04:50:51 EST
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.
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?