aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/fork.c
diff options
context:
space:
mode:
authorKirill A. Shutemov <kirill.shutemov@linux.intel.com>2017-11-15 20:35:40 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2017-11-15 21:21:04 -0500
commitaf5b0f6a09e42c9f4fa87735f2a366748767b686 (patch)
treeac9a7992f92ae5a7902805e980bb31e8edc4555b /kernel/fork.c
parentc4812909f5d5a9b7f1c85a2d95be388a066cda52 (diff)
mm: consolidate page table accounting
Currently, we account page tables separately for each page table level, but that's redundant -- we only make use of total memory allocated to page tables for oom_badness calculation. We also provide the information to userspace, but it has dubious value there too. This patch switches page table accounting to single counter. mm->pgtables_bytes is now used to account all page table levels. We use bytes, because page table size for different levels of page table tree may be different. The change has user-visible effect: we don't have VmPMD and VmPUD reported in /proc/[pid]/status. Not sure if anybody uses them. (As alternative, we can always report 0 kB for them.) OOM-killer report is also slightly changed: we now report pgtables_bytes instead of nr_ptes, nr_pmd, nr_puds. Apart from reducing number of counters per-mm, the benefit is that we now calculate oom_badness() more correctly for machines which have different size of page tables depending on level or where page tables are less than a page in size. The only downside can be debuggability because we do not know which page table level could leak. But I do not remember many bugs that would be caught by separate counters so I wouldn't lose sleep over this. [akpm@linux-foundation.org: fix mm/huge_memory.c] Link: http://lkml.kernel.org/r/20171006100651.44742-2-kirill.shutemov@linux.intel.com Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Acked-by: Michal Hocko <mhocko@suse.com> [kirill.shutemov@linux.intel.com: fix build] Link: http://lkml.kernel.org/r/20171016150113.ikfxy3e7zzfvsr4w@black.fi.intel.com Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/fork.c')
-rw-r--r--kernel/fork.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/kernel/fork.c b/kernel/fork.c
index 946922a30ede..006dc5899a1a 100644
--- a/kernel/fork.c
+++ b/kernel/fork.c
@@ -817,9 +817,7 @@ static struct mm_struct *mm_init(struct mm_struct *mm, struct task_struct *p,
817 init_rwsem(&mm->mmap_sem); 817 init_rwsem(&mm->mmap_sem);
818 INIT_LIST_HEAD(&mm->mmlist); 818 INIT_LIST_HEAD(&mm->mmlist);
819 mm->core_state = NULL; 819 mm->core_state = NULL;
820 mm_nr_ptes_init(mm); 820 mm_pgtables_bytes_init(mm);
821 mm_nr_pmds_init(mm);
822 mm_nr_puds_init(mm);
823 mm->map_count = 0; 821 mm->map_count = 0;
824 mm->locked_vm = 0; 822 mm->locked_vm = 0;
825 mm->pinned_vm = 0; 823 mm->pinned_vm = 0;
@@ -873,15 +871,9 @@ static void check_mm(struct mm_struct *mm)
873 "mm:%p idx:%d val:%ld\n", mm, i, x); 871 "mm:%p idx:%d val:%ld\n", mm, i, x);
874 } 872 }
875 873
876 if (mm_nr_ptes(mm)) 874 if (mm_pgtables_bytes(mm))
877 pr_alert("BUG: non-zero nr_ptes on freeing mm: %ld\n", 875 pr_alert("BUG: non-zero pgtables_bytes on freeing mm: %ld\n",
878 mm_nr_ptes(mm)); 876 mm_pgtables_bytes(mm));
879 if (mm_nr_pmds(mm))
880 pr_alert("BUG: non-zero nr_pmds on freeing mm: %ld\n",
881 mm_nr_pmds(mm));
882 if (mm_nr_puds(mm))
883 pr_alert("BUG: non-zero nr_puds on freeing mm: %ld\n",
884 mm_nr_puds(mm));
885 877
886#if defined(CONFIG_TRANSPARENT_HUGEPAGE) && !USE_SPLIT_PMD_PTLOCKS 878#if defined(CONFIG_TRANSPARENT_HUGEPAGE) && !USE_SPLIT_PMD_PTLOCKS
887 VM_BUG_ON_MM(mm->pmd_huge_pte, mm); 879 VM_BUG_ON_MM(mm->pmd_huge_pte, mm);