假设我看到一个名为/dev/shm/some.segment
我如何才能找到(使用命令行):
与之相关的流程是什么?
它所在的NUMA节点?
对于 #2,我可以编写一个小的 C 程序来move_pages()
找出答案。只是想知道是否有方便的东西。
如果有必要的话,我使用 CentOS 7。
谢谢!
================
更新(尝试了harrymc的建议):
[myuser@mylinux ~]$ ipcs -pm
------ Shared Memory Creator/Last-op PIDs --------
shmid owner cpid lpid
131072 myuser 2999 3144
163841 myuser 2999 3144
262146 myuser 3226 3288
753667 myuser 3288 2006
655364 myuser 3226 2006
360453 myuser 2819 4036
622598 myuser 3226 2006
589831 myuser 3226 2006
524296 myuser 3226 2006
786441 myuser 3226 2006
819210 myuser 3226 2006
917515 myuser 4042 4050
950284 myuser 4099 4099
1048589 myuser 4106 4839
[myuser@mylinux ~]$ sudo grep 131072 /proc/*/maps
/proc/2006/maps:7f252828b000-7f252830b000 rw-s 00000000 00:04 131072 /SYSV00000000 (deleted)
/proc/2999/maps:7f2854017000-7f2854097000 rw-s 00000000 00:04 131072 /SYSV00000000 (deleted)
[myuser@mylinux ~]$ sudo grep 163841 /proc/*/maps
/proc/2006/maps:7f2527e8b000-7f252828b000 rw-s 00000000 00:04 163841 /SYSV00000000 (deleted)
/proc/2999/maps:7f2844a12000-7f2844e12000 rw-s 00000000 00:04 163841 /SYSV00000000 (deleted)
[myuser@mylinux ~]$ sudo grep 262146 /proc/*/maps
/proc/2006/maps:7f2527e2b000-7f2527e8b000 rw-s 00000000 00:04 262146 /SYSV00000000 (deleted)
/proc/3226/maps:7f28ce834000-7f28ce894000 rw-s 00000000 00:04 262146 /SYSV00000000 (deleted)
[myuser@mylinux ~]$ sudo grep 1048589 /proc/*/maps
/proc/2006/maps:7f2524c99000-7f2525499000 rw-s 00000000 00:04 1048589 /SYSV00000000 (deleted)
/proc/4106/maps:7fe5af800000-7fe5b0000000 rw-s 00000000 00:04 1048589 /SYSV00000000 (deleted)
[myuser@mylinux ~]$ ll /dev/shm/
total 1000
-rwx------ 1 myuser myuser 67108904 Sep 23 09:42 pulse-shm-1190977916
-rwx------ 1 myuser myuser 67108904 Sep 23 09:48 pulse-shm-1218108161
-rwx------ 1 myuser myuser 67108904 Sep 23 10:03 pulse-shm-1238825830
-rwx------ 1 myuser myuser 67108904 Sep 23 10:03 pulse-shm-13579424
-rwx------ 1 myuser myuser 67108904 Sep 23 09:42 pulse-shm-2544170821
-rwx------ 1 gdm gdm 67108904 Sep 23 09:42 pulse-shm-2626080508
-rwx------ 1 gdm gdm 67108904 Sep 23 09:42 pulse-shm-3289673610
-rwx------ 1 myuser myuser 67108904 Sep 23 09:42 pulse-shm-4099527713
-rwx------ 1 myuser myuser 67108904 Sep 23 09:42 pulse-shm-52369360
[myuser@mylinux ~]$ lsof /dev/shm/pulse-shm-1190977916
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
pulseaudi 2663 myuser mem REG 0,19 67108904 34513 /dev/shm/pulse-shm-1190977916
[myuser@mylinux ~]$ ps aux | grep 2663
myuser 2663 0.2 0.0 640560 8044 ? S<l 09:42 0:03 /usr/bin/pulseaudio --start --log-target=syslog
myuser 8144 0.0 0.0 112712 972 pts/0 S+ 10:05 0:00 grep --color=auto 2663
[myuser@mylinux ~]$
答案1
该lsof
命令应该提供大部分信息。
您可以用 grep 来查找其输出shmid
,您可以使用 来找到它ipcs -m
。