Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
why qemu creates 4 threads for a single-core vm
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
fpemud
Guru
Guru


Joined: 15 Feb 2012
Posts: 349

PostPosted: Sun May 05, 2013 2:19 pm    Post subject: why qemu creates 4 threads for a single-core vm Reply with quote

My box is quad-core, but my virt-machine is a single-core one.
qemu created 4 threads for this virt-machine, 2 of them take much cpu time.

AFAIK, one of the 4 threads simulates the cpu of the vm.
Can anyone tell me what the functions of the rest 3 threads are? is there any relative doc?

Code:

[fpemud@fpemud-workstation /usr/lib64/fpemud-virtmanager/plugins/winxp]$ pstree -c
...
├─gnome-terminal─┬─bash───fpemud-virtmana───sh───qemu-system-x86─┬─{qemu-system-x86}
                                                                                                            ├─{qemu-system-x86}
                                                                                                            ├─{qemu-system-x86}
                                                                                                            ├─{qemu-system-x86}
...

Code:

[fpemud@fpemud-workstation /usr/lib64/fpemud-virtmanager/plugins/winxp]$ cat /tmp/new2/fqemu.cmd
/usr/bin/qemu-system-x86_64 -name "" -enable-kvm -no-user-config -nodefaults -M pc -cpu host -smp 1,sockets=1,cores=1,threads=1 -m 1024 -rtc base=localtime -drive 'file=/tmp/new2/disk-main.img,if=none,id=main-disk,format=raw' -device ide-hd,bus=ide.0,unit=0,drive=main-disk,id=main-disk,bootindex=2 -drive 'file=/tmp/new2/temp/floppy.img,if=none,id=extra-floopy,format=raw' -global isa-fdc.driveA=extra-floopy -drive 'file=/opt/fpemud-virtmanager/plugins/winxp/winxp_sp3.iso,if=none,id=extra-cdrom,readonly=on,format=raw' -device ide-cd,bus=ide.1,unit=0,drive=extra-cdrom,id=extra-cdrom,bootindex=1 -spice port=5910,addr=127.0.0.1,disable-ticketing,seamless-migration=on -device VGA,bus=pci.0,addr=0x04 -usbdevice tablet >fqemu.log 2>&1
Back to top
View user's profile Send private message
vaxbrat
l33t
l33t


Joined: 05 Oct 2005
Posts: 731
Location: DC Burbs

PostPosted: Sat May 11, 2013 5:03 am    Post subject: Is it constant or just in initial bootup? Reply with quote

I do sometimes see qemu buzzing top for a windows guest (xp, server 2003) in the initial black screen mode with however many cores I've thrown at it get maxed. It does settle right down after whatever foolishness M$ does plumbing up the devices.

I see you doing spice. I think some threads are for the spice agent and clipboarding.
Back to top
View user's profile Send private message
_______0
Guru
Guru


Joined: 15 Oct 2012
Posts: 521

PostPosted: Sat May 11, 2013 10:18 am    Post subject: Reply with quote

kvm may use whatever cpu's are availble on your system as it sees fit irrespective if you assign half cpu to your vm guest. That's the nature of threaded apps. Or do you want to hand pick threading to every single process on your system (possibly doable with cpu-set kernel option)?
Back to top
View user's profile Send private message
Hu
Moderator
Moderator


Joined: 06 Mar 2007
Posts: 21624

PostPosted: Sat May 11, 2013 5:34 pm    Post subject: Reply with quote

_______0 wrote:
kvm may use whatever cpu's are availble on your system as it sees fit irrespective if you assign half cpu to your vm guest. That's the nature of threaded apps. Or do you want to hand pick threading to every single process on your system (possibly doable with cpu-set kernel option)?
I believe the OP was curious why qemu created more threads than he could justify based on the VM configuration. KVM is not able to take more CPUs than it has threads to run, and the number of vCPUs in the guest influences how many threads KVM creates.

Threads can be restricted to a subset of CPUs via taskset.
Back to top
View user's profile Send private message
fpemud
Guru
Guru


Joined: 15 Feb 2012
Posts: 349

PostPosted: Tue May 14, 2013 4:28 am    Post subject: Reply with quote

thank you all for replying.

I think vaxbrat gives a good hint.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
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