What Does Pss Mean in /Proc/Pid/Smaps

What does pss mean in /proc/pid/smaps

Quoting from lwn.net

The "proportional set size" (PSS) of a process is the count of pages
it has in memory, where each page is divided by the number of
processes sharing it. So if a process has 1000 pages all to itself,
and 1000 shared with one other process, its PSS will be 1500

From Linux Kernel Documentation,

The /proc/PID/smaps is an extension based on maps, showing the memory
consumption for each of the process's mappings. For each of mappings there
is a series of lines such as the following:

08048000-080bc000 r-xp 00000000 03:02 13130      /bin/bash
Size: 1084 kB
Rss: 892 kB
Pss: 374 kB
Shared_Clean: 892 kB
Shared_Dirty: 0 kB
Private_Clean: 0 kB
Private_Dirty: 0 kB
Referenced: 892 kB
Anonymous: 0 kB
Swap: 0 kB
KernelPageSize: 4 kB
MMUPageSize: 4 kB
Locked: 374 kB

The first of these lines shows the same information as is displayed
for the mapping in /proc/PID/maps. The remaining lines show the size
of the mapping (size), the amount of the mapping that is currently
resident in RAM (RSS), the process' proportional share of this mapping
(PSS), the number of clean and dirty private pages in the mapping.
Note that even a page which is part of a MAP_SHARED mapping, but has
only a single pte mapped, i.e. is currently used by only one process,
is accounted as private and not as shared. "Referenced" indicates the
amount of memory currently marked as referenced or accessed.
"Anonymous" shows the amount of memory that does not belong to any
file. Even a mapping associated with a file may contain anonymous
pages: when MAP_PRIVATE and a page is modified, the file page is
replaced by a private anonymous copy. "Swap" shows how much
would-be-anonymous memory is also used, but out on swap.

This Question on Unix and Linux Stackexchange covers almost the topic. See Mat's excellent answer which will surely clear all your doubts.

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"

Android : PSS (Proportional Set Size) Calculation

Yes, that information is accurate, and that's exactly how it is calculated. (The LWN.net article is here; note that Matt Mackall who participates in that thread you link to developed that feature.)

PSS is in kilobytes, like all the other information you get in /proc/<pid>/smaps. Its unit follows from how it is calculated.

(How often is PSS value updated for a given process in /proc/pid/smaps has some pointers as to where and how PSS is calculated - disclaimer: I wrote the answer there. There are a few other posts on Unix & Linux that discuss PSS and related metrics.)

What [vectors] mean in smaps?

[vectors] indicates a page used by the VDSO mechanism. VDSO is a way of accelerating common system calls by eliminating the overhead of context switching.
Basically the kernel just shares a bit of its memory with the result of common system calls (think gettimeofday() and the like) where your user space process can read it.

You should not count it as used memory, as the same memory will be shared by all processes.



Related Topics



Leave a reply



Submit