[RFC] don't create cpu/online sysfs file
Joel Schopp
jschopp at austin.ibm.com
Sat Jun 5 08:06:14 EST 2004
I might change cpu_is_hotpluggable to __cpu_is_hotpluggable to help
indicate it is a platform specific function. Also, won't you want to
stub out the function for the other platforms that do cpu hotplug?
-Joel
Dave Hansen wrote:
> I sent this out earlier this week, but wanted to make sure everybody is
> happy with it before I sent it upstream. I'm doing it backwards:
> [PATCH] before [RFC]. :)
>
> Rusty said he didn't have a problem with it already. Anton, do mind
> putting this in your patch queue, or should I send it upstream myself?
>
> --
>
> The following patch restricts creation of the
> /sys/devices/system/cpu/cpuX/online file to conditions where it is known
> that cpu hotplugging might be possible. It also leaves room for a much
> more complex method of deciding this information in the future, on a
> per-cpu basis.
>
> It fixes a bug where CPU hotplug ppc64 RTAS calls were being made on a
> non-partitioned system. This caused RTAS assertions, which are bad.
>
> Any new architecture that defines CONFIG_HOTPLUG_CPU will need to
> implement a cpu_is_hotpluggable() function. This could be overcome by a
> series of #ifdefs, but I think someone porting CPU hotplug to a new
> architecture can figure this one out.
> Tested on 16-way ppc64 LPAR and 8-way bare-metal ppc64. Compile tested
> on x86.
>
> -- Dave
>
>
> ------------------------------------------------------------------------
>
> Signed-off-by: Dave Hansen <haveblue at us.ibm.com>
>
> diff -urp linux-2.6.7-rc2-mm2-clean/arch/ppc64/kernel/smp.c linux-2.6.7-rc2-mm2-cpuonline/arch/ppc64/kernel/smp.c
> --- linux-2.6.7-rc2-mm2-clean/arch/ppc64/kernel/smp.c Fri Jun 4 13:27:13 2004
> +++ linux-2.6.7-rc2-mm2-cpuonline/arch/ppc64/kernel/smp.c Fri Jun 4 13:27:29 2004
> @@ -444,6 +444,21 @@ static inline void look_for_more_cpus(vo
> for (i = 0; i < maxcpus; i++)
> cpu_set(i, cpu_possible_map);
> }
> +
> +int cpu_is_hotpluggable(struct cpu *cpu)
> +{
> + /*
> + * For now, we just see if the system supports making
> + * the RTAS calls for CPU hotplug. But, there may be a
> + * more comprehensive way to do this for an individual
> + * CPU. For instance, the boot cpu might never be valid
> + * for hotplugging.
> + */
> + if (systemcfg->platform == PLATFORM_PSERIES_LPAR)
> + return 1;
> +
> + return 0;
> +}
> #else /* ... CONFIG_HOTPLUG_CPU */
> static inline int __devinit smp_startup_cpu(unsigned int lcpu)
> {
> diff -urp linux-2.6.7-rc2-mm2-clean/drivers/base/cpu.c linux-2.6.7-rc2-mm2-cpuonline/drivers/base/cpu.c
> --- linux-2.6.7-rc2-mm2-clean/drivers/base/cpu.c Fri Jun 4 13:27:09 2004
> +++ linux-2.6.7-rc2-mm2-cpuonline/drivers/base/cpu.c Fri Jun 4 13:27:29 2004
> @@ -48,7 +48,8 @@ static SYSDEV_ATTR(online, 0600, show_on
>
> static void __init register_cpu_control(struct cpu *cpu)
> {
> - sysdev_create_file(&cpu->sysdev, &attr_online);
> + if (cpu_is_hotpluggable(cpu))
> + sysdev_create_file(&cpu->sysdev, &attr_online);
> }
> #else /* ... !CONFIG_HOTPLUG_CPU */
> static inline void register_cpu_control(struct cpu *cpu)
> diff -urp linux-2.6.7-rc2-mm2-clean/include/linux/cpu.h linux-2.6.7-rc2-mm2-cpuonline/include/linux/cpu.h
> --- linux-2.6.7-rc2-mm2-clean/include/linux/cpu.h Fri Jun 4 13:27:11 2004
> +++ linux-2.6.7-rc2-mm2-cpuonline/include/linux/cpu.h Fri Jun 4 13:27:29 2004
> @@ -65,6 +65,10 @@ extern struct semaphore cpucontrol;
> register_cpu_notifier(&fn##_nb); \
> }
> int cpu_down(unsigned int cpu);
> +
> +/* expected to be defined in arch-specific code */
> +extern int cpu_is_hotpluggable(struct cpu *cpu);
> +
> #define cpu_is_offline(cpu) unlikely(!cpu_online(cpu))
> #else
> #define lock_cpu_hotplug() do { } while (0)
> @@ -74,6 +78,7 @@ int cpu_down(unsigned int cpu);
>
> /* CPUs don't go offline once they're online w/o CONFIG_HOTPLUG_CPU */
> #define cpu_is_offline(cpu) 0
> +#define cpu_is_hotpluggable(cpu) 0
> #endif
>
> #endif /* _LINUX_CPU_H_ */
** Sent via the linuxppc64-dev mail list. See http://lists.linuxppc.org/
More information about the Linuxppc64-dev
mailing list