Is it possible to isolate a cpu from the linux scheduler in code, and to grant a user rights to do this so that he doesn't have to be root?
I can readily set a process/thread's cpu affinity:
// set thread affinity to core 1
cpu_set_t cpu_set;
CPU_ZERO(&cpu_set);
CPU_SET(1, &cpu_set);
sched_setaffinity(tid, sizeof(cpu_set_t), &cpu_set);
I would now like to isolate this cpu from all other processes in the system.
I know that I can do this on Redhat using tuna:
sudo tuna --cpus 1 --isolate
sudo tuna --cpus 3 --isolate
I read somewhere that it is possible to isolate as follows:
sudo echo 0 > /sys/devices/system/cpu/cpu1/online
sudo echo 1 > /sys/devices/system/cpu/cpu1/isolated
sudo echo 1 > /sys/devices/system/cpu/cpu1/online
However, attempts to create the isolated
file fail with Permission denied
Finally, is there a way to grant a particular user rights to isolate a cpu (much like it is possible to increase certain limits in /etc/security/limits.conf
)?
username hard memlock unlimited
username soft memlock unlimited
username - rtprio 99