Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I know the list of isolated cpu for the current running kernel?

So far my application requests the list of isolated cpu in its configuration file. Then it uses pthread_setaffinity_np() in order to force running on that kind of cpu. Usually the guy who made the configuration file goes into the file /boot/grub/menu.lst and pick the correct entry, in order to know what is the current list of isolated cpu.

title CentOS (2.6.32-431.5.1.el6.x86_64)
        root (hd0,1)
        kernel ... isolcpus=4-15

So, I would like to avoid the guy to have to enter that list manually in the configuration file. Is there a possible way for my application to get that list programatically?

like image 598
yves Baumes Avatar asked Oct 19 '25 10:10

yves Baumes


2 Answers

cat /sys/devices/system/cpu/isolated
like image 161
Brendan Avatar answered Oct 21 '25 22:10

Brendan


Only in a very backwards way - /proc/cmdline has the current kernel command line which you can parse to get the parameters the kernel was booted with, including isolcpus

like image 22
gby Avatar answered Oct 21 '25 22:10

gby