Skip to content

Commit

Permalink
x86: add cpu hotplug hooks into smp_ops
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Nixon <alex.nixon@citrix.com>
Acked-by: Jeremy Fitzhardinge <jeremy@goop.org>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
  • Loading branch information
Alex Nixon authored and Ingo Molnar committed Aug 25, 2008
1 parent e4f807c commit 93be71b
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 13 deletions.
4 changes: 2 additions & 2 deletions arch/x86/kernel/process_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ static void cpu_exit_clear(void)
}

/* We don't actually take CPU down, just spin without interrupts. */
static inline void play_dead(void)
void native_play_dead(void)
{
/* This must be done before dead CPU ack */
cpu_exit_clear();
Expand All @@ -107,7 +107,7 @@ static inline void play_dead(void)
wbinvd_halt();
}
#else
static inline void play_dead(void)
void native_play_dead(void)
{
BUG();
}
Expand Down
4 changes: 2 additions & 2 deletions arch/x86/kernel/process_64.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ DECLARE_PER_CPU(int, cpu_state);

#include <asm/nmi.h>
/* We halt the CPU with physical CPU hotplug */
static inline void play_dead(void)
void native_play_dead(void)
{
idle_task_exit();
mb();
Expand All @@ -102,7 +102,7 @@ static inline void play_dead(void)
wbinvd_halt();
}
#else
static inline void play_dead(void)
void native_play_dead(void)
{
BUG();
}
Expand Down
6 changes: 5 additions & 1 deletion arch/x86/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,12 +214,16 @@ void smp_call_function_single_interrupt(struct pt_regs *regs)
struct smp_ops smp_ops = {
.smp_prepare_boot_cpu = native_smp_prepare_boot_cpu,
.smp_prepare_cpus = native_smp_prepare_cpus,
.cpu_up = native_cpu_up,
.smp_cpus_done = native_smp_cpus_done,

.smp_send_stop = native_smp_send_stop,
.smp_send_reschedule = native_smp_send_reschedule,

.cpu_up = native_cpu_up,
.cpu_die = native_cpu_die,
.cpu_disable = native_cpu_disable,
.play_dead = native_play_dead,

.send_call_func_ipi = native_send_call_func_ipi,
.send_call_func_single_ipi = native_send_call_func_single_ipi,
};
Expand Down
8 changes: 4 additions & 4 deletions arch/x86/kernel/smpboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -1346,7 +1346,7 @@ static void __ref remove_cpu_from_maps(int cpu)
numa_remove_cpu(cpu);
}

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

Expand Down Expand Up @@ -1385,7 +1385,7 @@ int __cpu_disable(void)
return 0;
}

void __cpu_die(unsigned int cpu)
void native_cpu_die(unsigned int cpu)
{
/* We don't do anything here: idle task is faking death itself. */
unsigned int i;
Expand All @@ -1403,12 +1403,12 @@ void __cpu_die(unsigned int cpu)
printk(KERN_ERR "CPU %u didn't die...\n", cpu);
}
#else /* ... !CONFIG_HOTPLUG_CPU */
int __cpu_disable(void)
int native_cpu_disable(void)
{
return -ENOSYS;
}

void __cpu_die(unsigned int cpu)
void native_cpu_die(unsigned int cpu)
{
/* We said "no" in __cpu_disable */
BUG();
Expand Down
28 changes: 24 additions & 4 deletions include/asm-x86/smp.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,16 @@ extern struct {
struct smp_ops {
void (*smp_prepare_boot_cpu)(void);
void (*smp_prepare_cpus)(unsigned max_cpus);
int (*cpu_up)(unsigned cpu);
void (*smp_cpus_done)(unsigned max_cpus);

void (*smp_send_stop)(void);
void (*smp_send_reschedule)(int cpu);

int (*cpu_up)(unsigned cpu);
int (*cpu_disable)(void);
void (*cpu_die)(unsigned int cpu);
void (*play_dead)(void);

void (*send_call_func_ipi)(cpumask_t mask);
void (*send_call_func_single_ipi)(int cpu);
};
Expand Down Expand Up @@ -91,6 +95,21 @@ static inline int __cpu_up(unsigned int cpu)
return smp_ops.cpu_up(cpu);
}

static inline int __cpu_disable(void)
{
return smp_ops.cpu_disable();
}

static inline void __cpu_die(unsigned int cpu)
{
smp_ops.cpu_die(cpu);
}

static inline void play_dead(void)
{
smp_ops.play_dead();
}

static inline void smp_send_reschedule(int cpu)
{
smp_ops.smp_send_reschedule(cpu);
Expand All @@ -110,12 +129,13 @@ void native_smp_prepare_boot_cpu(void);
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);
int native_cpu_disable(void);
void native_cpu_die(unsigned int cpu);
void native_play_dead(void);

void native_send_call_func_ipi(cpumask_t mask);
void native_send_call_func_single_ipi(int cpu);

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

void smp_store_cpu_info(int id);
#define cpu_physical_id(cpu) per_cpu(x86_cpu_to_apicid, cpu)

Expand Down

0 comments on commit 93be71b

Please sign in to comment.