@@ -63,6 +63,9 @@ struct memory_stat {
63
63
uint64_t total_inactive_file ;
64
64
uint64_t total_active_file ;
65
65
uint64_t total_unevictable ;
66
+ uint64_t slab ;
67
+ uint64_t slab_reclaimable ;
68
+ uint64_t slab_unreclaimable ;
66
69
};
67
70
68
71
static off_t get_procfile_size (const char * path )
@@ -1368,6 +1371,12 @@ static bool cgroup_parse_memory_stat(const char *cgroup, struct memory_stat *mst
1368
1371
sscanf (line , unified ? "active_file %" PRIu64 : "total_active_file %" PRIu64 , & (mstat -> total_active_file ));
1369
1372
} else if (startswith (line , unified ? "unevictable" : "total_unevictable" )) {
1370
1373
sscanf (line , unified ? "unevictable %" PRIu64 : "total_unevictable %" PRIu64 , & (mstat -> total_unevictable ));
1374
+ } else if (unified && startswith (line , "slab " )) {
1375
+ sscanf (line , "slab %" PRIu64 , & (mstat -> slab ));
1376
+ } else if (unified && startswith (line , "slab_reclaimable" )) {
1377
+ sscanf (line , "slab_reclaimable %" PRIu64 , & (mstat -> slab_reclaimable ));
1378
+ } else if (unified && startswith (line , "slab_unreclaimable" )) {
1379
+ sscanf (line , "slab_unreclaimable %" PRIu64 , & (mstat -> slab_unreclaimable ));
1371
1380
}
1372
1381
}
1373
1382
@@ -1464,7 +1473,8 @@ static int proc_meminfo_read(char *buf, size_t size, off_t offset,
1464
1473
snprintf (lbuf , 100 , "MemFree: %8" PRIu64 " kB\n" , memlimit - memusage );
1465
1474
printme = lbuf ;
1466
1475
} else if (startswith (line , "MemAvailable:" )) {
1467
- snprintf (lbuf , 100 , "MemAvailable: %8" PRIu64 " kB\n" , memlimit - memusage + (mstat .total_active_file + mstat .total_inactive_file ) / 1024 );
1476
+ snprintf (lbuf , 100 , "MemAvailable: %8" PRIu64 " kB\n" , memlimit - memusage +
1477
+ (mstat .total_active_file + mstat .total_inactive_file + mstat .slab_reclaimable ) / 1024 );
1468
1478
printme = lbuf ;
1469
1479
} else if (startswith (line , "SwapTotal:" )) {
1470
1480
if (wants_swap ) {
@@ -1499,7 +1509,7 @@ static int proc_meminfo_read(char *buf, size_t size, off_t offset,
1499
1509
snprintf (lbuf , 100 , "SwapFree: %8" PRIu64 " kB\n" , swfree );
1500
1510
printme = lbuf ;
1501
1511
} else if (startswith (line , "Slab:" )) {
1502
- snprintf (lbuf , 100 , "Slab: %8" PRIu64 " kB\n" , ( uint64_t ) 0 );
1512
+ snprintf (lbuf , 100 , "Slab: %8" PRIu64 " kB\n" , mstat . slab / 1024 );
1503
1513
printme = lbuf ;
1504
1514
} else if (startswith (line , "Buffers:" )) {
1505
1515
snprintf (lbuf , 100 , "Buffers: %8" PRIu64 " kB\n" , (uint64_t )0 );
@@ -1562,10 +1572,10 @@ static int proc_meminfo_read(char *buf, size_t size, off_t offset,
1562
1572
mstat .total_mapped_file / 1024 );
1563
1573
printme = lbuf ;
1564
1574
} else if (startswith (line , "SReclaimable:" )) {
1565
- snprintf (lbuf , 100 , "SReclaimable: %8" PRIu64 " kB\n" , ( uint64_t ) 0 );
1575
+ snprintf (lbuf , 100 , "SReclaimable: %8" PRIu64 " kB\n" , mstat . slab_reclaimable / 1024 );
1566
1576
printme = lbuf ;
1567
1577
} else if (startswith (line , "SUnreclaim:" )) {
1568
- snprintf (lbuf , 100 , "SUnreclaim: %8" PRIu64 " kB\n" , ( uint64_t ) 0 );
1578
+ snprintf (lbuf , 100 , "SUnreclaim: %8" PRIu64 " kB\n" , mstat . slab_unreclaimable / 1024 );
1569
1579
printme = lbuf ;
1570
1580
} else if (startswith (line , "Shmem:" )) {
1571
1581
snprintf (lbuf , 100 , "Shmem: %8" PRIu64 " kB\n" ,
0 commit comments