All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Webb <chris@arachsys.com>
To: Avi Kivity <avi@redhat.com>
Cc: "Jernej Simončič" <jernej's-kvm@eternallybored.org>,
	kvm@vger.kernel.org, qemu-devel@nongnu.org
Subject: High CPU use of -usbdevice tablet (was Re: KVM usability)
Date: Sun, 4 Apr 2010 13:31:16 +0100	[thread overview]
Message-ID: <20100404123116.GA19866@arachsys.com> (raw)
In-Reply-To: <4B938F9D.7010207@redhat.com>

Avi Kivity <avi@redhat.com> writes:

> On 03/02/2010 11:34 AM, Jernej Simončič wrote:
> >On Tuesday, March 2, 2010, 9:21:18, Chris Webb wrote:
> >
> >>I remember about a year ago, someone asserting on the list that -usbdevice
> >>tablet was very CPU intensive even when not in use, and should be avoided if
> >>mouse support wasn't needed, e.g. on non-graphical VMs. Was that actually a
> >>significant hit, and is it still true today?
> >It would appear that this is still the case, at least on slower hosts
> >- on Atom Z530 (1,6GHz), the XP VM uses ~30% CPU when idle with
> >-usbdevice tablet, but only ~4% without it. However, on a faster host
> >(Core2 Quad 2,66GHz), there's practically no difference (Vista x64 VM
> >uses ~1% CPU when idle regardless of -usbdevice tablet).
> 
> Looks like the tablet is set to 100 Hz polling rate.  We may be able
> to get away with 30 Hz or even less (ep_bInterval, in ms, in
> hw/usb-wacom.c).

Hi Avi. Sorry for the very late follow-up, but I decided to experiment with
this. The cpu impact of the usb tablet device shows up fairly clearly on a
crude test on my (relatively low-spec) desktop. Running an idle Fedora 11
livecd on qemu-kvm 0.12.3, top shows around 0.1% of my cpu in use, but this
increases to roughly 5% when specifying -usbdevice tablet, and more detailed
examination with perf record/report suggests about a factor of thirty too.

It's actually a more general symptom with USB or at least HID devices by the
look of things: although -usb doesn't increase CPU use on its own, the same
increase in load can also be triggered by -usbdevice keyboard or mouse.
However, running with all three of -usbdevice mouse, keyboard and tablet
doesn't increase load any more than just one of these.

Changing the USB tablet polling interval from 10ms to 100ms in both
hw/usb-wacom.c and hw/usb-hid.c made no difference except the an increase in
bInterval shown in lsusb -v in the guest and the hint of jerky mouse
movement I expected from setting this value so high. A similar change to the
polling interval for the keyboard and mouse also made no difference to their
performance impact.

Taking the FRAME_TIMER_FREQ down to 100 in hw/usb-uhci.c does seem to reduce
the CPU load quite a bit, but at the expense of making the USB tablet (and
presumably all other USB devices) very laggy.

Could there be some bug here that causes the usb hid devices to wake qemu at
the maximum rate possible (FRAME_TIMER_FREQ?) rather than the configured
polling interval?

Best wishes,

Chris.

PS Vmmouse works fine as an absolute pointing device in the place of
-usbdevice tablet without the performance impact, but this isn't supported
out of the box with typical linux live CDs (e.g. Fedora 11 and 12 or
Knoppix) so unfortunately it's probably less suitable as a default
configuration to expose to end-users.

WARNING: multiple messages have this Message-ID (diff)
From: Chris Webb <chris@arachsys.com>
To: Avi Kivity <avi@redhat.com>
Cc: kvm@vger.kernel.org,
	"Jernej Simončič" <jernej's-kvm@eternallybored.org>,
	qemu-devel@nongnu.org
Subject: [Qemu-devel] High CPU use of -usbdevice tablet (was Re: KVM usability)
Date: Sun, 4 Apr 2010 13:31:16 +0100	[thread overview]
Message-ID: <20100404123116.GA19866@arachsys.com> (raw)
In-Reply-To: <4B938F9D.7010207@redhat.com>

Avi Kivity <avi@redhat.com> writes:

> On 03/02/2010 11:34 AM, Jernej Simončič wrote:
> >On Tuesday, March 2, 2010, 9:21:18, Chris Webb wrote:
> >
> >>I remember about a year ago, someone asserting on the list that -usbdevice
> >>tablet was very CPU intensive even when not in use, and should be avoided if
> >>mouse support wasn't needed, e.g. on non-graphical VMs. Was that actually a
> >>significant hit, and is it still true today?
> >It would appear that this is still the case, at least on slower hosts
> >- on Atom Z530 (1,6GHz), the XP VM uses ~30% CPU when idle with
> >-usbdevice tablet, but only ~4% without it. However, on a faster host
> >(Core2 Quad 2,66GHz), there's practically no difference (Vista x64 VM
> >uses ~1% CPU when idle regardless of -usbdevice tablet).
> 
> Looks like the tablet is set to 100 Hz polling rate.  We may be able
> to get away with 30 Hz or even less (ep_bInterval, in ms, in
> hw/usb-wacom.c).

