diff options
author | Christoffer Dall <c.dall@virtualopensystems.com> | 2012-03-08 16:44:24 -0500 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2012-04-08 05:47:47 -0400 |
commit | b6d33834bd4e8bdf4a199812e31b3e36da53c794 (patch) | |
tree | 3360ac4b5fa572e3acb21ecdc686c6d941baa2fc /virt/kvm/kvm_main.c | |
parent | 66ef89315f121cda9bf5b65a4ef02ad1b4fb16d9 (diff) |
KVM: Factor out kvm_vcpu_kick to arch-generic code
The kvm_vcpu_kick function performs roughly the same funcitonality on
most all architectures, so we shouldn't have separate copies.
PowerPC keeps a pointer to interchanging waitqueues on the vcpu_arch
structure and to accomodate this special need a
__KVM_HAVE_ARCH_VCPU_GET_WQ define and accompanying function
kvm_arch_vcpu_wq have been defined. For all other architectures this
is a generic inline that just returns &vcpu->wq;
Acked-by: Scott Wood <scottwood@freescale.com>
Signed-off-by: Christoffer Dall <c.dall@virtualopensystems.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
Diffstat (limited to 'virt/kvm/kvm_main.c')
-rw-r--r-- | virt/kvm/kvm_main.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index a9565e240636..7149a2e65524 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c | |||
@@ -1514,6 +1514,28 @@ void kvm_vcpu_block(struct kvm_vcpu *vcpu) | |||
1514 | finish_wait(&vcpu->wq, &wait); | 1514 | finish_wait(&vcpu->wq, &wait); |
1515 | } | 1515 | } |
1516 | 1516 | ||
1517 | /* | ||
1518 | * Kick a sleeping VCPU, or a guest VCPU in guest mode, into host kernel mode. | ||
1519 | */ | ||
1520 | void kvm_vcpu_kick(struct kvm_vcpu *vcpu) | ||
1521 | { | ||
1522 | int me; | ||
1523 | int cpu = vcpu->cpu; | ||
1524 | wait_queue_head_t *wqp; | ||
1525 | |||
1526 | wqp = kvm_arch_vcpu_wq(vcpu); | ||
1527 | if (waitqueue_active(wqp)) { | ||
1528 | wake_up_interruptible(wqp); | ||
1529 | ++vcpu->stat.halt_wakeup; | ||
1530 | } | ||
1531 | |||
1532 | me = get_cpu(); | ||
1533 | if (cpu != me && (unsigned)cpu < nr_cpu_ids && cpu_online(cpu)) | ||
1534 | if (kvm_arch_vcpu_should_kick(vcpu)) | ||
1535 | smp_send_reschedule(cpu); | ||
1536 | put_cpu(); | ||
1537 | } | ||
1538 | |||
1517 | void kvm_resched(struct kvm_vcpu *vcpu) | 1539 | void kvm_resched(struct kvm_vcpu *vcpu) |
1518 | { | 1540 | { |
1519 | if (!need_resched()) | 1541 | if (!need_resched()) |