Skip to contentSkip to conversation

0.11: SMP guests using one host CPU only?

DISCUSSION Tomasz Chmielewski 2 participants 10 messages Oct 20, 2009 – Oct 22, 2009 KVM

lore
Share & tools
lore
#0 lore raw

On a 8 CPU host, I created a guest with 4 CPUs (-smp 4).

Unfortunately, the guest only uses one host CPU.
For example, running "cat /dev/urandom | gzip -9 >/dev/null &" several times on this guest causes load on only one host CPU.

Is it expected?

The host is running 2.6.32-rc5 and qemu-kvm-0.11. I also tried 2.6.31.5 with qemu-kvm-0.11 with the same result.

I have another machine, running 2.6.24 kernel, where it works just fine (running several CPU-intensive tasks on a guest result in several host CPUs being loaded).

Signature · 2 lines
Tomasz Chmielewski
http://wpkg.org
#1 lore raw
Quoted 6 lines · Tomasz Chmielewski

On a 8 CPU host, I created a guest with 4 CPUs (-smp 4).

Unfortunately, the guest only uses one host CPU.
For example, running "cat /dev/urandom | gzip -9 >/dev/null &" several times on this guest causes load on only one host CPU.

Is it expected?

No. What does 'top -H' show?

Signature · 2 lines
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.
#2 lore raw
Quoted 9 lines · Avi Kivity
Quoted 6 lines · Tomasz Chmielewski

On a 8 CPU host, I created a guest with 4 CPUs (-smp 4).

Unfortunately, the guest only uses one host CPU.
For example, running "cat /dev/urandom | gzip -9 >/dev/null &" several times on this guest causes load on only one host CPU.

Is it expected?

No. What does 'top -H' show?

In the guest - 4 CPUs with ~100% usage each (when I press "1"), otherwise, in the task list, multiple "cat" processes taking most CPU time (as it reads from /dev/urandom).

In the host - qemu-system-x86 (one process/thread) taking ~100% CPU; when I press "1", I see only one CPU is used 100%, 7 other CPUs are more or less not used.

guest command line:

/usr/bin/qemu-system-x86_64 -m 1024 -drive file=/srv/kvm/images/lvs2,if=virtio,cache=writeback,index=0,boot=on -net nic,vlan=0,model=virtio,macaddr=F2:4A:51:41:B1:3F -net tap,vlan=0,script=/etc/qemu-ifup -localtime -smp 4

There are 5 other guests (1 CPU) started before this guest.

Signature · 2 lines
Tomasz Chmielewski
http://wpkg.org
#3 lore raw
Quoted 7 lines · Tomasz Chmielewski
Quoted 6 lines · Avi Kivity
Quoted 5 lines · Tomasz Chmielewski

On a 8 CPU host, I created a guest with 4 CPUs (-smp 4).

Unfortunately, the guest only uses one host CPU.
For example, running "cat /dev/urandom | gzip -9 >/dev/null &" several times on this guest causes load on only one host CPU.

Quoted 9 lines
Quoted 3 lines
Quoted 1 line

Is it expected?

No. What does 'top -H' show?

In the guest - 4 CPUs with ~100% usage each (when I press "1"), otherwise, in the task list, multiple "cat" processes taking most CPU time (as it reads from /dev/urandom).

In the host - qemu-system-x86 (one process/thread) taking ~100% CPU; when I press "1", I see only one CPU is used 100%, 7 other CPUs are more or less not used.

I meant, how many qemu threads are there, and how much cpu does each take?

Signature · 2 lines
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.
#4 lore raw
Quoted 12 lines · Avi Kivity
Quoted 11 lines · Tomasz Chmielewski
Quoted 9 lines · Avi Kivity
Quoted 6 lines · Tomasz Chmielewski

On a 8 CPU host, I created a guest with 4 CPUs (-smp 4).

Unfortunately, the guest only uses one host CPU.
For example, running "cat /dev/urandom | gzip -9 >/dev/null &" several times on this guest causes load on only one host CPU.

Is it expected?

No. What does 'top -H' show?

Quoted 7 lines
Quoted 5 lines

In the guest - 4 CPUs with ~100% usage each (when I press "1"), otherwise, in the task list, multiple "cat" processes taking most CPU time (as it reads from /dev/urandom).

In the host - qemu-system-x86 (one process/thread) taking ~100% CPU; when I press "1", I see only one CPU is used 100%, 7 other CPUs are more or less not used.

I meant, how many qemu threads are there, and how much cpu does each take?

There is only one qemu thread for the 4-cpu guest.

Signature · 2 lines
Tomasz Chmielewski
http://wpkg.org
#5 lore raw
Quoted 5 lines · Tomasz Chmielewski
Quoted 2 lines

I meant, how many qemu threads are there, and how much cpu does each take?

There is only one qemu thread for the 4-cpu guest.

Not possible. Even a single-cpu guest has two threads.

What does 'ls /proc/$(pgrep qemu)/task' show?

Signature · 2 lines
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.
#6 lore raw
Quoted 8 lines · Avi Kivity
Quoted 5 lines · Tomasz Chmielewski
Quoted 2 lines

I meant, how many qemu threads are there, and how much cpu does each take?

There is only one qemu thread for the 4-cpu guest.

Not possible. Even a single-cpu guest has two threads.

"ps auxH" shuld show me all threads? I started it multiple times, and it shown 1 thread for the 4-CPU guest (with no CPU intensive tasks running - could this be a reason?).

Quoted 1 line

