Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 88735
b: refs/heads/master
c: 69c18c1
h: refs/heads/master
i:
  88733: ba27a1d
  88731: 531e017
  88727: 70d6ac8
  88719: f6f734e
  88703: 7e67311
v: v3
  • Loading branch information
Glauber Costa authored and Ingo Molnar committed Apr 17, 2008
1 parent 28076a5 commit ee3c336
Show file tree
Hide file tree
Showing 7 changed files with 89 additions and 153 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: e9a6cb96fafa4d4df2033ab6cf9c817f6f47e052
refs/heads/master: 69c18c15d39c4622c6e2f97e5db4d8c9c43adaaa
85 changes: 85 additions & 0 deletions trunk/arch/x86/kernel/smpboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
#include <linux/smp.h>
#include <linux/module.h>
#include <linux/sched.h>
#include <linux/percpu.h>

#include <asm/nmi.h>
#include <asm/irq.h>
#include <asm/smp.h>
#include <asm/cpu.h>
#include <asm/numa.h>

/* Number of siblings per CPU package */
int smp_num_siblings = 1;
Expand Down Expand Up @@ -181,5 +188,83 @@ __init void prefill_possible_map(void)
for (i = 0; i < possible; i++)
cpu_set(i, cpu_possible_map);
}

static void __ref remove_cpu_from_maps(int cpu)
{
cpu_clear(cpu, cpu_online_map);
#ifdef CONFIG_X86_64
cpu_clear(cpu, cpu_callout_map);
cpu_clear(cpu, cpu_callin_map);
/* was set by cpu_init() */
clear_bit(cpu, (unsigned long *)&cpu_initialized);
clear_node_cpumask(cpu);
#endif
}

int __cpu_disable(void)
{
int cpu = smp_processor_id();

/*
* Perhaps use cpufreq to drop frequency, but that could go
* into generic code.
*
* We won't take down the boot processor on i386 due to some
* interrupts only being able to be serviced by the BSP.
* Especially so if we're not using an IOAPIC -zwane
*/
if (cpu == 0)
return -EBUSY;

if (nmi_watchdog == NMI_LOCAL_APIC)
stop_apic_nmi_watchdog(NULL);
clear_local_APIC();

/*
* HACK:
* Allow any queued timer interrupts to get serviced
* This is only a temporary solution until we cleanup
* fixup_irqs as we do for IA64.
*/
local_irq_enable();
mdelay(1);

local_irq_disable();
remove_siblinginfo(cpu);

/* It's now safe to remove this processor from the online map */
remove_cpu_from_maps(cpu);
fixup_irqs(cpu_online_map);
return 0;
}

void __cpu_die(unsigned int cpu)
{
/* We don't do anything here: idle task is faking death itself. */
unsigned int i;

for (i = 0; i < 10; i++) {
/* They ack this in play_dead by setting CPU_DEAD */
if (per_cpu(cpu_state, cpu) == CPU_DEAD) {
printk(KERN_INFO "CPU %d is now offline\n", cpu);
if (1 == num_online_cpus())
alternatives_smp_switch(0);
return;
}
msleep(100);
}
printk(KERN_ERR "CPU %u didn't die...\n", cpu);
}
#else /* ... !CONFIG_HOTPLUG_CPU */
int __cpu_disable(void)
{
return -ENOSYS;
}

void __cpu_die(unsigned int cpu)
{
/* We said "no" in __cpu_disable */
BUG();
}
#endif

67 changes: 0 additions & 67 deletions trunk/arch/x86/kernel/smpboot_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -1040,73 +1040,6 @@ void __init native_smp_prepare_boot_cpu(void)
__get_cpu_var(cpu_state) = CPU_ONLINE;
}

#ifdef CONFIG_HOTPLUG_CPU
static void __ref remove_cpu_from_maps(int cpu)
{
cpu_clear(cpu, cpu_online_map);
}

int __cpu_disable(void)
{
cpumask_t map = cpu_online_map;
int cpu = smp_processor_id();

/*
* Perhaps use cpufreq to drop frequency, but that could go
* into generic code.
*
* We won't take down the boot processor on i386 due to some
* interrupts only being able to be serviced by the BSP.
* Especially so if we're not using an IOAPIC -zwane
*/
if (cpu == 0)
return -EBUSY;
if (nmi_watchdog == NMI_LOCAL_APIC)
stop_apic_nmi_watchdog(NULL);
clear_local_APIC();
/* Allow any queued timer interrupts to get serviced */
local_irq_enable();
mdelay(1);
local_irq_disable();

remove_siblinginfo(cpu);

remove_cpu_from_maps(cpu);
fixup_irqs(map);

return 0;
}

