From: Liu Ping Fan <kernelfans@gmail.com>
To: linuxppc-dev@lists.ozlabs.org, kvm-ppc@vger.kernel.org
Cc: Paul Mackerras <paulus@samba.org>,
"Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>,
Alexander Graf <agraf@suse.de>
Subject: [PATCH 4/4] powernv: kvm: make the handling of _PAGE_NUMA faster for guest
Date: Wed, 11 Dec 2013 16:47:54 +0800 [thread overview]
Message-ID: <1386751674-14136-5-git-send-email-pingfank@linux.vnet.ibm.com> (raw)
In-Reply-To: <1386751674-14136-1-git-send-email-pingfank@linux.vnet.ibm.com>
The period check of _PAGE_NUMA can probably happen on the correctly
placed page. For this case, when guest try to setup hpte in real mode,
we try to resolve the numa fault in real mode, since the switch between
guest context and host context costs too much.
Signed-off-by: Liu Ping Fan <pingfank@linux.vnet.ibm.com>
---
arch/powerpc/kvm/book3s_hv_rm_mmu.c | 32 ++++++++++++++++++++++++++++++--
1 file changed, 30 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/kvm/book3s_hv_rm_mmu.c b/arch/powerpc/kvm/book3s_hv_rm_mmu.c
index ae46052..a06b199 100644
--- a/arch/powerpc/kvm/book3s_hv_rm_mmu.c
+++ b/arch/powerpc/kvm/book3s_hv_rm_mmu.c
@@ -179,6 +179,11 @@ long kvmppc_do_h_enter(struct kvm *kvm, unsigned long flags,
unsigned int writing;
unsigned long mmu_seq;
unsigned long rcbits;
+ struct mm_struct *mm = kvm->mm;
+ struct vm_area_struct *vma;
+ int page_nid, target_nid;
+ struct page *test_page;
+ pte_t *ptep;
psize = hpte_page_size(pteh, ptel);
if (!psize)
@@ -234,8 +239,26 @@ long kvmppc_do_h_enter(struct kvm *kvm, unsigned long flags,
/* Look up the Linux PTE for the backing page */
pte_size = psize;
- pte = lookup_linux_pte(pgdir, hva, writing, &pte_size, NULL);
- if (pte_present(pte) && !pte_numa(pte)) {
+ pte = lookup_linux_pte(pgdir, hva, writing, &pte_size, &ptep);
+ if (pte_present(pte)) {
+ if (pte_numa(pte)) {
+ /* If fail, let gup handle it */
+ if (unlikely(!down_read_trylock(&mm->mmap_sem)))
+ goto pte_check;
+
+ vma = find_vma(mm, hva);
+ up_read(&mm->mmap_sem);
+ test_page = pte_page(pte);
+ page_nid = page_to_nid(test_page);
+ target_nid = numa_migrate_prep(test_page, vma,
+ hva, page_nid);
+ put_page(test_page);
+ if (unlikely(target_nid != -1)) {
+ /* If fail, let gup handle it */
+ goto pte_check;
+ }
+ }
+
if (writing && !pte_write(pte))
/* make the actual HPTE be read-only */
ptel = hpte_make_readonly(ptel);
@@ -244,6 +267,7 @@ long kvmppc_do_h_enter(struct kvm *kvm, unsigned long flags,
}
}
+pte_check:
if (pte_size < psize)
return H_PARAMETER;
if (pa && pte_size > psize)
@@ -339,6 +363,10 @@ long kvmppc_do_h_enter(struct kvm *kvm, unsigned long flags,
pteh &= ~HPTE_V_VALID;
unlock_rmap(rmap);
} else {
+ if (pte_numa(pte) && pa) {
+ pte = pte_mknonnuma(pte);
+ *ptep = pte;
+ }
kvmppc_add_revmap_chain(kvm, rev, rmap, pte_index,
realmode);
/* Only set R/C in real HPTE if already set in *rmap */
--
1.8.1.4
next prev parent reply other threads:[~2013-12-11 8:47 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-11 8:47 [PATCH 0/4] powernv: kvm: numa fault improvement Liu Ping Fan
2013-12-11 8:47 ` [PATCH 1/4] mm: export numa_migrate_prep() Liu Ping Fan
2013-12-11 8:47 ` [PATCH 2/4] powernv: kvm: make _PAGE_NUMA take effect Liu Ping Fan
2014-01-20 15:22 ` Aneesh Kumar K.V
2013-12-11 8:47 ` [PATCH 3/4] powernv: kvm: extend input param for lookup_linux_pte Liu Ping Fan
2013-12-11 8:47 ` Liu Ping Fan [this message]
2014-01-09 12:08 ` [PATCH 0/4] powernv: kvm: numa fault improvement Alexander Graf
2014-01-15 6:36 ` Liu ping fan
2014-01-20 14:48 ` Alexander Graf
2014-01-21 11:22 ` Paul Mackerras
2014-01-22 5:18 ` Aneesh Kumar K.V
2014-01-22 8:33 ` Liu ping fan
2014-02-26 3:09 ` Liu ping fan
2014-01-20 15:45 ` Aneesh Kumar K.V
2014-01-21 2:30 ` Liu ping fan
2014-01-21 3:40 ` Aneesh Kumar K.V
2014-01-21 9:07 ` Liu ping fan
2014-01-21 9:11 ` Liu ping fan
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=1386751674-14136-5-git-send-email-pingfank@linux.vnet.ibm.com \
--to=kernelfans@gmail.com \
--cc=agraf@suse.de \
--cc=aneesh.kumar@linux.vnet.ibm.com \
--cc=kvm-ppc@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=paulus@samba.org \
/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).