Commit f6498b77 authored by Johannes Weiner's avatar Johannes Weiner Committed by Andrew Morton
Browse files

mm: zswap: add basic meminfo and vmstat coverage

Currently it requires poking at debugfs to figure out the size and
population of the zswap cache on a host.  There are no counters for reads
and writes against the cache.  As a result, it's difficult to understand
zswap behavior on production systems.

Print zswap memory consumption and how many pages are zswapped out in
/proc/meminfo.  Count zswapouts and zswapins in /proc/vmstat.

Link: https://lkml.kernel.org/r/20220510152847.230957-6-hannes@cmpxchg.org


Signed-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 b3fbd58f
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -964,6 +964,8 @@ Example output. You may not have all of these fields.
    Mlocked:               0 kB
    SwapTotal:             0 kB
    SwapFree:              0 kB
    Zswap:              1904 kB
    Zswapped:           7792 kB
    Dirty:                12 kB
    Writeback:             0 kB
    AnonPages:       4654780 kB
@@ -1055,6 +1057,10 @@ SwapTotal
SwapFree
              Memory which has been evicted from RAM, and is temporarily
              on the disk
Zswap
              Memory consumed by the zswap backend (compressed size)
Zswapped
              Amount of anonymous memory stored in zswap (original size)
Dirty
              Memory which is waiting to get written back to the disk
Writeback
+7 −0
Original line number Diff line number Diff line
@@ -86,6 +86,13 @@ static int meminfo_proc_show(struct seq_file *m, void *v)

	show_val_kb(m, "SwapTotal:      ", i.totalswap);
	show_val_kb(m, "SwapFree:       ", i.freeswap);
#ifdef CONFIG_ZSWAP
	seq_printf(m,  "Zswap:          %8lu kB\n",
		   (unsigned long)(zswap_pool_total_size >> 10));
	seq_printf(m,  "Zswapped:       %8lu kB\n",
		   (unsigned long)atomic_read(&zswap_stored_pages) <<
		   (PAGE_SHIFT - 10));
#endif
	show_val_kb(m, "Dirty:          ",
		    global_node_page_state(NR_FILE_DIRTY));
	show_val_kb(m, "Writeback:      ",
+5 −0
Original line number Diff line number Diff line
@@ -620,6 +620,11 @@ static inline int mem_cgroup_swappiness(struct mem_cgroup *mem)
}
#endif

#ifdef CONFIG_ZSWAP
extern u64 zswap_pool_total_size;
extern atomic_t zswap_stored_pages;
#endif

#if defined(CONFIG_SWAP) && defined(CONFIG_MEMCG) && defined(CONFIG_BLK_CGROUP)
extern void __cgroup_throttle_swaprate(struct page *page, gfp_t gfp_mask);
static inline  void cgroup_throttle_swaprate(struct page *page, gfp_t gfp_mask)
+4 −0
Original line number Diff line number Diff line
@@ -136,6 +136,10 @@ enum vm_event_item { PGPGIN, PGPGOUT, PSWPIN, PSWPOUT,
#ifdef CONFIG_KSM
		COW_KSM,
#endif
#ifdef CONFIG_ZSWAP
		ZSWPIN,
		ZSWPOUT,
#endif
#ifdef CONFIG_X86
		DIRECT_MAP_LEVEL2_SPLIT,
		DIRECT_MAP_LEVEL3_SPLIT,
+4 −0
Original line number Diff line number Diff line
@@ -1396,6 +1396,10 @@ const char * const vmstat_text[] = {
#ifdef CONFIG_KSM
	"cow_ksm",
#endif
#ifdef CONFIG_ZSWAP
	"zswpin",
	"zswpout",
#endif
#ifdef CONFIG_X86
	"direct_map_level2_splits",
	"direct_map_level3_splits",
Loading