Skip to content

Commit 3565522

Browse files
kevin-brodsky-armakpm00
authored andcommitted
parisc: mm: ensure pagetable_pmd_[cd]tor are called
The implementation of pmd_{alloc_one,free} on parisc requires a non-zero allocation order, but is completely standard aside from that. Let's reuse the generic implementation of pmd_alloc_one(). Explicit zeroing is not needed as GFP_PGTABLE_KERNEL includes __GFP_ZERO. The generic pmd_free() can handle higher allocation orders so we don't need to define our own. These changes ensure that pagetable_pmd_[cd]tor are called, improving the accounting of page table pages. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Kevin Brodsky <[email protected]> Acked-by: Dave Hansen <[email protected]> Acked-by: Qi Zheng <[email protected]> Cc: Andy Lutomirski <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Linus Walleij <[email protected]> Cc: Matthew Wilcox (Oracle) <[email protected]> Cc: Mike Rapoport (Microsoft) <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Ryan Roberts <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Will Deacon <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 11e2400 commit 3565522

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

arch/parisc/include/asm/pgalloc.h

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include <asm/cache.h>
1212

1313
#define __HAVE_ARCH_PMD_ALLOC_ONE
14-
#define __HAVE_ARCH_PMD_FREE
1514
#define __HAVE_ARCH_PGD_FREE
1615
#include <asm-generic/pgalloc.h>
1716

@@ -46,17 +45,19 @@ static inline void pud_populate(struct mm_struct *mm, pud_t *pud, pmd_t *pmd)
4645

4746
static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address)
4847
{
49-
pmd_t *pmd;
48+
struct ptdesc *ptdesc;
49+
gfp_t gfp = GFP_PGTABLE_USER;
5050

51-
pmd = (pmd_t *)__get_free_pages(GFP_PGTABLE_KERNEL, PMD_TABLE_ORDER);
52-
if (likely(pmd))
53-
memset ((void *)pmd, 0, PAGE_SIZE << PMD_TABLE_ORDER);
54-
return pmd;
55-
}
56-
57-
static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd)
58-
{
59-
free_pages((unsigned long)pmd, PMD_TABLE_ORDER);
51+
if (mm == &init_mm)
52+
gfp = GFP_PGTABLE_KERNEL;
53+
ptdesc = pagetable_alloc(gfp, PMD_TABLE_ORDER);
54+
if (!ptdesc)
55+
return NULL;
56+
if (!pagetable_pmd_ctor(ptdesc)) {
57+
pagetable_free(ptdesc);
58+
return NULL;
59+
}
60+
return ptdesc_address(ptdesc);
6061
}
6162
#endif
6263

0 commit comments

Comments
 (0)