From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chris Webb Subject: High CPU use of -usbdevice tablet (was Re: KVM usability) Date: Sun, 4 Apr 2010 13:31:16 +0100 Message-ID: <20100404123116.GA19866@arachsys.com> References: <4B87A6BF.3090301@redhat.com> <20100226111734.GE7463@elte.hu> <4B8813F2.8090208@redhat.com> <20100227105643.GA17425@elte.hu> <4B8C38B8.8010007@codemonkey.ws> <1267498953.2460.32.camel@x200> <20100302082118.GT1924@arachsys.com> <428008581.20100302103400@eternallybored.org> <4B938F9D.7010207@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Cc: Jernej =?utf-8?B?U2ltb27EjWnEjQ==?= , kvm@vger.kernel.org, qemu-devel@nongnu.org To: Avi Kivity Return-path: Received: from alpha.arachsys.com ([91.203.57.7]:49437 "EHLO alpha.arachsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754049Ab0DDMbd (ORCPT ); Sun, 4 Apr 2010 08:31:33 -0400 Content-Disposition: inline In-Reply-To: <4B938F9D.7010207@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: Avi Kivity writes: > On 03/02/2010 11:34 AM, Jernej Simon=C4=8Di=C4=8D wrote: > >On Tuesday, March 2, 2010, 9:21:18, Chris Webb wrote: > > > >>I remember about a year ago, someone asserting on the list that -us= bdevice > >>tablet was very CPU intensive even when not in use, and should be a= voided if > >>mouse support wasn't needed, e.g. on non-graphical VMs. Was that ac= tually a > >>significant hit, and is it still true today? > >It would appear that this is still the case, at least on slower host= s > >- 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 hos= t > >(Core2 Quad 2,66GHz), there's practically no difference (Vista x64 V= M > >uses ~1% CPU when idle regardless of -usbdevice tablet). >=20 > 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 o= n 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 det= ailed examination with perf record/report suggests about a factor of thirty t= oo. It's actually a more general symptom with USB or at least HID devices b= y 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 table= t 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 increa= se 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 t= o 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 r= educe 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 qe= mu at the maximum rate possible (FRAME_TIMER_FREQ?) rather than the configure= d 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 suppor= ted 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.