On Mon, Aug 23, 2010 at 06:26:58PM +0300, Avi Kivity wrote:
>  On 07/19/2010 06:30 PM, Gleb Natapov wrote:
> >Enable async PF in a guest if async PF capability is discovered.
> >
> >Signed-off-by: Gleb Natapov<g...@redhat.com>
> >---
> >  arch/x86/include/asm/kvm_para.h |    5 +++
> >  arch/x86/kernel/kvm.c           |   68 
> > +++++++++++++++++++++++++++++++++++++++
> >  2 files changed, 73 insertions(+), 0 deletions(-)
> >
> >diff --git a/arch/x86/include/asm/kvm_para.h 
> >b/arch/x86/include/asm/kvm_para.h
> >index 5b05e9f..f1662d7 100644
> >--- a/arch/x86/include/asm/kvm_para.h
> >+++ b/arch/x86/include/asm/kvm_para.h
> >@@ -65,6 +65,11 @@ struct kvm_mmu_op_release_pt {
> >     __u64 pt_phys;
> >  };
> >
> >+struct kvm_vcpu_pv_apf_data {
> >+    __u32 reason;
> >+    __u32 enabled;
> >+};
> >+
> 
> The guest will have to align this on a 64 byte boundary, should this
> be marked __aligned(64) here?
> 
I do __aligned(64) when I declare variable of that type:

static DEFINE_PER_CPU(struct kvm_vcpu_pv_apf_data, apf_reason) __aligned(64);

> >@@ -231,12 +235,72 @@ static void __init paravirt_ops_setup(void)
> >  #endif
> >  }
> >
> >+void __cpuinit kvm_guest_cpu_init(void)
> >+{
> >+    if (!kvm_para_available())
> >+            return;
> >+
> >+    if (kvm_para_has_feature(KVM_FEATURE_ASYNC_PF)) {
> >+            u64 pa = __pa(&__get_cpu_var(apf_reason));
> >+
> >+            if (native_write_msr_safe(MSR_KVM_ASYNC_PF_EN,
> >+                                      pa | KVM_ASYNC_PF_ENABLED, pa>>  32))
> >+                    return;
> >+            __get_cpu_var(apf_reason).enabled = 1;
> >+            printk(KERN_INFO"KVM setup async PF for cpu %d\n",
> >+                   smp_processor_id());
> >+    }
> >+}
> 
> Need a way to disable apf from the guest kernel command line.
> 
OK.

> >+
> >+static int __cpuinit kvm_cpu_notify(struct notifier_block *self,
> >+                                unsigned long action, void *hcpu)
> >+{
> >+    switch (action) {
> >+    case CPU_ONLINE:
> >+    case CPU_ONLINE_FROZEN:
> >+            kvm_guest_cpu_init();
> >+            break;
> >+    default:
> >+            break;
> 
> Should we disable apf if the cpu is dying here?
> 
Why? Can CPU die with outstanding sleeping tasks?

> >+    }
> >+    return NOTIFY_OK;
> >+}
> >+
> 
> -- 
> error compiling committee.c: too many arguments to function

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

Reply via email to