Message ID | 20230913163823.7880-21-james.morse@arm.com |
---|---|
State | New |
Headers | show |
Series | ACPI/arm64: add support for virtual cpuhotplug | expand |
On Wed, 13 Sep 2023 16:38:08 +0000 James Morse <james.morse@arm.com> wrote: > acpi_processor_hotadd_init() will make a CPU present by mapping it > based on its hardware id. > > 'hotadd_init' is ambiguous once there are two different behaviours > for cpu hotplug. This is for toggling the _STA present bit. Subsequent > patches will add support for toggling the _STA enabled bit, named > acpi_processor_make_enabled(). > > Rename it acpi_processor_make_present() to make it clear this is > for CPUs that were not previously present. > > Expose the function prototypes it uses to allow the preprocessor > guards to be removed. The IS_ENABLED() check will let the compiler > dead-code elimination pass remove this if it isn't going to be > used. > > Signed-off-by: James Morse <james.morse@arm.com> > --- > drivers/acpi/acpi_processor.c | 14 +++++--------- > include/linux/acpi.h | 2 -- > 2 files changed, 5 insertions(+), 11 deletions(-) > > diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c > index 75257fae10e7..22a15a614f95 100644 > --- a/drivers/acpi/acpi_processor.c > +++ b/drivers/acpi/acpi_processor.c > @@ -182,13 +182,15 @@ static void __init acpi_pcc_cpufreq_init(void) {} > #endif /* CONFIG_X86 */ > > /* Initialization */ > -#ifdef CONFIG_ACPI_HOTPLUG_PRESENT_CPU > -static int acpi_processor_hotadd_init(struct acpi_processor *pr) > +static int acpi_processor_make_present(struct acpi_processor *pr) > { > unsigned long long sta; > acpi_status status; > int ret; > > + if (!IS_ENABLED(CONFIG_ACPI_HOTPLUG_PRESENT_CPU)) > + return -ENODEV; > + > if (invalid_phys_cpuid(pr->phys_id)) > return -ENODEV; > > @@ -222,12 +224,6 @@ static int acpi_processor_hotadd_init(struct acpi_processor *pr) > cpu_maps_update_done(); > return ret; > } > -#else > -static inline int acpi_processor_hotadd_init(struct acpi_processor *pr) > -{ > - return -ENODEV; > -} > -#endif /* CONFIG_ACPI_HOTPLUG_PRESENT_CPU */ > > static int acpi_processor_get_info(struct acpi_device *device) > { > @@ -335,7 +331,7 @@ static int acpi_processor_get_info(struct acpi_device *device) > * because cpuid <-> apicid mapping is persistent now. > */ > if (invalid_logical_cpuid(pr->id) || !cpu_present(pr->id)) { > - int ret = acpi_processor_hotadd_init(pr); > + int ret = acpi_processor_make_present(pr); > > if (ret) > return ret; > diff --git a/include/linux/acpi.h b/include/linux/acpi.h > index 651dd43976a9..b7ab85857bb7 100644 > --- a/include/linux/acpi.h > +++ b/include/linux/acpi.h > @@ -316,12 +316,10 @@ static inline int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu, > } > #endif > > -#ifdef CONFIG_ACPI_HOTPLUG_PRESENT_CPU > /* Arch dependent functions for cpu hotplug support */ > int acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, u32 acpi_id, > int *pcpu); > int acpi_unmap_cpu(int cpu); I've lost track somewhat but I think the definitions of these are still under ifdefs which is messy if nothing else and might cause build issues. > -#endif /* CONFIG_ACPI_HOTPLUG_PRESENT_CPU */ > > #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC > int acpi_get_ioapic_id(acpi_handle handle, u32 gsi_base, u64 *phys_addr);
On 9/15/23 00:17, Jonathan Cameron wrote: > On Wed, 13 Sep 2023 16:38:08 +0000 > James Morse <james.morse@arm.com> wrote: > >> acpi_processor_hotadd_init() will make a CPU present by mapping it >> based on its hardware id. >> >> 'hotadd_init' is ambiguous once there are two different behaviours >> for cpu hotplug. This is for toggling the _STA present bit. Subsequent >> patches will add support for toggling the _STA enabled bit, named >> acpi_processor_make_enabled(). >> >> Rename it acpi_processor_make_present() to make it clear this is >> for CPUs that were not previously present. >> >> Expose the function prototypes it uses to allow the preprocessor >> guards to be removed. The IS_ENABLED() check will let the compiler >> dead-code elimination pass remove this if it isn't going to be >> used. >> >> Signed-off-by: James Morse <james.morse@arm.com> >> --- >> drivers/acpi/acpi_processor.c | 14 +++++--------- >> include/linux/acpi.h | 2 -- >> 2 files changed, 5 insertions(+), 11 deletions(-) >> >> diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c >> index 75257fae10e7..22a15a614f95 100644 >> --- a/drivers/acpi/acpi_processor.c >> +++ b/drivers/acpi/acpi_processor.c >> @@ -182,13 +182,15 @@ static void __init acpi_pcc_cpufreq_init(void) {} >> #endif /* CONFIG_X86 */ >> >> /* Initialization */ >> -#ifdef CONFIG_ACPI_HOTPLUG_PRESENT_CPU >> -static int acpi_processor_hotadd_init(struct acpi_processor *pr) >> +static int acpi_processor_make_present(struct acpi_processor *pr) >> { >> unsigned long long sta; >> acpi_status status; >> int ret; >> >> + if (!IS_ENABLED(CONFIG_ACPI_HOTPLUG_PRESENT_CPU)) >> + return -ENODEV; >> + >> if (invalid_phys_cpuid(pr->phys_id)) >> return -ENODEV; >> >> @@ -222,12 +224,6 @@ static int acpi_processor_hotadd_init(struct acpi_processor *pr) >> cpu_maps_update_done(); >> return ret; >> } >> -#else >> -static inline int acpi_processor_hotadd_init(struct acpi_processor *pr) >> -{ >> - return -ENODEV; >> -} >> -#endif /* CONFIG_ACPI_HOTPLUG_PRESENT_CPU */ >> >> static int acpi_processor_get_info(struct acpi_device *device) >> { >> @@ -335,7 +331,7 @@ static int acpi_processor_get_info(struct acpi_device *device) >> * because cpuid <-> apicid mapping is persistent now. >> */ >> if (invalid_logical_cpuid(pr->id) || !cpu_present(pr->id)) { >> - int ret = acpi_processor_hotadd_init(pr); >> + int ret = acpi_processor_make_present(pr); >> >> if (ret) >> return ret; >> diff --git a/include/linux/acpi.h b/include/linux/acpi.h >> index 651dd43976a9..b7ab85857bb7 100644 >> --- a/include/linux/acpi.h >> +++ b/include/linux/acpi.h >> @@ -316,12 +316,10 @@ static inline int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu, >> } >> #endif >> >> -#ifdef CONFIG_ACPI_HOTPLUG_PRESENT_CPU >> /* Arch dependent functions for cpu hotplug support */ >> int acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, u32 acpi_id, >> int *pcpu); >> int acpi_unmap_cpu(int cpu); > > I've lost track somewhat but I think the definitions of these are still under ifdefs > which is messy if nothing else and might cause build issues. > Yup, it's not safe to use 'if (!IS_ENABLED(CONFIG_ACPI_HOTPLUG_PRESENT_CPU))' in acpi_processor_make_present() until the ifdefs are removed for those two functions in individual architectures. >> -#endif /* CONFIG_ACPI_HOTPLUG_PRESENT_CPU */ >> >> #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC >> int acpi_get_ioapic_id(acpi_handle handle, u32 gsi_base, u64 *phys_addr); Thanks, Gavin
On Mon, Sep 18, 2023 at 03:50:09PM +1000, Gavin Shan wrote: > > On 9/15/23 00:17, Jonathan Cameron wrote: > > On Wed, 13 Sep 2023 16:38:08 +0000 > > James Morse <james.morse@arm.com> wrote: > > > > > acpi_processor_hotadd_init() will make a CPU present by mapping it > > > based on its hardware id. > > > > > > 'hotadd_init' is ambiguous once there are two different behaviours > > > for cpu hotplug. This is for toggling the _STA present bit. Subsequent > > > patches will add support for toggling the _STA enabled bit, named > > > acpi_processor_make_enabled(). > > > > > > Rename it acpi_processor_make_present() to make it clear this is > > > for CPUs that were not previously present. > > > > > > Expose the function prototypes it uses to allow the preprocessor > > > guards to be removed. The IS_ENABLED() check will let the compiler > > > dead-code elimination pass remove this if it isn't going to be > > > used. > > > > > > Signed-off-by: James Morse <james.morse@arm.com> > > > --- > > > drivers/acpi/acpi_processor.c | 14 +++++--------- > > > include/linux/acpi.h | 2 -- > > > 2 files changed, 5 insertions(+), 11 deletions(-) > > > > > > diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c > > > index 75257fae10e7..22a15a614f95 100644 > > > --- a/drivers/acpi/acpi_processor.c > > > +++ b/drivers/acpi/acpi_processor.c > > > @@ -182,13 +182,15 @@ static void __init acpi_pcc_cpufreq_init(void) {} > > > #endif /* CONFIG_X86 */ > > > /* Initialization */ > > > -#ifdef CONFIG_ACPI_HOTPLUG_PRESENT_CPU > > > -static int acpi_processor_hotadd_init(struct acpi_processor *pr) > > > +static int acpi_processor_make_present(struct acpi_processor *pr) > > > { > > > unsigned long long sta; > > > acpi_status status; > > > int ret; > > > + if (!IS_ENABLED(CONFIG_ACPI_HOTPLUG_PRESENT_CPU)) > > > + return -ENODEV; > > > + > > > if (invalid_phys_cpuid(pr->phys_id)) > > > return -ENODEV; > > > @@ -222,12 +224,6 @@ static int acpi_processor_hotadd_init(struct acpi_processor *pr) > > > cpu_maps_update_done(); > > > return ret; > > > } > > > -#else > > > -static inline int acpi_processor_hotadd_init(struct acpi_processor *pr) > > > -{ > > > - return -ENODEV; > > > -} > > > -#endif /* CONFIG_ACPI_HOTPLUG_PRESENT_CPU */ > > > static int acpi_processor_get_info(struct acpi_device *device) > > > { > > > @@ -335,7 +331,7 @@ static int acpi_processor_get_info(struct acpi_device *device) > > > * because cpuid <-> apicid mapping is persistent now. > > > */ > > > if (invalid_logical_cpuid(pr->id) || !cpu_present(pr->id)) { > > > - int ret = acpi_processor_hotadd_init(pr); > > > + int ret = acpi_processor_make_present(pr); > > > if (ret) > > > return ret; > > > diff --git a/include/linux/acpi.h b/include/linux/acpi.h > > > index 651dd43976a9..b7ab85857bb7 100644 > > > --- a/include/linux/acpi.h > > > +++ b/include/linux/acpi.h > > > @@ -316,12 +316,10 @@ static inline int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu, > > > } > > > #endif > > > -#ifdef CONFIG_ACPI_HOTPLUG_PRESENT_CPU > > > /* Arch dependent functions for cpu hotplug support */ > > > int acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, u32 acpi_id, > > > int *pcpu); > > > int acpi_unmap_cpu(int cpu); > > > > I've lost track somewhat but I think the definitions of these are still under ifdefs > > which is messy if nothing else and might cause build issues. > > > > Yup, it's not safe to use 'if (!IS_ENABLED(CONFIG_ACPI_HOTPLUG_PRESENT_CPU))' in > acpi_processor_make_present() until the ifdefs are removed for those two functions > in individual architectures. The same thing appears in a final patch that James seems to have added to the repository: ACPI: processor: Only call arch_unregister_cpu() if HOTPLUG_CPU is selected in which acpi_processor_post_eject() has this change: - if (!device) + if (!IS_ENABLED(CONFIG_HOTPLUG_CPU) || !device) I'm wondering if that's caused by a previous patch making the weak definition of arch_unregister_cpu() dependent on HOTPLUG_CPU, and whether dropping that ifdef around the function would be better. I think I already asked that question, but this final patch seems to be the confirmation that we need to provide a definition of it. I think the reason James did it like that is because unregister_cpu() is dependent upon CONFIG_HOTPLUG_CPU, but it's probably better to do: #ifdef CONFIG_HOTPLUG_CPU void __weak arch_unregister_cpu(int num) { unregister_cpu(&per_cpu(cpu_devices, num)); } #else void __weak arch_unregister_cpu(int num) { } #endif Agreed?
diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c index 75257fae10e7..22a15a614f95 100644 --- a/drivers/acpi/acpi_processor.c +++ b/drivers/acpi/acpi_processor.c @@ -182,13 +182,15 @@ static void __init acpi_pcc_cpufreq_init(void) {} #endif /* CONFIG_X86 */ /* Initialization */ -#ifdef CONFIG_ACPI_HOTPLUG_PRESENT_CPU -static int acpi_processor_hotadd_init(struct acpi_processor *pr) +static int acpi_processor_make_present(struct acpi_processor *pr) { unsigned long long sta; acpi_status status; int ret; + if (!IS_ENABLED(CONFIG_ACPI_HOTPLUG_PRESENT_CPU)) + return -ENODEV; + if (invalid_phys_cpuid(pr->phys_id)) return -ENODEV; @@ -222,12 +224,6 @@ static int acpi_processor_hotadd_init(struct acpi_processor *pr) cpu_maps_update_done(); return ret; } -#else -static inline int acpi_processor_hotadd_init(struct acpi_processor *pr) -{ - return -ENODEV; -} -#endif /* CONFIG_ACPI_HOTPLUG_PRESENT_CPU */ static int acpi_processor_get_info(struct acpi_device *device) { @@ -335,7 +331,7 @@ static int acpi_processor_get_info(struct acpi_device *device) * because cpuid <-> apicid mapping is persistent now. */ if (invalid_logical_cpuid(pr->id) || !cpu_present(pr->id)) { - int ret = acpi_processor_hotadd_init(pr); + int ret = acpi_processor_make_present(pr); if (ret) return ret; diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 651dd43976a9..b7ab85857bb7 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -316,12 +316,10 @@ static inline int acpi_processor_evaluate_cst(acpi_handle handle, u32 cpu, } #endif -#ifdef CONFIG_ACPI_HOTPLUG_PRESENT_CPU /* Arch dependent functions for cpu hotplug support */ int acpi_map_cpu(acpi_handle handle, phys_cpuid_t physid, u32 acpi_id, int *pcpu); int acpi_unmap_cpu(int cpu); -#endif /* CONFIG_ACPI_HOTPLUG_PRESENT_CPU */ #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC int acpi_get_ioapic_id(acpi_handle handle, u32 gsi_base, u64 *phys_addr);
acpi_processor_hotadd_init() will make a CPU present by mapping it based on its hardware id. 'hotadd_init' is ambiguous once there are two different behaviours for cpu hotplug. This is for toggling the _STA present bit. Subsequent patches will add support for toggling the _STA enabled bit, named acpi_processor_make_enabled(). Rename it acpi_processor_make_present() to make it clear this is for CPUs that were not previously present. Expose the function prototypes it uses to allow the preprocessor guards to be removed. The IS_ENABLED() check will let the compiler dead-code elimination pass remove this if it isn't going to be used. Signed-off-by: James Morse <james.morse@arm.com> --- drivers/acpi/acpi_processor.c | 14 +++++--------- include/linux/acpi.h | 2 -- 2 files changed, 5 insertions(+), 11 deletions(-)