Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c4812909 authored by Kirill A. Shutemov's avatar Kirill A. Shutemov Committed by Linus Torvalds
Browse files

mm: introduce wrappers to access mm->nr_ptes

Let's add wrappers for ->nr_ptes with the same interface as for nr_pmd
and nr_pud.

The patch also makes nr_ptes accounting dependent onto CONFIG_MMU.  Page
table accounting doesn't make sense if you don't have page tables.

It's preparation for consolidation of page-table counters in mm_struct.

Link: http://lkml.kernel.org/r/20171006100651.44742-1-kirill.shutemov@linux.intel.com


Signed-off-by: default avatarKirill A. Shutemov <kirill.shutemov@linux.intel.com>
Acked-by: default avatarMichal Hocko <mhocko@suse.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent b4e98d9a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -141,7 +141,7 @@ void pgd_free(struct mm_struct *mm, pgd_t *pgd_base)
	pte = pmd_pgtable(*pmd);
	pmd_clear(pmd);
	pte_free(mm, pte);
	atomic_long_dec(&mm->nr_ptes);
	mm_dec_nr_ptes(mm);
no_pmd:
	pud_clear(pud);
	pmd_free(mm, pmd);
+1 −1
Original line number Diff line number Diff line
@@ -397,7 +397,7 @@ static void hugetlb_free_pte_range(struct mmu_gather *tlb, pmd_t *pmd,

	pmd_clear(pmd);
	pte_free_tlb(tlb, token, addr);
	atomic_long_dec(&tlb->mm->nr_ptes);
	mm_dec_nr_ptes(tlb->mm);
}

static void hugetlb_free_pmd_range(struct mmu_gather *tlb, pud_t *pud,
+1 −1
Original line number Diff line number Diff line
@@ -97,7 +97,7 @@ void free_pgd_slow(struct mm_struct *mm, pgd_t *pgd)
	pte = pmd_pgtable(*pmd);
	pmd_clear(pmd);
	pte_free(mm, pte);
	atomic_long_dec(&mm->nr_ptes);
	mm_dec_nr_ptes(mm);
	pmd_free(mm, pmd);
	mm_dec_nr_pmds(mm);
free:
+1 −1
Original line number Diff line number Diff line
@@ -50,7 +50,7 @@ void task_mem(struct seq_file *m, struct mm_struct *mm)
	text = (PAGE_ALIGN(mm->end_code) - (mm->start_code & PAGE_MASK)) >> 10;
	lib = (mm->exec_vm << (PAGE_SHIFT-10)) - text;
	swap = get_mm_counter(mm, MM_SWAPENTS);
	ptes = PTRS_PER_PTE * sizeof(pte_t) * atomic_long_read(&mm->nr_ptes);
	ptes = PTRS_PER_PTE * sizeof(pte_t) * mm_nr_ptes(mm);
	pmds = PTRS_PER_PMD * sizeof(pmd_t) * mm_nr_pmds(mm);
	puds = PTRS_PER_PUD * sizeof(pud_t) * mm_nr_puds(mm);
	seq_printf(m,
+32 −0
Original line number Diff line number Diff line
@@ -1680,6 +1680,38 @@ static inline void mm_dec_nr_pmds(struct mm_struct *mm)
}
#endif

#ifdef CONFIG_MMU
static inline void mm_nr_ptes_init(struct mm_struct *mm)
{
	atomic_long_set(&mm->nr_ptes, 0);
}

static inline unsigned long mm_nr_ptes(const struct mm_struct *mm)
{
	return atomic_long_read(&mm->nr_ptes);
}

static inline void mm_inc_nr_ptes(struct mm_struct *mm)
{
	atomic_long_inc(&mm->nr_ptes);
}

static inline void mm_dec_nr_ptes(struct mm_struct *mm)
{
	atomic_long_dec(&mm->nr_ptes);
}
#else
static inline void mm_nr_ptes_init(struct mm_struct *mm) {}

static inline unsigned long mm_nr_ptes(const struct mm_struct *mm)
{
	return 0;
}

static inline void mm_inc_nr_ptes(struct mm_struct *mm) {}
static inline void mm_dec_nr_ptes(struct mm_struct *mm) {}
#endif

int __pte_alloc(struct mm_struct *mm, pmd_t *pmd, unsigned long address);
int __pte_alloc_kernel(pmd_t *pmd, unsigned long address);

Loading