From: Huacai Chen <chenhuacai@gmail.com>
To: Sean Christopherson <sean.j.christopherson@intel.com>
Cc: Wanpeng Li <wanpengli@tencent.com>, kvm <kvm@vger.kernel.org>,
David Hildenbrand <david@redhat.com>,
LKML <linux-kernel@vger.kernel.org>,
Paul Mackerras <paulus@ozlabs.org>,
Ben Gardon <bgardon@google.com>,
Claudio Imbrenda <imbrenda@linux.ibm.com>,
kvmarm@lists.cs.columbia.edu,
Janosch Frank <frankja@linux.ibm.com>,
Marc Zyngier <maz@kernel.org>, Joerg Roedel <joro@8bytes.org>,
Christian Borntraeger <borntraeger@de.ibm.com>,
Junaid Shahid <junaids@google.com>,
kvm-ppc@vger.kernel.org,
linux-arm-kernel <linux-arm-kernel@lists.infradead.org>,
Jim Mattson <jmattson@google.com>,
Cornelia Huck <cohuck@redhat.com>,
Peter Shier <pshier@google.com>,
"open list:MIPS" <linux-mips@vger.kernel.org>,
Paolo Bonzini <pbonzini@redhat.com>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
Peter Feiner <pfeiner@google.com>
Subject: Re: [PATCH 21/21] KVM: MIPS: Use common KVM implementation of MMU memory caches
Date: Mon, 8 Jun 2020 16:57:20 +0800 [thread overview]
Message-ID: <CAAhV-H4XrXx9ktum-E706ggukSU77hdN-iofJ-DDGtLeGt+KPA@mail.gmail.com> (raw)
In-Reply-To: <20200605213853.14959-22-sean.j.christopherson@intel.com>
Reviewed-by: Huacai Chen <chenhc@lemote.com>
On Sat, Jun 6, 2020 at 5:41 AM Sean Christopherson
<sean.j.christopherson@intel.com> wrote:
>
> Move to the common MMU memory cache implementation now that the common
> code and MIPS's existing code are semantically compatible.
>
> No functional change intended.
>
> Suggested-by: Christoffer Dall <christoffer.dall@arm.com>
> Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
> ---
> arch/mips/include/asm/kvm_host.h | 11 ---------
> arch/mips/include/asm/kvm_types.h | 2 ++
> arch/mips/kvm/mmu.c | 40 ++++---------------------------
> 3 files changed, 7 insertions(+), 46 deletions(-)
>
> diff --git a/arch/mips/include/asm/kvm_host.h b/arch/mips/include/asm/kvm_host.h
> index 363e7a89d173..f49617175f60 100644
> --- a/arch/mips/include/asm/kvm_host.h
> +++ b/arch/mips/include/asm/kvm_host.h
> @@ -335,17 +335,6 @@ struct kvm_mips_tlb {
> long tlb_lo[2];
> };
>
> -#define KVM_NR_MEM_OBJS 4
> -
> -/*
> - * We don't want allocation failures within the mmu code, so we preallocate
> - * enough memory for a single page fault in a cache.
> - */
> -struct kvm_mmu_memory_cache {
> - int nobjs;
> - void *objects[KVM_NR_MEM_OBJS];
> -};
> -
> #define KVM_MIPS_AUX_FPU 0x1
> #define KVM_MIPS_AUX_MSA 0x2
>
> diff --git a/arch/mips/include/asm/kvm_types.h b/arch/mips/include/asm/kvm_types.h
> index 5efeb32a5926..213754d9ef6b 100644
> --- a/arch/mips/include/asm/kvm_types.h
> +++ b/arch/mips/include/asm/kvm_types.h
> @@ -2,4 +2,6 @@
> #ifndef _ASM_MIPS_KVM_TYPES_H
> #define _ASM_MIPS_KVM_TYPES_H
>
> +#define KVM_ARCH_NR_OBJS_PER_MEMORY_CACHE 4
> +
> #endif /* _ASM_MIPS_KVM_TYPES_H */
> diff --git a/arch/mips/kvm/mmu.c b/arch/mips/kvm/mmu.c
> index 41a4a063a730..d6acd88c0c46 100644
> --- a/arch/mips/kvm/mmu.c
> +++ b/arch/mips/kvm/mmu.c
> @@ -25,39 +25,9 @@
> #define KVM_MMU_CACHE_MIN_PAGES 2
> #endif
>
> -static int mmu_topup_memory_cache(struct kvm_mmu_memory_cache *cache, int min)
> -{
> - void *page;
> -
> - if (cache->nobjs >= min)
> - return 0;
> - while (cache->nobjs < ARRAY_SIZE(cache->objects)) {
> - page = (void *)__get_free_page(GFP_KERNEL_ACCOUNT);
> - if (!page)
> - return -ENOMEM;
> - cache->objects[cache->nobjs++] = page;
> - }
> - return 0;
> -}
> -
> -static void mmu_free_memory_cache(struct kvm_mmu_memory_cache *mc)
> -{
> - while (mc->nobjs)
> - free_page((unsigned long)mc->objects[--mc->nobjs]);
> -}
> -
> -static void *mmu_memory_cache_alloc(struct kvm_mmu_memory_cache *mc)
> -{
> - void *p;
> -
> - BUG_ON(!mc || !mc->nobjs);
> - p = mc->objects[--mc->nobjs];
> - return p;
> -}
> -
> void kvm_mmu_free_memory_caches(struct kvm_vcpu *vcpu)
> {
> - mmu_free_memory_cache(&vcpu->arch.mmu_page_cache);
> + kvm_mmu_free_memory_cache(&vcpu->arch.mmu_page_cache);
> }
>
> /**
> @@ -151,7 +121,7 @@ static pte_t *kvm_mips_walk_pgd(pgd_t *pgd, struct kvm_mmu_memory_cache *cache,
>
> if (!cache)
> return NULL;
> - new_pmd = mmu_memory_cache_alloc(cache);
> + new_pmd = kvm_mmu_memory_cache_alloc(cache);
> pmd_init((unsigned long)new_pmd,
> (unsigned long)invalid_pte_table);
> pud_populate(NULL, pud, new_pmd);
> @@ -162,7 +132,7 @@ static pte_t *kvm_mips_walk_pgd(pgd_t *pgd, struct kvm_mmu_memory_cache *cache,
>
> if (!cache)
> return NULL;
> - new_pte = mmu_memory_cache_alloc(cache);
> + new_pte = kvm_mmu_memory_cache_alloc(cache);
> clear_page(new_pte);
> pmd_populate_kernel(NULL, pmd, new_pte);
> }
> @@ -709,7 +679,7 @@ static int kvm_mips_map_page(struct kvm_vcpu *vcpu, unsigned long gpa,
> goto out;
>
> /* We need a minimum of cached pages ready for page table creation */
> - err = mmu_topup_memory_cache(memcache, KVM_MMU_CACHE_MIN_PAGES);
> + err = kvm_mmu_topup_memory_cache(memcache, KVM_MMU_CACHE_MIN_PAGES);
> if (err)
> goto out;
>
> @@ -793,7 +763,7 @@ static pte_t *kvm_trap_emul_pte_for_gva(struct kvm_vcpu *vcpu,
> int ret;
>
> /* We need a minimum of cached pages ready for page table creation */
> - ret = mmu_topup_memory_cache(memcache, KVM_MMU_CACHE_MIN_PAGES);
> + ret = kvm_mmu_topup_memory_cache(memcache, KVM_MMU_CACHE_MIN_PAGES);
> if (ret)
> return NULL;
>
> --
> 2.26.0
>
_______________________________________________
kvmarm mailing list
kvmarm@lists.cs.columbia.edu
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm
next prev parent reply other threads:[~2020-06-08 9:36 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-05 21:38 [PATCH 00/21] KVM: Cleanup and unify kvm_mmu_memory_cache usage Sean Christopherson
2020-06-05 21:38 ` [PATCH 01/21] KVM: x86/mmu: Track the associated kmem_cache in the MMU caches Sean Christopherson
2020-06-09 21:07 ` Ben Gardon
2020-06-05 21:38 ` [PATCH 02/21] KVM: x86/mmu: Consolidate "page" variant of memory cache helpers Sean Christopherson
2020-06-09 22:54 ` Ben Gardon
2020-06-05 21:38 ` [PATCH 03/21] KVM: x86/mmu: Use consistent "mc" name for kvm_mmu_memory_cache locals Sean Christopherson
2020-06-10 22:03 ` Ben Gardon
2020-06-05 21:38 ` [PATCH 04/21] KVM: x86/mmu: Remove superfluous gotos from mmu_topup_memory_caches() Sean Christopherson
2020-06-09 22:57 ` Ben Gardon
2020-06-05 21:38 ` [PATCH 05/21] KVM: x86/mmu: Try to avoid crashing KVM if a MMU memory cache is empty Sean Christopherson
2020-06-10 22:12 ` Ben Gardon
2020-06-17 0:53 ` Sean Christopherson
2020-06-17 16:36 ` Ben Gardon
2020-06-05 21:38 ` [PATCH 06/21] KVM: x86/mmu: Move fast_page_fault() call above mmu_topup_memory_caches() Sean Christopherson
2020-06-09 23:03 ` Ben Gardon
2020-06-05 21:38 ` [PATCH 07/21] KVM: x86/mmu: Topup memory caches after walking GVA->GPA Sean Christopherson
2020-06-10 22:34 ` Ben Gardon
2020-06-05 21:38 ` [PATCH 08/21] KVM: x86/mmu: Clean up the gorilla math in mmu_topup_memory_caches() Sean Christopherson
2020-06-10 22:20 ` Ben Gardon
2020-06-05 21:38 ` [PATCH 09/21] KVM: x86/mmu: Separate the memory caches for shadow pages and gfn arrays Sean Christopherson
2020-06-09 23:56 ` Ben Gardon
2020-06-05 21:38 ` [PATCH 10/21] KVM: x86/mmu: Make __GFP_ZERO a property of the memory cache Sean Christopherson
2020-06-10 18:57 ` Ben Gardon
2020-06-22 19:40 ` Sean Christopherson
2020-06-05 21:38 ` [PATCH 11/21] KVM: x86/mmu: Zero allocate shadow pages (outside of mmu_lock) Sean Christopherson
2020-06-10 18:49 ` Ben Gardon
2020-06-05 21:38 ` [PATCH 12/21] KVM: x86/mmu: Skip filling the gfn cache for guaranteed direct MMU topups Sean Christopherson
2020-06-10 18:52 ` Ben Gardon
2020-06-05 21:38 ` [PATCH 13/21] KVM: x86/mmu: Prepend "kvm_" to memory cache helpers that will be global Sean Christopherson
2020-06-10 18:56 ` Ben Gardon
2020-06-05 21:38 ` [PATCH 14/21] KVM: Move x86's version of struct kvm_mmu_memory_cache to common code Sean Christopherson
2020-06-10 19:01 ` Ben Gardon
2020-06-10 21:58 ` Ben Gardon
2020-06-22 16:57 ` Sean Christopherson
2020-06-11 7:42 ` Marc Zyngier
2020-06-05 21:38 ` [PATCH 15/21] KVM: Move x86's MMU memory cache helpers to common KVM code Sean Christopherson
2020-06-10 20:24 ` Ben Gardon
2020-06-05 21:38 ` [PATCH 16/21] KVM: arm64: Drop @max param from mmu_topup_memory_cache() Sean Christopherson
2020-06-10 22:00 ` Ben Gardon
2020-06-11 15:59 ` Sean Christopherson
2020-06-05 21:38 ` [PATCH 17/21] KVM: arm64: Use common code's approach for __GFP_ZERO with memory caches Sean Christopherson
2020-06-11 7:59 ` Marc Zyngier
2020-06-11 15:43 ` Sean Christopherson
2020-06-11 15:51 ` Marc Zyngier
2020-06-05 21:38 ` [PATCH 18/21] KVM: arm64: Use common KVM implementation of MMU " Sean Christopherson
2020-06-11 8:01 ` Marc Zyngier
2020-06-11 15:46 ` Sean Christopherson
2020-06-05 21:38 ` [PATCH 19/21] KVM: MIPS: Drop @max param from mmu_topup_memory_cache() Sean Christopherson
2020-06-08 8:56 ` Huacai Chen
2020-06-05 21:38 ` [PATCH 20/21] KVM: MIPS: Account pages used for GPA page tables Sean Christopherson
2020-06-08 8:56 ` Huacai Chen
2020-06-05 21:38 ` [PATCH 21/21] KVM: MIPS: Use common KVM implementation of MMU memory caches Sean Christopherson
2020-06-08 8:57 ` Huacai Chen [this message]
2020-06-11 8:06 ` [PATCH 00/21] KVM: Cleanup and unify kvm_mmu_memory_cache usage Marc Zyngier
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=CAAhV-H4XrXx9ktum-E706ggukSU77hdN-iofJ-DDGtLeGt+KPA@mail.gmail.com \
--to=chenhuacai@gmail.com \
--cc=bgardon@google.com \
--cc=borntraeger@de.ibm.com \
--cc=cohuck@redhat.com \
--cc=david@redhat.com \
--cc=frankja@linux.ibm.com \
--cc=imbrenda@linux.ibm.com \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=junaids@google.com \
--cc=kvm-ppc@vger.kernel.org \
--cc=kvm@vger.kernel.org \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mips@vger.kernel.org \
--cc=maz@kernel.org \
--cc=paulus@ozlabs.org \
--cc=pbonzini@redhat.com \
--cc=pfeiner@google.com \
--cc=pshier@google.com \
--cc=sean.j.christopherson@intel.com \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.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).