Re: [PATCH v4] KVM: Factor out kvm_vcpu_kick to arch-generic code

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 08.03.2012, at 22:44, Christoffer Dall wrote:

> Any news on the status of this?
> 
> On Thu, Feb 9, 2012 at 8:45 PM, Alexander Graf <agraf@xxxxxxx> wrote:
>> 
>> On 10.02.2012, at 02:40, Christoffer Dall wrote:
>> 
>>> 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;
>>> 
>>> This patch applies to d1c28f7568a74faacec896ee4f84afbffd20e5ab on
>>> git://git.kernel.org/pub/scm/virt/kvm/kvm.git.
>>> 
>>> Changes since v3:
>>> - Doesn't try to generalize vcpu->mode across all architectures and
>>>   instead calls kvm_arch_vcpu_should_kick, which is properly defined
>>>   on x86 and ia64, but other architectures simply return 1 as to maintain
>>>   status quo.
>>> 
>>> Changes since v2:
>>> - Restore arch-specific vcpu->cpu assignment to arch-specific code
>>> 
>>> Changes since v1:
>>> - Abstact CPU mode check into arch-specific function
>>> - Remove redundant vcpu->cpu assignment
>>> 
>>> Signed-off-by: Christoffer Dall <c.dall@xxxxxxxxxxxxxxxxxxxxxx>
>>> ---
>>> arch/ia64/include/asm/kvm_host.h    |    1 +
>>> arch/ia64/kvm/kvm-ia64.c            |   20 +++++---------------
>>> arch/powerpc/include/asm/kvm_host.h |    6 ++++++
>>> arch/powerpc/kvm/powerpc.c          |   21 ++++++---------------
>>> arch/s390/kvm/kvm-s390.c            |    8 ++++++++
>>> arch/x86/kvm/x86.c                  |   16 ++--------------
>>> include/linux/kvm_host.h            |    9 +++++++++
>>> virt/kvm/kvm_main.c                 |   22 ++++++++++++++++++++++
>>> 8 files changed, 59 insertions(+), 44 deletions(-)
>>> 
>>> diff --git a/arch/ia64/include/asm/kvm_host.h b/arch/ia64/include/asm/kvm_host.h
>>> index 2689ee5..06a5e91 100644
>>> --- a/arch/ia64/include/asm/kvm_host.h
>>> +++ b/arch/ia64/include/asm/kvm_host.h
>>> @@ -365,6 +365,7 @@ struct thash_cb {
>>> };
>>> 
>>> struct kvm_vcpu_stat {
>>> +     u32 halt_wakeup;
>>> };
>>> 
>>> struct kvm_vcpu_arch {
>>> diff --git a/arch/ia64/kvm/kvm-ia64.c b/arch/ia64/kvm/kvm-ia64.c
>>> index 8ca7261..96dceaa 100644
>>> --- a/arch/ia64/kvm/kvm-ia64.c
>>> +++ b/arch/ia64/kvm/kvm-ia64.c
>>> @@ -1857,21 +1857,6 @@ void kvm_arch_hardware_unsetup(void)
>>> {
>>> }
>>> 
>>> -void kvm_vcpu_kick(struct kvm_vcpu *vcpu)
>>> -{
>>> -     int me;
>>> -     int cpu = vcpu->cpu;
>>> -
>>> -     if (waitqueue_active(&vcpu->wq))
>>> -             wake_up_interruptible(&vcpu->wq);
>>> -
>>> -     me = get_cpu();
>>> -     if (cpu != me && (unsigned) cpu < nr_cpu_ids && cpu_online(cpu))
>>> -             if (!test_and_set_bit(KVM_REQ_KICK, &vcpu->requests))
>>> -                     smp_send_reschedule(cpu);
>>> -     put_cpu();
>>> -}
>>> -
>>> int kvm_apic_set_irq(struct kvm_vcpu *vcpu, struct kvm_lapic_irq *irq)
>>> {
>>>       return __apic_accept_irq(vcpu, irq->vector);
>>> @@ -1941,6 +1926,11 @@ int kvm_arch_vcpu_runnable(struct kvm_vcpu *vcpu)
>>>               (kvm_highest_pending_irq(vcpu) != -1);
>>> }
>>> 
>>> +int kvm_arch_vcpu_should_kick(struct kvm_vcpu *vcpu)
>>> +{
>>> +     return (!test_and_set_bit(KVM_REQ_KICK, &vcpu->requests));
>>> +}
>>> +
>>> int kvm_arch_vcpu_ioctl_get_mpstate(struct kvm_vcpu *vcpu,
>>>                                   struct kvm_mp_state *mp_state)
>>> {
>>> diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h
>>> index 1843d5d..d089969 100644
>>> --- a/arch/powerpc/include/asm/kvm_host.h
>>> +++ b/arch/powerpc/include/asm/kvm_host.h
>>> @@ -495,4 +495,10 @@ struct kvm_vcpu_arch {
>>> #define KVM_MMIO_REG_QPR      0x0040
>>> #define KVM_MMIO_REG_FQPR     0x0060
>>> 
>>> +#define __KVM_HAVE_ARCH_VCPU_GET_WQ 1
>>> +static inline wait_queue_head *kvm_arch_vcpu_wq(struct kvm_vcpu *vcpu)
>>> +{
>>> +     return vcpu->arch.wqp;

Sorry for the late notification - I didn't compile test it.

That code breaks for 2 reasons:

  1) It's wait_queue_head_t, not wait_queue_head
  2) struct kvm_vcpu isn't defined here yet, only arch is. Maybe we could pass in &vcpu->arch instead of vcpu? Or move the function somewhere else?


Alex

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux