Linux Os: /Proc/[Pid]/Smaps Vs /Proc/[Pid]/Statm

What is the reason for the discrepancy between /proc/[pid]/status:RssAnon and /proc/[pid]/smaps_rollup:Anonymous?

The plausible theory you mention is true. The man pages have been updated: https://www.spinics.net/lists/linux-mm/msg230450.html

Since 34e55232e59f7b19050267a05ff1226e5cd122a5 (introduced back in
v2.6.34), Linux uses per-thread RSS counters to reduce cache contention on
the per-mm counters. With a 4K page size, that means that you can end up
with the counters off by up to 252KiB* per thread.

(*this precise number is not strictly accurate, see thread for details)

Linux /proc/pid/smaps proportional swap (like Pss but for swap)

You just have to divide Swap value by number of process that are sharing this Virtual Memory Area.

Actually, I didn't find how to get number of process sharing a VMA. However, it is sometime possible to calculate it by dividing RSS with PSS. Sure, it only work if PSS != 0.

Finaly, you can use this perl code (pass smap file as argument):

#!/usr/bin/perl -w
my ($rss, $pss);
my $total = 0;

while(<>) {
$rss = $1 if /Rss: *([0-9]*) kB/;
$pss = $1 if /Pss: *([0-9]*) kB/;
if (/Swap: *([0-9]*) kB/) {
my $swap = $1;
if ($swap != 0) {
if ($pss == 0) {
print "Cannot get number of process using this VMA\n";

} else {
my $swap = $swap * $rss / $pss;
print "P-swap: $swap\n";
}
$total += $swap;
}
}
}
print "Total P-Swap: $total kB\n"


Related Topics



Leave a reply



Submit