On 2023/02/14 23:37, Lianbo Jiang wrote: > The "kmem -i" option may output the bogus statistics of CACHED, which > might be observed when some extreme situations occur in kernel, such as > OOM, disk IO errors, etc. > > The following result of calculation may be a negative value, refer to > the dump_kmeminfo(): > page_cache_size = nr_file_pages - swapper_space_nrpages - buffer_pages; > > As a result, the negative value will be converted to unsigned long > integer, eventually it overflows and gets a big integer. > > crash> kmem -i > PAGES TOTAL PERCENTAGE > TOTAL MEM 255314511 973.9 GB ---- > FREE 533574 2 GB 0% of TOTAL MEM > USED 254780937 971.9 GB 99% of TOTAL MEM > SHARED 1713 6.7 MB 0% of TOTAL MEM > BUFFERS 374 1.5 MB 0% of TOTAL MEM > CACHED -114 70368744177664 GB 72251060080% of TOTAL MEM > ^^^^ ^^^^^^^^^^^^^^ ^^^^^^^^^^^^ I think that this is not very bad output :) because we can notice the negative value. Maybe it's due to future kernel changes. So if you set it to zero, what about emitting an info message? + if (page_cache_size < 0) { + error(INFO, "page_cache_size went negative (%ld), setting to 0\n", + page_cache_size); + page_cache_size = 0; + } For example, crash> kmem -i PAGES TOTAL PERCENTAGE TOTAL MEM 16252500 62 GB ---- FREE 246162 961.6 MB 1% of TOTAL MEM USED 16006338 61.1 GB 98% of TOTAL MEM SHARED 329258 1.3 GB 2% of TOTAL MEM BUFFERS 1436 5.6 MB 0% of TOTAL MEM kmem: page_cache_size went negative (-114), setting to 0 CACHED 0 0 0% of TOTAL MEM SLAB 311514 1.2 GB 1% of TOTAL MEM Thanks, Kazu > ... > > Let's normalize it to zero to fix such corner cases. > > Reported-by: Buland Kumar Singh <bsingh@xxxxxxxxxx> > Signed-off-by: Lianbo Jiang <lijiang@xxxxxxxxxx> > --- > memory.c | 2 ++ > 1 file changed, 2 insertions(+) > > diff --git a/memory.c b/memory.c > index e0742c1bd3a4..860a3a978a4d 100644 > --- a/memory.c > +++ b/memory.c > @@ -8615,6 +8615,8 @@ dump_kmeminfo(void) > page_cache_size = 0; > > > + if (page_cache_size < 0) > + page_cache_size = 0; > pct = (page_cache_size * 100)/totalram_pages; > fprintf(fp, "%13s %7ld %11s %3ld%% of TOTAL MEM\n", > "CACHED", page_cache_size, -- Crash-utility mailing list Crash-utility@xxxxxxxxxx https://listman.redhat.com/mailman/listinfo/crash-utility Contribution Guidelines: https://github.com/crash-utility/crash/wiki