linux /proc/pid/smaps各字段含义

/proc/$PID/smaps

这里写图片描述
第一行:
08048000-080bc000 地址空间的开始地址 - 结束地址
r-xp 属性。前三个是rwx(读、写、可执行),如果不具有则为“-”。最后一个是p/s(私有/共享)
00000000 偏移量。如果这段内存是从文件里映射过来的,则偏移量为这段内容在文件中的偏移量。如果不是从文件里面映射过来的则为0.
03:02 If the region was mapped from a file, this is the major and minor device number (in hex) where the file lives.
13130 If the region was mapped from a file, this is the file number.
/bin/bash If the region was mapped from a file, this is the name of the file. This field is blank for anonymous mapped regions. There are also special regions with names like [heap], [stack], or [vdso]. [vdso] stands for virtual dynamic shared object. It’s used by system calls to switch to kernel mode.

Rss-Resident Set Size 实际使用物理内存(包含共享库占用的内存)
Rss=Shared_Clean+Shared_Dirty+Private_Clean+Private_Dirty
Pss 实际使用的物理内存(按比例包含共享库占用的内存)。比如四个进程共享同一个占内存1000MB的共享库,每个进程算进250MB在Pss。
Shared_CleanShared_DirtyPrivate_CleanPrivate_Dirty
(shared/private)共享和私有
一个页的clean字段表示没有更改此页,当发生换页时不用写回。dirty表示更改了此页,当发生换页时要写回磁盘。此处这四个值是遍历页表中各个页后得到的。
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.

  • 3
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
回答: /proc/2042/smaps是一个特殊的文件,它提供了关于进程2042的虚拟内存映射的详细信息。当我们执行cat /proc/2042/smaps时,实际上是在读取该进程对应的虚拟内存区间的信息。这个过程涉及到两个主要步骤:open()和read()。首先,用户态的open("/proc/2042/smaps")函数会陷入内核,通过/proc/2042/smaps文件相关的inode来找到进程2042的相关信息,并将这些信息搜集到proc_maps_private结构中。然后,open()函数将proc_maps_private结构和smaps文件的具体操作函数结构放到file->private_data中,并返回smaps文件对应的文件描述符fd。接下来,用户态的read(fd)函数通过传入的文件描述符fd找到之前open()函数准备好的file结构,并进行读取操作,将文件内容显示给我们。\[1\]\[2\]所以,执行cat /proc/2042/smaps实际上是通过open()和read()函数来读取进程2042的虚拟内存映射信息。\[1\]\[2\] #### 引用[.reference_title] - *1* *2* [cat /proc/$pid/smaps浅析(一)](https://blog.csdn.net/wennuanddianbo/article/details/96473862)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [Linux内存管理 -- /proc/{pid}/smaps讲解](https://blog.csdn.net/armlinuxww/article/details/109022698)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值