From: Gleb Natapov <gleb@redhat.com>
To: Dominik Dingel <dingel@linux.vnet.ibm.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
Christian Borntraeger <borntraeger@de.ibm.com>,
Heiko Carstens <heiko.carstens@de.ibm.com>,
Martin Schwidefsky <schwidefsky@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
Subject: Re: [PATCH 3/4] PF: Provide additional direct page notification
Date: Sun, 7 Jul 2013 12:28:04 +0300 [thread overview]
Message-ID: <20130707092804.GU5113@redhat.com> (raw)
In-Reply-To: <1373057754-59225-4-git-send-email-dingel@linux.vnet.ibm.com>
On Fri, Jul 05, 2013 at 10:55:53PM +0200, Dominik Dingel wrote:
> 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.
>
> 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>
> ---
> 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 210f493..969d575 100644
> --- a/include/linux/kvm_host.h
> +++ b/include/linux/kvm_host.h
> @@ -175,7 +175,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..715e6b5 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_DIRECT
> + bool
> +
> config HAVE_KVM_MSI
> bool
>
> diff --git a/virt/kvm/async_pf.c b/virt/kvm/async_pf.c
> index ea475cd..b8df37a 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_direct_present(struct kvm_vcpu *vcpu,
> + struct kvm_async_pf *work)
> +{
> +#ifdef CONFIG_KVM_ASYNC_PF_DIRECT
> + kvm_arch_async_page_present(vcpu, work);
> +#endif
> +}
> +static inline void kvm_async_page_batch_present(struct kvm_vcpu *vcpu,
> + struct kvm_async_pf *work)
> +{
> +#ifndef CONFIG_KVM_ASYNC_PF_DIRECT
> + kvm_arch_async_page_present(vcpu, work);
> +#endif
> +}
> +
I would call them kvm_async_page_present_(async|sync)().
Hmm, to much "sync" in each function name, but I still think it is
better.
> 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_direct_present(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_batch_present(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
--
Gleb.
--
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-07 9:28 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-05 20:55 [RFC PATCH v2 0/4] Enable async page faults on s390 Dominik Dingel
2013-07-05 20:55 ` [PATCH 1/4] PF: Add FAULT_FLAG_RETRY_NOWAIT for guest fault Dominik Dingel
2013-07-05 20:55 ` [PATCH 2/4] PF: Move architecture specifics to the backends Dominik Dingel
2013-07-07 9:20 ` Gleb Natapov
2013-07-05 20:55 ` [PATCH 3/4] PF: Provide additional direct page notification Dominik Dingel
2013-07-07 9:28 ` Gleb Natapov [this message]
2013-07-05 20:55 ` [PATCH 4/4] PF: Async page fault support on s390 Dominik Dingel
-- 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 16:01 ` Christian Borntraeger
2013-07-10 10:39 ` Alexander Graf
2013-07-10 10:42 ` Gleb Natapov
2013-07-10 10:45 ` Alexander Graf
2013-07-10 10:48 ` Gleb Natapov
2013-07-10 10:52 ` Alexander Graf
2013-07-10 10:49 ` Christian Borntraeger
2013-07-10 10:51 ` Alexander Graf
2013-07-10 12:59 [PATCH v4 0/4] Enable async page faults on s390 Dominik Dingel
2013-07-10 12:59 ` [PATCH 3/4] PF: Provide additional direct page notification Dominik Dingel
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=20130707092804.GU5113@redhat.com \
--to=gleb@redhat.com \
--cc=agraf@suse.de \
--cc=borntraeger@de.ibm.com \
--cc=christoffer.dall@linaro.org \
--cc=dingel@linux.vnet.ibm.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: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).