SUSE/cpuset

cset shield fails if non-trailing CPU cores are offline

Opened this issue · 2 comments

(Logfile attached.)

root@localhost:~# cset set
cset: 
         Name       CPUs-X    MEMs-X Tasks Subs Path
 ------------ ---------- - ------- - ----- ---- ----------
         root       0-15 y       0 y   224    0 /

# Take "last" core offline
root@localhost:~# echo 0 > /sys/devices/system/cpu/cpu15/online 

root@localhost:~# cset shield -c2-5
cset: --> activating shielding:
cset: moving 37 tasks from root into system cpuset...
[==================================================]%
cset: "system" cpuset of CPUSPEC(0-1,6-14) with 37 tasks running
cset: "user" cpuset of CPUSPEC(2-5) with 0 tasks running

# cset shield succeeds
root@localhost:~# cset set
cset: 
         Name       CPUs-X    MEMs-X Tasks Subs Path
 ------------ ---------- - ------- - ----- ---- ----------
         root       0-14 y       0 y   187    2 /
         user        2-5 y       0 n     0    0 /user
       system   0-1,6-14 y       0 n    37    0 /system

root@localhost:~# cset shield -r   
cset: --> deactivating/reseting shielding
cset: moving 0 tasks from "/user" user set to root set...
cset: moving 37 tasks from "/system" system set to root set...
[==================================================]%
cset: deleting "/user" and "/system" sets
cset: done

root@localhost:~# cset set
cset: 
         Name       CPUs-X    MEMs-X Tasks Subs Path
 ------------ ---------- - ------- - ----- ---- ----------
         root       0-14 y       0 y   225    0 /

# Restore "last" core
root@localhost:~# echo 1 > /sys/devices/system/cpu/cpu15/online 
# Take second last core offline
root@localhost:~# echo 0 > /sys/devices/system/cpu/cpu14/online 

root@localhost:~# cset set
cset: 
         Name       CPUs-X    MEMs-X Tasks Subs Path
 ------------ ---------- - ------- - ----- ---- ----------
         root    0-13,15 y       0 y   225    0 /

# cset shield fails
root@localhost:~# cset -l /tmp/bad_shield shield -c2-5
cset: --> failed to create shield, hint: do other cpusets exist?
cset: **> [Errno 22] Invalid argument

# HOWEVER! I can manually create a non-contiguous set (not using "shield")
[bad_shield.txt](https://github.com/lpechacek/cpuset/files/5431496/bad_shield.txt)


root@localhost:~# cset set
cset: 
         Name       CPUs-X    MEMs-X Tasks Subs Path
 ------------ ---------- - ------- - ----- ---- ----------
         root    0-13,15 y       0 y   212    0 /

root@localhost:~# cset set -c2-5 --cpu_exclusive user
cset: --> created cpuset "user"
root@localhost:~# cset set
cset: 
         Name       CPUs-X    MEMs-X Tasks Subs Path
 ------------ ---------- - ------- - ----- ---- ----------
         root    0-13,15 y       0 y   212    1 /
         user        2-5 y       0 n     0    0 /user

Thanks for the report.

I peeked into the code and this is rather a feature request than bug report. The shielding currently doesn't support CPU hotplugging. (I.e. offlining the trailing cpus makes it work rather accidentally.)

What is the use case behind this? (Or do you happen to work on system with non-contiguous CPU list by default?)

My use case is an odd one. I am attempting to emulate a non-hyperthreaded processor on a hyperthreaded processor. I am doing this by offlining the secondary virtual cores on the individual physical cores. On some AMD platforms, the virtual to physical is [0,1] -> 0, [2,3] -> 1, etc. So, I end up offlining virtual 1,3, etc. leading to the non-contiguous CPU list.