[patch 24/28] drivers/base/cpu.c: fix maxcpus boot option

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Youquan Song <youquan.song@xxxxxxxxx>
Subject: drivers/base/cpu.c: fix maxcpus boot option

The maxcpus boot option limits the maximum number of CPUs in the system,
but this option is broken in recent kernels.  Though we use maxcpus to
limit CPUs number, the current kernel will register all of the present
CPUs in sysfs.  udev will enumerate all registered cpu in sysfs, and it
will bring up the CPU if the CPU is offline.  So the maxcpus option is
broken.

This patch will only register a CPU which is not over the limit of the
maxcpus option in sysfs.  So it will keep the maxcpus limitation during
udev enumeration or other bringup of CPUs over the limitation by methods
such as echo 1 > /sys/devices/system/cpu/online

[akpm@xxxxxxxxxxxxxxxxxxxx: fix CONFIG_SMP=n build]
Signed-off-by: Youquan Song <youquan.song@xxxxxxxxx>
Cc: Greg KH <greg@xxxxxxxxx>
Cc: <stable@xxxxxxxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 drivers/base/cpu.c |    6 ++++++
 1 file changed, 6 insertions(+)

diff -puN drivers/base/cpu.c~drivers-base-cpuc-fix-maxcpus-boot-option drivers/base/cpu.c
--- a/drivers/base/cpu.c~drivers-base-cpuc-fix-maxcpus-boot-option
+++ a/drivers/base/cpu.c
@@ -272,6 +272,12 @@ int __cpuinit register_cpu(struct cpu *c
 {
 	int error;
 
+#ifdef CONFIG_SMP
+	/* return when cpu number greater than maximum number of CPUs */
+	if (num >= setup_max_cpus)
+		return 0;
+#endif
+
 	cpu->node_id = cpu_to_node(num);
 	memset(&cpu->dev, 0x00, sizeof(struct device));
 	cpu->dev.id = num;
_
--
To unsubscribe from this list: send the line "unsubscribe stable" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel]     [Kernel Development Newbies]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite Hiking]     [Linux Kernel]     [Linux SCSI]