From 8690fa3fc22ac74304f26441798e540f8f929926 Mon Sep 17 00:00:00 2001 From: Sung-hun Kim Date: Wed, 15 Sep 2021 13:28:04 +0900 Subject: [PATCH] mm, meminfo: modify page counting Two counters, nr_phys_huge_pmd_pages and nr_phys_cont_pte_pages, are counted by different units. This patch enforces two counters counted by pages, not huge pages. Change-Id: I1fcb6a1a9c3a60c956b861e79ec3714a33004991 Signed-off-by: Sung-hun Kim --- fs/proc/meminfo.c | 2 +- mm/huge_memory.c | 4 ++-- mm/memory.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c index 014f197..abc072ba 100644 --- a/fs/proc/meminfo.c +++ b/fs/proc/meminfo.c @@ -155,7 +155,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v) phys_cont_pte_pages()); #endif /* CONFIG_FINEGRAINED_THP */ show_val_kb(m, "PhysPmdMapped: ", - phys_huge_pmd_pages() * HPAGE_PMD_NR); + phys_huge_pmd_pages()); #endif #ifdef CONFIG_CMA show_val_kb(m, "CmaTotal: ", totalcma_pages); diff --git a/mm/huge_memory.c b/mm/huge_memory.c index 20ea663..23d21e5 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c @@ -1670,7 +1670,7 @@ int zap_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma, if (vma_is_special_huge(vma)) { if (arch_needs_pgtable_deposit()) zap_deposited_table(tlb->mm, pmd); - atomic_long_dec(&nr_phys_huge_pmd_pages); + atomic_long_add(-HPAGE_PMD_NR, &nr_phys_huge_pmd_pages); spin_unlock(ptl); if (is_huge_zero_pmd(orig_pmd)) tlb_remove_page_size(tlb, pmd_page(orig_pmd), HPAGE_PMD_SIZE); @@ -2281,7 +2281,7 @@ repeat: pmd_t orig_pmd; orig_pmd = pmdp_huge_get_and_clear_full(vma, haddr, pmd, 0); - atomic_long_dec(&nr_phys_huge_pmd_pages); + atomic_long_add(-HPAGE_PMD_NR, &nr_phys_huge_pmd_pages); thp_remap_pte_range_locked(mm, pmd, haddr, haddr + HPAGE_PMD_SIZE, pmd_pfn(orig_pmd), diff --git a/mm/memory.c b/mm/memory.c index bdf18e9..e6deee2 100644 --- a/mm/memory.c +++ b/mm/memory.c @@ -2287,7 +2287,7 @@ static int remap_try_huge_pmd(struct mm_struct *mm, pmd_t *pmd, unsigned long ad ret = pmd_set_huge(pmd, phys_addr, prot); spin_unlock(ptl); - atomic_long_inc(&nr_phys_huge_pmd_pages); + atomic_long_add(HPAGE_PMD_NR, &nr_phys_huge_pmd_pages); return ret; } -- 2.7.4