qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] Performance of usb tablet over ehci
@ 2012-12-11 19:45 luo_brian
  2012-12-11 22:40 ` Hans de Goede
  0 siblings, 1 reply; 7+ messages in thread
From: luo_brian @ 2012-12-11 19:45 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 2759 bytes --]

 I just noticed a patch recently submitted to qemu, attempting to lower the cpu load for idle vm using usb tablet emulation.

This is the comment of commit 427e3aa151c749225364d0c30640e2e3c1756d9d:

usb-tablet: Allow connecting to ehci

Our ehci code has is capable of significantly lowering the wakeup rate
for the hcd emulation while the device is idle. It is possible to add
similar code ot the uhci emulation, but that simply is not there atm,
and there is no reason why a (virtual) usb-tablet can not be a USB-2 device.

Making usb-hid devices connect to the emulated ehci controller instead
of the emulated uhci controller on vms which have both lowers the cpuload
for a fully idle vm from 20% to 2-3% (on my laptop).

An alternative implementation to using a property to select the tablet
type, would be simply making it a new device type, ie usb-tablet2, but the
downside of that is that this will require libvirt changes to be available
through libvirt at all, and then management tools changes to become the
default for new vms, where as using a property will automatically get
any pc-1.3 type vms the lower cpuload.

I tried to connect usb tablet to ehci by libvirt, which automatically generted qemu command as follows. However, the cpuload of idle vm is still much higher than PS2 mouse emulation on my laptop. (usb-tablet: 30-35%, usb-tablet2: 16-19%, PS2 mouse: 9-10%). Is there something wrong with my configuration?

 57         <controller type='usb' index='0' model='ehci'/>
 58         <input type='tablet' bus='usb'>
 59             <address type='usb' bus='0' port='1'/>
 60         </input>


/usr/bin/qemu-kvm -name winxp -S -cpu host -enable-kvm -m 1024 -smp 2,sockets=2,cores=1,threads=1 -uuid 883d614a-30e9-474d-b81e-c131e4a06249 -no-user-config -nodefaults -chardev socket,id=charmonitor,path=/var/lib/libvirt/qemu/winxp.monitor,server,nowait -mon chardev=charmonitor,id=monitor,mode=control -rtc base=localtime -no-shutdown -device usb-ehci,id=usb,bus=pci.0,addr=0x5 -device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x6 -drive file=/home/vm/winxp/winxp.img,if=none,id=drive-virtio-disk0,format=qcow2,cache=none,aio=native -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x7,drive=drive-virtio-disk0,id=virtio-disk0,bootindex=1 -netdev tap,fd=23,id=hostnet0,vhost=on,vhostfd=24 -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:65:f3:de,bus=pci.0,addr=0x3 -chardev spicevmc,id=charchannel0,name=vdagent -device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=com.redhat.spice.0 -device usb-tablet,id=input0,bus=usb.0,port=1 -spice port=5900,addr=0.0.0.0,disable-ticketing,seamless-migration=on -vga qxl -global qxl-vga.vram_size=67108864 -device AC97,id=sound0,bus=pci.0,addr=0x4


[-- Attachment #2: Type: text/html, Size: 3248 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] Performance of usb tablet over ehci
  2012-12-11 19:45 [Qemu-devel] Performance of usb tablet over ehci luo_brian
@ 2012-12-11 22:40 ` Hans de Goede
  2012-12-12  8:29   ` Gerd Hoffmann
  0 siblings, 1 reply; 7+ messages in thread
From: Hans de Goede @ 2012-12-11 22:40 UTC (permalink / raw)
  To: luo_brian; +Cc: qemu-devel

Hi,

On 12/11/2012 08:45 PM, luo_brian wrote:
>   I just noticed a patch recently submitted to qemu, attempting to lower the cpu load for idle vm using usb tablet emulation.
>
> This is the comment of commit 427e3aa151c749225364d0c30640e2e3c1756d9d:
>
> usb-tablet: Allow connecting to ehci
>
> Our ehci code has is capable of significantly lowering the wakeup rate
> for the hcd emulation while the device is idle. It is possible to add
> similar code ot the uhci emulation, but that simply is not there atm,
> and there is no reason why a (virtual) usb-tablet can not be a USB-2 device.
>
> Making usb-hid devices connect to the emulated ehci controller instead
> of the emulated uhci controller on vms which have both lowers the cpuload
> for a fully idle vm from 20% to 2-3% (on my laptop).
>
> An alternative implementation to using a property to select the tablet
> type, would be simply making it a new device type, ie usb-table! t2, but the
> downside of that is that this will require libvirt changes to be available
> through libvirt at all, and then management tools changes to become the
> default for new vms, where as using a property will automatically get
> any pc-1.3 type vms the lower cpuload.
>
> I tried to connect usb tablet to ehci by libvirt, which automatically generted qemu command as follows. However, the cpuload of idle vm is still much higher than PS2 mouse emulation on my laptop. (usb-tablet: 30-35%, usb-tablet2: 16-19%, PS2 mouse: 9-10%). Is there something wrong with my configuration?

Given that the cpu-load with the usb-tablet almost halved I think the patches
are working as intended and your config is ok :)

My tests were run with a Linux guest (with the udev rule for enabling usb
remote wakeup disabled), it is possible that Windows uses the HID idle report
feature which would still cause some wakeups. Also note that if you actually
move the mouse over the vm window this will temporarily increase the
wakeup rate too.

In the end the problem stays that usb uses a polling model versus the
async interrupt model ps2 uses.

Regards,

Hans

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] Performance of usb tablet over ehci
  2012-12-11 22:40 ` Hans de Goede
@ 2012-12-12  8:29   ` Gerd Hoffmann
  2012-12-13 15:25     ` luo_brian
  0 siblings, 1 reply; 7+ messages in thread
