From: Mike Rapoport <hidden> Date: 2019-05-02 15:30:07
Hi,
I've tried to trim down the recipients list, but it's still quite long, so
sorry for the spam.
Many architectures have similar, if not identical implementation of
pte_alloc_one_kernel(), pte_alloc_one(), pte_free_kernel() and pte_free().
A while ago Anshuman suggested to introduce a common definition of
GFP_PGTABLE and during the discussion it was suggested to rather
consolidate the allocators.
These patches introduce generic version of PTE allocation and free and
enable their use on several architectures.
The conversion introduces some changes for some of the architectures.
Here's the executive summary and the details are described at each patch.
* Most architectures do not set __GFP_ACCOUNT for the user page tables.
Switch to the generic functions is "spreading that goodness to all other
architectures"
* arm, arm64 and unicore32 used to check if the pte is not NULL before
freeing its memory in pte_free_kernel(). It's dropped during the
conversion as it seems superfluous.
* x86 used to BUG_ON() is pte was not page aligned duirng
pte_free_kernel(), the generic version simply frees the memory without any
checks.
This set only performs the straightforward conversion, the architectures
with different logic in pte_alloc_one() and pte_alloc_one_kernel() are not
touched, as well as architectures that have custom page table allocators.
[1] https://lore.kernel.org/lkml/1547619692-7946-1-git-send-email-anshuman.khandual@arm.com
asm-generic, x86: introduce generic pte_{alloc,free}_one[_kernel]
Mike Rapoport (15):
asm-generic, x86: introduce generic pte_{alloc,free}_one[_kernel]
alpha: switch to generic version of pte allocation
arm: switch to generic version of pte allocation
arm64: switch to generic version of pte allocation
csky: switch to generic version of pte allocation
hexagon: switch to generic version of pte allocation
m68k: sun3: switch to generic version of pte allocation
mips: switch to generic version of pte allocation
nds32: switch to generic version of pte allocation
nios2: switch to generic version of pte allocation
parisc: switch to generic version of pte allocation
powerpc/nohash/64: switch to generic version of pte allocation
riscv: switch to generic version of pte allocation
um: switch to generic version of pte allocation
unicore32: switch to generic version of pte allocation
arch/alpha/include/asm/pgalloc.h | 40 +---------
arch/arm/include/asm/pgalloc.h | 41 ++++------
arch/arm/mm/mmu.c | 2 +-
arch/arm64/include/asm/pgalloc.h | 43 +----------
arch/arm64/mm/mmu.c | 2 +-
arch/arm64/mm/pgd.c | 4 +-
arch/csky/include/asm/pgalloc.h | 30 +-------
arch/hexagon/include/asm/pgalloc.h | 34 +--------
arch/m68k/include/asm/sun3_pgalloc.h | 41 +---------
arch/mips/include/asm/pgalloc.h | 33 +--------
arch/nds32/include/asm/pgalloc.h | 31 +-------
arch/nios2/include/asm/pgalloc.h | 37 +--------
arch/parisc/include/asm/pgalloc.h | 33 +--------
arch/powerpc/include/asm/nohash/64/pgalloc.h | 35 +--------
arch/riscv/include/asm/pgalloc.h | 29 +-------
arch/um/include/asm/pgalloc.h | 16 +---
arch/um/kernel/mem.c | 22 ------
arch/unicore32/include/asm/pgalloc.h | 36 ++-------
arch/x86/include/asm/pgalloc.h | 19 +----
arch/x86/mm/pgtable.c | 33 +++------
include/asm-generic/pgalloc.h | 107 ++++++++++++++++++++++++++-
virt/kvm/arm/mmu.c | 2 +-
22 files changed, 171 insertions(+), 499 deletions(-)
--
2.7.4
From: Mike Rapoport <hidden> Date: 2019-05-02 15:29:29
The PTE allocations in arm64 are identical to the generic ones modulo the
GFP flags.
Using the generic pte_alloc_one() functions ensures that the user page
tables are allocated with __GFP_ACCOUNT set.
The arm64 definition of PGALLOC_GFP is removed and replaced with
GFP_PGTABLE_USER for p[gum]d_alloc_one() and for KVM memory cache.
The mappings created with create_pgd_mapping() are now using
GFP_PGTABLE_KERNEL.
The conversion to the generic version of pte_free_kernel() removes the NULL
check for pte.
The pte_free() version on arm64 is identical to the generic one and
can be simply dropped.
Signed-off-by: Mike Rapoport <redacted>
---
arch/arm64/include/asm/pgalloc.h | 43 ++++------------------------------------
arch/arm64/mm/mmu.c | 2 +-
arch/arm64/mm/pgd.c | 4 ++--
virt/kvm/arm/mmu.c | 2 +-
4 files changed, 8 insertions(+), 43 deletions(-)
From: Mark Rutland <mark.rutland@arm.com> Date: 2019-05-03 10:05:20
Hi,
On Thu, May 02, 2019 at 06:28:31PM +0300, Mike Rapoport wrote:
The PTE allocations in arm64 are identical to the generic ones modulo the
GFP flags.
Using the generic pte_alloc_one() functions ensures that the user page
tables are allocated with __GFP_ACCOUNT set.
The arm64 definition of PGALLOC_GFP is removed and replaced with
GFP_PGTABLE_USER for p[gum]d_alloc_one() and for KVM memory cache.
The mappings created with create_pgd_mapping() are now using
GFP_PGTABLE_KERNEL.
The conversion to the generic version of pte_free_kernel() removes the NULL
check for pte.
The pte_free() version on arm64 is identical to the generic one and
can be simply dropped.
Signed-off-by: Mike Rapoport <redacted>
---
arch/arm64/include/asm/pgalloc.h | 43 ++++------------------------------------
arch/arm64/mm/mmu.c | 2 +-
arch/arm64/mm/pgd.c | 4 ++--
virt/kvm/arm/mmu.c | 2 +-
4 files changed, 8 insertions(+), 43 deletions(-)
In efi_virtmap_init() we use pgd_alloc() to allocate a pgd for EFI
runtime services, which we map with a special kernel page table.
I'm not sure if accounting that is problematic, as it's allocated in a
kernel thread off the back of an early_initcall.
Just to check, Is that sound, or do we need a pgd_alloc_kernel()?
Thanks,
Mark.
From: Mike Rapoport <hidden> Date: 2019-05-05 06:20:16
On Fri, May 03, 2019 at 11:05:09AM +0100, Mark Rutland wrote:
Hi,
On Thu, May 02, 2019 at 06:28:31PM +0300, Mike Rapoport wrote:
quoted
The PTE allocations in arm64 are identical to the generic ones modulo the
GFP flags.
Using the generic pte_alloc_one() functions ensures that the user page
tables are allocated with __GFP_ACCOUNT set.
The arm64 definition of PGALLOC_GFP is removed and replaced with
GFP_PGTABLE_USER for p[gum]d_alloc_one() and for KVM memory cache.
The mappings created with create_pgd_mapping() are now using
GFP_PGTABLE_KERNEL.
The conversion to the generic version of pte_free_kernel() removes the NULL
check for pte.
The pte_free() version on arm64 is identical to the generic one and
can be simply dropped.
Signed-off-by: Mike Rapoport <redacted>
---
arch/arm64/include/asm/pgalloc.h | 43 ++++------------------------------------
arch/arm64/mm/mmu.c | 2 +-
arch/arm64/mm/pgd.c | 4 ++--
virt/kvm/arm/mmu.c | 2 +-
4 files changed, 8 insertions(+), 43 deletions(-)
In efi_virtmap_init() we use pgd_alloc() to allocate a pgd for EFI
runtime services, which we map with a special kernel page table.
I'm not sure if accounting that is problematic, as it's allocated in a
kernel thread off the back of an early_initcall.
The accounting bypasses kernel threads so there should be no problem.
Just to check, Is that sound, or do we need a pgd_alloc_kernel()?
Thanks,
Mark.
From: Mike Rapoport <hidden> Date: 2019-05-02 15:29:48
The sun3 MMU variant of m68k uses GFP_KERNEL to allocate a PTE page and
then memset(0) or clear_highpage() to clear it.
This is equivalent to allocating the page with GFP_KERNEL | __GFP_ZERO,
which allows replacing sun3 implementation of pte_alloc_one() and
pte_alloc_one_kernel() with the generic ones.
The pte_free() and pte_free_kernel() versions are identical to the generic
ones and can be simply dropped.
Signed-off-by: Mike Rapoport <redacted>
---
arch/m68k/include/asm/sun3_pgalloc.h | 41 ++----------------------------------
1 file changed, 2 insertions(+), 39 deletions(-)
From: Mike Rapoport <hidden> Date: 2019-05-02 15:29:50
MIPS allocates kernel PTE pages with
__get_free_pages(GFP_KERNEL | __GFP_ZERO, PTE_ORDER)
and user PTE pages with
alloc_pages(GFP_KERNEL | __GFP_ZERO, PTE_ORDER)
The PTE_ORDER is hardwired to zero, which makes MIPS implementation almost
identical to the generic one.
Switch MIPS to the generic version that does exactly the same thing for the
kernel page tables and adds __GFP_ACCOUNT for the user PTEs.
The pte_free_kernel() and pte_free() versions on mips are identical to the
generic ones and can be simply dropped.
Signed-off-by: Mike Rapoport <redacted>
---
arch/mips/include/asm/pgalloc.h | 33 ++-------------------------------
1 file changed, 2 insertions(+), 31 deletions(-)
From: Paul Burton <hidden> Date: 2019-05-02 19:09:53
Hi Mike,
On Thu, May 02, 2019 at 06:28:35PM +0300, Mike Rapoport wrote:
MIPS allocates kernel PTE pages with
__get_free_pages(GFP_KERNEL | __GFP_ZERO, PTE_ORDER)
and user PTE pages with
alloc_pages(GFP_KERNEL | __GFP_ZERO, PTE_ORDER)
That bit isn't quite true - we don't use __GFP_ZERO in pte_alloc_one() &
instead call clear_highpage() on the allocated page. Not that I have a
problem with using __GFP_ZERO - it seems like the more optimal choice.
It just might be worth mentioning the change & expected equivalent
behavior.
Otherwise:
Acked-by: Paul Burton [off-list ref]
Thanks,
Paul
From: Mike Rapoport <hidden> Date: 2019-05-05 06:17:55
On Thu, May 02, 2019 at 07:09:47PM +0000, Paul Burton wrote:
Hi Mike,
On Thu, May 02, 2019 at 06:28:35PM +0300, Mike Rapoport wrote:
quoted
MIPS allocates kernel PTE pages with
__get_free_pages(GFP_KERNEL | __GFP_ZERO, PTE_ORDER)
and user PTE pages with
alloc_pages(GFP_KERNEL | __GFP_ZERO, PTE_ORDER)
That bit isn't quite true - we don't use __GFP_ZERO in pte_alloc_one() &
instead call clear_highpage() on the allocated page. Not that I have a
problem with using __GFP_ZERO - it seems like the more optimal choice.
It just might be worth mentioning the change & expected equivalent
behavior.
From: Mike Rapoport <hidden> Date: 2019-05-02 15:30:10
parisc allocates PTE pages with __get_free_page() and uses
GFP_KERNEL | __GFP_ZERO for the allocations.
Switch it to the generic version that does exactly the same thing for the
kernel page tables and adds __GFP_ACCOUNT for the user PTEs.
The pte_free_kernel() and pte_free() versions on are identical to the
generic ones and can be simply dropped.
Signed-off-by: Mike Rapoport <redacted>
---
arch/parisc/include/asm/pgalloc.h | 33 ++-------------------------------
1 file changed, 2 insertions(+), 31 deletions(-)
@@ -10,6 +10,8 @@#include<asm/cache.h>+#include<asm-generic/pgalloc.h> /* for pte_{alloc,free}_one */+/* Allocate the top level pgd (page directory)**Here(for64bitkernels)weimplementaHybridL2/L3scheme:we
@@ -121,37 +123,6 @@ pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, pte_t *pte)pmd_populate_kernel(mm,pmd,page_address(pte_page))#define pmd_pgtable(pmd) pmd_page(pmd)-staticinlinepgtable_t-pte_alloc_one(structmm_struct*mm)-{-structpage*page=alloc_page(GFP_KERNEL|__GFP_ZERO);-if(!page)-returnNULL;-if(!pgtable_page_ctor(page)){-__free_page(page);-returnNULL;-}-returnpage;-}--staticinlinepte_t*-pte_alloc_one_kernel(structmm_struct*mm)-{-pte_t*pte=(pte_t*)__get_free_page(GFP_KERNEL|__GFP_ZERO);-returnpte;-}--staticinlinevoidpte_free_kernel(structmm_struct*mm,pte_t*pte)-{-free_page((unsignedlong)pte);-}--staticinlinevoidpte_free(structmm_struct*mm,structpage*pte)-{-pgtable_page_dtor(pte);-pte_free_kernel(mm,page_address(pte));-}-#define check_pgt_cache() do { } while (0)#endif
From: Mike Rapoport <hidden> Date: 2019-05-02 15:30:20
The only difference between the generic and RISC-V implementation of PTE
allocation is the usage of __GFP_RETRY_MAYFAIL for both kernel and user
PTEs and the absence of __GFP_ACCOUNT for the user PTEs.
The conversion to the generic version removes the __GFP_RETRY_MAYFAIL and
ensures that GFP_ACCOUNT is used for the user PTE allocations.
The pte_free() and pte_free_kernel() versions are identical to the generic
ones and can be simply dropped.
Signed-off-by: Mike Rapoport <redacted>
---
arch/riscv/include/asm/pgalloc.h | 29 ++---------------------------
1 file changed, 2 insertions(+), 27 deletions(-)
On Thu, 02 May 2019 08:28:40 PDT (-0700), rppt@linux.ibm.com wrote:
The only difference between the generic and RISC-V implementation of PTE
allocation is the usage of __GFP_RETRY_MAYFAIL for both kernel and user
PTEs and the absence of __GFP_ACCOUNT for the user PTEs.
The conversion to the generic version removes the __GFP_RETRY_MAYFAIL and
ensures that GFP_ACCOUNT is used for the user PTE allocations.
Reviewed-by: Palmer Dabbelt <redacted>
I'm assuming this is going in along with the rest of the patches, so I'm not
going to add it to my tree.
quoted hunk
The pte_free() and pte_free_kernel() versions are identical to the generic
ones and can be simply dropped.
Signed-off-by: Mike Rapoport <redacted>
---
arch/riscv/include/asm/pgalloc.h | 29 ++---------------------------
1 file changed, 2 insertions(+), 27 deletions(-)
From: Mike Rapoport <hidden> Date: 2019-05-02 15:37:06
Replace __get_free_page() and alloc_pages() calls with the generic
__pte_alloc_one_kernel() and __pte_alloc_one().
There is no functional change for the kernel PTE allocation.
The difference for the user PTEs, is that the clear_pte_table() is now
called after pgtable_page_ctor() and the addition of __GFP_ACCOUNT to the
GFP flags.
The pte_free() and pte_free_kernel() versions are identical to the generic
ones and can be simply dropped.
Signed-off-by: Mike Rapoport <redacted>
---
arch/unicore32/include/asm/pgalloc.h | 36 ++++++++----------------------------
1 file changed, 8 insertions(+), 28 deletions(-)
From: Mike Rapoport <hidden> Date: 2019-05-02 15:37:25
um allocates PTE pages with __get_free_page() and uses
GFP_KERNEL | __GFP_ZERO for the allocations.
Switch it to the generic version that does exactly the same thing for the
kernel page tables and adds __GFP_ACCOUNT for the user PTEs.
The pte_free() and pte_free_kernel() versions are identical to the generic
ones and can be simply dropped.
Signed-off-by: Mike Rapoport <redacted>
---
arch/um/include/asm/pgalloc.h | 16 ++--------------
arch/um/kernel/mem.c | 22 ----------------------
2 files changed, 2 insertions(+), 36 deletions(-)
From: Anton Ivanov <anton.ivanov@cambridgegreys.com> Date: 2019-05-03 13:29:39
On 02/05/2019 16:28, Mike Rapoport wrote:
quoted hunk
um allocates PTE pages with __get_free_page() and uses
GFP_KERNEL | __GFP_ZERO for the allocations.
Switch it to the generic version that does exactly the same thing for the
kernel page tables and adds __GFP_ACCOUNT for the user PTEs.
The pte_free() and pte_free_kernel() versions are identical to the generic
ones and can be simply dropped.
Signed-off-by: Mike Rapoport <redacted>
---
arch/um/include/asm/pgalloc.h | 16 ++--------------
arch/um/kernel/mem.c | 22 ----------------------
2 files changed, 2 insertions(+), 36 deletions(-)
Reviewed-by: Anton Ivanov <anton.ivanov@cambridgegreys.com>
Acked-by: Anton Ivanov <anton.ivanov@cambridgegreys.com>
--
Anton R. Ivanov
Cambridgegreys Limited. Registered in England. Company Number 10273661
https://www.cambridgegreys.com/
From: Mike Rapoport <hidden> Date: 2019-05-02 15:37:29
Most architectures have identical or very similar implementation of
pte_alloc_one_kernel(), pte_alloc_one(), pte_free_kernel() and pte_free().
Add a generic implementation that can be reused across architectures and
enable its use on x86.
The generic implementation uses
GFP_KERNEL | __GFP_ZERO
for the kernel page tables and
GFP_KERNEL | __GFP_ZERO | __GFP_ACCOUNT
for the user page tables.
The "base" functions for PTE allocation, namely __pte_alloc_one_kernel()
and __pte_alloc_one() are intended for the architectures that require
additional actions after actual memory allocation or must use non-default
GFP flags.
x86 is switched to use generic pte_alloc_one_kernel(), pte_free_kernel() and
pte_free().
x86 still implements pte_alloc_one() to allow run-time control of GFP flags
required for "userpte" command line option.
Signed-off-by: Mike Rapoport <redacted>
---
arch/x86/include/asm/pgalloc.h | 19 ++------
arch/x86/mm/pgtable.c | 33 ++++---------
include/asm-generic/pgalloc.h | 107 +++++++++++++++++++++++++++++++++++++++--
3 files changed, 115 insertions(+), 44 deletions(-)
@@ -6,6 +6,9 @@#include<linux/mm.h> /* for struct page */#include<linux/pagemap.h>+#define __HAVE_ARCH_PTE_ALLOC_ONE+#include<asm-generic/pgalloc.h> /* for pte_{alloc,free}_one */+staticinlineint__paravirt_pgd_alloc(structmm_struct*mm){return0;}#ifdef CONFIG_PARAVIRT_XXL
@@ -47,24 +50,8 @@ extern gfp_t __userpte_alloc_gfp;externpgd_t*pgd_alloc(structmm_struct*);externvoidpgd_free(structmm_struct*mm,pgd_t*pgd);-externpte_t*pte_alloc_one_kernel(structmm_struct*);externpgtable_tpte_alloc_one(structmm_struct*);-/* Should really implement gc for free page table pages. This could be-donewithareferencecountinstructpage.*/--staticinlinevoidpte_free_kernel(structmm_struct*mm,pte_t*pte)-{-BUG_ON((unsignedlong)pte&(PAGE_SIZE-1));-free_page((unsignedlong)pte);-}--staticinlinevoidpte_free(structmm_struct*mm,structpage*pte)-{-pgtable_page_dtor(pte);-__free_page(pte);-}-externvoid___pte_free_tlb(structmmu_gather*tlb,structpage*pte);staticinlinevoid__pte_free_tlb(structmmu_gather*tlb,structpage*pte,
@@ -1,13 +1,112 @@/* SPDX-License-Identifier: GPL-2.0 */#ifndef __ASM_GENERIC_PGALLOC_H#define __ASM_GENERIC_PGALLOC_H-/*-*anemptyfileisenoughforanommuarchitecture-*/+#ifdef CONFIG_MMU-#error need to implement an architecture specific asm/pgalloc.h++#define GFP_PGTABLE_KERNEL (GFP_KERNEL | __GFP_ZERO)+#define GFP_PGTABLE_USER (GFP_PGTABLE_KERNEL | __GFP_ACCOUNT)++/**+*__pte_alloc_one_kernel-allocateapageforPTE-levelkernelpagetable+*@mm:themm_structofthecurrentcontext+*+*Thisfunctionisintendedforarchitecturesthatneed+*anythingbeyondsimplepageallocation.+*+*Return:pointertotheallocatedmemoryor%NULLonerror+*/+staticinlinepte_t*__pte_alloc_one_kernel(structmm_struct*mm)+{+return(pte_t*)__get_free_page(GFP_PGTABLE_KERNEL);+}++#ifndef __HAVE_ARCH_PTE_ALLOC_ONE_KERNEL+/**+*pte_alloc_one_kernel-allocateapageforPTE-levelkernelpagetable+*@mm:themm_structofthecurrentcontext+*+*Return:pointertotheallocatedmemoryor%NULLonerror+*/+staticinlinepte_t*pte_alloc_one_kernel(structmm_struct*mm)+{+return__pte_alloc_one_kernel(mm);+}+#endif++/**+*pte_free_kernel-freePTE-levelkernelpagetablepage+*@mm:themm_structofthecurrentcontext+*@pte:pointertothememorycontainingthepagetable+*/+staticinlinevoidpte_free_kernel(structmm_struct*mm,pte_t*pte)+{+free_page((unsignedlong)pte);+}++/**+*__pte_alloc_one-allocateapageforPTE-leveluserpagetable+*@mm:themm_structofthecurrentcontext+*@gfp:GFPflagstousefortheallocation+*+*Allocatesapageandrunsthepgtable_page_ctor().+*+*Thisfunctionisintendedforarchitecturesthatneed+*anythingbeyondsimplepageallocationormusthavecustomGFPflags.+*+*Return:`structpage`initializedaspagetableor%NULLonerror+*/+staticinlinepgtable_t__pte_alloc_one(structmm_struct*mm,gfp_tgfp)+{+structpage*pte;++pte=alloc_page(gfp);+if(!pte)+returnNULL;+if(!pgtable_page_ctor(pte)){+__free_page(pte);+returnNULL;+}++returnpte;+}++#ifndef __HAVE_ARCH_PTE_ALLOC_ONE+/**+*pte_alloc_one-allocateapageforPTE-leveluserpagetable+*@mm:themm_structofthecurrentcontext+*+*Allocatesapageandrunsthepgtable_page_ctor().+*+*Return:`structpage`initializedaspagetableor%NULLonerror+*/+staticinlinepgtable_tpte_alloc_one(structmm_struct*mm)+{+return__pte_alloc_one(mm,GFP_PGTABLE_USER);+}#endif+/*+*Shouldreallyimplementgcforfreepagetablepages.Thiscouldbe+*donewithareferencecountinstructpage.+*/++/**+*pte_free_kernel-freePTE-leveluserpagetablepage+*@mm:themm_structofthecurrentcontext+*@pte_page:the`structpage`representingthepagetable+*/+staticinlinevoidpte_free(structmm_struct*mm,structpage*pte_page)+{+pgtable_page_dtor(pte_page);+__free_page(pte_page);+}++#else /* CONFIG_MMU */++/* This is enough for a nommu architecture */#define check_pgt_cache() do { } while (0)+#endif /* CONFIG_MMU */+#endif /* __ASM_GENERIC_PGALLOC_H */
From: Mike Rapoport <hidden> Date: 2019-05-02 15:37:37
nios2 allocates kernel PTE pages with
__get_free_pages(GFP_KERNEL | __GFP_ZERO, PTE_ORDER);
and user page tables with
pte = alloc_pages(GFP_KERNEL, PTE_ORDER);
if (pte)
clear_highpage();
The PTE_ORDER is hardwired to zero, which makes nios2 implementation almost
identical to the generic one.
Switch nios2 to the generic version that does exactly the same thing for
the kernel page tables and adds __GFP_ACCOUNT for the user PTEs.
The pte_free_kernel() and pte_free() versions on nios2 are identical to the
generic ones and can be simply dropped.
Signed-off-by: Mike Rapoport <redacted>
---
arch/nios2/include/asm/pgalloc.h | 37 ++-----------------------------------
1 file changed, 2 insertions(+), 35 deletions(-)
From: Mike Rapoport <hidden> Date: 2019-05-02 15:37:47
The 64-bit book-E powerpc implements pte_alloc_one(),
pte_alloc_one_kernel(), pte_free_kernel() and pte_free() the same way as
the generic version.
Switch it to the generic version that does exactly the same thing.
Signed-off-by: Mike Rapoport <redacted>
---
arch/powerpc/include/asm/nohash/64/pgalloc.h | 35 ++--------------------------
1 file changed, 2 insertions(+), 33 deletions(-)
Switch it to the generic version that does exactly the same thing.
Signed-off-by: Mike Rapoport <redacted>
---
arch/powerpc/include/asm/nohash/64/pgalloc.h | 35 ++--------------------------
1 file changed, 2 insertions(+), 33 deletions(-)
Thanks for the heads up. I'll drop this from the next re-spin.
Christophe
quoted
Switch it to the generic version that does exactly the same thing.
Signed-off-by: Mike Rapoport <redacted>
---
arch/powerpc/include/asm/nohash/64/pgalloc.h | 35 ++--------------------------
1 file changed, 2 insertions(+), 33 deletions(-)
From: Mike Rapoport <hidden> Date: 2019-05-02 15:38:55
The nds32 implementation of pte_alloc_one_kernel() differs from the generic
in the use of __GFP_RETRY_MAYFAIL flag, which is removed after the
conversion.
The nds32 version of pte_alloc_one() missed the call to pgtable_page_ctor()
and also used __GFP_RETRY_MAYFAIL. Switching it to use generic
__pte_alloc_one() for the PTE page allocation ensures that page table
constructor is run and the user page tables are allocated with
__GFP_ACCOUNT.
The conversion to the generic version of pte_free_kernel() removes the NULL
check for pte.
The pte_free() version on nds32 is identical to the generic one and can be
simply dropped.
Signed-off-by: Mike Rapoport <redacted>
---
arch/nds32/include/asm/pgalloc.h | 31 ++++---------------------------
1 file changed, 4 insertions(+), 27 deletions(-)
From: Greentime Hu <hidden> Date: 2019-05-07 06:49:48
Hi Mike,
Mike Rapoport [off-list ref] 於 2019年5月2日 週四 下午11:30寫道:
The nds32 implementation of pte_alloc_one_kernel() differs from the generic
in the use of __GFP_RETRY_MAYFAIL flag, which is removed after the
conversion.
The nds32 version of pte_alloc_one() missed the call to pgtable_page_ctor()
and also used __GFP_RETRY_MAYFAIL. Switching it to use generic
__pte_alloc_one() for the PTE page allocation ensures that page table
constructor is run and the user page tables are allocated with
__GFP_ACCOUNT.
The conversion to the generic version of pte_free_kernel() removes the NULL
check for pte.
The pte_free() version on nds32 is identical to the generic one and can be
simply dropped.
Signed-off-by: Mike Rapoport <redacted>
---
arch/nds32/include/asm/pgalloc.h | 31 ++++---------------------------
1 file changed, 4 insertions(+), 27 deletions(-)
Thanks for your patch.
I'm assuming this is going in along with the rest of the patches, so I'm not
going to add it to my tree.
Acked-by: Greentime Hu <redacted>
From: Mike Rapoport <hidden> Date: 2019-05-02 15:39:30
The hexagon implementation pte_alloc_one(), pte_alloc_one_kernel(),
pte_free_kernel() and pte_free() is identical to the generic except of
lack of __GFP_ACCOUNT for the user PTEs allocation.
Switch hexagon to use generic version of these functions.
Signed-off-by: Mike Rapoport <redacted>
---
arch/hexagon/include/asm/pgalloc.h | 34 ++--------------------------------
1 file changed, 2 insertions(+), 32 deletions(-)
@@ -24,6 +24,8 @@#include<asm/mem-layout.h>#include<asm/atomic.h>+#include<asm-generic/pgalloc.h> /* for pte_{alloc,free}_one */+#define check_pgt_cache() do {} while (0)externunsignedlonglongkmap_generation;
@@ -59,38 +61,6 @@ static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd)free_page((unsignedlong)pgd);}-staticinlinestructpage*pte_alloc_one(structmm_struct*mm)-{-structpage*pte;--pte=alloc_page(GFP_KERNEL|__GFP_ZERO);-if(!pte)-returnNULL;-if(!pgtable_page_ctor(pte)){-__free_page(pte);-returnNULL;-}-returnpte;-}--/* _kernel variant gets to use a different allocator */-staticinlinepte_t*pte_alloc_one_kernel(structmm_struct*mm)-{-gfp_tflags=GFP_KERNEL|__GFP_ZERO;-return(pte_t*)__get_free_page(flags);-}--staticinlinevoidpte_free(structmm_struct*mm,structpage*pte)-{-pgtable_page_dtor(pte);-__free_page(pte);-}--staticinlinevoidpte_free_kernel(structmm_struct*mm,pte_t*pte)-{-free_page((unsignedlong)pte);-}-staticinlinevoidpmd_populate(structmm_struct*mm,pmd_t*pmd,pgtable_tpte){
From: Mike Rapoport <hidden> Date: 2019-05-02 15:39:36
Replace __get_free_page() and alloc_pages() calls with the generic
__pte_alloc_one_kernel() and __pte_alloc_one().
There is no functional change for the kernel PTE allocation.
The difference for the user PTEs, is that the clear_pte_table() is now
called after pgtable_page_ctor() and the addition of __GFP_ACCOUNT to the
GFP flags.
The conversion to the generic version of pte_free_kernel() removes the NULL
check for pte.
The pte_free() version on arm is identical to the generic one and can be
simply dropped.
Signed-off-by: Mike Rapoport <redacted>
---
arch/arm/include/asm/pgalloc.h | 41 +++++++++++++----------------------------
arch/arm/mm/mmu.c | 2 +-
2 files changed, 14 insertions(+), 29 deletions(-)
From: Mike Rapoport <hidden> Date: 2019-05-02 15:39:51
The csky implementation pte_alloc_one(), pte_free_kernel() and pte_free()
is identical to the generic except of lack of __GFP_ACCOUNT for the user
PTEs allocation.
Switch csky to use generic version of these functions.
The csky implementation of pte_alloc_one_kernel() is not replaced because
it does not clear the allocated page but rather sets each PTE in it to a
non-zero value.
The pte_free_kernel() and pte_free() versions on csky are identical to the
generic ones and can be simply dropped.
Signed-off-by: Mike Rapoport <redacted>
---
arch/csky/include/asm/pgalloc.h | 30 +++---------------------------
1 file changed, 3 insertions(+), 27 deletions(-)
Hi Mike,
Acked-by: Guo Ren <redacted>
On Thu, May 02, 2019 at 06:28:32PM +0300, Mike Rapoport wrote:
The csky implementation pte_alloc_one(), pte_free_kernel() and pte_free()
is identical to the generic except of lack of __GFP_ACCOUNT for the user
PTEs allocation.
Switch csky to use generic version of these functions.
Ok.
The csky implementation of pte_alloc_one_kernel() is not replaced because
it does not clear the allocated page but rather sets each PTE in it to a
non-zero value.
Yes, we must set each PTE to _PAGE_GLOBAL because hardware refill the
MMU TLB entry with two PTEs and it use the result of pte0.global | pte1.global.
If pte0 is valid and pte1 is invalid, we must set _PAGE_GLOBAL in
invalid pte entry. Fortunately, there is no performance issue.
The pte_free_kernel() and pte_free() versions on csky are identical to the
generic ones and can be simply dropped.
On Sat, May 04, 2019 at 12:03:48AM +0800, Guo Ren wrote:
Hi Mike,
Acked-by: Guo Ren <redacted>
On Thu, May 02, 2019 at 06:28:32PM +0300, Mike Rapoport wrote:
quoted
The csky implementation pte_alloc_one(), pte_free_kernel() and pte_free()
is identical to the generic except of lack of __GFP_ACCOUNT for the user
PTEs allocation.
Switch csky to use generic version of these functions.
Ok.
quoted
The csky implementation of pte_alloc_one_kernel() is not replaced because
it does not clear the allocated page but rather sets each PTE in it to a
non-zero value.
Yes, we must set each PTE to _PAGE_GLOBAL because hardware refill the
MMU TLB entry with two PTEs and it use the result of pte0.global | pte1.global.
From: Mike Rapoport <hidden> Date: 2019-05-02 15:40:25
alpha allocates PTE pages with __get_free_page() and uses
GFP_KERNEL | __GFP_ZERO for the allocations.
Switch it to the generic version that does exactly the same thing for the
kernel page tables and adds __GFP_ACCOUNT for the user PTEs.
The alpha pte_free() and pte_free_kernel() versions are identical to the
generic ones and can be simply dropped.
Signed-off-by: Mike Rapoport <redacted>
---
arch/alpha/include/asm/pgalloc.h | 40 +++-------------------------------------
1 file changed, 3 insertions(+), 37 deletions(-)