pss在/proc/pid/smaps中是什么意思 [英] What does pss mean in /proc/pid/smaps

查看:253
本文介绍了pss在/proc/pid/smaps中是什么意思的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对/proc/pid/smaps中的pss列感到困惑,所以我编写了一个程序对其进行测试:

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

在这里,我发现pss等于Private_Dirty,但我想知道为什么.

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

顺便说一句:smaps是否有详细的文献资料?

BTW: is there any detailed documention for smaps?

推荐答案

lwn.net 引用

进程的比例集大小"(PSS)是页数 它在内存中,其中每一页除以 共享它的过程.因此,如果一个进程本身拥有1000页, 并与其他进程共享1000,则其PSS将为1500

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

来自 Linux内核文档

/proc/PID/smaps是基于地图的扩展,显示了内存 每个流程映射的消耗.对于每个映射 是以下几行:

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

这些行的第一行显示的信息与显示的相同 /proc/PID/maps 中的映射.其余各行显示大小 映射的大小( size ),即当前映射的数量 驻留在RAM( RSS )中,该进程在此映射中的比例份额 ( PSS ),映射中干净和肮脏的私人页面的数量. 请注意,即使页面是 MAP_SHARED 映射的一部分,但具有 仅映射了一个pte,即当前仅由一个进程使用, 被视为私有而非共享. "参考"表示 当前标记为已引用或已访问的内存量. "匿名"显示不属于任何内存的内存量 文件.甚至与文件关联的映射也可能包含匿名 页面: MAP_PRIVATE 和页面被修改后,文件页面为 替换为私人匿名副本. "交换"显示了多少 也将使用匿名内存,但是会在交换时耗尽.

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.

此问题Unix and Linux上,Stackexchange涵盖了几乎所有主题.请参阅Mat的出色回答,这肯定会清除您的所有疑问.

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

这篇关于pss在/proc/pid/smaps中是什么意思的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