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