by smtp.nexlab.net (Postfix) with ESMTP id 368A1FB5B for <[email protected]>; Tue, 24 May 2005 10:26:40 +0200 (CEST)
Received: ([email protected]) by vger.kernel.org via listexpand
id S261440AbVEXIUK (ORCPT <rfc822;[email protected]>); Tue, 24 May 2005 04:20:10 -0400
Received: ([email protected]) by vger.kernel.org id S261457AbVEXIUJ
(ORCPT <rfc822;linux-kernel-outgoing>); Tue, 24 May 2005 04:20:09 -0400
Received: from fmr18.intel.com ([134.134.136.17]:22223 "EHLO
orsfmr003.jf.intel.com") by vger.kernel.org with ESMTP id S261440AbVEXIOH (ORCPT <rfc822;[email protected]>); Tue, 24 May 2005 04:14:07 -0400
Received: from orsfmr101.jf.intel.com (orsfmr101.jf.intel.com [10.7.209.17])
by orsfmr003.jf.intel.com (8.12.10/8.12.10/d: major-outer.mc,v 1.1 2004/09/17 17:50:56 root Exp $) with ESMTP id j4O8CeCc026197; Tue, 24 May 2005 08:12:40 GMT
Received: from csdlinux-2.jf.intel.com (csdlinux-2.jf.intel.com [10.23.61.107])
by orsfmr101.jf.intel.com (8.12.10/8.12.10/d: major-inner.mc,v 1.2 2004/09/17 18:05:01 root Exp $) with ESMTP id j4O8CeG7015354; Tue, 24 May 2005 08:12:40 GMT
Received: by csdlinux-2.jf.intel.com (Postfix, from userid 47353)
id B97882BCFB3; Tue, 24 May 2005 01:08:00 -0700 (PDT)
Message-Id: <[email protected]>
References: <[email protected]>
Date: Tue, 24 May 2005 00:27:51 -0700
From: Ashok Raj <[email protected]>
To: [email protected], [email protected]
Cc: [email protected], [email protected], [email protected],
[email protected], [email protected], [email protected], [email protected]
Subject: [patch 2/4] CPU Hotplug support for X86_64
Content-Disposition: inline; filename=x86_64-cpuhotplug.patch
X-Scanned-By: MIMEDefang 2.44
Sender: [email protected]
Precedence: bulk
X-Mailing-List: [email protected]
Subject: [patch 2/4] x86_64: CPU hotplug support.
From: Ashok Raj <[email protected]>
Experimental CPU hotplug patch for x86_64
-----------------------------------------
This supports logical CPU online and offline.
- Test with maxcpus=1, and then kick other cpu's off to test if init code is all cleaned up.
- idle threads are forked on demand from keventd threads for clean startup
TBD:
1. Not tested on a real NUMA machine (tested with numa=fake=2)
2. CONFIG_SCHED_SMT seems to have trouble handling cpu add/removal
3. Handle ACPI pieces for physical hotplug support.
-----------
arch/i386/mach-default/topology.c | 7 - arch/x86_64/Kconfig | 9 + arch/x86_64/kernel/irq.c | 30 +++++ arch/x86_64/kernel/process.c | 33 +++++ arch/x86_64/kernel/smp.c | 12 ++ arch/x86_64/kernel/smpboot.c | 213 ++++++++++++++++++++++++++++++++++---- arch/x86_64/kernel/traps.c | 9 + include/asm-x86_64/irq.h | 5 include/asm-x86_64/smp.h | 4 9 files changed, 297 insertions(+), 25 deletions(-)
arch/x86_64/Kconfig +9 -0
@@ -294,6 +294,15 @@ config NR_CPUS This is purely to save memory - each supported CPU requires memory in the static kernel configuration. +config HOTPLUG_CPU + bool "Support for hot-pluggable CPUs (EXPERIMENTAL)" + depends on SMP && HOTPLUG && EXPERIMENTAL + 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. + + config HPET_TIMER bool default y
arch/x86_64/kernel/smpboot.c +192 -21
332 lines not on this page · raw message
arch/x86_64/kernel/irq.c +30 -0
@@ -14,6 +14,7 @@#include <linux/interrupt.h> #include <linux/seq_file.h> #include <linux/module.h> +#include <linux/delay.h> #include <asm/uaccess.h> #include <asm/io_apic.h>
@@ -106,3 +107,32 @@ asmlinkage unsigned int do_IRQ(struct ptreturn 1 ; } + +#ifdef CONFIG_HOTPLUG_CPU +void fixup_irqs (cpumask_t map) +{ +unsigned int irq; +static int warned; + +for (irq =0 ; irq <NR_IRQS ; irq++) { +cpumask_t mask; +if (irq ==2 ) +continue ; + +cpus_and (mask, irq_affinity[irq], map); +if (any_online_cpu (mask) ==NR_CPUS ) { +printk ("Breaking affinity for irq %i\n" , irq); + mask = map; + } +if (irq_desc[irq].handler->set_affinity) + irq_desc[irq].handler->set_affinity (irq, mask); +else if (irq_desc[irq].action && !(warned++)) +printk ("Cannot set affinity for irq %i\n" , irq); + } + +/* That doesn't seem sufficient. Give it 1ms. */ +local_irq_enable (); +mdelay (1 ); +local_irq_disable (); +} +#endif
include/asm-x86_64/irq.h +5 -0
@@ -52,4 +52,9 @@ struct irqaction;struct pt_regs ;int handle_IRQ_event (unsigned int ,struct pt_regs *,struct irqaction *); +#ifdef CONFIG_HOTPLUG_CPU +#include <linux/cpumask.h> +extern void fixup_irqs (cpumask_t map); +#endif +#endif /* _ASM_IRQ_H */
arch/x86_64/kernel/process.c +32 -1
@@ -8,7 +8,8 @@* * X86-64 port * Andi Kleen. -* +* +* CPU hotplug support - [email protected] * $Id: process.c,v 1.38 2002/01/15 10:08:03 ak Exp $ */
@@ -18,6 +19,7 @@#include <stdarg.h> +#include <linux/cpu.h> #include <linux/errno.h> #include <linux/sched.h> #include <linux/kernel.h>
@@ -154,6 +156,33 @@ void cpu_idle_wait(void) }EXPORT_SYMBOL_GPL (cpu_idle_wait); +#ifdef CONFIG_HOTPLUG_CPU +DECLARE_PER_CPU (int, cpu_state); + +#include <asm/nmi.h> +/* We don't actually take CPU down, just spin without interrupts. */ +static inline void play_dead (void ) +{ +idle_task_exit (); +mb (); +/* Ack it */ +__get_cpu_var (cpu_state) =CPU_DEAD ; + +local_irq_disable (); +while (1 ) +safe_halt (); +#if 0 +while (1 ) + __asm__ __volatile__("hlt" :::"memory" ); +#endif +} +#else +static inline void play_dead (void ) +{ +BUG (); +} +#endif /* CONFIG_HOTPLUG_CPU */ +/* * The idle thread. There's no useful work to be * done, so just try to conserve power and have a
@@ -174,6 +203,8 @@ void cpu_idle (void) idle = pm_idle;if (!idle) idle = default_idle; +if (cpu_is_offline (smp_processor_id ())) +play_dead ();idle (); }
include/asm-x86_64/smp.h +4 -0
@@ -44,6 +44,8 @@ extern void smp_alloc_memory(void);extern volatile unsigned long smp_invalidate_needed;extern int pic_mode;extern int smp_num_siblings; +extern void lock_ipi_calllock (void ); +extern void unlock_ipi_calllock (void );extern void smp_flush_tlb (void );extern void smp_message_irq (int cpl,void *dev_id,struct pt_regs *regs);extern void smp_send_reschedule (int cpu);
@@ -77,6 +79,8 @@ extern __inline int hard_smp_processor_i }extern int safe_smp_processor_id (void ); +extern int __cpu_disable (void ); +extern void __cpu_die (unsigned int cpu);#endif /* !ASSEMBLY */
arch/x86_64/kernel/traps.c +8 -1
@@ -587,11 +587,18 @@ static void unknown_nmi_error(unsigned c asmlinkage void default_do_nmi(struct pt_regs *regs) {unsigned char reason =0 ; +int cpu; + + cpu =smp_processor_id ();/* Only the BSP gets external NMIs from the system. */ -if (!smp_processor_id ()) +if (!cpu) reason =get_nmi_reason (); +#ifdef CONFIG_HOTPLUG_CPU +if (!cpu_online (cpu)) +return ; +#endif if (!(reason &0xc0 )) {if (notify_die (DIE_NMI_IPI ,"nmi_ipi" , regs, reason,0 ,SIGINT ) ==NOTIFY_STOP )
arch/x86_64/kernel/smp.c +12 -0
@@ -295,6 +295,18 @@ struct call_data_struct {static struct call_data_struct * call_data; +void +lock_ipi_calllock (void ) +{ +spin_lock_irq (&call_lock); +} + +void +unlock_ipi_calllock (void ) +{ +spin_unlock_irq (&call_lock); +} +/* * this function sends a 'generic call function' IPI to all other CPUs * in the system.
arch/i386/mach-default/topology.c +5 -2
@@ -88,8 +88,11 @@ static int __init topology_init(void) {int i; -for (i =0 ; i <NR_CPUS ; i++) -if (cpu_possible (i))arch_register_cpu (i); +for (i =0 ; i <NR_CPUS ; i++) { +if (cpu_possible (i)) { +arch_register_cpu (i); + } + }return 0 ; }
--
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/