slabinfo: add comment for cache_size calculation

One of our physical machine shows that the "CACHE SIZE" column
of slabtop output is extremely high, three times of the products
of objs nums and objs size. After some analysis, we found that
the order of slab, which decides "pages per slab", will shrink
when memory pressure is high and normal order allocation failed.
So we think it might help to add these comments to the man help.

Minor fix: add the "memory." back, which is lost after
"aa461df0: docs: Minor manpage fixes"

Signed-off-by: Zhao Mengmeng <zhaomengmeng@kylinos.cn>
This commit is contained in:
Zhao Mengmeng 2023-04-11 05:52:24 -04:00 committed by Craig Small
parent 833cdc64f0
commit 25cd1bee0c
3 changed files with 12 additions and 2 deletions

View File

@ -40,7 +40,7 @@ enum slabinfo_item {
SLAB_ACTIVE_SLABS, // u_int " SLAB_ACTIVE_SLABS, // u_int "
SLAB_PAGES_PER_SLAB, // u_int " SLAB_PAGES_PER_SLAB, // u_int "
SLAB_PERCENT_USED, // u_int derived from ACTIVE_OBJS / NUM_OBJS SLAB_PERCENT_USED, // u_int derived from ACTIVE_OBJS / NUM_OBJS
SLAB_SIZE_TOTAL, // ul_int derived from page size * NUM_OBJS * PAGES_PER_SLAB SLAB_SIZE_TOTAL, // ul_int derived from page size * NUMS_SLABS * PAGES_PER_SLAB
SLABS_CACHES_TOTAL, // u_int derived from all caches SLABS_CACHES_TOTAL, // u_int derived from all caches
SLABS_CACHES_ACTIVE, // u_int " SLABS_CACHES_ACTIVE, // u_int "

View File

@ -434,6 +434,10 @@ static int parse_slabinfo20 (
if (node->obj_size > slabs->max_obj_size) if (node->obj_size > slabs->max_obj_size)
slabs->max_obj_size = node->obj_size; slabs->max_obj_size = node->obj_size;
/* cache_size is not accurate, it's the upper limit of memory used by this slab.
* When system using slub(most common case) is under high memory pressure, there
* are slab order fallbacks, which means pages_per_slab is not constant and may decrease.
*/
node->cache_size = (unsigned long)node->nr_slabs * node->pages_per_slab * page_size; node->cache_size = (unsigned long)node->nr_slabs * node->pages_per_slab * page_size;
if (node->nr_objs) { if (node->nr_objs) {

View File

@ -104,7 +104,13 @@ The
.B slabtop .B slabtop
statistic header is tracking how many bytes of slabs are being statistic header is tracking how many bytes of slabs are being
used and is not a measure of physical memory. The 'Slab' field in the used and is not a measure of physical memory. The 'Slab' field in the
\fI/proc/meminfo\fR file is tracking information about used slab physical \fI/proc/meminfo\fR file is tracking information about used slab physical memory.
.PP
The
.B CACHE SIZE
column is not accurate, it's the upper limit of memory used by specific slab. When system
using slub (most common case) is under high memory pressure, there are slab order
fallbacks, which means "pages per slab" is not constant and may decrease.
.SH AUTHORS .SH AUTHORS
Written by Chris Rivera and Robert Love. Written by Chris Rivera and Robert Love.
.PP .PP