I'm trying to use the kernel's cpuset
to isolate my process. To obtain this, I follow the instructions(2.1 Basic Usage) from kernel doc cpusets, however, it didn't work in my environment.
I have tried in both my centos7 server and my ubuntu16.04 work pc, but neither did work.
- centos kernel version:
[root@node ~]# uname -r
3.10.0-327.el7.x86_64
- ubuntu kernel version:
4.15.0-46-generic
What I have tried is as follows.
root@Latitude:/sys/fs/cgroup/cpuset# pwd
/sys/fs/cgroup/cpuset
root@Latitude:/sys/fs/cgroup/cpuset# cat cpuset.cpus
0-3
root@Latitude:/sys/fs/cgroup/cpuset# cat cpuset.mems
0
root@Latitude:/sys/fs/cgroup/cpuset# cat cpuset.cpu_exclusive
1
root@Latitude:/sys/fs/cgroup/cpuset# cat cpuset.mem_exclusive
1
root@Latitude:/sys/fs/cgroup/cpuset# find . -name cpuset.cpu_excl
usive | xargs cat
0
0
0
0
0
1
root@Latitude:/sys/fs/cgroup/cpuset# mkdir my_cpuset
root@Latitude:/sys/fs/cgroup/cpuset# echo 1 > my_cpuset/cpuset.cpus
root@Latitude:/sys/fs/cgroup/cpuset# echo 0 > my_cpuset/cpuset.mems
root@Latitude:/sys/fs/cgroup/cpuset# echo 1 > my_cpuset/cpuset.cpu_exclusive
bash: echo: write error: Invalid argument
root@Latitude:/sys/fs/cgroup/cpuset#
It just printed the error bash: echo: write error: Invalid argument
.
Google it, however, I can't get the correct answers.
As I pasted above, before my operation, I confirmed that the cpuset
root path have enabled the cpu_exclusive function and all the cpus are not been excluded by other sub-cpuset.
By using ps -o pid,psr,comm -p $PID
, I can confirm that the cpus can be assigned to some process if I don't care cpu_exclusive
. But I have also proved that if cpu_exclusive
is not set, the same cpus can also be assigned to another processes.
I don't know if it is because some pre-setting are missed.
What I expected is "using cpuset to obtain exclusive use of cpus". Can anyboy give any clues?
Thanks very much.