Skip to contentSkip to conversation

take3: Updated CPU Hotplug patches for IA64 (pj blessed) Patch [7/7]

PATCH Ashok Raj 1 participant 1 message May 4, 2004

lore
Share & tools
lore

Ashok Raj

author
#0 lore raw

Name: hotcpu_ia64.patch
Author: Ashok Raj (Intel Corporation)
D: Supports basic ability to enable hotplug functions for IA64.
D: Code is just evolving, and there are several loose ends to tie up. D:
D: What this code drop does
D: - Support logical online and offline
D: - Handles interrupt migration without loss of interrupts.
D: - Handles stress fine > 24+ hrs with make -j/ftp/rcp workloads
D: - Handles irq migration from a dying cpu without loss of interrupts.
D: What needs to be done
D: - Boot CPU removal support, with platform level authentication
D: - Putting cpu being removed in BOOT_RENDEZ mode.

---

 linux-2.6.5-lhcs-root/arch/ia64/Kconfig           |    9 +
 linux-2.6.5-lhcs-root/arch/ia64/kernel/iosapic.c  |    7 -
 linux-2.6.5-lhcs-root/arch/ia64/kernel/irq.c      |  103 +++++++++++++++
 linux-2.6.5-lhcs-root/arch/ia64/kernel/irq_ia64.c |   60 ++++++++-
 linux-2.6.5-lhcs-root/arch/ia64/kernel/process.c  |   43 ++++++
 linux-2.6.5-lhcs-root/arch/ia64/kernel/sal.c      |   13 ++
 linux-2.6.5-lhcs-root/arch/ia64/kernel/smp.c      |   26 +++-
 linux-2.6.5-lhcs-root/arch/ia64/kernel/smpboot.c  |  143 ++++++++++++++++++++--
 linux-2.6.5-lhcs-root/arch/ia64/kernel/time.c     |    5 
 linux-2.6.5-lhcs-root/include/asm-ia64/smp.h      |    2 
 10 files changed, 394 insertions(+), 17 deletions(-)
arch/ia64/Kconfig renamed from arch/ia64/Kconfig~hotcpu_ia64 +9 -0
diff -puN arch/ia64/Kconfig~hotcpu_ia64 arch/ia64/Kconfig
@@ -78,6 +78,15 @@ config IA64_HP_SIM
 
 endchoice
 
+config HOTPLUG_CPU
+    bool "Support for hot-pluggable CPUs (EXPERIMENTAL)"
+    depends on SMP && HOTPLUG && EXPERIMENTAL
+	default n
+    ---help---
+      Say Y here to experiment with turning CPUs off and on.  CPUs
+      can be controlled through /sys/devices/system/cpu/cpu#.
+      Say N if you want to disable cpu hotplug.
+
 choice
 	prompt "Processor type"
 	default ITANIUM
arch/ia64/kernel/irq.c renamed from arch/ia64/kernel/irq.c~hotcpu_ia64 +103 -0

135 lines not on this page · raw message

arch/ia64/kernel/process.c renamed from arch/ia64/kernel/process.c~hotcpu_ia64 +42 -1

86 lines not on this page · raw message

arch/ia64/kernel/smpboot.c renamed from arch/ia64/kernel/smpboot.c~hotcpu_ia64 +135 -8

222 lines not on this page · raw message

arch/ia64/kernel/smp.c renamed from arch/ia64/kernel/smp.c~hotcpu_ia64 +25 -1
diff -puN arch/ia64/kernel/smp.c~hotcpu_ia64 arch/ia64/kernel/smp.c
@@ -71,10 +71,23 @@ static volatile struct call_data_struct 
 /* This needs to be cacheline aligned because it is written to by *other* CPUs.  */
 static DEFINE_PER_CPU(u64, ipi_operation) ____cacheline_aligned;
 
+extern void cpu_halt (void);
+
+void
+lock_ipi_calllock(void)
+{
+	spin_lock_irq(&call_lock);
+}
+
+void
+unlock_ipi_calllock(void)
+{
+	spin_unlock_irq(&call_lock);
+}
+
 static void
 stop_this_cpu (void)
 {
-	extern void cpu_halt (void);
 	/*
 	 * Remove this CPU:
 	 */
@@ -84,6 +97,17 @@ stop_this_cpu (void)
 	cpu_halt();
 }
 