Hi Avi. Sorry for the very late follow-up, but I decided to experiment with
this. The cpu impact of the usb tablet device shows up fairly clearly on a
crude test on my (relatively low-spec) desktop. Running an idle Fedora 11
livecd on qemu-kvm 0.12.3, top shows around 0.1% of my cpu in use, but this
increases to roughly 5% when specifying -usbdevice tablet, and more detailed
examination with perf record/report suggests about a factor of thirty too.

It's actually a more general symptom with USB or at least HID devices by the
look of things: although -usb doesn't increase CPU use on its own, the same
increase in load can also be triggered by -usbdevice keyboard or mouse.
However, running with all three of -usbdevice mouse, keyboard and tablet
doesn't increase load any more than just one of these.

Changing the USB tablet polling interval from 10ms to 100ms in both
hw/usb-wacom.c and hw/usb-hid.c made no difference except the an increase in
bInterval shown in lsusb -v in the guest and the hint of jerky mouse
movement I expected from setting this value so high. A similar change to the
polling interval for the keyboard and mouse also made no difference to their
performance impact.

Taking the FRAME_TIMER_FREQ down to 100 in hw/usb-uhci.c does seem to reduce
the CPU load quite a bit, but at the expense of making the USB tablet (and
presumably all other USB devices) very laggy.

Could there be some bug here that causes the usb hid devices to wake qemu at
the maximum rate possible (FRAME_TIMER_FREQ?) rather than the configured
polling interval?

Best wishes,

Chris.

PS Vmmouse works fine as an absolute pointing device in the place of
-usbdevice tablet without the performance impact, but this isn't supported
out of the box with typical linux live CDs (e.g. Fedora 11 and 12 or
Knoppix) so unfortunately it's probably less suitable as a default
configuration to expose to end-users.

  reply	other threads:[~2010-04-04 12:31 UTC|newest]

