cpuset
config isolcpus https://blog.csdn.net/tang05505622334/article/details/96477552
(1)在/etc/default/grub中的下面一行添加最后的isolcpus参数
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash isolcpus=1,3"(这里表示1和3两个cpu被隔离,cpu序号从0开始)
也可以添加到:GRUB_CMDLINE_LINUX="isolcpus=1,3"
(2)更新/boot/grub/grub.cfg文件
常规方法是:sudo update-grub
(3)reboot
(4)检查是否生效(参考:https://unix.stackexchange.com/questions/336017/how-to-detect-if-isolcpus-is-activated/338372)
有好几种方法:
- 首先可以查看 /proc/cmdline里是不是有isolcpu参数,有的话说明本次重启确实带了这个参数
- 查看进程1的cpu affinity:
$taskset -cp 1
pid 1's current affinity list: ff5
如果没有cpu隔离的话,这里应该是fff(假设有12个逻辑cpu)
也可以查看当前进程的cpu affinity: $taskset -cp $$
- 查看所有进程、线程的cpu分配情况(可以用htop查看,也可以用ps -eo pid,cmd,psr查看所有进程cpu分配情况,用ps -To 'pid,lwp,psr,cmd' -p [PID]查看进程的所有线程的cpu分配情
stress -c `nproc`
htop
use cpuset http://blog.chinaunix.net/uid-11278770-id-3237057.html
查看进程在哪个cpu(逻辑cpu核)上跑:
moonx@moonx:~/apollo$ ps -eo pid,args:50,psr
PID COMMAND PSR
1 /sbin/init splash 10
2 [kthreadd] 7
4 [kworker/0:0H] 0
6 [mm_percpu_wq] 0
7 [ksoftirqd/0] 0
8 [rcu_sched] 5
9 [rcu_bh] 0
10 [migration/0] 0
11 [watchdog/0] 0
12 [cpuhp/0] 0
13 [cpuhp/1] 1
14 [watchdog/1] 1
15 [migration/1] 1
16 [ksoftirqd/1] 1
18 [kworker/1:0H] 1
19 [cpuhp/2] 2
20 [watchdog/2] 2
21 [migration/2] 2
22 [ksoftirqd/2] 2
24 [kworker/2:0H] 2
25 [cpuhp/3] 3
moonx@moonx:~$ cat test.cc
int main() {
while(1){ }
return 0;
}
moonx@moonx:~$ ./while1 & ./while1 &
[1] 21756
[2] 21757
moonx@moonx:~$ ps -o pid,psr,comm 21756 21757
PID PSR COMMAND
21756 2 while1
21757 4 while1
nvidia@Xavier-4:~$ uname -a
Linux Xavier-4 4.9.140-tegra #8 SMP PREEMPT Tue Mar 24 15:33:58 CST 2020 aarch64 aarch64 aarch64 GNU/Linux
sudo ./flash.sh -k kernel -k kernel-dtb -C isolcpus=2,3 jetson-xavier mmcblk0p1
posted on 2020-06-03 18:18 csuyangpeng 阅读(442) 评论(0) 编辑 收藏 举报