+void
+cpu_die(void)
+{
+	max_xtp();
+	local_irq_disable();
+	cpu_halt();
+	/* Should never be here */
+	BUG();
+	for (;;);
+}
+
 irqreturn_t
 handle_IPI (int irq, void *dev_id, struct pt_regs *regs)
 {
arch/ia64/kernel/time.c renamed from arch/ia64/kernel/time.c~hotcpu_ia64 +5 -0
diff -puN arch/ia64/kernel/time.c~hotcpu_ia64 arch/ia64/kernel/time.c
@@ -10,6 +10,7 @@
  */
 #include <linux/config.h>
 
+#include <linux/cpu.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/module.h>
@@ -244,6 +245,10 @@ timer_interrupt (int irq, void *dev_id, 
 {
 	unsigned long new_itm;
 
+	if (unlikely(cpu_is_offline(smp_processor_id()))) {
+		return IRQ_HANDLED;
+	}
+
 	platform_timer_interrupt(irq, dev_id, regs);
 
 	new_itm = local_cpu_data->itm_next;
include/asm-ia64/smp.h renamed from include/asm-ia64/smp.h~hotcpu_ia64 +2 -0
diff -puN include/asm-ia64/smp.h~hotcpu_ia64 include/asm-ia64/smp.h
@@ -121,6 +121,8 @@ extern void smp_do_timer (struct pt_regs
 extern int smp_call_function_single (int cpuid, void (*func) (void *info), void *info,
 				     int retry, int wait);
 extern void smp_send_reschedule (int cpu);
+extern void lock_ipi_calllock(void);
+extern void unlock_ipi_calllock(void);
 
 #endif /* CONFIG_SMP */
 #endif /* _ASM_IA64_SMP_H */
arch/ia64/kernel/iosapic.c renamed from arch/ia64/kernel/iosapic.c~hotcpu_ia64 +5 -2
diff -puN arch/ia64/kernel/iosapic.c~hotcpu_ia64 arch/ia64/kernel/iosapic.c
@@ -32,6 +32,8 @@
  * 03/02/19	B. Helgaas	Make pcat_compat system-wide, not per-IOSAPIC.
  *				Remove iosapic_address & gsi_base from external interfaces.
  *				Rationalize __init/__devinit attributes.
+ * 04/12/04 Ashok Raj	<[email protected]> Intel Corporation 2004
+ *				Updated to work with irq migration necessary for CPU Hotplug
  */
 /*
  * Here is what the interrupt logic between a PCI device and the kernel looks like:
@@ -189,8 +191,10 @@ set_rte (unsigned int vector, unsigned i
 	pol     = iosapic_intr_info[vector].polarity;
 	trigger = iosapic_intr_info[vector].trigger;
 	dmode   = iosapic_intr_info[vector].dmode;
+	vector &= (~IA64_IRQ_REDIRECTED);
 
 	redir = (dmode = IOSAPIC_LOWEST_PRIORITY) ? 1 : 0;
+
 #ifdef CONFIG_SMP
 	{
 		unsigned int irq;
@@ -308,9 +312,8 @@ iosapic_set_affinity (unsigned int irq, 
 
 	spin_lock_irqsave(&iosapic_lock, flags);
 	{
-		/* get current delivery mode by reading the low32 */
-		writel(IOSAPIC_RTE_LOW(rte_index), addr + IOSAPIC_REG_SELECT);
 		low32 = iosapic_intr_info[vec].low32 & ~(7 << IOSAPIC_DELIVERY_SHIFT);
+
 		if (redir)
 		        /* change delivery mode to lowest priority */
 			low32 |= (IOSAPIC_LOWEST_PRIORITY << IOSAPIC_DELIVERY_SHIFT);
arch/ia64/kernel/irq_ia64.c renamed from arch/ia64/kernel/irq_ia64.c~hotcpu_ia64 +55 -5

84 lines not on this page · raw message

arch/ia64/kernel/sal.c renamed from arch/ia64/kernel/sal.c~hotcpu_ia64 +13 -0
diff -puN arch/ia64/kernel/sal.c~hotcpu_ia64 arch/ia64/kernel/sal.c
@@ -122,10 +122,23 @@ sal_desc_entry_point (void *p)
 static void __init
 set_smp_redirect (int flag)
 {
+#ifndef CONFIG_HOTPLUG_CPU
 	if (no_int_routing)
 		smp_int_redirect &= ~flag;
 	else
 		smp_int_redirect |= flag;
+#else
+	/*
+	 * For CPU Hotplug we dont want to do any chipset supported
+	 * interrupt redirection. The reason is this would require that
+	 * All interrupts be stopped and hard bind the irq to a cpu.
+	 * Later when the interrupt is fired we need to set the redir hint
+	 * on again in the vector. This is combersome for something that the
+	 * user mode irq balancer will solve anyways.
+	 */
+	no_int_routing=1;
+	smp_int_redirect &= ~flag;
+#endif
 }
 #else
 #define set_smp_redirect(flag)	do { } while (0)

_