From: Gerd Hoffmann @ 2012-12-12  8:29 UTC (permalink / raw)
  To: Hans de Goede; +Cc: luo_brian, qemu-devel

  Hi,

> In the end the problem stays that usb uses a polling model versus the
> async interrupt model ps2 uses.

If your guest supports usb 3.0 (aka xhci) you can try that.  The
hardware design allows to not poll in the emulation, which brings down
the cpu load even more, should come pretty close to ps/2 mouse levels.

cheers,
  Gerd

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] Performance of usb tablet over ehci
  2012-12-12  8:29   ` Gerd Hoffmann
@ 2012-12-13 15:25     ` luo_brian
  2012-12-13 15:32       ` Gerd Hoffmann
  0 siblings, 1 reply; 7+ messages in thread
From: luo_brian @ 2012-12-13 15:25 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: Hans de Goede, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 730 bytes --]

I was using win7 32bit, and configured usb controller nec-xhci as well as usb tablet emulation. But it didn't work. Seems usb tablet failed to connect to xhci controller.

57 <controller type='usb' index='0' model='nec-xhci'/>
58 <input type='tablet' bus='usb'>
59 <address type='usb' bus='0' port='1'/>
60 </input>

At 2012-12-12 16:29:20,"Gerd Hoffmann" <kraxel@redhat.com> wrote: >  Hi, > >> In the end the problem stays that usb uses a polling model versus the >> async interrupt model ps2 uses. > >If your guest supports usb 3.0 (aka xhci) you can try that.  The >hardware design allows to not poll in the emulation, which brings down >the cpu load even more, should come pretty close to ps/2 mouse levels. > >cheers, >  Gerd

[-- Attachment #2: Type: text/html, Size: 1384 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] Performance of usb tablet over ehci
  2012-12-13 15:25     ` luo_brian
@ 2012-12-13 15:32       ` Gerd Hoffmann
  2012-12-19 17:48         ` Hao Luo
  0 siblings, 1 reply; 7+ messages in thread
From: Gerd Hoffmann @ 2012-12-13 15:32 UTC (permalink / raw)
  To: luo_brian; +Cc: Hans de Goede, qemu-devel

On 12/13/12 16:25, luo_brian wrote:
> I was using win7 32bit, and configured usb controller nec-xhci as
> well as usb tablet emulation. But it didn't work. Seems usb tablet
> failed to connect to xhci controller.

win7 doesn't ship with a xhci driver (win8 does).

cheers,
  Gerd

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] Performance of usb tablet over ehci
  2012-12-13 15:32       ` Gerd Hoffmann
@ 2012-12-19 17:48         ` Hao Luo
  2012-12-20  6:54           ` Gerd Hoffmann
  0 siblings, 1 reply; 7+ messages in thread
From: Hao Luo @ 2012-12-19 17:48 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: Hans de Goede, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1040 bytes --]

Gerd,

Thanks very much.

I tried to install usb 3.0 driver in win7 guest, and the cpu load decreased to about 9%, as much as PS2 mouse emulation.

BTW, there are >90 fds polled by qemu_iohandler_poll(). According to the perf profiling report, when uhci hid mouse is enabled, this function will be called much more frequently than using PS2 mouse. Any source code or functions I should refer to so that I can find out which fds take most of CPU time? 

2012-12-20



Hao Luo



发件人:Gerd Hoffmann
发送时间:2012-12-13 23:32
主题:Re: [Qemu-devel] Performance of usb tablet over ehci
收件人:"luo_brian"<luo_brian@126.com>
抄送:"Hans de Goede"<hdegoede@redhat.com>,"qemu-devel"<qemu-devel@nongnu.org>

On 12/13/12 16:25, luo_brian wrote: 
> I was using win7 32bit, and configured usb controller nec-xhci as 
> well as usb tablet emulation. But it didn't work. Seems usb tablet 
> failed to connect to xhci controller. 

win7 doesn't ship with a xhci driver (win8 does). 

cheers, 
  Gerd 

[-- Attachment #2: Type: text/html, Size: 3173 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [Qemu-devel] Performance of usb tablet over ehci
  2012-12-19 17:48         ` Hao Luo
@ 2012-12-20  6:54           ` Gerd Hoffmann
  0 siblings, 0 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2012-12-20  6:54 UTC (permalink / raw)
  To: Hao Luo; +Cc: Hans de Goede, qemu-devel

On 12/19/12 18:48, Hao Luo wrote:
> Gerd,
> 
> Thanks very much.
> 
> I tried to install usb 3.0 driver in win7 guest, and the cpu load
> decreased to about 9%, as much as PS2 mouse emulation.

Good to see this actually meets the expectations ;)

> BTW, there are >90 fds polled by qemu_iohandler_poll(). According to
> the perf profiling report, when uhci hid mouse is enabled, this
> function will be called much more frequently than using PS2 mouse.

Yes.  It's called each time qemu goes sleep, even if sleeping for a very
short time only.

> Any source code or functions I should refer to so that I can find out
> which fds take most of CPU time?

The problem isn't the high number of fds, the problem which causes the
high load is the high wakeup rate needed by uhci emulation (which is
largely dictated by the design of the hardware we are emulating).

cheers,
  Gerd

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2012-12-20  6:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-11 19:45 [Qemu-devel] Performance of usb tablet over ehci luo_brian
2012-12-11 22:40 ` Hans de Goede
2012-12-12  8:29   ` Gerd Hoffmann
2012-12-13 15:25     ` luo_brian
2012-12-13 15:32       ` Gerd Hoffmann
2012-12-19 17:48         ` Hao Luo
2012-12-20  6:54           ` Gerd Hoffmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).