Linux 切換進程執行的 CPU

Linux CPU

物理 CPU:cat /proc/cpuinfo | grep 'physical id' | uniq

核心:cat /proc/cpuinfo | grep 'core id' | sort | uniq

邏輯 CPU:cat /proc/cpuinfo | grep 'processor'

taskset

taskset --help

Usage: taskset [options] [mask | cpu-list] [pid|cmd [args…]]

Show or change the CPU affinity of a process.

Options:
-a, --all-tasks operate on all the tasks (threads) for a given pid
-p, --pid operate on existing given pid
-c, --cpu-list display and specify cpus in list format
-h, --help display this help
-V, --version output version information

顯示進程的 CPU affinity

taskset -p pid

結果是fff(每一位代表 CPU),那麼就是 0~11

taskset -pc pid

直接顯示 0~11

將進程綁定指定邏輯 CPU

taskset -pc cpu-id pid

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章