mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [RFC PATCH v2] ACPI / processor: Fix possible CPUs map
@ 2018-03-15  3:07 Dou Liyang
  2018-03-15 13:45 ` Thomas Gleixner
  2018-03-19  6:28 ` [ACPI / processor] c1294b481b: WARNING:at_include/linux/cpumask.h:#invoke_rcu_core kernel test robot
  0 siblings, 2 replies; 4+ messages in thread
From: Dou Liyang @ 2018-03-15  3:07 UTC (permalink / raw)
  To: linux-acpi, linux-kernel
  Cc: rjw, lenb, tglx, rafael, dedekind1, ming.lei, andy.shevchenko,
	Dou Liyang

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(+)

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)
-- 
2.14.3

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-03-19  6:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-15  3:07 [RFC PATCH v2] ACPI / processor: Fix possible CPUs map Dou Liyang
2018-03-15 13:45 ` Thomas Gleixner
2018-03-16  2:51   ` Dou Liyang
2018-03-19  6:28 ` [ACPI / processor] c1294b481b: WARNING:at_include/linux/cpumask.h:#invoke_rcu_core kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®