赞
踩
多核程序,需要查看进程绑定的CPU Affinity是否正确无误,否则性能可能大受影响,通常想知道进程所在cpu可通过下面命令查询:
pgrep 进程名得到进程pid: process_id
ps –eo pid,psr | grep process_id 就可以得到绑定的cpu id
假如多进程进程名都一致,那么一个一个查询显得不那么直观,也可以直接通过top显示出cpu affinity情况
1:top查看
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
18722 root 20 0 5232m 5.0g 32m R 56.7 8.0 1540:10 echo
19158 root 20 0 2553m 2.4g 32m R 53.3 3.8 1539:18 echo
5154 root 20 0 15300 1568 956 R 0.3 0.0 0:00.05 top
1 root 20 0 19352 508 296 S 0.0 0.0 0:02.49 init
2:输入小写f
Current Fields: AEHIOQTWKNMbcdfgjplrsuvyzX for window 1:Def
Toggle fields via field letter, type any other key to return
* A: PID = Process Id 0x00000100 PF_SUPERPRIV
* E: USER = User Name 0x00000200 PF_DUMPCORE
* H: PR = Priority 0x00000400 PF_SIGNALED
* I: NI = Nice value 0x00000800 PF_MEMALLOC
* O: VIRT = Virtual Image (kb) 0x00002000 PF_FREE_PAGES (2.5)
* Q: RES = Resident size (kb) 0x00008000 debug flag (2.5)
* T: SHR = Shared Mem size (kb) 0x00024000 special threads (2.5)
* W: S = Process Status 0x001D0000 special states (2.5)
* K: %CPU = CPU usage 0x00100000 PF_USEDFPU (thru 2.4)
* N: %MEM = Memory usage (RES)
* M: TIME+ = CPU Time, hundredths
b: PPID = Parent Process Pid
c: RUSER = Real user name
d: UID = User Id
f: GROUP = Group Name
g: TTY = Controlling Tty
j: P = Last used cpu (SMP) p: SWAP = Swapped size (kb)
l: TIME = CPU Time
r: CODE = Code size (kb)
s: DATA = Data+Stack size (kb)
u: nFLT = Page Fault count
v: nDRT = Dirty Pages count
y: WCHAN = Sleeping in Function
z: Flags = Task Flags
* X: COMMAND = Command name/line
3:输入小写j,那么上面红色那一行的j会变成大写
* J: P = Last used cpu (SMP)
4:确定回车,返回top界面,多出来的一列,就能得到该进程所在的cpu id
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ P COMMAND
18722 root 20 0 5232m 5.0g 32m R 56.9 8.0 1540:44 0 echo
19158 root 20 0 2553m 2.4g 32m R 53.6 3.8 1539:52 8 echo
5166 root 20 0 15300 1576 960 R 0.3 0.0 0:00.21 14 top
1 root 20 0 19352 508 296 S 0.0 0.0 0:02.49 13 init
当然越是占用资源越多的,越排在top的前列,越容易直观地查看,假如资源占用不多top无法查看,还是可以用开始的命令得出结果
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。