Is it possible to prevent a CPU core from being used by the OS in Linux? The maxcpus=<n>
boot parameter prevents specified number of cores from being seen in the OS. I want that all cores be visible but yet only some be used by the OS for scheduling processes.
EDIT: This is required to ensure that critical processes can be scheduled on a core and remaining not absolutely important but highly CPU intensive processes can compete amongst themselves for the other cores. This is on CentOS 6.
Use the
isolcpus
parameter on the kernel command line to isolate certain cores from user-space tasks. Quoting from kernel boot parameters documentation:You can disable processors for example (core0) with
echo 0 > /sys/devices/system/cpu/cpu0/online
and enable withecho 1 > /sys/devices/system/cpu/cpu0/online
You can verify the state with
cat /proc/cpuinfo
Generic answer... until you provide more information.
You may want to use the CPU isolation tool of choice for your distribution. Also, cgroups may be relevant, depending on what you specifically trying to accomplish.
difference between taskset and cpuset
Edit:
You're looking for a CPU shield. On EL6, you may want to read up on cgroups and the
cgred
daemon andcgconfig
package.For instance:
/etc/cgconfig.conf:
The snippet above limits processes in the "ppro-users" cgroup to certain CPUs. I augment that by using the cgred package to identify and manage processes that should belong to that cgroup.
/etc/cgrules.conf