Skip to contentSkip to conversation

make smp_prepare_cpu to a weak function

PATCH Ashok Raj 2 participants 3 messages May 6, 2005

Subsystems (2)
lore
Share & tools
lore

Ashok Raj

author
#0 lore raw

Hi Andrew

This is just a cleanup, the existing code seems to trigger compile errors since smp_prepar_cpu() is defined with ARCH_HAS... and its not easy to either introduce a arch call, or ideally remove it finally. This is against 2.6.12-rc3-mm3

Cheers,
ashok
----

I really wish smp_prepare_cpu() would disappear eventually. In the interim this is ideally a weak function, so we dont end up changing several places to define this dummy in headers.

Today since the dummy declaration is done only in drivers/base/cpu.c but the function is called in kernel/power/smp.c i get undefined reference in my cpu hotplug code for x86_64 under development.

include/asm-i386/smp.h +0 -3
Index: linux-2.6.12-rc3-mm3/include/asm-i386/smp.h
===================================================================
@@ -51,9 +51,6 @@
 #ifdef CONFIG_HOTPLUG_CPU
 extern void cpu_exit_clear(void);
 extern void cpu_uninit(void);
-
-#define __HAVE_ARCH_SMP_PREPARE_CPU
-extern int smp_prepare_cpu(int cpu);
 #endif
 
 /*
drivers/base/cpu.c +5 -4
Index: linux-2.6.12-rc3-mm3/drivers/base/cpu.c
===================================================================
@@ -16,9 +16,10 @@
 EXPORT_SYMBOL(cpu_sysdev_class);
 
 #ifdef CONFIG_HOTPLUG_CPU
-#ifndef __HAVE_ARCH_SMP_PREPARE_CPU
-#define smp_prepare_cpu(cpu) (0)
-#endif
+int __attribute__((weak)) smp_prepare_cpu (int cpu)
+{
+	return 0;
+}
 
 static ssize_t show_online(struct sys_device *dev, char *buf)
 {
@@ -41,7 +42,7 @@
 		break;
 	case '1':
 		ret = smp_prepare_cpu(cpu->sysdev.id);
-		if (ret == 0)
+		if (!ret)
 			ret = cpu_up(cpu->sysdev.id);
 		if (!ret)
 			kobject_hotplug(&dev->kobj, KOBJ_ONLINE);
include/linux/cpu.h +1 -0
Index: linux-2.6.12-rc3-mm3/include/linux/cpu.h
===================================================================
@@ -69,6 +69,7 @@
 	register_cpu_notifier(&fn##_nb);			\
 }
 int cpu_down(unsigned int cpu);
+extern int __attribute__((weak)) smp_prepare_cpu(int cpu);
 #define cpu_is_offline(cpu) unlikely(!cpu_online(cpu))
 #else
 #define lock_cpu_hotplug()	do { } while (0)
Signature · 3 lines
Cheers,
Ashok Raj
- Open Source Technology Center
#1 lore raw

drivers/base/cpu.c line 22

Quoted 4 lines · Ashok Raj
drivers/base/cpu.c +4 -0
+int __attribute__((weak)) smp_prepare_cpu (int cpu)
+{
+	return 0;
+}

ehhh what does this attribute mean here?????

author
#2 lore raw
Quoted 10 lines · Arjan van de Ven

drivers/base/cpu.c line 22

Quoted 4 lines · Ashok Raj
drivers/base/cpu.c +4 -0
+int __attribute__((weak)) smp_prepare_cpu (int cpu)
+{
+	return 0;
+}

ehhh what does this attribute mean here?????

This function exists only for i386. Today for smp suspend they are using cpu hotplug code, but since i386 startup code is not like
true smp bringup, so there is this hack to prepare something before calling __cpu_up().

This is just to provide a default implementation, in the case arch doesnt provide a smp_prepare_cpu().

Hope i answered the right question, unless you have something subtle here :-(

Cheers,
ashok

Signature · 3 lines
Cheers,
Ashok Raj
- Open Source Technology Center