Linux /proc/pid/smaps 中的 pss 是什么意思
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9922928/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What does pss mean in /proc/pid/smaps
提问by camino
I was confused about the pss column in /proc/pid/smaps, so I wrote a program to test it:
我对/proc/pid/smaps中的pss列感到困惑,所以我写了一个程序来测试它:
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.
在这里我发现 pss 等于 Private_Dirty,但我想知道为什么。
BTW: is there any detailed documention for smaps
?
顺便说一句:有没有详细的文档smaps
?
采纳答案by Pavan Manjunath
Quoting from lwn.net
引自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
进程的“比例集大小”(PSS) 是它在内存中的页数,其中每个页除以共享它的进程数。因此,如果一个进程拥有 1000 个页面,并且与另一个进程共享 1000 个页面,则其 PSS 将为 1500
From Linux Kernel Documentation,
来自Linux 内核文档,
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:
这/proc/PID/smaps
是一个基于映射的扩展,显示了每个进程映射的内存消耗。对于每个映射,都有一系列如下所示的行:
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_SHAREDmapping, 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_PRIVATEand 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.
这些行中的第一行显示的信息与/proc/PID/maps 中的映射所显示的信息相同。其余行显示映射的大小 ( size)、当前驻留在 RAM 中的映射量 ( RSS)、进程在此映射中的比例份额 ( PSS)、干净和脏私有页面的数量映射。请注意,即使是MAP_SHARED映射的一部分,但只有一个 pte 映射的页面,即当前仅由一个进程使用,也被视为私有而不是共享。“引用”表示当前标记为引用或访问的内存量。"匿名" 显示不属于任何文件的内存量。即使与文件关联的映射也可能包含匿名页面:当MAP_PRIVATE和页面被修改时,文件页面将被私有匿名副本替换。“交换”显示如何也使用了很多可能是匿名的内存,但在交换中。
This Questionon Unix and Linux
Stackexchange covers almost the topic. See Mat's excellent answer which will surely clear all your doubts.
Unix and Linux
Stackexchange上的这个问题几乎涵盖了这个主题。请参阅 Mat 的出色回答,这肯定会消除您的所有疑虑。