tmpfs - what portion of a tmpfs partition is swapped out

From: Adam Romanek
Date: Fri Mar 15 2019 - 02:30:23 EST


Hi,

I have an embedded platform running Linux 3.12.x with rootfs
uncompressed to RAM and using a tmpfs partition. I also use ZRAM on this
platform, so I expect parts of the root filesystem to get swapped out
over time. I'm struggling with poor performance which I believe is
somehow related to swapping. I'm able to measure the number of pages
swapped in and out, I'm also able to measure the amount of swapped
memory for user-space processes (thanks to Android's procrank tool).

Now in order to fully understand what happens within the system I'd like
to measure what portion of the root filesystem is swapped to ZRAM.

I found that include/linux/shmem_fs.h contains 'struct shmem_inode_info'
which on the other hand contains 'swapped' field. If I'm correct then
iterating over all inodes from the root filesystem and summing up the
values of this field should provide me with the result. Is that correct?

I'm not a regular Linux kernel developer so any help on implementing
this would be appreciated.

Best regards,
Adam Romanek