Commit 39799b64 authored by Johannes Weiner's avatar Johannes Weiner Committed by akpm

Documentation: filesystems: proc: update meminfo section

Patch series "zswap: accounting & cgroup control", v2.

Zswap can consume nearly a quarter of RAM in the default configuration,
yet it's neither listed in /proc/meminfo, nor is it accounted and
manageable on a per-cgroup basis.

This makes reasoning about the memory situation on a host in general
rather difficult.  On shared/cgrouped hosts, the consequences are worse. 
First, workloads can escape memory containment and cause resource priority
inversions: a lo-pri group can fill the global zswap pool and force a
hi-pri group out to disk.  Second, not all workloads benefit from zswap
equally.  Some even suffer when memory contents compress poorly, and are
better off going to disk swap directly.  On a host with mixed workloads,
it's currently not possible to enable zswap for one workload but not for
the other.

This series implements the missing global accounting as well as cgroup
tracking & control for zswap backing memory:

- Patch 1 refreshes the very out-of-date meminfo documentation in
  Documentation/filesystems/proc.rst.

- Patches 2-4 clean up related and adjacent options in Kconfig. Not
  actual dependencies, just things I noticed during development.

- Patch 5 adds meminfo and vmstat coverage for zswap consumption and
  activity.

- Patch 6 implements per-cgroup tracking & control of zswap memory.


This patch (of 6):

Add new entries.  Minor corrections and cleanups.

[hannes@cmpxchg.org: fix htmldocs warnings]
  Link: https://lkml.kernel.org/r/Ynve8dg4zJyhH2gW@cmpxchg.org
