Commit 198d1597 authored by Rafael Aquini's avatar Rafael Aquini Committed by Linus Torvalds
Browse files

fs: proc: task_mmu: show page size in /proc/<pid>/numa_maps

The output of /proc/$pid/numa_maps is in terms of number of pages like
anon=22 or dirty=54.  Here's some output:

  7f4680000000 default file=/hugetlb/bigfile anon=50 dirty=50 N0=50
  7f7659600000 default file=/anon_hugepage\040(deleted) anon=50 dirty=50 N0=50
  7fff8d425000 default stack anon=50 dirty=50 N0=50

Looks like we have a stack and a couple of anonymous hugetlbfs
areas page which both use the same amount of memory.  They don't.

The 'bigfile' uses 1GB pages and takes up ~50GB of space.  The
anon_hugepage uses 2MB pages and takes up ~100MB of space while the stack
uses normal 4k pages.  You can go over to smaps to figure out what the
page size _really_ is with KernelPageSize or MMUPageSize.  But, I think
this is a pretty nasty and counterintuitive interface as it stands.

This patch introduces 'kernelpagesize_kB' line element to
/proc/<pid>/numa_maps report file in order to help identifying the size of
pages that are backing memory areas mapped by a given task.  This is
specially useful to help differentiating between HUGE and GIGANTIC page
backed VMAs.

This patch is based on Dave Hansen's proposal and reviewer's follow-ups
taken from the following dicussion threads:

Signed-off-by: default avatarRafael Aquini <>
Cc: Johannes Weiner <>
Cc: Dave Hansen <>
Acked-by: default avatarDavid Rientjes <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 0c369711
......@@ -508,22 +508,22 @@ summarized separated by blank spaces, one mapping per each file line:
address policy mapping details
00400000 default file=/usr/local/bin/app kernelpagesize_kB=4 mapped=1 active=0 N3=1
00600000 default file=/usr/local/bin/app kernelpagesize_kB=4 anon=1 dirty=1 N3=1
3206000000 default file=/lib64/ kernelpagesize_kB=4 mapped=26 mapmax=6 N0=24 N3=2
320621f000 default file=/lib64/ kernelpagesize_kB=4 anon=1 dirty=1 N3=1
3206220000 default file=/lib64/ kernelpagesize_kB=4 anon=1 dirty=1 N3=1
3206221000 default kernelpagesize_kB=4 anon=1 dirty=1 N3=1
3206800000 default file=/lib64/ kernelpagesize_kB=4 mapped=59 mapmax=21 active=55 N0=41 N3=18
00400000 default file=/usr/local/bin/app mapped=1 active=0 N3=1 kernelpagesize_kB=4
00600000 default file=/usr/local/bin/app anon=1 dirty=1 N3=1 kernelpagesize_kB=4
3206000000 default file=/lib64/ mapped=26 mapmax=6 N0=24 N3=2 kernelpagesize_kB=4
320621f000 default file=/lib64/ anon=1 dirty=1 N3=1 kernelpagesize_kB=4
3206220000 default file=/lib64/ anon=1 dirty=1 N3=1 kernelpagesize_kB=4
3206221000 default anon=1 dirty=1 N3=1 kernelpagesize_kB=4
3206800000 default file=/lib64/ mapped=59 mapmax=21 active=55 N0=41 N3=18 kernelpagesize_kB=4
320698b000 default file=/lib64/
3206b8a000 default file=/lib64/ kernelpagesize_kB=4 anon=2 dirty=2 N3=2
3206b8e000 default file=/lib64/ kernelpagesize_kB=4 anon=1 dirty=1 N3=1
3206b8f000 default kernelpagesize_kB=4 anon=3 dirty=3 active=1 N3=3
7f4dc10a2000 default kernelpagesize_kB=4 anon=3 dirty=3 N3=3
7f4dc10b4000 default kernelpagesize_kB=4 anon=2 dirty=2 active=1 N3=2
7f4dc1200000 default file=/anon_hugepage\040(deleted) huge kernelpagesize_kB=2048 anon=1 dirty=1 N3=1
7fff335f0000 default stack kernelpagesize_kB=4 anon=3 dirty=3 N3=3
7fff3369d000 default kernelpagesize_kB=4 mapped=1 mapmax=35 active=0 N3=1
3206b8a000 default file=/lib64/ anon=2 dirty=2 N3=2 kernelpagesize_kB=4
3206b8e000 default file=/lib64/ anon=1 dirty=1 N3=1 kernelpagesize_kB=4
3206b8f000 default anon=3 dirty=3 active=1 N3=3 kernelpagesize_kB=4
7f4dc10a2000 default anon=3 dirty=3 N3=3 kernelpagesize_kB=4
7f4dc10b4000 default anon=2 dirty=2 active=1 N3=2 kernelpagesize_kB=4
7f4dc1200000 default file=/anon_hugepage\040(deleted) huge anon=1 dirty=1 N3=1 kernelpagesize_kB=2048
7fff335f0000 default stack anon=3 dirty=3 N3=3 kernelpagesize_kB=4
7fff3369d000 default mapped=1 mapmax=35 active=0 N3=1 kernelpagesize_kB=4
"address" is the starting address for the mapping;
......@@ -1557,6 +1557,8 @@ static int show_numa_map(struct seq_file *m, void *v, int is_pid)
for_each_node_state(nid, N_MEMORY)
if (md->node[nid])
seq_printf(m, " N%d=%lu", nid, md->node[nid]);
seq_printf(m, " kernelpagesize_kB=%lu", vma_kernel_pagesize(vma) >> 10);
seq_putc(m, '\n');
m_cache_vma(m, vma);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment