diff options
author | Vlastimil Babka <vbabka@suse.cz> | 2018-10-26 18:05:50 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-10-26 19:26:32 -0400 |
commit | 61f94e18de94f79abaad3bb83549ff78923ac785 (patch) | |
tree | e76af5163ffc10843bf5d6c5e07a2078b2dd4b30 | |
parent | b29940c1abd7a4c3abeb926df0a5ec84d6902d47 (diff) |
mm, proc: add KReclaimable to /proc/meminfo
The vmstat NR_KERNEL_MISC_RECLAIMABLE counter is for kernel non-slab
allocations that can be reclaimed via shrinker. In /proc/meminfo, we can
show the sum of all reclaimable kernel allocations (including slab) as
"KReclaimable". Add the same counter also to per-node meminfo under /sys
With this counter, users will have more complete information about kernel
memory usage. Non-slab reclaimable pages (currently just the ION
allocator) will not be missing from /proc/meminfo, making users wonder
where part of their memory went. More precisely, they already appear in
MemAvailable, but without the new counter, it's not obvious why the value
in MemAvailable doesn't fully correspond with the sum of other counters
participating in it.
Link: http://lkml.kernel.org/r/20180731090649.16028-6-vbabka@suse.cz
Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Acked-by: Roman Gushchin <guro@fb.com>
Cc: Christoph Lameter <cl@linux.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Laura Abbott <labbott@redhat.com>
Cc: Matthew Wilcox <willy@infradead.org>
Cc: Mel Gorman <mgorman@techsingularity.net>
Cc: Michal Hocko <mhocko@kernel.org>
Cc: Sumit Semwal <sumit.semwal@linaro.org>
Cc: Vijayanand Jitta <vjitta@codeaurora.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | Documentation/filesystems/proc.txt | 4 | ||||
-rw-r--r-- | drivers/base/node.c | 19 | ||||
-rw-r--r-- | fs/proc/meminfo.c | 16 |
3 files changed, 24 insertions, 15 deletions
diff --git a/Documentation/filesystems/proc.txt b/Documentation/filesystems/proc.txt index 22b4b00dee31..12a5e6e693b6 100644 --- a/Documentation/filesystems/proc.txt +++ b/Documentation/filesystems/proc.txt | |||
@@ -858,6 +858,7 @@ Writeback: 0 kB | |||
858 | AnonPages: 861800 kB | 858 | AnonPages: 861800 kB |
859 | Mapped: 280372 kB | 859 | Mapped: 280372 kB |
860 | Shmem: 644 kB | 860 | Shmem: 644 kB |
861 | KReclaimable: 168048 kB | ||
861 | Slab: 284364 kB | 862 | Slab: 284364 kB |
862 | SReclaimable: 159856 kB | 863 | SReclaimable: 159856 kB |
863 | SUnreclaim: 124508 kB | 864 | SUnreclaim: 124508 kB |
@@ -925,6 +926,9 @@ AnonHugePages: Non-file backed huge pages mapped into userspace page tables | |||
925 | ShmemHugePages: Memory used by shared memory (shmem) and tmpfs allocated | 926 | ShmemHugePages: Memory used by shared memory (shmem) and tmpfs allocated |
926 | with huge pages | 927 | with huge pages |
927 | ShmemPmdMapped: Shared memory mapped into userspace with huge pages | 928 | ShmemPmdMapped: Shared memory mapped into userspace with huge pages |
929 | KReclaimable: Kernel allocations that the kernel will attempt to reclaim | ||
930 | under memory pressure. Includes SReclaimable (below), and other | ||
931 | direct allocations with a shrinker. | ||
928 | Slab: in-kernel data structures cache | 932 | Slab: in-kernel data structures cache |
929 | SReclaimable: Part of Slab, that might be reclaimed, such as caches | 933 | SReclaimable: Part of Slab, that might be reclaimed, such as caches |
930 | SUnreclaim: Part of Slab, that cannot be reclaimed on memory pressure | 934 | SUnreclaim: Part of Slab, that cannot be reclaimed on memory pressure |
diff --git a/drivers/base/node.c b/drivers/base/node.c index 1ac4c36e13bb..86d6cd92ce3d 100644 --- a/drivers/base/node.c +++ b/drivers/base/node.c | |||
@@ -67,8 +67,11 @@ static ssize_t node_read_meminfo(struct device *dev, | |||
67 | int nid = dev->id; | 67 | int nid = dev->id; |
68 | struct pglist_data *pgdat = NODE_DATA(nid); | 68 | struct pglist_data *pgdat = NODE_DATA(nid); |
69 | struct sysinfo i; | 69 | struct sysinfo i; |
70 | unsigned long sreclaimable, sunreclaimable; | ||
70 | 71 | ||
71 | si_meminfo_node(&i, nid); | 72 | si_meminfo_node(&i, nid); |
73 | sreclaimable = node_page_state(pgdat, NR_SLAB_RECLAIMABLE); | ||
74 | sunreclaimable = node_page_state(pgdat, NR_SLAB_UNRECLAIMABLE); | ||
72 | n = sprintf(buf, | 75 | n = sprintf(buf, |
73 | "Node %d MemTotal: %8lu kB\n" | 76 | "Node %d MemTotal: %8lu kB\n" |
74 | "Node %d MemFree: %8lu kB\n" | 77 | "Node %d MemFree: %8lu kB\n" |
@@ -118,6 +121,7 @@ static ssize_t node_read_meminfo(struct device *dev, | |||
118 | "Node %d NFS_Unstable: %8lu kB\n" | 121 | "Node %d NFS_Unstable: %8lu kB\n" |
119 | "Node %d Bounce: %8lu kB\n" | 122 | "Node %d Bounce: %8lu kB\n" |
120 | "Node %d WritebackTmp: %8lu kB\n" | 123 | "Node %d WritebackTmp: %8lu kB\n" |
124 | "Node %d KReclaimable: %8lu kB\n" | ||
121 | "Node %d Slab: %8lu kB\n" | 125 | "Node %d Slab: %8lu kB\n" |
122 | "Node %d SReclaimable: %8lu kB\n" | 126 | "Node %d SReclaimable: %8lu kB\n" |
123 | "Node %d SUnreclaim: %8lu kB\n" | 127 | "Node %d SUnreclaim: %8lu kB\n" |
@@ -138,20 +142,21 @@ static ssize_t node_read_meminfo(struct device *dev, | |||
138 | nid, K(node_page_state(pgdat, NR_UNSTABLE_NFS)), | 142 | nid, K(node_page_state(pgdat, NR_UNSTABLE_NFS)), |
139 | nid, K(sum_zone_node_page_state(nid, NR_BOUNCE)), | 143 | nid, K(sum_zone_node_page_state(nid, NR_BOUNCE)), |
140 | nid, K(node_page_state(pgdat, NR_WRITEBACK_TEMP)), | 144 | nid, K(node_page_state(pgdat, NR_WRITEBACK_TEMP)), |
141 | nid, K(node_page_state(pgdat, NR_SLAB_RECLAIMABLE) + | 145 | nid, K(sreclaimable + |
142 | node_page_state(pgdat, NR_SLAB_UNRECLAIMABLE)), | 146 | node_page_state(pgdat, NR_KERNEL_MISC_RECLAIMABLE)), |
143 | nid, K(node_page_state(pgdat, NR_SLAB_RECLAIMABLE)), | 147 | nid, K(sreclaimable + sunreclaimable), |
148 | nid, K(sreclaimable), | ||
149 | nid, K(sunreclaimable) | ||
144 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE | 150 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE |
145 | nid, K(node_page_state(pgdat, NR_SLAB_UNRECLAIMABLE)), | 151 | , |
146 | nid, K(node_page_state(pgdat, NR_ANON_THPS) * | 152 | nid, K(node_page_state(pgdat, NR_ANON_THPS) * |
147 | HPAGE_PMD_NR), | 153 | HPAGE_PMD_NR), |
148 | nid, K(node_page_state(pgdat, NR_SHMEM_THPS) * | 154 | nid, K(node_page_state(pgdat, NR_SHMEM_THPS) * |
149 | HPAGE_PMD_NR), | 155 | HPAGE_PMD_NR), |
150 | nid, K(node_page_state(pgdat, NR_SHMEM_PMDMAPPED) * | 156 | nid, K(node_page_state(pgdat, NR_SHMEM_PMDMAPPED) * |
151 | HPAGE_PMD_NR)); | 157 | HPAGE_PMD_NR) |
152 | #else | ||
153 | nid, K(node_page_state(pgdat, NR_SLAB_UNRECLAIMABLE))); | ||
154 | #endif | 158 | #endif |
159 | ); | ||
155 | n += hugetlb_report_node_meminfo(nid, buf + n); | 160 | n += hugetlb_report_node_meminfo(nid, buf + n); |
156 | return n; | 161 | return n; |
157 | } | 162 | } |
diff --git a/fs/proc/meminfo.c b/fs/proc/meminfo.c index edda898714eb..568d90e17c17 100644 --- a/fs/proc/meminfo.c +++ b/fs/proc/meminfo.c | |||
@@ -38,6 +38,7 @@ static int meminfo_proc_show(struct seq_file *m, void *v) | |||
38 | long cached; | 38 | long cached; |
39 | long available; | 39 | long available; |
40 | unsigned long pages[NR_LRU_LISTS]; | 40 | unsigned long pages[NR_LRU_LISTS]; |
41 | unsigned long sreclaimable, sunreclaim; | ||
41 | int lru; | 42 | int lru; |
42 | 43 | ||
43 | si_meminfo(&i); | 44 | si_meminfo(&i); |
@@ -53,6 +54,8 @@ static int meminfo_proc_show(struct seq_file *m, void *v) | |||
53 | pages[lru] = global_node_page_state(NR_LRU_BASE + lru); | 54 | pages[lru] = global_node_page_state(NR_LRU_BASE + lru); |
54 | 55 | ||
55 | available = si_mem_available(); | 56 | available = si_mem_available(); |
57 | sreclaimable = global_node_page_state(NR_SLAB_RECLAIMABLE); | ||
58 | sunreclaim = global_node_page_state(NR_SLAB_UNRECLAIMABLE); | ||
56 | 59 | ||
57 | show_val_kb(m, "MemTotal: ", i.totalram); | 60 | show_val_kb(m, "MemTotal: ", i.totalram); |
58 | show_val_kb(m, "MemFree: ", i.freeram); | 61 | show_val_kb(m, "MemFree: ", i.freeram); |
@@ -94,14 +97,11 @@ static int meminfo_proc_show(struct seq_file *m, void *v) | |||
94 | show_val_kb(m, "Mapped: ", | 97 | show_val_kb(m, "Mapped: ", |
95 | global_node_page_state(NR_FILE_MAPPED)); | 98 | global_node_page_state(NR_FILE_MAPPED)); |
96 | show_val_kb(m, "Shmem: ", i.sharedram); | 99 | show_val_kb(m, "Shmem: ", i.sharedram); |
97 | show_val_kb(m, "Slab: ", | 100 | show_val_kb(m, "KReclaimable: ", sreclaimable + |
98 | global_node_page_state(NR_SLAB_RECLAIMABLE) + | 101 | global_node_page_state(NR_KERNEL_MISC_RECLAIMABLE)); |
99 | global_node_page_state(NR_SLAB_UNRECLAIMABLE)); | 102 | show_val_kb(m, "Slab: ", sreclaimable + sunreclaim); |
100 | 103 | show_val_kb(m, "SReclaimable: ", sreclaimable); | |
101 | show_val_kb(m, "SReclaimable: ", | 104 | show_val_kb(m, "SUnreclaim: ", sunreclaim); |
102 | global_node_page_state(NR_SLAB_RECLAIMABLE)); | ||
103 | show_val_kb(m, "SUnreclaim: ", | ||
104 | global_node_page_state(NR_SLAB_UNRECLAIMABLE)); | ||
105 | seq_printf(m, "KernelStack: %8lu kB\n", | 105 | seq_printf(m, "KernelStack: %8lu kB\n", |
106 | global_zone_page_state(NR_KERNEL_STACK_KB)); | 106 | global_zone_page_state(NR_KERNEL_STACK_KB)); |
107 | show_val_kb(m, "PageTables: ", | 107 | show_val_kb(m, "PageTables: ", |