Message ID | 1548307220-19756-7-git-send-email-anshuman.khandual@arm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | arm64/mm: Enable accounting for page table pages | expand |
On Thu, Jan 24, 2019 at 10:50:20AM +0530, Anshuman Khandual wrote: > Page table pages created for user space processes must be accounted against > their memory control groups if initialized. This just introduces a helper > function pgtable_gfp_flags() which returns PGALLOC_GFP for all kernel page > table page allocations but adds __GFP_ACCOUNT for user page table pages. > > Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com> > --- > arch/arm64/include/asm/pgalloc.h | 12 +++++++++++- > 1 file changed, 11 insertions(+), 1 deletion(-) > > diff --git a/arch/arm64/include/asm/pgalloc.h b/arch/arm64/include/asm/pgalloc.h > index 076764f..775cde9 100644 > --- a/arch/arm64/include/asm/pgalloc.h > +++ b/arch/arm64/include/asm/pgalloc.h > @@ -100,12 +100,22 @@ pte_alloc_one_kernel(struct mm_struct *mm) > return (pte_t *)pte_alloc_one_virt(mm); > } > > +static inline gfp_t pgtable_gfp_flags(struct mm_struct *mm) > +{ > + if (unlikely(mm == &init_mm)) > + return PGALLOC_GFP; > + else > + return PGALLOC_GFP | __GFP_ACCOUNT; > +} Hmm, what about things like the efi mm? Will
On 02/14/2019 10:41 PM, Will Deacon wrote: > On Thu, Jan 24, 2019 at 10:50:20AM +0530, Anshuman Khandual wrote: >> Page table pages created for user space processes must be accounted against >> their memory control groups if initialized. This just introduces a helper >> function pgtable_gfp_flags() which returns PGALLOC_GFP for all kernel page >> table page allocations but adds __GFP_ACCOUNT for user page table pages. >> >> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com> >> --- >> arch/arm64/include/asm/pgalloc.h | 12 +++++++++++- >> 1 file changed, 11 insertions(+), 1 deletion(-) >> >> diff --git a/arch/arm64/include/asm/pgalloc.h b/arch/arm64/include/asm/pgalloc.h >> index 076764f..775cde9 100644 >> --- a/arch/arm64/include/asm/pgalloc.h >> +++ b/arch/arm64/include/asm/pgalloc.h >> @@ -100,12 +100,22 @@ pte_alloc_one_kernel(struct mm_struct *mm) >> return (pte_t *)pte_alloc_one_virt(mm); >> } >> >> +static inline gfp_t pgtable_gfp_flags(struct mm_struct *mm) >> +{ >> + if (unlikely(mm == &init_mm)) >> + return PGALLOC_GFP; >> + else >> + return PGALLOC_GFP | __GFP_ACCOUNT; >> +} > > Hmm, what about things like the efi mm? EFI mappings are created with efi_virtmap_init() -> efi_create_mapping() -> create_pgd_mapping() which calls into pgd_pgtable_alloc(). Sure will add check for efi_mm along with init_mm not to use __GFP_ACCOUNT.
diff --git a/arch/arm64/include/asm/pgalloc.h b/arch/arm64/include/asm/pgalloc.h index 076764f..775cde9 100644 --- a/arch/arm64/include/asm/pgalloc.h +++ b/arch/arm64/include/asm/pgalloc.h @@ -100,12 +100,22 @@ pte_alloc_one_kernel(struct mm_struct *mm) return (pte_t *)pte_alloc_one_virt(mm); } +static inline gfp_t pgtable_gfp_flags(struct mm_struct *mm) +{ + if (unlikely(mm == &init_mm)) + return PGALLOC_GFP; + else + return PGALLOC_GFP | __GFP_ACCOUNT; +} + static inline pgtable_t pte_alloc_one(struct mm_struct *mm) { struct page *pte; + gfp_t gfp; - pte = alloc_pages(PGALLOC_GFP, 0); + gfp = pgtable_gfp_flags(mm); + pte = alloc_pages(gfp, 0); if (!pte) return NULL; if (!pgtable_page_ctor(pte)) {
Page table pages created for user space processes must be accounted against their memory control groups if initialized. This just introduces a helper function pgtable_gfp_flags() which returns PGALLOC_GFP for all kernel page table page allocations but adds __GFP_ACCOUNT for user page table pages. Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com> --- arch/arm64/include/asm/pgalloc.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)