All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Graf <agraf@suse.de>
To: Christoffer Dall <c.dall@virtualopensystems.com>
Cc: KVM devel mailing list <kvm@vger.kernel.org>,
	tech@virtualopensystems.com,
	android-virt <android-virt@lists.cs.columbia.edu>,
	kvm-ppc <kvm-ppc@vger.kernel.org>,
	Marcelo Tosatti <mtosatti@redhat.com>,
	Paul Mackerras <paulus@samba.org>,
	Scott Wood <scottwood@freescale.com>
Subject: Re: [PATCH v4] KVM: Factor out kvm_vcpu_kick to arch-generic code
Date: Tue, 13 Mar 2012 21:34:00 +0100	[thread overview]
Message-ID: <F99F975F-5CB0-4567-9954-0061629327CF@suse.de> (raw)
In-Reply-To: <CANM98qJXzw+4aLnHFgzYTr-=qH95HpM_sbg7gBdZzXx2XvmM_g@mail.gmail.com>


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@suse.de> 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@virtualopensystems.com>
>>> ---
>>> 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

WARNING: multiple messages have this Message-ID (diff)
From: Alexander Graf <agraf@suse.de>
To: Christoffer Dall <c.dall@virtualopensystems.com>
Cc: KVM devel mailing list <kvm@vger.kernel.org>,
	tech@virtualopensystems.com,
	android-virt <android-virt@lists.cs.columbia.edu>,
	kvm-ppc <kvm-ppc@vger.kernel.org>,
	Marcelo Tosatti <mtosatti@redhat.com>,
	Paul Mackerras <paulus@samba.org>,
	Scott Wood <scottwood@freescale.com>
Subject: Re: [PATCH v4] KVM: Factor out kvm_vcpu_kick to arch-generic code
Date: Tue, 13 Mar 2012 20:34:00 +0000	[thread overview]
Message-ID: <F99F975F-5CB0-4567-9954-0061629327CF@suse.de> (raw)
In-Reply-To: <CANM98qJXzw+4aLnHFgzYTr-=qH95HpM_sbg7gBdZzXx2XvmM_g@mail.gmail.com>


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@suse.de> 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@virtualopensystems.com>
>>> ---
>>> 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


  parent reply	other threads:[~2012-03-13 20:34 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-10  1:40 [PATCH v4] KVM: Factor out kvm_vcpu_kick to arch-generic code Christoffer Dall
2012-02-10  1:40 ` Christoffer Dall
2012-02-10  1:45 ` Alexander Graf
2012-02-10  1:45   ` Alexander Graf
2012-02-10  1:49   ` Christoffer Dall
2012-02-10  1:49     ` Christoffer Dall
2012-03-08 21:44   ` Christoffer Dall
2012-03-08 21:44     ` Christoffer Dall
2012-03-08 21:51     ` Scott Wood
2012-03-08 21:51       ` Scott Wood
2012-03-10  0:09     ` Marcelo Tosatti
2012-03-10  0:09       ` Marcelo Tosatti
2012-03-13 20:34     ` Alexander Graf [this message]
2012-03-13 20:34       ` Alexander Graf
2012-03-13 20:47       ` [Android-virt] " Christoffer Dall
2012-03-13 20:47         ` Christoffer Dall
2012-03-13 20:48         ` Alexander Graf
2012-03-13 20:48           ` Alexander Graf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=F99F975F-5CB0-4567-9954-0061629327CF@suse.de \
    --to=agraf@suse.de \
    --cc=android-virt@lists.cs.columbia.edu \
    --cc=c.dall@virtualopensystems.com \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    --cc=paulus@samba.org \
    --cc=scottwood@freescale.com \
    --cc=tech@virtualopensystems.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.