It seems (from looking at the Linux kernel source) that the Swap:
metric in /proc/pid/smaps
is the total swap accessible by the given pid.
In the case where there is shared memory involved, this seems to be an over-approximation of actual swap usage. For example when summing swap usage of a parent pid with its forked children, and if they have common shared memory in the swap, then it appears that this portion (swapped shared memory) is counted multiple times (once per pid).
My question is whether there is a way to figure out a fair swap usage metric based on the number of processes sharing it (similar to Pss:
).
top
orhtop
? They seems to have a good number of option aboutswap
and shared memory usage... – Carrion