void __cpu_die(unsigned int cpu)
{
/* We don't do anything here: idle task is faking death itself. */
unsigned int i;

for (i = 0; i < 10; i++) {
/* They ack this in play_dead by setting CPU_DEAD */
if (per_cpu(cpu_state, cpu) == CPU_DEAD) {
printk ("CPU %d is now offline\n", cpu);
if (1 == num_online_cpus())
alternatives_smp_switch(0);
return;
}
msleep(100);
}
printk(KERN_ERR "CPU %u didn't die...\n", cpu);
}
#else /* ... !CONFIG_HOTPLUG_CPU */
int __cpu_disable(void)
{
return -ENOSYS;
}

void __cpu_die(unsigned int cpu)
{
/* We said "no" in __cpu_disable */
BUG();
}
#endif /* CONFIG_HOTPLUG_CPU */

int __cpuinit native_cpu_up(unsigned int cpu)
{
unsigned long flags;
Expand Down
79 changes: 0 additions & 79 deletions trunk/arch/x86/kernel/smpboot_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -836,82 +836,3 @@ void __init native_smp_cpus_done(unsigned int max_cpus)
setup_ioapic_dest();
check_nmi_watchdog();
}

#ifdef CONFIG_HOTPLUG_CPU
static void __ref remove_cpu_from_maps(int cpu)
{
cpu_clear(cpu, cpu_online_map);
cpu_clear(cpu, cpu_callout_map);
cpu_clear(cpu, cpu_callin_map);
clear_bit(cpu, (unsigned long *)&cpu_initialized); /* was set by cpu_init() */
clear_node_cpumask(cpu);
}

int __cpu_disable(void)
{
int cpu = smp_processor_id();

/*
* Perhaps use cpufreq to drop frequency, but that could go
* into generic code.
*
* We won't take down the boot processor on i386 due to some
* interrupts only being able to be serviced by the BSP.
* Especially so if we're not using an IOAPIC -zwane
*/
if (cpu == 0)
return -EBUSY;

if (nmi_watchdog == NMI_LOCAL_APIC)
stop_apic_nmi_watchdog(NULL);
clear_local_APIC();

/*
* HACK:
* Allow any queued timer interrupts to get serviced
* This is only a temporary solution until we cleanup
* fixup_irqs as we do for IA64.
*/
local_irq_enable();
mdelay(1);

local_irq_disable();
remove_siblinginfo(cpu);

/* It's now safe to remove this processor from the online map */
remove_cpu_from_maps(cpu);
fixup_irqs(cpu_online_map);
return 0;
}

void __cpu_die(unsigned int cpu)
{
/* We don't do anything here: idle task is faking death itself. */
unsigned int i;

for (i = 0; i < 10; i++) {
/* They ack this in play_dead by setting CPU_DEAD */
if (per_cpu(cpu_state, cpu) == CPU_DEAD) {
printk ("CPU %d is now offline\n", cpu);
if (1 == num_online_cpus())
alternatives_smp_switch(0);
return;
}
msleep(100);
}
printk(KERN_ERR "CPU %u didn't die...\n", cpu);
}

#else /* ... !CONFIG_HOTPLUG_CPU */

int __cpu_disable(void)
{
return -ENOSYS;
}

void __cpu_die(unsigned int cpu)
{
/* We said "no" in __cpu_disable */
BUG();
}
#endif /* CONFIG_HOTPLUG_CPU */
3 changes: 3 additions & 0 deletions trunk/include/asm-x86/smp.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ void native_smp_prepare_cpus(unsigned int max_cpus);
void native_smp_cpus_done(unsigned int max_cpus);
int native_cpu_up(unsigned int cpunum);

extern int __cpu_disable(void);
extern void __cpu_die(unsigned int cpu);

extern unsigned disabled_cpus;
extern void prefill_possible_map(void);
#endif
Expand Down
3 changes: 0 additions & 3 deletions trunk/include/asm-x86/smp_32.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ DECLARE_PER_CPU(u16, x86_cpu_to_apicid);
#define startup_ipi_hook(phys_apicid, start_eip, start_esp) do { } while (0)
#endif

extern int __cpu_disable(void);
extern void __cpu_die(unsigned int cpu);

/*
* This function is needed by all SMP systems. It must _always_ be valid
* from the initial startup. We map APIC_BASE very early in page_setup(),
Expand Down
3 changes: 0 additions & 3 deletions trunk/include/asm-x86/smp_64.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,6 @@ static inline int cpu_present_to_apicid(int mps_cpu)

#define SMP_TRAMPOLINE_BASE 0x6000

extern int __cpu_disable(void);
extern void __cpu_die(unsigned int cpu);

#define raw_smp_processor_id() read_pda(cpunumber)
#define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu)

Expand Down

0 comments on commit ee3c336

Please sign in to comment.