From: Dominik Dingel <dingel@linux.vnet.ibm.com> To: Gleb Natapov <gleb@redhat.com>, Paolo Bonzini <pbonzini@redhat.com> Cc: Christian Borntraeger <borntraeger@de.ibm.com>, Heiko Carstens <heiko.carstens@de.ibm.com>, Martin Schwidefsky <schwidefsky@de.ibm.com>, Cornelia Huck <cornelia.huck@de.ibm.com>, Xiantao Zhang <xiantao.zhang@intel.com>, Alexander Graf <agraf@suse.de>, Christoffer Dall <christoffer.dall@linaro.org>, Marc Zyngier <marc.zyngier@arm.com>, Ralf Baechle <ralf@linux-mips.org>, kvm@vger.kernel.org, linux-s390@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Dominik Dingel <dingel@linux.vnet.ibm.com> Subject: [PATCH 3/4] PF: Provide additional direct page notification Date: Wed, 10 Jul 2013 14:59:54 +0200 [thread overview] Message-ID: <1373461195-27628-4-git-send-email-dingel@linux.vnet.ibm.com> (raw) In-Reply-To: <1373461195-27628-1-git-send-email-dingel@linux.vnet.ibm.com> By setting a Kconfig option, the architecture can control when guest notifications will be presented by the apf backend. So there is the default batch mechanism, working as before, where the vcpu thread should pull in this information. On the other hand there is now the direct mechanism, this will directly push the information to the guest. This way s390 can use an already existing architecture interface. Still the vcpu thread should call check_completion to cleanup leftovers, that leaves most of the common code untouched. Signed-off-by: Dominik Dingel <dingel@linux.vnet.ibm.com> Acked-by: Christian Borntraeger <borntraeger@de.ibm.com> --- arch/x86/kvm/mmu.c | 2 +- include/linux/kvm_host.h | 2 +- virt/kvm/Kconfig | 4 ++++ virt/kvm/async_pf.c | 22 +++++++++++++++++++--- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 0d094da..b8632e9 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -3343,7 +3343,7 @@ static int kvm_arch_setup_async_pf(struct kvm_vcpu *vcpu, gva_t gva, gfn_t gfn) arch.direct_map = vcpu->arch.mmu.direct_map; arch.cr3 = vcpu->arch.mmu.get_cr3(vcpu); - return kvm_setup_async_pf(vcpu, gva, gfn, &arch); + return kvm_setup_async_pf(vcpu, gva, gfn_to_hva(vcpu->kvm, gfn), &arch); } static bool can_do_async_pf(struct kvm_vcpu *vcpu) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 92e8f64..fe87e46 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -191,7 +191,7 @@ struct kvm_async_pf { void kvm_clear_async_pf_completion_queue(struct kvm_vcpu *vcpu); void kvm_check_async_pf_completion(struct kvm_vcpu *vcpu); -int kvm_setup_async_pf(struct kvm_vcpu *vcpu, gva_t gva, gfn_t gfn, +int kvm_setup_async_pf(struct kvm_vcpu *vcpu, gva_t gva, unsigned long hva, struct kvm_arch_async_pf *arch); int kvm_async_pf_wakeup_all(struct kvm_vcpu *vcpu); #endif diff --git a/virt/kvm/Kconfig b/virt/kvm/Kconfig index 779262f..0774495 100644 --- a/virt/kvm/Kconfig +++ b/virt/kvm/Kconfig @@ -22,6 +22,10 @@ config KVM_MMIO config KVM_ASYNC_PF bool +# Toggle to switch between direct notification and batch job +config KVM_ASYNC_PF_SYNC + bool + config HAVE_KVM_MSI bool diff --git a/virt/kvm/async_pf.c b/virt/kvm/async_pf.c index ea475cd..cfa9366 100644 --- a/virt/kvm/async_pf.c +++ b/virt/kvm/async_pf.c @@ -28,6 +28,21 @@ #include "async_pf.h" #include <trace/events/kvm.h> +static inline void kvm_async_page_present_sync(struct kvm_vcpu *vcpu, + struct kvm_async_pf *work) +{ +#ifdef CONFIG_KVM_ASYNC_PF_SYNC + kvm_arch_async_page_present(vcpu, work); +#endif +} +static inline void kvm_async_page_present_async(struct kvm_vcpu *vcpu, + struct kvm_async_pf *work) +{ +#ifndef CONFIG_KVM_ASYNC_PF_SYNC + kvm_arch_async_page_present(vcpu, work); +#endif +} + static struct kmem_cache *async_pf_cache; int kvm_async_pf_init(void) @@ -70,6 +85,7 @@ static void async_pf_execute(struct work_struct *work) down_read(&mm->mmap_sem); get_user_pages(current, mm, addr, 1, 1, 0, &page, NULL); up_read(&mm->mmap_sem); + kvm_async_page_present_sync(vcpu, apf); unuse_mm(mm); spin_lock(&vcpu->async_pf.lock); @@ -134,7 +150,7 @@ void kvm_check_async_pf_completion(struct kvm_vcpu *vcpu) if (work->page) kvm_arch_async_page_ready(vcpu, work); - kvm_arch_async_page_present(vcpu, work); + kvm_async_page_present_async(vcpu, work); list_del(&work->queue); vcpu->async_pf.queued--; @@ -144,7 +160,7 @@ void kvm_check_async_pf_completion(struct kvm_vcpu *vcpu) } } -int kvm_setup_async_pf(struct kvm_vcpu *vcpu, gva_t gva, gfn_t gfn, +int kvm_setup_async_pf(struct kvm_vcpu *vcpu, gva_t gva, unsigned long hva, struct kvm_arch_async_pf *arch) { struct kvm_async_pf *work; @@ -166,7 +182,7 @@ int kvm_setup_async_pf(struct kvm_vcpu *vcpu, gva_t gva, gfn_t gfn, work->done = false; work->vcpu = vcpu; work->gva = gva; - work->addr = gfn_to_hva(vcpu->kvm, gfn); + work->addr = hva; work->arch = *arch; work->mm = current->mm; atomic_inc(&work->mm->mm_count); -- 1.8.2.2
WARNING: multiple messages have this Message-ID (diff)
From: Dominik Dingel <dingel@linux.vnet.ibm.com> To: Gleb Natapov <gleb@redhat.com>, Paolo Bonzini <pbonzini@redhat.com> Cc: Christian Borntraeger <borntraeger@de.ibm.com>, Heiko Carstens <heiko.carstens@de.ibm.com>, Martin Schwidefsky <schwidefsky@de.ibm.com>, Cornelia Huck <cornelia.huck@de.ibm.com>, Xiantao Zhang <xiantao.zhang@intel.com>, Alexander Graf <agraf@suse.de>, Christoffer Dall <christoffer.dall@linaro.org>, Marc Zyngier <marc.zyngier@arm.com>, Ralf Baechle <ralf@linux-mips.org>, kvm@vger.kernel.org, linux-s390@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, Dominik Dingel <dingel@linux.vnet.ibm.com> Subject: [PATCH 3/4] PF: Provide additional direct page notification Date: Wed, 10 Jul 2013 14:59:54 +0200 [thread overview] Message-ID: <1373461195-27628-4-git-send-email-dingel@linux.vnet.ibm.com> (raw) In-Reply-To: <1373461195-27628-1-git-send-email-dingel@linux.vnet.ibm.com> By setting a Kconfig option, the architecture can control when guest notifications will be presented by the apf backend. So there is the default batch mechanism, working as before, where the vcpu thread should pull in this information. On the other hand there is now the direct mechanism, this will directly push the information to the guest. This way s390 can use an already existing architecture interface. Still the vcpu thread should call check_completion to cleanup leftovers, that leaves most of the common code untouched. Signed-off-by: Dominik Dingel <dingel@linux.vnet.ibm.com> Acked-by: Christian Borntraeger <borntraeger@de.ibm.com> --- arch/x86/kvm/mmu.c | 2 +- include/linux/kvm_host.h | 2 +- virt/kvm/Kconfig | 4 ++++ virt/kvm/async_pf.c | 22 +++++++++++++++++++--- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c index 0d094da..b8632e9 100644 --- a/arch/x86/kvm/mmu.c +++ b/arch/x86/kvm/mmu.c @@ -3343,7 +3343,7 @@ static int kvm_arch_setup_async_pf(struct kvm_vcpu *vcpu, gva_t gva, gfn_t gfn) arch.direct_map = vcpu->arch.mmu.direct_map; arch.cr3 = vcpu->arch.mmu.get_cr3(vcpu); - return kvm_setup_async_pf(vcpu, gva, gfn, &arch); + return kvm_setup_async_pf(vcpu, gva, gfn_to_hva(vcpu->kvm, gfn), &arch); } static bool can_do_async_pf(struct kvm_vcpu *vcpu) diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 92e8f64..fe87e46 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -191,7 +191,7 @@ struct kvm_async_pf { void kvm_clear_async_pf_completion_queue(struct kvm_vcpu *vcpu); void kvm_check_async_pf_completion(struct kvm_vcpu *vcpu); -int kvm_setup_async_pf(struct kvm_vcpu *vcpu, gva_t gva, gfn_t gfn, +int kvm_setup_async_pf(struct kvm_vcpu *vcpu, gva_t gva, unsigned long hva, struct kvm_arch_async_pf *arch); int kvm_async_pf_wakeup_all(struct kvm_vcpu *vcpu); #endif diff --git a/virt/kvm/Kconfig b/virt/kvm/Kconfig index 779262f..0774495 100644 --- a/virt/kvm/Kconfig +++ b/virt/kvm/Kconfig @@ -22,6 +22,10 @@ config KVM_MMIO config KVM_ASYNC_PF bool +# Toggle to switch between direct notification and batch job +config KVM_ASYNC_PF_SYNC + bool + config HAVE_KVM_MSI bool diff --git a/virt/kvm/async_pf.c b/virt/kvm/async_pf.c index ea475cd..cfa9366 100644 --- a/virt/kvm/async_pf.c +++ b/virt/kvm/async_pf.c @@ -28,6 +28,21 @@ #include "async_pf.h" #include <trace/events/kvm.h> +static inline void kvm_async_page_present_sync(struct kvm_vcpu *vcpu, + struct kvm_async_pf *work) +{ +#ifdef CONFIG_KVM_ASYNC_PF_SYNC + kvm_arch_async_page_present(vcpu, work); +#endif +} +static inline void kvm_async_page_present_async(struct kvm_vcpu *vcpu, + struct kvm_async_pf *work) +{ +#ifndef CONFIG_KVM_ASYNC_PF_SYNC + kvm_arch_async_page_present(vcpu, work); +#endif +} + static struct kmem_cache *async_pf_cache; int kvm_async_pf_init(void) @@ -70,6 +85,7 @@ static void async_pf_execute(struct work_struct *work) down_read(&mm->mmap_sem); get_user_pages(current, mm, addr, 1, 1, 0, &page, NULL); up_read(&mm->mmap_sem); + kvm_async_page_present_sync(vcpu, apf); unuse_mm(mm); spin_lock(&vcpu->async_pf.lock); @@ -134,7 +150,7 @@ void kvm_check_async_pf_completion(struct kvm_vcpu *vcpu) if (work->page) kvm_arch_async_page_ready(vcpu, work); - kvm_arch_async_page_present(vcpu, work); + kvm_async_page_present_async(vcpu, work); list_del(&work->queue); vcpu->async_pf.queued--; @@ -144,7 +160,7 @@ void kvm_check_async_pf_completion(struct kvm_vcpu *vcpu) } } -int kvm_setup_async_pf(struct kvm_vcpu *vcpu, gva_t gva, gfn_t gfn, +int kvm_setup_async_pf(struct kvm_vcpu *vcpu, gva_t gva, unsigned long hva, struct kvm_arch_async_pf *arch) { struct kvm_async_pf *work; @@ -166,7 +182,7 @@ int kvm_setup_async_pf(struct kvm_vcpu *vcpu, gva_t gva, gfn_t gfn, work->done = false; work->vcpu = vcpu; work->gva = gva; - work->addr = gfn_to_hva(vcpu->kvm, gfn); + work->addr = hva; work->arch = *arch; work->mm = current->mm; atomic_inc(&work->mm->mm_count); -- 1.8.2.2 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2013-07-10 13:01 UTC|newest] Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top 2013-07-10 12:59 [PATCH v4 0/4] Enable async page faults on s390 Dominik Dingel 2013-07-10 12:59 ` Dominik Dingel 2013-07-10 12:59 ` [PATCH 1/4] PF: Add FAULT_FLAG_RETRY_NOWAIT for guest fault Dominik Dingel 2013-07-10 12:59 ` Dominik Dingel 2013-07-10 12:59 ` [PATCH 2/4] PF: Make KVM_HVA_ERR_BAD usable on s390 Dominik Dingel 2013-07-10 12:59 ` Dominik Dingel 2013-07-10 12:59 ` Dominik Dingel [this message] 2013-07-10 12:59 ` [PATCH 3/4] PF: Provide additional direct page notification Dominik Dingel 2013-07-10 12:59 ` [PATCH 4/4] PF: Async page fault support on s390 Dominik Dingel 2013-07-10 12:59 ` Dominik Dingel 2013-07-11 9:04 ` Gleb Natapov 2013-07-11 9:04 ` Gleb Natapov 2013-07-11 10:41 ` Christian Borntraeger 2013-07-11 10:41 ` Christian Borntraeger 2013-07-11 10:58 ` Gleb Natapov 2013-07-11 10:58 ` Gleb Natapov 2013-07-18 13:57 ` Paolo Bonzini 2013-07-18 13:57 ` Paolo Bonzini 2013-07-18 14:12 ` Christian Borntraeger 2013-07-18 14:12 ` Christian Borntraeger -- strict thread matches above, loose matches on Subject: below -- 2013-07-09 13:56 [PATCH v3 0/4] Enable async page faults " Dominik Dingel 2013-07-09 13:56 ` [PATCH 3/4] PF: Provide additional direct page notification Dominik Dingel 2013-07-09 13:56 ` Dominik Dingel 2013-07-09 16:01 ` Christian Borntraeger 2013-07-09 16:01 ` Christian Borntraeger 2013-07-10 10:39 ` Alexander Graf 2013-07-10 10:39 ` Alexander Graf 2013-07-10 10:42 ` Gleb Natapov 2013-07-10 10:42 ` Gleb Natapov 2013-07-10 10:45 ` Alexander Graf 2013-07-10 10:45 ` Alexander Graf 2013-07-10 10:48 ` Gleb Natapov 2013-07-10 10:48 ` Gleb Natapov 2013-07-10 10:52 ` Alexander Graf 2013-07-10 10:52 ` Alexander Graf 2013-07-10 10:49 ` Christian Borntraeger 2013-07-10 10:49 ` Christian Borntraeger 2013-07-10 10:51 ` Alexander Graf 2013-07-10 10:51 ` Alexander Graf 2013-07-05 20:55 [RFC PATCH v2 0/4] Enable async page faults on s390 Dominik Dingel 2013-07-05 20:55 ` [PATCH 3/4] PF: Provide additional direct page notification Dominik Dingel 2013-07-05 20:55 ` Dominik Dingel 2013-07-07 9:28 ` Gleb Natapov 2013-07-07 9:28 ` Gleb Natapov
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=1373461195-27628-4-git-send-email-dingel@linux.vnet.ibm.com \ --to=dingel@linux.vnet.ibm.com \ --cc=agraf@suse.de \ --cc=borntraeger@de.ibm.com \ --cc=christoffer.dall@linaro.org \ --cc=cornelia.huck@de.ibm.com \ --cc=gleb@redhat.com \ --cc=heiko.carstens@de.ibm.com \ --cc=kvm@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mm@kvack.org \ --cc=linux-s390@vger.kernel.org \ --cc=marc.zyngier@arm.com \ --cc=pbonzini@redhat.com \ --cc=ralf@linux-mips.org \ --cc=schwidefsky@de.ibm.com \ --cc=xiantao.zhang@intel.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: linkBe 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.