[pve-devel] qemu-server: cgroups && cpu.shares implementation

Alexandre DERUMIER aderumier at odiso.com
Thu May 28 15:25:56 CEST 2015


better with scope:


systemd-run --scope --slice=qemu --unit 100 -p CPUShares=499 /usr/bin/kvm -id 100 ...


like this, cgroup is autoremoved on process stop.


----- Mail original -----
De: "aderumier" <aderumier at odiso.com>
À: "dietmar" <dietmar at proxmox.com>
Cc: "pve-devel" <pve-devel at pve.proxmox.com>
Envoyé: Jeudi 28 Mai 2015 15:21:10
Objet: Re: [pve-devel] qemu-server: cgroups && cpu.shares implementation

>>Another way could be use launch qemu with systemd-run, I think we can specify cgroup (slice in systemd) directly. 

for example: 

systemd-run --remain-after-exit --slice=qemu --unit=100 -p CPUShares=499 /usr/bin/kvm -id 100 .... 


Seem better than hacking qemu ? 


----- Mail original ----- 
De: "aderumier" <aderumier at odiso.com> 
À: "Stefan Priebe" <s.priebe at profihost.ag> 
Cc: "pve-devel" <pve-devel at pve.proxmox.com> 
Envoyé: Jeudi 28 Mai 2015 15:02:36 
Objet: Re: [pve-devel] qemu-server: cgroups && cpu.shares implementation 

Another way could be use launch qemu with systemd-run, I think we can specify cgroup (slice in systemd) directly. 


----- Mail original ----- 
De: "aderumier" <aderumier at odiso.com> 
À: "Stefan Priebe" <s.priebe at profihost.ag> 
Cc: "pve-devel" <pve-devel at pve.proxmox.com> 
Envoyé: Jeudi 28 Mai 2015 13:36:25 
Objet: Re: [pve-devel] qemu-server: cgroups && cpu.shares implementation 

>>Not tested but what about this: 
>> 
>>fork() 
>># in child 
>>put current pid into cgroup 
>>exec kvm 

Yes, I think it should work, if we put the pid of the forked process in cgroups. 

Other child threads should go automaticaly to the parent cgroup. 
I have done tests with hotplug virtio-net with vhost threads, or iothread drive, 
and their threads pid go to the cgroup. 



----- Mail original ----- 
De: "Stefan Priebe" <s.priebe at profihost.ag> 
À: "dietmar" <dietmar at proxmox.com>, "aderumier" <aderumier at odiso.com>, "pve-devel" <pve-devel at pve.proxmox.com> 
Envoyé: Jeudi 28 Mai 2015 12:55:29 
Objet: Re: [pve-devel] qemu-server: cgroups && cpu.shares implementation 

Am 28.05.2015 um 12:51 schrieb Dietmar Maurer: 
>> Here the patches serie for implemtation of cpuunits through cgroups 
> 
> If you implement it inside qemu-server you have a race-condition, because 
> you do it too late and qemu already started the threads? Or maybe only parts 
> of necessary threads are already created? 
> 
> So wouldn't it be easier to do it inside qemu? 

Not tested but what about this: 

fork() 
# in child 
put current pid into cgroup 
exec kvm 

# parent 
... 

<= wouldn't this put all threads kvm creates automatically into the 
right cgroup? 

Stefan 

_______________________________________________ 
pve-devel mailing list 
pve-devel at pve.proxmox.com 
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel 
_______________________________________________ 
pve-devel mailing list 
pve-devel at pve.proxmox.com 
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel 



More information about the pve-devel mailing list