* [patch 1/2] i386: Dont use IPI broadcast when using cpu hotplug.
2005-06-08 3:09 [patch 0/2] i386: CPU hotplug related patch series Ashok Raj
@ 2005-06-08 3:09 ` Ashok Raj
2005-06-08 3:09 ` [patch 2/2] i386: hold call_lock when updating cpu_online_map Ashok Raj
1 sibling, 0 replies; 3+ messages in thread
From: Ashok Raj @ 2005-06-08 3:09 UTC (permalink / raw)
To: Andrew Morton, linux-kernel
Cc: Zwane Mwaikambo, Srivattsa Vaddagiri, Shaohua Li, Rusty Russell,
Ashok Raj
[-- Attachment #1: i386-dont-use-ipi-broadcast.patch --]
[-- Type: text/plain, Size: 3352 bytes --]
This patch introduces a startup parameter no_broadcast. When we
enable CONFIG_HOTPLUG_CPU, we dont want to use broadcast shortcut as it
has ill effects on a offline cpu. If we issue broadcast, the IPI is also
delivered to offline cpus, or partially up cpu causing stale IPI's to be
handled, which is a problem and can cause undesirable effects.
Introduces a new startup cmdline option no_ipi_broadcast, that can be
switched at cmdline if necessary.
Signed-off-by: Ashok Raj <ashok.raj@intel.com>
Acked-by: Shaohua Li <shaohua.li@intel.com>
----------------------------------------------------
arch/i386/mach-default/setup.c | 27 +++++++++++++++++++++++++++
include/asm-i386/mach-default/mach_ipi.h | 27 +++++++++++++++++++++++++--
2 files changed, 52 insertions(+), 2 deletions(-)
Index: linux-2.6.12-rc6-mm1/include/asm-i386/mach-default/mach_ipi.h
===================================================================
--- linux-2.6.12-rc6-mm1.orig/include/asm-i386/mach-default/mach_ipi.h
+++ linux-2.6.12-rc6-mm1/include/asm-i386/mach-default/mach_ipi.h
@@ -4,11 +4,34 @@
void send_IPI_mask_bitmask(cpumask_t mask, int vector);
void __send_IPI_shortcut(unsigned int shortcut, int vector);
+extern int no_broadcast;
+
static inline void send_IPI_mask(cpumask_t mask, int vector)
{
send_IPI_mask_bitmask(mask, vector);
}
+static inline void __local_send_IPI_allbutself(int vector)
+{
+ if (no_broadcast) {
+ cpumask_t mask = cpu_online_map;
+ int this_cpu = get_cpu();
+
+ cpu_clear(this_cpu, mask);
+ send_IPI_mask(mask, vector);
+ put_cpu();
+ } else
+ __send_IPI_shortcut(APIC_DEST_ALLBUT, vector);
+}
+
+static inline void __local_send_IPI_all(int vector)
+{
+ if (no_broadcast)
+ send_IPI_mask(cpu_online_map, vector);
+ else
+ __send_IPI_shortcut(APIC_DEST_ALLINC, vector);
+}
+
static inline void send_IPI_allbutself(int vector)
{
/*
@@ -18,13 +41,13 @@ static inline void send_IPI_allbutself(i
if (!(num_online_cpus() > 1))
return;
- __send_IPI_shortcut(APIC_DEST_ALLBUT, vector);
+ __local_send_IPI_allbutself(vector);
return;
}
static inline void send_IPI_all(int vector)
{
- __send_IPI_shortcut(APIC_DEST_ALLINC, vector);
+ __local_send_IPI_all(vector);
}
#endif /* __ASM_MACH_IPI_H */
Index: linux-2.6.12-rc6-mm1/arch/i386/mach-default/setup.c
===================================================================
--- linux-2.6.12-rc6-mm1.orig/arch/i386/mach-default/setup.c
+++ linux-2.6.12-rc6-mm1/arch/i386/mach-default/setup.c
@@ -10,6 +10,14 @@
#include <asm/acpi.h>
#include <asm/arch_hooks.h>
+#ifdef CONFIG_HOTPLUG_CPU
+#define DEFAULT_SEND_IPI (1)
+#else
+#define DEFAULT_SEND_IPI (0)
+#endif
+
+int no_broadcast=DEFAULT_SEND_IPI;
+
/**
* pre_intr_init_hook - initialisation prior to setting up interrupt vectors
*
@@ -104,3 +112,22 @@ void __init mca_nmi_hook(void)
printk("NMI generated from unknown source!\n");
}
#endif
+
+static __init int no_ipi_broadcast(char *str)
+{
+ get_option(&str, &no_broadcast);
+ printk ("Using %s mode\n", no_broadcast ? "No IPI Broadcast" :
+ "IPI Broadcast");
+ return 1;
+}
+
+__setup("no_ipi_broadcast", no_ipi_broadcast);
+
+static int __init print_ipi_mode(void)
+{
+ printk ("Using IPI %s mode\n", no_broadcast ? "No-Shortcut" :
+ "Shortcut");
+ return 0;
+}
+
+late_initcall(print_ipi_mode);
--
^ permalink raw reply [flat|nested] 3+ messages in thread* [patch 2/2] i386: hold call_lock when updating cpu_online_map
2005-06-08 3:09 [patch 0/2] i386: CPU hotplug related patch series Ashok Raj
2005-06-08 3:09 ` [patch 1/2] i386: Dont use IPI broadcast when using cpu hotplug Ashok Raj
@ 2005-06-08 3:09 ` Ashok Raj
1 sibling, 0 replies; 3+ messages in thread
From: Ashok Raj @ 2005-06-08 3:09 UTC (permalink / raw)
To: Andrew Morton, linux-kernel
Cc: Zwane Mwaikambo, Srivattsa Vaddagiri, Shaohua Li, Rusty Russell,
Ashok Raj
[-- Attachment #1: i386-hold-call-lock-when-adding-to-onlinemap.patch --]
[-- Type: text/plain, Size: 2351 bytes --]
We need to hold call-lock when updating cpu-online-map to ensure
the newly upcoming cpu is excluded in an ongoing smp_call_function.
Signed-off-by: Ashok Raj <ashok.raj@intel.com>
Acked-by: Shaohua Li <shaohua.li@intel.com>
-------------------------------------------------
arch/i386/kernel/smp.c | 10 ++++++++++
arch/i386/kernel/smpboot.c | 10 ++++++++++
include/asm-i386/smp.h | 2 ++
3 files changed, 22 insertions(+)
Index: linux-2.6.12-rc6-mm1/arch/i386/kernel/smp.c
===================================================================
--- linux-2.6.12-rc6-mm1.orig/arch/i386/kernel/smp.c
+++ linux-2.6.12-rc6-mm1/arch/i386/kernel/smp.c
@@ -506,6 +506,16 @@ struct call_data_struct {
int wait;
};
+void lock_ipi_call_lock(void)
+{
+ spin_lock_irq(&call_lock);
+}
+
+void unlock_ipi_call_lock(void)
+{
+ spin_unlock_irq(&call_lock);
+}
+
static struct call_data_struct * call_data;
/*
Index: linux-2.6.12-rc6-mm1/include/asm-i386/smp.h
===================================================================
--- linux-2.6.12-rc6-mm1.orig/include/asm-i386/smp.h
+++ linux-2.6.12-rc6-mm1/include/asm-i386/smp.h
@@ -42,6 +42,8 @@ extern void smp_message_irq(int cpl, voi
extern void smp_invalidate_rcv(void); /* Process an NMI */
extern void (*mtrr_hook) (void);
extern void zap_low_mappings (void);
+extern void lock_ipi_call_lock(void);
+extern void unlock_ipi_call_lock(void);
#define MAX_APICID 256
extern u8 x86_cpu_to_apicid[];
Index: linux-2.6.12-rc6-mm1/arch/i386/kernel/smpboot.c
===================================================================
--- linux-2.6.12-rc6-mm1.orig/arch/i386/kernel/smpboot.c
+++ linux-2.6.12-rc6-mm1/arch/i386/kernel/smpboot.c
@@ -503,7 +503,17 @@ static void __devinit start_secondary(vo
set_cpu_sibling_map(raw_smp_processor_id());
wmb();
+ /*
+ * We need to hold call_lock, so there is no inconsistency
+ * between the time smp_call_function() determines number of
+ * IPI receipients, and the time when the determination is made
+ * for which cpus receive the IPI. Holding this
+ * lock helps us to not include this cpu in a currently in progress
+ * smp_call_function().
+ */
+ lock_ipi_call_lock();
cpu_set(smp_processor_id(), cpu_online_map);
+ unlock_ipi_call_lock();
/* We can take interrupts now: we're officially "up". */
local_irq_enable();
--
^ permalink raw reply [flat|nested] 3+ messages in thread