What does 'ls /proc/$(pgrep qemu)/task' show?

Running several CPU-intensive processes on this guest uses only one CPU on the host.

Both "ps auxH" and /proc confirm that this guest has 4-5 threads when I run several CPU-intensive apps.

Only one thread for this guest uses 100% CPU time; other threads use ~0%.

If I don't run any CPU-intensive tasks on this guests, it only runs one thread (unless I misinterpret something here).

Some 1-CPU guests have only one thread though?

# QEMU_TASKS=$(pgrep qemu)

# for QEMU_TASK in $QEMU_TASKS; do cat /proc/$QEMU_TASK/cmdline ; echo ; ls /proc/$QEMU_TASK/task ; echo ; done
/usr/bin/qemu-system-x86_64-m1024-drivefile=/srv/kvm/images/lvs2,if=virtio,cache=writeback,index=0,boot=on-netnic,vlan=0,model=virtio,macaddr=F2:4A:51:41:B1:3F-nettap,vlan=0,script=/etc/qemu-ifup-localtime-smp4
17687/  19018/  19020/  19069/

/usr/bin/qemu-system-x86_64-m1024-drivefile=/srv/kvm/images/gluster1a,if=virtio,cache=writeback,index=0,boot=on-netnic,vlan=0,model=virtio,macaddr=F2:4A:51:41:B1:3A-nettap,vlan=0,script=/etc/qemu-ifup-localtime 19220/ 24857/

/usr/bin/qemu-system-x86_64-m1024-drivefile=/srv/kvm/images/gluster2a,if=virtio,cache=writeback,index=0,boot=on-netnic,vlan=0,model=virtio,macaddr=F2:4A:51:41:B1:3B-nettap,vlan=0,script=/etc/qemu-ifup-localtime 19252/ 24896/

/usr/bin/qemu-system-x86_64-m1024-drivefile=/srv/kvm/images/gluster3a,if=virtio,cache=writeback,index=0,boot=on-netnic,vlan=0,model=virtio,macaddr=F2:4A:51:41:B1:3C-nettap,vlan=0,script=/etc/qemu-ifup-localtime 19258/ 24934/

/usr/bin/qemu-system-x86_64-m1024-drivefile=/srv/kvm/images/gluster4a,if=virtio,cache=writeback,index=0,boot=on-netnic,vlan=0,model=virtio,macaddr=F2:4A:51:41:B1:3D-nettap,vlan=0,script=/etc/qemu-ifup-localtime 25878/

/usr/bin/qemu-system-x86_64-m1024-drivefile=/srv/kvm/images/lvs1,if=virtio,cache=writeback,index=0,boot=on-netnic,vlan=0,model=virtio,macaddr=F2:4A:51:41:B1:3E-nettap,vlan=0,script=/etc/qemu-ifup-localtime 25920/

No CPU-intensive apps:

/usr/bin/qemu-system-x86_64-m1024-drivefile=/srv/kvm/images/lvs2,if=virtio,cache=writeback,index=0,boot=on-netnic,vlan=0,model=virtio,macaddr=F2:4A:51:41:B1:3F-nettap,vlan=0,script=/etc/qemu-ifup-localtime-smp4 17687/

Signature · 2 lines
Tomasz Chmielewski
http://wpkg.org
#7 lore raw
Quoted 6 lines · Tomasz Chmielewski
Quoted 5 lines · Avi Kivity
Quoted 4 lines · Tomasz Chmielewski
Quoted 2 lines

I meant, how many qemu threads are there, and how much cpu does each take?

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

There is only one qemu thread for the 4-cpu guest.

Not possible. Even a single-cpu guest has two threads.

"ps auxH" shuld show me all threads? I started it multiple times, and it shown 1 thread for the 4-CPU guest (with no CPU intensive tasks running - could this be a reason?).

No. kvm implies 2+ threads.

Quoted 6 lines
Quoted 3 lines

What does 'ls /proc/$(pgrep qemu)/task' show?

Running several CPU-intensive processes on this guest uses only one CPU on the host.

Quoted 9 lines

Both "ps auxH" and /proc confirm that this guest has 4-5 threads when I run several CPU-intensive apps.

Only one thread for this guest uses 100% CPU time; other threads use ~0%.

If I don't run any CPU-intensive tasks on this guests, it only runs one thread (unless I misinterpret something here).

Some 1-CPU guests have only one thread though?

Are you sure they're using kvm? Try 'info kvm' in the monitor. tcg will only use on thread (more will be spawned for I/O, but will eventually die).

Signature · 2 lines
I have a truly marvellous patch that fixes the bug which this
signature is too narrow to contain.
#8 lore raw
Quoted 4 lines · Avi Kivity
Quoted 2 lines

Some 1-CPU guests have only one thread though?

Are you sure they're using kvm? Try 'info kvm' in the monitor. tcg will only use on thread (more will be spawned for I/O, but will eventually die).

Indeed, that was a good suggestion - they were not using KVM (support not compiled in, and kvm didn't complain when starting).

IO and CPU speed was rather OK, so I didn't notice ;)

To sum up the thread: I guess qemu _without_ KVM will only use one CPU, even when you assign more CPUs to the guest?

Signature · 2 lines
Tomasz Chmielewski
http://wpkg.org
#9 lore raw
Quoted 2 lines · Tomasz Chmielewski

To sum up the thread: I guess qemu _without_ KVM will only use one CPU, even when you assign more CPUs to the guest?

Yes.

Signature · 1 line
error compiling committee.c: too many arguments to function