Linux系統定位進程在使用哪個 CPU 內核
taskset -c -p
如果一個進程使用 命令明確的被固定(pinned)到 CPU 的特定內核上,你可以使用 taskset 命令找出被固定的 CPU 內核
taskset -c -p 11281
如圖 進程11281使用了4個內核cpu(我的機器是4核)沒有明確固定進程到任何 CPU 內核,輸出表明該進程可能會被安排在從0到3中的任何一個 CPU 內核。在這種情況下,taskset 不能識別該進程當前被分配給哪個 CPU 內核.
ps -o pid,psr,comm -p
ps -o pid,psr,comm -p 11281
輸出表示進程的 PID 為 11281目前在CPU 內核 0上運行著。如果該過程沒有被固定,PSR 列會根據內核可能調度該進程到不同內核而改變顯示。
htop
安裝htop yum install -y htop
啟動 htop。按 鍵,進入"Columns",在"Available Columns"下會添加 PROCESSOR。
注意:所有以前使用的命令 taskset,和 top 分配CPU 內核的 為 0,1,2,...,N-1。然而,htop 分配 CPU 內核 從 1開始(直到 N)
閱讀更多 運維搬磚工 的文章