Thread overview: 109+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1267068445.1726.25.camel@localhost>
     [not found] ` <1267089644.12790.74.camel@laptop>
2010-02-26  2:49   ` Enhance perf to support KVM Zhang, Yanmin
2010-02-26  9:01     ` Ingo Molnar
2010-02-26  9:53       ` Avi Kivity
2010-02-26 10:35         ` Ingo Molnar
2010-02-26 10:47           ` Avi Kivity
2010-02-26 11:17             ` Ingo Molnar
2010-02-26 11:44               ` Avi Kivity
2010-02-26 12:46                 ` Ingo Molnar
2010-02-26 12:54                   ` Avi Kivity
2010-02-26 13:16                     ` Ingo Molnar
2010-02-26 13:57                       ` Jes Sorensen
2010-02-26 14:04                       ` Avi Kivity
2010-02-26 14:23                         ` Ingo Molnar
2010-02-26 15:06                           ` Avi Kivity
2010-03-02 16:46                           ` Paolo Bonzini
2010-03-02 17:12                             ` Arnaldo Carvalho de Melo
2010-03-02 17:20                               ` Paolo Bonzini
2010-03-02 17:24                                 ` Ingo Molnar
2010-03-02 17:17                             ` Ingo Molnar
2010-03-07 14:17                               ` Avi Kivity
2010-02-26 18:33               ` Avi Kivity
2010-02-27 10:56                 ` KVM usability Ingo Molnar
2010-02-27 13:30                   ` Jan Kiszka
2010-02-27 13:30                     ` [Qemu-devel] " Jan Kiszka
2010-02-27 14:48                   ` Ian Kirk
2010-02-27 15:32                   ` Zachary Amsden
2010-02-27 17:25                     ` Ingo Molnar
2010-03-01 15:33                       ` Anthony Liguori
2010-03-01 16:48                       ` Zachary Amsden
2010-03-01 17:41                         ` Arnaldo Carvalho de Melo
2010-03-01 18:29                           ` Zachary Amsden
2010-03-01 20:56                             ` Ingo Molnar
2010-03-01 21:45                               ` Anthony Liguori
2010-03-01 22:06                                 ` Zachary Amsden
2010-03-02  0:33                                   ` Ingo Molnar
2010-03-02  0:30                                 ` Ingo Molnar
2010-03-02  2:34                                   ` Anthony Liguori
2010-03-02  8:39                                   ` Chris Webb
2010-03-07 18:42                                   ` Avi Kivity
2010-03-02 10:30                               ` Ingo Molnar
2010-03-07  9:35                                 ` Avi Kivity
2010-03-07  9:56                                   ` Pekka Enberg
2010-03-07 10:11                                     ` Avi Kivity
2010-03-07 18:42                                     ` Ingo Molnar
2010-03-07 15:14                                   ` Luca Barbieri
2010-03-07 18:16                                     ` Avi Kivity
2010-03-07 18:01                                   ` Arnaldo Carvalho de Melo
2010-03-07 18:15                                     ` Avi Kivity
2010-03-07 18:53                                       ` Arnaldo Carvalho de Melo
2010-03-07 19:05                                         ` Avi Kivity
2010-03-07 18:25                       ` Avi Kivity
2010-03-01  9:25                     ` Ingo Molnar
2010-03-01 15:36                       ` Anthony Liguori
2010-03-01 15:14                   ` Anthony Liguori
2010-03-01 15:42                     ` Daniel P. Berrange
2010-03-02  1:12                     ` Dustin Kirkland
2010-03-02 10:11                     ` Peter Zijlstra
2010-03-02 13:37                       ` Nikolai K. Bochev
2010-03-02 14:22                         ` Gerd Hoffmann
2010-03-02 14:29                           ` Ingo Molnar
2010-03-07  9:22                             ` Avi Kivity
2010-03-02 14:37                           ` Daniel P. Berrange
2010-03-02 14:52                             ` Gerd Hoffmann
2010-03-02 14:56                               ` Daniel P. Berrange
2010-03-02 15:13                                 ` Gerd Hoffmann
2010-03-04 20:00                       ` Lucas Meneghel Rodrigues
2010-03-04 20:13                         ` Zachary Amsden
2010-03-04 20:34                           ` Anthony Liguori
2010-03-04 22:23                           ` H. Peter Anvin
2010-03-05  7:44                             ` Markus Armbruster
2010-03-07 11:25                     ` Avi Kivity
2010-03-01 21:12                   ` Dustin Kirkland
2010-03-01 21:59                     ` Anthony Liguori
2010-03-02  2:34                       ` Alexander Graf
2010-03-02  2:36                         ` Anthony Liguori
2010-03-09 13:32                           ` Avi Kivity
2010-03-09 14:32                             ` Dustin Kirkland
2010-03-09 14:38                               ` Alexander Graf
2010-03-09 14:50                                 ` Anthony Liguori
2010-03-09 14:52                                   ` Avi Kivity
2010-03-09 14:57                                     ` Anthony Liguori
2010-03-09 17:11                                       ` Avi Kivity
2010-03-09 17:27                                         ` Anthony Liguori
2010-03-09 17:30                                           ` Avi Kivity
2010-03-09 14:49                             ` Anthony Liguori
2010-03-09 14:54                               ` Avi Kivity
2010-03-02  3:02                       ` Dustin Kirkland
2010-03-02  8:21                         ` Chris Webb
2010-03-02 14:54                           ` Dustin Kirkland
     [not found]                           ` <428008581.20100302103400@eternallybored.org>
2010-03-07 11:35                             ` Avi Kivity
2010-04-04 12:31                               ` Chris Webb [this message]
2010-04-04 12:31                                 ` [Qemu-devel] High CPU use of -usbdevice tablet (was Re: KVM usability) Chris Webb
2010-04-04 14:25                                 ` Paul Brook
2010-04-04 14:25                                   ` Paul Brook
2010-04-04 16:58                                   ` Avi Kivity
2010-04-04 16:58                                     ` Avi Kivity
2010-04-04 21:03                                     ` Paul Brook
2010-04-04 21:03                                       ` Paul Brook
2010-04-04 21:53                                     ` Paul Brook
2010-04-04 21:53                                       ` Paul Brook
2010-04-05  8:22                                       ` Avi Kivity
2010-04-05  8:22                                         ` Avi Kivity
2010-03-03  2:57                       ` KVM usability Ross Boylan
2010-03-03  8:55                         ` Daniel P. Berrange
2010-03-03 15:42                           ` Ross Boylan
2010-03-07 14:29                             ` Avi Kivity
2010-02-26 11:48             ` Enhance perf to support KVM Peter Zijlstra
2010-02-26 11:53               ` Avi Kivity
2010-02-26 20:17           ` Anthony Liguori

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100404123116.GA19866@arachsys.com \
    --to=chris@arachsys.com \
    --cc=avi@redhat.com \
    --cc=jernej's-kvm@eternallybored.org \
    --cc=kvm@vger.kernel.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.