procmap incorrectly reads shared_clean, shared_dirty, private_clean and private_dirty under latest Linux kernel's procfs
Versions:
- Linux Kernel 6.5.6
- Arch Linux
libgtop 2.41.1-1
MRE:
// gcc smaps.c -I/usr/include/libgtop-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -lgtop-2.0 -lglib-2.0
#include <glibtop.h>
#include <glibtop/procmap.h>
#include <glibtop/sysinfo.h>
#include <glibtop/procstate.h>
#include <stdio.h>
#include <assert.h>
int main(int argc, char **argv) {
glibtop_init();
pid_t pid = atoi(argv[1]);
glibtop_proc_map buf;
glibtop_map_entry *maps = glibtop_get_proc_map(&buf, pid);
assert(maps);
for (int i = 0; i < buf.number; i++) {
printf("%lu %lu %lu %lu\n", maps[i].shared_clean, maps[i].shared_dirty, maps[i].private_clean, maps[i].private_dirty);
}
g_free(maps);
glibtop_close();
return 0;
}
$PID=[SOME PID I COULD READ]
# This outputs lines all with only "0 0 0 0"
$ ./a.out $PID | grep -v "0 0 0 0" | wc
0 0 0
# While simple grep doesn't
$ grep -E "(Shared|Private)_(Clean|Dirty)" /proc/$PID/smaps | grep -v "0 kB" | wc
46 138 1288
smaps file: