Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cset shield fails if non-trailing CPU cores are offline #37

Open
apighin opened this issue Oct 23, 2020 · 2 comments
Open

cset shield fails if non-trailing CPU cores are offline #37

apighin opened this issue Oct 23, 2020 · 2 comments

Comments

@apighin
Copy link

apighin commented Oct 23, 2020

(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
@Werkov
Copy link
Member

Werkov commented Oct 26, 2020

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?)

@apighin
Copy link
Author

apighin commented Oct 26, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants