Message ID | 20180315030756.5548-1-douly.fnst@cn.fujitsu.com (mailing list archive) |
---|---|
State | RFC, archived |
Headers | show |
On Thu, 15 Mar 2018, Dou Liyang wrote: > > +static void __init acpi_update_possible_map(void) > +{ > + unsigned int cpu; > + > + if (nr_unique_ids >= nr_cpu_ids) > + return; > + > + /* Don't yet figure out if it's superfluous */ > + if (nr_unique_ids >= cpumask_last(cpu_possible_mask)) > + return; > + > + for_each_cpu_wrap(cpu, cpu_possible_mask, nr_unique_ids) > + set_cpu_possible(cpu, false); > + > + nr_cpu_ids = nr_unique_ids; > + pr_info("Allowing %d possible CPUs\n", nr_cpu_ids); > +} > + > static void __init acpi_processor_check_duplicates(void) > { > /* check the correctness for all processors in ACPI namespace */ > @@ -680,6 +698,9 @@ static void __init acpi_processor_check_duplicates(void) > NULL, NULL, NULL); > acpi_get_devices(ACPI_PROCESSOR_DEVICE_HID, acpi_processor_ids_walk, > NULL, NULL); > + > + /* make possible CPU count more realistic */ > + acpi_update_possible_map(); > } I tested this on a machine which claims to have gazillion of hotplugable CPUs: smpboot: Allowing 152 CPUs, 120 hotplug CPUs setup_percpu: NR_CPUS:512 nr_cpumask_bits:512 nr_cpu_ids:152 nr_node_ids:2 smp: Brought up 2 nodes, 32 CPUs Now with your patch applied it's still saying: smpboot: Allowing 152 CPUs, 120 hotplug CPUs setup_percpu: NR_CPUS:512 nr_cpumask_bits:512 nr_cpu_ids:152 nr_node_ids:2 smp: Brought up 2 nodes, 32 CPUs and the above code runs later on and the result is: nr_unique_ids 1 nr_cpu_ids 152 Allowing 1 possible CPU which subsequently causes the machine to die as we have already 32 CPUs online. So nr_unique_ids is not what it should be and even if it would be the code runs way too late. It needs to run _before_ setup_percpu() is invoked to scale everything correctly. Thanks, tglx -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Thomas, At 03/15/2018 09:45 PM, Thomas Gleixner wrote: [...] > I tested this on a machine which claims to have gazillion of hotplugable > CPUs: I really appreciate your test. > > smpboot: Allowing 152 CPUs, 120 hotplug CPUs > setup_percpu: NR_CPUS:512 nr_cpumask_bits:512 nr_cpu_ids:152 nr_node_ids:2 > smp: Brought up 2 nodes, 32 CPUs > > Now with your patch applied it's still saying: > > smpboot: Allowing 152 CPUs, 120 hotplug CPUs > setup_percpu: NR_CPUS:512 nr_cpumask_bits:512 nr_cpu_ids:152 nr_node_ids:2 > smp: Brought up 2 nodes, 32 CPUs > > and the above code runs later on and the result is: > > nr_unique_ids 1 nr_cpu_ids 152 > Allowing 1 possible CPU > > which subsequently causes the machine to die as we have already 32 CPUs > online. > That is so interesting, it proofs that this strategy is risky. I've been wondering how to determine the number of possible CPUs. Due to the diversity of ACPI in different systems, that seems impossible. Why don't I change my mind? Here is a new strategy and I think it is more reasonable and minimally invasive. As we all know, we reset possible CPUs in the prefill_possible_map(), If CONFIG_HOTPLUG_CPU = y : nr_possible_CPUs = num_processors + disabled_cpus. Before the prefill_possible_map(), *Fix the inaccurate disabled_cpus*: 1) For each disabled CPUs, get it's processor id from ACPI MADT 2) Check whether this processor id is existed in ACPI namespace or not. If false, disabled_cpus--; I will show you the code and test it later. And IMO, the code logic in prefill_possible_map() is a little mess, will try to sort it out first. > So nr_unique_ids is not what it should be and even if it would be the code > runs way too late. It needs to run _before_ setup_percpu() is invoked to > scale everything correctly. > Yes, Got it. Thanks, dou > Thanks, > > tglx > > > > > > -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c index 449d86d39965..ac45380f4439 100644 --- a/drivers/acpi/acpi_processor.c +++ b/drivers/acpi/acpi_processor.c @@ -671,6 +671,24 @@ static acpi_status __init acpi_processor_ids_walk(acpi_handle handle, } +static void __init acpi_update_possible_map(void) +{ + unsigned int cpu; + + if (nr_unique_ids >= nr_cpu_ids) + return; + + /* Don't yet figure out if it's superfluous */ + if (nr_unique_ids >= cpumask_last(cpu_possible_mask)) + return; + + for_each_cpu_wrap(cpu, cpu_possible_mask, nr_unique_ids) + set_cpu_possible(cpu, false); + + nr_cpu_ids = nr_unique_ids; + pr_info("Allowing %d possible CPUs\n", nr_cpu_ids); +} + static void __init acpi_processor_check_duplicates(void) { /* check the correctness for all processors in ACPI namespace */ @@ -680,6 +698,9 @@ static void __init acpi_processor_check_duplicates(void) NULL, NULL, NULL); acpi_get_devices(ACPI_PROCESSOR_DEVICE_HID, acpi_processor_ids_walk, NULL, NULL); + + /* make possible CPU count more realistic */ + acpi_update_possible_map(); } bool acpi_duplicate_processor_id(int proc_id)
Rafael J told me in order for the ACPI-based physical CPU hotplug to work, there have to be objects in the ACPI namespace corresponding to all of the processors in question. If they are not present, there is no way to signal insertion and eject the processors safely. But, Kernel calculates the possible CPU count from the number of Local APIC entries in ACPI MADT. It doesn't consider with the ACPI namespace and reports unrealistically high numbers. And kernel allocates resources according to num_possible_cpus(), such as vectors, that may cause vector space exhaustion and even bugs. Depth-first search the namespace tree, check and collect the correct CPUs and update the possible map. Signed-off-by: Dou Liyang <douly.fnst@cn.fujitsu.com> --- Changelog v1 --> v2: -Optimize the code by Andy Shevchenko's suggestion -modify the changelog drivers/acpi/acpi_processor.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+)