View previous topic :: View next topic |
Author |
Message |
jpp_ Tux's lil' helper
Joined: 23 Oct 2009 Posts: 110 Location: Argentina
|
Posted: Mon Jun 20, 2022 3:18 pm Post subject: Isolate CPU for kvm |
|
|
Hello.
I move from systemd to openrc again
And i wish to have a hook qemu working
cat /etc/libvirt/hooks/qemu
Code: | #!/bin/sh
command=$2
if [ "$command" = "started" ]; then
systemctl set-property --runtime -- system.slice AllowedCPUs=0,1,2,3,4,5,16,17,18,19,20,21
systemctl set-property --runtime -- user.slice AllowedCPUs=0,1,2,3,4,5,16,17,18,19,20,21
systemctl set-property --runtime -- init.scope AllowedCPUs=0,1,2,3,4,5,16,17,18,19,20,21
elif [ "$command" = "release" ]; then
systemctl set-property --runtime -- system.slice AllowedCPUs=0-31
systemctl set-property --runtime -- user.slice AllowedCPUs=0-31
systemctl set-property --runtime -- init.scope AllowedCPUs=0-31
fi
|
How can i do this with openrc?
Regards |
|
Back to top |
|
|
user Apprentice
Joined: 08 Feb 2004 Posts: 200
|
Posted: Mon Jun 20, 2022 9:22 pm Post subject: |
|
|
Hi jpp_
qemu don't support native cpu pinning after years and cgroups setup maybe too hassle so playing with taskset can be useful.
Something like:
Code: |
sleep 15 && ps -To spid --no-headers -p $(pidof qemu-system-x86_64) | xargs -n1 taskset --cpu-list --pid 0,1,2,3,4,5,16,17,18,19,20,21
|
(there can be additional qemu IO worker processes later on) |
|
Back to top |
|
|
szatox Advocate
Joined: 27 Aug 2013 Posts: 3131
|
Posted: Mon Jun 20, 2022 11:42 pm Post subject: |
|
|
Haven't tried it, but I think it could be done with cgroups.
Like in, drop the process and cpu cores it's supposed to run on into the same cgroup. If I understand it correctly, the process and all its children spawned afterwards will be pinned to those selected cores and also those cores will be reserved for said processes.
Looks promising.
Taskset is a bit simpler, it can prevent a process from running on some cores, but it's very easy to use, so yeah, it is a good first pick.
I wonder what you're trying to achieve though, why is default scheduling not good enough? Are your processes constantly getting kicked around causing cache misses or something like that? |
|
Back to top |
|
|
jpp_ Tux's lil' helper
Joined: 23 Oct 2009 Posts: 110 Location: Argentina
|
Posted: Tue Jun 21, 2022 3:05 pm Post subject: |
|
|
For what i read, im trying to use one physical part of the cpu with his cache only for the vm, so the host dont see / use it and add latency, and also i use part of the other half to iothread and qemu.
Part of the VM xml
Code: | <memory unit="KiB">24971520</memory>
<currentMemory unit="KiB">24971520</currentMemory>
<vcpu placement="static">16</vcpu>
<iothreads>2</iothreads>
<cputune>
<vcpupin vcpu="0" cpuset="8"/>
<vcpupin vcpu="1" cpuset="24"/>
<vcpupin vcpu="2" cpuset="9"/>
<vcpupin vcpu="3" cpuset="25"/>
<vcpupin vcpu="4" cpuset="10"/>
<vcpupin vcpu="5" cpuset="26"/>
<vcpupin vcpu="6" cpuset="11"/>
<vcpupin vcpu="7" cpuset="27"/>
<vcpupin vcpu="8" cpuset="12"/>
<vcpupin vcpu="9" cpuset="28"/>
<vcpupin vcpu="10" cpuset="13"/>
<vcpupin vcpu="11" cpuset="29"/>
<vcpupin vcpu="12" cpuset="14"/>
<vcpupin vcpu="13" cpuset="30"/>
<vcpupin vcpu="14" cpuset="15"/>
<vcpupin vcpu="15" cpuset="31"/>
<emulatorpin cpuset="7,23"/>
<iothreadpin iothread="1" cpuset="6,22"/>
<iothreadpin iothread="2" cpuset="7,23"/>
<vcpusched vcpus="0" scheduler="rr" priority="1"/>
<vcpusched vcpus="1" scheduler="rr" priority="1"/>
<vcpusched vcpus="2" scheduler="rr" priority="1"/>
<vcpusched vcpus="3" scheduler="rr" priority="1"/>
<vcpusched vcpus="4" scheduler="rr" priority="1"/>
<vcpusched vcpus="5" scheduler="rr" priority="1"/>
<vcpusched vcpus="6" scheduler="rr" priority="1"/>
<vcpusched vcpus="7" scheduler="rr" priority="1"/>
<vcpusched vcpus="8" scheduler="rr" priority="1"/>
<vcpusched vcpus="9" scheduler="rr" priority="1"/>
<vcpusched vcpus="10" scheduler="rr" priority="1"/>
<vcpusched vcpus="11" scheduler="rr" priority="1"/>
<vcpusched vcpus="12" scheduler="rr" priority="1"/>
<vcpusched vcpus="13" scheduler="rr" priority="1"/>
<vcpusched vcpus="14" scheduler="rr" priority="1"/>
<vcpusched vcpus="15" scheduler="rr" priority="1"/>
<iothreadsched iothreads="2" scheduler="fifo" priority="98"/>
</cputune> |
Code: | ~
╰─λ lscpu -e
CPU NODE SOCKET CORE L1d:L1i:L2:L3 ONLINE MAXMHZ MINMHZ MHZ
0 0 0 0 0:0:0:0 yes 5083.3979 2200.0000 2897.301
1 0 0 1 1:1:1:0 yes 5083.3979 2200.0000 2200.000
2 0 0 2 2:2:2:0 yes 5083.3979 2200.0000 3318.368
3 0 0 3 3:3:3:0 yes 5083.3979 2200.0000 3400.000
4 0 0 4 4:4:4:0 yes 5083.3979 2200.0000 2200.000
5 0 0 5 5:5:5:0 yes 5083.3979 2200.0000 2200.000
6 0 0 6 6:6:6:0 yes 5083.3979 2200.0000 2200.000
7 0 0 7 7:7:7:0 yes 5083.3979 2200.0000 2200.000
8 0 0 8 8:8:8:1 yes 5083.3979 2200.0000 3400.000
9 0 0 9 9:9:9:1 yes 5083.3979 2200.0000 4666.853
10 0 0 10 10:10:10:1 yes 5083.3979 2200.0000 2200.000
11 0 0 11 11:11:11:1 yes 5083.3979 2200.0000 2200.000
12 0 0 12 12:12:12:1 yes 5083.3979 2200.0000 2200.000
13 0 0 13 13:13:13:1 yes 5083.3979 2200.0000 2200.000
14 0 0 14 14:14:14:1 yes 5083.3979 2200.0000 3441.394
15 0 0 15 15:15:15:1 yes 5083.3979 2200.0000 2200.000
16 0 0 0 0:0:0:0 yes 5083.3979 2200.0000 2200.000
17 0 0 1 1:1:1:0 yes 5083.3979 2200.0000 2200.000
18 0 0 2 2:2:2:0 yes 5083.3979 2200.0000 2200.000
19 0 0 3 3:3:3:0 yes 5083.3979 2200.0000 2200.000
20 0 0 4 4:4:4:0 yes 5083.3979 2200.0000 2200.000
21 0 0 5 5:5:5:0 yes 5083.3979 2200.0000 2200.000
22 0 0 6 6:6:6:0 yes 5083.3979 2200.0000 2200.000
23 0 0 7 7:7:7:0 yes 5083.3979 2200.0000 2200.000
24 0 0 8 8:8:8:1 yes 5083.3979 2200.0000 2200.000
25 0 0 9 9:9:9:1 yes 5083.3979 2200.0000 2200.000
26 0 0 10 10:10:10:1 yes 5083.3979 2200.0000 2200.000
27 0 0 11 11:11:11:1 yes 5083.3979 2200.0000 2200.000
28 0 0 12 12:12:12:1 yes 5083.3979 2200.0000 2200.000
29 0 0 13 13:13:13:1 yes 5083.3979 2200.0000 2200.000
30 0 0 14 14:14:14:1 yes 5083.3979 2200.0000 2200.000
31 0 0 15 15:15:15:1 yes 5083.3979 2200.0000 2200.000
|
|
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|