[hannes@cmpxchg.org: change `Unevictable' wording, per David]
  Link: https://lkml.kernel.org/r/YnwFraZlVWQoCjz3@cmpxchg.org
Link: https://lkml.kernel.org/r/20220510152847.230957-1-hannes@cmpxchg.org
Link: https://lkml.kernel.org/r/20220510152847.230957-2-hannes@cmpxchg.orgSigned-off-by: default avatarJohannes Weiner <hannes@cmpxchg.org>
Acked-by: default avatarDavid Hildenbrand <david@redhat.com>
Cc: Dan Streetman <ddstreet@ieee.org>
Cc: Michal Hocko <mhocko@suse.com>
Cc: Minchan Kim <minchan@kernel.org>
Cc: Roman Gushchin <guro@fb.com>
Cc: Seth Jennings <sjenning@redhat.com>
Cc: Shakeel Butt <shakeelb@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
parent ff351f4b
...@@ -942,56 +942,71 @@ can be substantial. In many cases there are other means to find out ...@@ -942,56 +942,71 @@ can be substantial. In many cases there are other means to find out
additional memory using subsystem specific interfaces, for instance additional memory using subsystem specific interfaces, for instance
/proc/net/sockstat for TCP memory allocations. /proc/net/sockstat for TCP memory allocations.
The following is from a 16GB PIII, which has highmem enabled. Example output. You may not have all of these fields.
You may not have all of these fields.
:: ::
> cat /proc/meminfo > cat /proc/meminfo
MemTotal: 16344972 kB MemTotal: 32858820 kB
MemFree: 13634064 kB MemFree: 21001236 kB
MemAvailable: 14836172 kB MemAvailable: 27214312 kB
Buffers: 3656 kB Buffers: 581092 kB
Cached: 1195708 kB Cached: 5587612 kB
SwapCached: 0 kB SwapCached: 0 kB
Active: 891636 kB Active: 3237152 kB
Inactive: 1077224 kB Inactive: 7586256 kB
HighTotal: 15597528 kB Active(anon): 94064 kB
HighFree: 13629632 kB Inactive(anon): 4570616 kB
LowTotal: 747444 kB Active(file): 3143088 kB
LowFree: 4432 kB Inactive(file): 3015640 kB
SwapTotal: 0 kB Unevictable: 0 kB
SwapFree: 0 kB Mlocked: 0 kB
Dirty: 968 kB SwapTotal: 0 kB
Writeback: 0 kB SwapFree: 0 kB
AnonPages: 861800 kB Dirty: 12 kB
Mapped: 280372 kB Writeback: 0 kB
Shmem: 644 kB AnonPages: 4654780 kB
KReclaimable: 168048 kB Mapped: 266244 kB
Slab: 284364 kB Shmem: 9976 kB
SReclaimable: 159856 kB KReclaimable: 517708 kB
SUnreclaim: 124508 kB Slab: 660044 kB
PageTables: 24448 kB SReclaimable: 517708 kB
NFS_Unstable: 0 kB SUnreclaim: 142336 kB
Bounce: 0 kB KernelStack: 11168 kB
WritebackTmp: 0 kB PageTables: 20540 kB
CommitLimit: 7669796 kB NFS_Unstable: 0 kB
Committed_AS: 100056 kB Bounce: 0 kB
VmallocTotal: 112216 kB WritebackTmp: 0 kB
VmallocUsed: 428 kB CommitLimit: 16429408 kB
VmallocChunk: 111088 kB Committed_AS: 7715148 kB
Percpu: 62080 kB VmallocTotal: 34359738367 kB
HardwareCorrupted: 0 kB VmallocUsed: 40444 kB
AnonHugePages: 49152 kB VmallocChunk: 0 kB
ShmemHugePages: 0 kB Percpu: 29312 kB
ShmemPmdMapped: 0 kB HardwareCorrupted: 0 kB
AnonHugePages: 4149248 kB
ShmemHugePages: 0 kB
ShmemPmdMapped: 0 kB
FileHugePages: 0 kB
FilePmdMapped: 0 kB
CmaTotal: 0 kB
CmaFree: 0 kB
HugePages_Total: 0
HugePages_Free: 0
HugePages_Rsvd: 0
HugePages_Surp: 0
Hugepagesize: 2048 kB
Hugetlb: 0 kB
DirectMap4k: 401152 kB
DirectMap2M: 10008576 kB
DirectMap1G: 24117248 kB
MemTotal MemTotal
Total usable RAM (i.e. physical RAM minus a few reserved Total usable RAM (i.e. physical RAM minus a few reserved
bits and the kernel binary code) bits and the kernel binary code)
MemFree MemFree
The sum of LowFree+HighFree Total free RAM. On highmem systems, the sum of LowFree+HighFree
MemAvailable MemAvailable
An estimate of how much memory is available for starting new An estimate of how much memory is available for starting new
applications, without swapping. Calculated from MemFree, applications, without swapping. Calculated from MemFree,
...@@ -1005,8 +1020,9 @@ Buffers ...@@ -1005,8 +1020,9 @@ Buffers
Relatively temporary storage for raw disk blocks Relatively temporary storage for raw disk blocks
shouldn't get tremendously large (20MB or so) shouldn't get tremendously large (20MB or so)
Cached Cached
in-memory cache for files read from the disk (the In-memory cache for files read from the disk (the
pagecache). Doesn't include SwapCached pagecache) as well as tmpfs & shmem.
Doesn't include SwapCached.
SwapCached SwapCached
Memory that once was swapped out, is swapped back in but Memory that once was swapped out, is swapped back in but
still also is in the swapfile (if memory is needed it still also is in the swapfile (if memory is needed it
...@@ -1018,6 +1034,11 @@ Active ...@@ -1018,6 +1034,11 @@ Active
Inactive Inactive
Memory which has been less recently used. It is more Memory which has been less recently used. It is more
eligible to be reclaimed for other purposes eligible to be reclaimed for other purposes
Unevictable
Memory allocated for userspace which cannot be reclaimed, such
as mlocked pages, ramfs backing pages, secret memfd pages etc.
Mlocked
Memory locked with mlock().
HighTotal, HighFree HighTotal, HighFree
Highmem is all memory above ~860MB of physical memory. Highmem is all memory above ~860MB of physical memory.
Highmem areas are for use by userspace programs, or Highmem areas are for use by userspace programs, or
...@@ -1040,20 +1061,10 @@ Writeback ...@@ -1040,20 +1061,10 @@ Writeback
Memory which is actively being written back to the disk Memory which is actively being written back to the disk
AnonPages AnonPages
Non-file backed pages mapped into userspace page tables Non-file backed pages mapped into userspace page tables
HardwareCorrupted
The amount of RAM/memory in KB, the kernel identifies as
corrupted.
AnonHugePages
Non-file backed huge pages mapped into userspace page tables
Mapped Mapped
files which have been mmaped, such as libraries files which have been mmaped, such as libraries
Shmem Shmem
Total memory used by shared memory (shmem) and tmpfs Total memory used by shared memory (shmem) and tmpfs
ShmemHugePages
Memory used by shared memory (shmem) and tmpfs allocated
with huge pages
ShmemPmdMapped
Shared memory mapped into userspace with huge pages
KReclaimable KReclaimable
Kernel allocations that the kernel will attempt to reclaim Kernel allocations that the kernel will attempt to reclaim
under memory pressure. Includes SReclaimable (below), and other under memory pressure. Includes SReclaimable (below), and other
...@@ -1064,9 +1075,10 @@ SReclaimable ...@@ -1064,9 +1075,10 @@ SReclaimable
Part of Slab, that might be reclaimed, such as caches Part of Slab, that might be reclaimed, such as caches
SUnreclaim SUnreclaim
Part of Slab, that cannot be reclaimed on memory pressure Part of Slab, that cannot be reclaimed on memory pressure
KernelStack
Memory consumed by the kernel stacks of all tasks
PageTables PageTables
amount of memory dedicated to the lowest level of page Memory consumed by userspace page tables
tables.
NFS_Unstable NFS_Unstable
Always zero. Previous counted pages which had been written to Always zero. Previous counted pages which had been written to
the server, but has not been committed to stable storage. the server, but has not been committed to stable storage.
...@@ -1098,7 +1110,7 @@ Committed_AS ...@@ -1098,7 +1110,7 @@ Committed_AS
has been allocated by processes, even if it has not been has been allocated by processes, even if it has not been
"used" by them as of yet. A process which malloc()'s 1G "used" by them as of yet. A process which malloc()'s 1G
of memory, but only touches 300M of it will show up as of memory, but only touches 300M of it will show up as
using 1G. This 1G is memory which has been "committed" to using 1G. This 1G is memory which has been "committed" to
by the VM and can be used at any time by the allocating by the VM and can be used at any time by the allocating
application. With strict overcommit enabled on the system application. With strict overcommit enabled on the system
(mode 2 in 'vm.overcommit_memory'), allocations which would (mode 2 in 'vm.overcommit_memory'), allocations which would
...@@ -1107,7 +1119,7 @@ Committed_AS ...@@ -1107,7 +1119,7 @@ Committed_AS
not fail due to lack of memory once that memory has been not fail due to lack of memory once that memory has been
successfully allocated. successfully allocated.
VmallocTotal VmallocTotal
total size of vmalloc memory area total size of vmalloc virtual address space
VmallocUsed VmallocUsed
amount of vmalloc area which is used amount of vmalloc area which is used
VmallocChunk VmallocChunk
...@@ -1115,6 +1127,30 @@ VmallocChunk ...@@ -1115,6 +1127,30 @@ VmallocChunk
Percpu Percpu
Memory allocated to the percpu allocator used to back percpu Memory allocated to the percpu allocator used to back percpu
allocations. This stat excludes the cost of metadata. allocations. This stat excludes the cost of metadata.
HardwareCorrupted
The amount of RAM/memory in KB, the kernel identifies as
corrupted.
AnonHugePages
Non-file backed huge pages mapped into userspace page tables
ShmemHugePages
Memory used by shared memory (shmem) and tmpfs allocated
with huge pages
ShmemPmdMapped
Shared memory mapped into userspace with huge pages
FileHugePages
Memory used for filesystem data (page cache) allocated
with huge pages
FilePmdMapped
Page cache mapped into userspace with huge pages
CmaTotal
Memory reserved for the Contiguous Memory Allocator (CMA)
CmaFree
Free remaining memory in the CMA reserves
HugePages_Total, HugePages_Free, HugePages_Rsvd, HugePages_Surp, Hugepagesize, Hugetlb
See Documentation/admin-guide/mm/hugetlbpage.rst.
DirectMap4k, DirectMap2M, DirectMap1G
Breakdown of page table sizes used in the kernel's
identity mapping of RAM
vmallocinfo vmallocinfo
~~~~~~~~~~~ ~~~~~~~~~~~
......
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