Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Suchanek <msuchanek@suse.de>2018-10-31 12:36:54 +0100
committerMichal Suchanek <msuchanek@suse.de>2018-10-31 23:28:39 +0100
commit4ea4c092f68a9c2561ed44b59c3692d5fe9ce022 (patch)
tree757b11cbaaecd0cd3c8b3960f7371767bec6fd5c
parent38d872bec664559bc4c3af310f6255166c3a98d6 (diff)
powerpc/kvm: Switch kvm pmd allocator to custom allocator
(bsc#1061840).
-rw-r--r--patches.arch/powerpc-kvm-Switch-kvm-pmd-allocator-to-custom-alloc.patch117
-rw-r--r--series.conf1
2 files changed, 118 insertions, 0 deletions
diff --git a/patches.arch/powerpc-kvm-Switch-kvm-pmd-allocator-to-custom-alloc.patch b/patches.arch/powerpc-kvm-Switch-kvm-pmd-allocator-to-custom-alloc.patch
new file mode 100644
index 0000000000..33f8ca9b3f
--- /dev/null
+++ b/patches.arch/powerpc-kvm-Switch-kvm-pmd-allocator-to-custom-alloc.patch
@@ -0,0 +1,117 @@
+From 21828c99ee91bec94c3d2c32b3d5562ffdea980a Mon Sep 17 00:00:00 2001
+From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
+Date: Mon, 16 Apr 2018 16:57:15 +0530
+Subject: [PATCH] powerpc/kvm: Switch kvm pmd allocator to custom allocator
+
+References: bsc#1061840
+Patch-mainline: v4.18-rc1
+Git-commit: 21828c99ee91bec94c3d2c32b3d5562ffdea980a
+
+In the next set of patches, we will switch pmd allocator to use page fragments
+and the locking will be updated to split pmd ptlock. We want to avoid using
+fragments for partition-scoped table. Use slab cache similar to level 4 table
+
+Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
+Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
+Acked-by: Michal Suchanek <msuchanek@suse.de>
+---
+ arch/powerpc/kvm/book3s_64_mmu_radix.c | 36 +++++++++++++++++++++++++++++-----
+ 1 file changed, 31 insertions(+), 5 deletions(-)
+
+diff --git a/arch/powerpc/kvm/book3s_64_mmu_radix.c b/arch/powerpc/kvm/book3s_64_mmu_radix.c
+index a57eafec4dc2..ccdf3761eec0 100644
+--- a/arch/powerpc/kvm/book3s_64_mmu_radix.c
++++ b/arch/powerpc/kvm/book3s_64_mmu_radix.c
+@@ -200,6 +200,7 @@ void kvmppc_radix_set_pte_at(struct kvm *kvm, unsigned long addr,
+ }
+
+ static struct kmem_cache *kvm_pte_cache;
++static struct kmem_cache *kvm_pmd_cache;
+
+ static pte_t *kvmppc_pte_alloc(void)
+ {
+@@ -217,6 +218,16 @@ static inline int pmd_is_leaf(pmd_t pmd)
+ return !!(pmd_val(pmd) & _PAGE_PTE);
+ }
+
++static pmd_t *kvmppc_pmd_alloc(void)
++{
++ return kmem_cache_alloc(kvm_pmd_cache, GFP_KERNEL);
++}
++
++static void kvmppc_pmd_free(pmd_t *pmdp)
++{
++ kmem_cache_free(kvm_pmd_cache, pmdp);
++}
++
+ static int kvmppc_create_pte(struct kvm *kvm, pte_t pte, unsigned long gpa,
+ unsigned int level, unsigned long mmu_seq)
+ {
+@@ -239,7 +250,7 @@ static int kvmppc_create_pte(struct kvm *kvm, pte_t pte, unsigned long gpa,
+ if (pud && pud_present(*pud) && !pud_huge(*pud))
+ pmd = pmd_offset(pud, gpa);
+ else if (level <= 1)
+- new_pmd = pmd_alloc_one(kvm->mm, gpa);
++ new_pmd = kvmppc_pmd_alloc();
+
+ if (level == 0 && !(pmd && pmd_present(*pmd) && !pmd_is_leaf(*pmd)))
+ new_ptep = kvmppc_pte_alloc();
+@@ -382,7 +393,7 @@ static int kvmppc_create_pte(struct kvm *kvm, pte_t pte, unsigned long gpa,
+ if (new_pud)
+ pud_free(kvm->mm, new_pud);
+ if (new_pmd)
+- pmd_free(kvm->mm, new_pmd);
++ kvmppc_pmd_free(new_pmd);
+ if (new_ptep)
+ kvmppc_pte_free(new_ptep);
+ return ret;
+@@ -758,7 +769,7 @@ void kvmppc_free_radix(struct kvm *kvm)
+ kvmppc_pte_free(pte);
+ pmd_clear(pmd);
+ }
+- pmd_free(kvm->mm, pmd_offset(pud, 0));
++ kvmppc_pmd_free(pmd_offset(pud, 0));
+ pud_clear(pud);
+ }
+ pud_free(kvm->mm, pud_offset(pgd, 0));
+@@ -770,20 +781,35 @@ void kvmppc_free_radix(struct kvm *kvm)
+
+ static void pte_ctor(void *addr)
+ {
+- memset(addr, 0, PTE_TABLE_SIZE);
++ memset(addr, 0, RADIX_PTE_TABLE_SIZE);
++}
++
++static void pmd_ctor(void *addr)
++{
++ memset(addr, 0, RADIX_PMD_TABLE_SIZE);
+ }
+
+ int kvmppc_radix_init(void)
+ {
+- unsigned long size = sizeof(void *) << PTE_INDEX_SIZE;
++ unsigned long size = sizeof(void *) << RADIX_PTE_INDEX_SIZE;
+
+ kvm_pte_cache = kmem_cache_create("kvm-pte", size, size, 0, pte_ctor);
+ if (!kvm_pte_cache)
+ return -ENOMEM;
++
++ size = sizeof(void *) << RADIX_PMD_INDEX_SIZE;
++
++ kvm_pmd_cache = kmem_cache_create("kvm-pmd", size, size, 0, pmd_ctor);
++ if (!kvm_pmd_cache) {
++ kmem_cache_destroy(kvm_pte_cache);
++ return -ENOMEM;
++ }
++
+ return 0;
+ }
+
+ void kvmppc_radix_exit(void)
+ {
+ kmem_cache_destroy(kvm_pte_cache);
++ kmem_cache_destroy(kvm_pmd_cache);
+ }
+--
+2.13.7
+
diff --git a/series.conf b/series.conf
index ce9f5110e9..827b03b767 100644
--- a/series.conf
+++ b/series.conf
@@ -16287,6 +16287,7 @@
patches.arch/powerpc-xive-prepare-all-hcalls-to-support-long-busy.patch
patches.suse/powerpc-livepatch-implement-reliable-stack-tracing-for-the-consistency-model.patch
patches.arch/powerpc-lib-Fix-the-feature-fixup-tests-to-actually-.patch
+ patches.arch/powerpc-kvm-Switch-kvm-pmd-allocator-to-custom-alloc.patch
patches.arch/powerpc-perf-Fix-memory-allocation-for-core-imc-base.patch
patches.suse/0001-powerpc-ptrace-Fix-enforcement-of-DAWR-constraints.patch
patches.fixes/4.4.139-044-powerpc-ptrace-Fix-setting-512B-aligned-break.patch