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
Match a String That Contains a Newline Using Sed
Aws Lambda Permission Denied When Trying to Use Ffmpeg
Bpf Verifier Rejects Code: "Invalid Bpf_Context Access"
Memory Access Error Sys_Rt_Sigaction (Signal Handler)
Bash Pass Variable as Argument with Quotes
What Is Partition Checker in Arm Secure Mode
How to Find Words from One File in Another File
Bash Store Output as a Variable
Is There a Limit on Number of Tcp/Ip Connections Between MAChines on Linux
How to Identify the Particular Linux Flavor via Command Line
How to Find Files That Only Have Certain Permission for Owner
Permissions Required to Move File to Different Directory in Unix/Linux
Add Margin to PDF File When Merging Using Pdftk or Similar
Is There an Acceptable Linux Targeted Gui Client for Git-Svn