From 699717c7720cb2a397ce59d0a0380c65d2693033 Mon Sep 17 00:00:00 2001 From: Lianbo Jiang Date: Fri, 23 Dec 2022 18:42:35 +0800 Subject: [PATCH 61/89] Fix for "kmem -i" to display correct SLAB statistics on Linux 5.9 and later Kernel commit d42f3245c7e2 ("mm: memcg: convert vmstat slab counters to bytes"), which is contained in Linux v5.9-rc1 and later kernels, renamed NR_SLAB_{RECLAIMABLE,UNRECLAIMABLE} to NR_SLAB_{RECLAIMABLE,UNRECLAIMABLE}_B. Without the patch, "kmem -i" command will display incorrect SLAB statistics: crash> kmem -i | grep -e PAGES -e SLAB PAGES TOTAL PERCENTAGE SLAB 89458 349.4 MB 0% of TOTAL MEM ^^^^^ ^^^^^ With the patch, the actual result is: crash> kmem -i | grep -e PAGES -e SLAB PAGES TOTAL PERCENTAGE SLAB 261953 1023.3 MB 0% of TOTAL MEM Reported-by: Buland Kumar Singh Signed-off-by: Lianbo Jiang Signed-off-by: Kazuhito Hagio --- memory.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/memory.c b/memory.c index d05737cc1429..625a94b7d7d4 100644 --- a/memory.c +++ b/memory.c @@ -8388,6 +8388,11 @@ dump_kmeminfo(void) get_slabs = nr_slab; if (dump_vm_stat("NR_SLAB_UNRECLAIMABLE", &nr_slab, 0)) get_slabs += nr_slab; + } else if (dump_vm_stat("NR_SLAB_RECLAIMABLE_B", &nr_slab, 0)) { + /* 5.9 and later */ + get_slabs = nr_slab; + if (dump_vm_stat("NR_SLAB_UNRECLAIMABLE_B", &nr_slab, 0)) + get_slabs += nr_slab; } } -- 2.37.1