Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does pss mean in /proc/pid/smaps

Tags:

I was confused about the Pss column in /proc/pid/smaps, so I wrote a program to test it:

void sa(); int main(int argc,char *argv[]) {     int fd;     sa();     sleep(1000); }  void sa() {    char *pi=new char[1024*1024*10];    for(int i=0;i<4;++i) {         for(int j=0;j<1024*1024;++j){                 *pi='o';                 pi++;         }    }    int cnt;    for(int i=0;i<6;++i) {         for(int j=0;j<1024*1024;++j){                 cnt+=*pi;                 pi++;         }    }    printf("%d",cnt); } 
$cat /proc/`pidof testprogram`/smaps  08838000-0885b000 rw-p 00000000 00:00 0          [heap] Size:                140 kB Rss:                  12 kB Pss:                  12 kB Shared_Clean:          0 kB Shared_Dirty:          0 kB Private_Clean:         0 kB Private_Dirty:        12 kB Referenced:           12 kB Swap:                  0 kB KernelPageSize:        4 kB MMUPageSize:           4 kB b6dcd000-b77d0000 rw-p 00000000 00:00 0  Size:              10252 kB Rss:               10252 kB Pss:                4108 kB Shared_Clean:          0 kB Shared_Dirty:          0 kB Private_Clean:         0 kB Private_Dirty:      4108 kB Referenced:         4108 kB Swap:                  0 kB KernelPageSize:        4 kB MMUPageSize:           4 kB 

Here I found Pss equal to Private_Dirty, but I wonder why.

BTW: Is there any detailed documentation for smaps?

like image 259
camino Avatar asked Mar 29 '12 09:03

camino


People also ask

What is Pss linux?

In computing, proportional set size (PSS) is the portion of main memory (RAM) occupied by a process and is composed by the private memory of that process plus the proportion of shared memory with one or more other processes. Unshared memory including the proportion of shared memory is reported as the PSS.

What is proc PID MEM?

/proc/PID/mem gives access to the memory of the process as it is mapped in the process: accessing the Nth byte of this file is equivalent to accessing (*unsigned char)N inside the process in C, or ptrace(PTRACE_PEEKDATA, PID, (void*)N, NULL) from another process (or PTRACE_POKEDATA for writing, and with the difference ...

What is proc PID stack?

According to proc manual: /proc/[pid]/stack (since Linux 2.6.29) This file provides a symbolic trace of the function calls in this process's kernel stack. This file is provided only if the kernel was built with the CONFIG_STACKTRACE configuration option.


1 Answers

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.

like image 138
Pavan Manjunath Avatar answered Oct 27 '22 00:10

Pavan Manjunath