CPU isolation and proc pinning
Configure Kernel for CPU isolation
sysinfo: Centos 7 x64
check current kernel in use
[root@min1 ~]# grubby --default-kernel
check current kernel arguments
[root@min1 ~]# grubby --info=/boot/vmlinuz-3.10.0-862.14.4.el7.x86_64
index=0
kernel=/boot/vmlinuz-3.10.0-862.14.4.el7.x86_64
args="ro no_timer_check console=tty0 console=ttyS0,115200n8 net.ifnames=0 biosdevname=0 elevator=noop crashkernel=auto LANG=en_US.UTF-8"
root=UUID=b5b20816-947c-4616-b15a-abaae4afe31b
initrd=/boot/initramfs-3.10.0-862.14.4.el7.x86_64.img
title=CentOS Linux (3.10.0-862.14.4.el7.x86_64) 7 (Core)
add cpu isolation for kernel
[root@min1 ~]# grubby --update-kernel=/boot/vmlinuz-3.10.0-862.14.4.el7.x86_64 --args=isolcpus=2,3
or to update ALL kernels
[root@min1 ~]# grubby --update-kernel=ALL --args=isolcpus=2,3
reboot to pick up changes
if arg already exists and you need to insert an additional argument, pass the entire arg string, not just the update
[root@min1 ~]# grubby --update-kernel=ALL --args=isolcpus=1,2,3,4
remove cpu isolation
grubby --remove-args="isolcpus=2,3" --update-kernel=ALL
isolate a process to particular CPU or range of CPUs
check what CPU process is pinned to
pidof q
342923 322403 322392 322381 322370 322359 322348 322337 322327 322283 322271 322259 322247 322235 322223 322211 322186 322174 322162 322150 322138 322126 322115 322103 322091
[11:44 root@min1:grub.d ]# cat /proc/342923/status | grep Cpus_allowed_list
Cpus_allowed_list: 0-24,26,48-447
start a process and pin to CPU # 26,27
taskset -c 26,27 /opt/kdb/q/l64/q
change pinned CPU on a running PID #1214
taskset -p -c 26,27 1214