Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 343516
b: refs/heads/master
c: 512691d
h: refs/heads/master
v: v3
  • Loading branch information
Paul Mackerras authored and Alexander Graf committed Oct 30, 2012
1 parent 7e6b9b1 commit 74d9578
Show file tree
Hide file tree
Showing 4 changed files with 65 additions and 3 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: c99ec973a63e2249020d6d93a46d7572432da6a2
refs/heads/master: 512691d4907d7cf4b8d05c6f8572d1fa60ccec20
8 changes: 8 additions & 0 deletions trunk/arch/powerpc/include/asm/smp.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,14 @@ void generic_cpu_die(unsigned int cpu);
void generic_mach_cpu_die(void);
void generic_set_cpu_dead(unsigned int cpu);
int generic_check_cpu_restart(unsigned int cpu);

extern void inhibit_secondary_onlining(void);
extern void uninhibit_secondary_onlining(void);

#else /* HOTPLUG_CPU */
static inline void inhibit_secondary_onlining(void) {}
static inline void uninhibit_secondary_onlining(void) {}

#endif

#ifdef CONFIG_PPC64
Expand Down
46 changes: 46 additions & 0 deletions trunk/arch/powerpc/kernel/smp.c
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,45 @@ int generic_check_cpu_restart(unsigned int cpu)
{
return per_cpu(cpu_state, cpu) == CPU_UP_PREPARE;
}

static atomic_t secondary_inhibit_count;

/*
* Don't allow secondary CPU threads to come online
*/
void inhibit_secondary_onlining(void)
{
/*
* This makes secondary_inhibit_count stable during cpu
* online/offline operations.
*/
get_online_cpus();

atomic_inc(&secondary_inhibit_count);
put_online_cpus();
}
EXPORT_SYMBOL_GPL(inhibit_secondary_onlining);

/*
* Allow secondary CPU threads to come online again
*/
void uninhibit_secondary_onlining(void)
{
get_online_cpus();
atomic_dec(&secondary_inhibit_count);
put_online_cpus();
}
EXPORT_SYMBOL_GPL(uninhibit_secondary_onlining);

static int secondaries_inhibited(void)
{
return atomic_read(&secondary_inhibit_count);
}

#else /* HOTPLUG_CPU */

#define secondaries_inhibited() 0

#endif

static void cpu_idle_thread_init(unsigned int cpu, struct task_struct *idle)
Expand All @@ -435,6 +474,13 @@ int __cpuinit __cpu_up(unsigned int cpu, struct task_struct *tidle)
{
int rc, c;

/*
* Don't allow secondary threads to come online if inhibited
*/
if (threads_per_core > 1 && secondaries_inhibited() &&
cpu % threads_per_core != 0)
return -EBUSY;

if (smp_ops == NULL ||
(smp_ops->cpu_bootable && !smp_ops->cpu_bootable(cpu)))
return -EINVAL;
Expand Down
12 changes: 10 additions & 2 deletions trunk/arch/powerpc/kvm/book3s_hv.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
#include <asm/page.h>
#include <asm/hvcall.h>
#include <asm/switch_to.h>
#include <asm/smp.h>
#include <linux/gfp.h>
#include <linux/vmalloc.h>
#include <linux/highmem.h>
Expand Down Expand Up @@ -1016,8 +1017,6 @@ static int kvmppc_run_core(struct kvmppc_vcore *vc)
/*
* Make sure we are running on thread 0, and that
* secondary threads are offline.
* XXX we should also block attempts to bring any
* secondary threads online.
*/
if (threads_per_core > 1 && !on_primary_thread()) {
list_for_each_entry(vcpu, &vc->runnable_threads, arch.run_list)
Expand Down Expand Up @@ -1730,11 +1729,20 @@ int kvmppc_core_init_vm(struct kvm *kvm)

kvm->arch.using_mmu_notifiers = !!cpu_has_feature(CPU_FTR_ARCH_206);
spin_lock_init(&kvm->arch.slot_phys_lock);

/*
* Don't allow secondary CPU threads to come online
* while any KVM VMs exist.
*/
inhibit_secondary_onlining();

return 0;
}

void kvmppc_core_destroy_vm(struct kvm *kvm)
{
uninhibit_secondary_onlining();

if (kvm->arch.rma) {
kvm_release_rma(kvm->arch.rma);
kvm->arch.rma = NULL;
Expand Down

0 comments on commit 74d9578

Please sign in to comment.