RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 889222 - Lower cpu cost of having the usb-tablet enabled
Summary: Lower cpu cost of having the usb-tablet enabled
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: qemu-kvm
Version: 7.0
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Hans de Goede
QA Contact: Virtualization Bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-12-20 14:43 UTC by Hans de Goede
Modified: 2016-04-19 17:21 UTC (History)
8 users (show)

Fixed In Version: 1.4.0
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2014-06-13 13:15:51 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Bugzilla 949547 0 unspecified CLOSED qemu-kvm process consumes 8% cpu even when windows guest is idle inside and 70% when guest uses 10% cpu inside 2021-02-22 00:41:40 UTC

Internal Links: 949547

Description Hans de Goede 2012-12-20 14:43:14 UTC
Upstream qemu (post 1.3) has some enhancements to significantly lower the cpu cost of having a usb-tablet enabled in vms with windows guests, we ought to have these changes in RHEL-7.0 too.

Comment 2 Qunfang Zhang 2014-01-28 06:15:15 UTC
Hi, Hans

I tested on old qemu-kvm-1.3.0-6.el7.x86_64 and latest qemu-kvm-1.5.3-41.el7.x86_64 with and without usb-tablet device for win2k8r2 guest. Compare the cpu usage, it does not show some difference on the old and new version.  cpu usage is higher with usb-tablet even on latest qemu-kvm. Could you give a help on my test result below and give me some suggestions?  Thank!

CLI:

 /usr/libexec/qemu-kvm -cpu SandyBridge -M pc -enable-kvm -m 2G -smp 2,sockets=2,cores=1,threads=1 -name win2k8r2 -uuid a589bcc5-96e1-4d97-9e34-78954f2f5725  -nodefconfig -nodefaults -monitor stdio -rtc base=utc,clock=host,driftfix=slew -no-kvm-pit-reinjection -no-shutdown -device virtio-serial-pci,id=virtio-serial0,bus=pci.0,addr=0x7 -drive file=/home/win2008r2-64-virtio.qcow2,if=none,id=drive-virtio-disk0,format=qcow2,cache=none -device virtio-blk-pci,scsi=off,bus=pci.0,addr=0x5,drive=drive-virtio-disk0,id=virtio-disk0 -drive if=none,media=cdrom,id=drive-ide0-1-0,readonly=on,format=raw -device ide-drive,bus=ide.1,unit=0,drive=drive-ide0-1-0,id=ide0-1-0 -netdev tap,id=hostnet0,vhost=on -device virtio-net-pci,netdev=hostnet0,id=net0,mac=52:54:00:d5:51:8a,bus=pci.0,addr=0x3  -vnc :11 -vga std  -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x6 -qmp tcp:0:5566,server,nowait -global PIIX4_PM.disable_s3=0 -global PIIX4_PM.disable_s4=0

On qemu-kvm-1.3.0-6.el7.x86_64:
(Host kernel: 3.7.0-0.36.el7.x86_64)

(1) with usb-tablet:

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND              
 4604 root      20   0 4666020 2.001g   6056 S 14.28 27.12   0:33.33 qemu-kvm             
 4681 root      20   0  118004   1396   1000 R 0.332 0.018   0:00.11 top  

(2) without usb-tablet:

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND              
 4472 root      20   0 4576872 1.998g   6028 R 2.324 27.08   0:32.20 qemu-kvm   


On qemu-kvm-1.5.3-41.el7.x86_64:
(Host kernel: 3.10.0-78.el7.x86_64)

(1) with usb-tablet:

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND               
17601 root      20   0 4576504 1.992g   6492 S  14.6 27.0   0:33.75 qemu-kvm 

(2) without usb-tablet:

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND               
17468 root      20   0 4575500 1.996g   6476 S   2.3 27.0   0:23.50 qemu-kvm  


Regards,
Qunfang

Comment 3 Qunfang Zhang 2014-01-28 06:17:01 UTC
When I tested "with usb-tablet" scenario, I just append "-usb -device usb-tablet" to the command line in comment 2.

Comment 4 Hans de Goede 2014-01-28 08:24:18 UTC
The lowering of the cpu load is done by making the usb-tablet be usb-2 compatible, which means it will use the ehci controller when available which is more efficient. But you've not configured an ehci controller.

Please try again using a vm configuration which includes an ehci controller.

Comment 5 Qunfang Zhang 2014-01-28 09:32:21 UTC
Thanks for the feedback.

Comment 6 Qunfang Zhang 2014-01-28 10:25:32 UTC
Re-test again on both old and new qemu-kvm version with ehci controller and usb-tablet device. Boot the guest and keep it idle (no application and windows opened inside guest). 

Tested on qemu-kvm-1.5.3-41.el7.x86_64:

(1) with "-device usb-ehci,id=ehci -device usb-tablet,bus=ehci.0":

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND               
17915 root      20   0 4616412 1.993g   6512 S   5.7 27.0   0:27.50 qemu-kvm  

(2) without echi controller and usb-tablet device: 

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND               
18080 root      20   0 4591852 1.991g   6484 S   2.3 27.0   0:22.41 qemu-kvm   

On qemu-kvm-1.4.0-1.el7.x86_64:

(1) with "-device usb-ehci,id=ehci -device usb-tablet,bus=ehci.0":

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND              
 5242 root      20   0 4593664 2.040g   6104 S 8.305 27.64   0:35.35 qemu-kvm     

(2) without echi controller and usb-tablet device: 


  PID USER      PR  NI    VIRT    RES    SHR S  %CPU  %MEM     TIME+ COMMAND              
 5380 root      20   0 4619440 2.037g   6076 S 2.325 27.60   0:23.86 qemu-kvm 


Hi, Hans

Based on the above result, the cpu usage is lower in the latest qemu-kvm with ehci+usb-device than in qemu-kvm-1.4.0-1.el7.x86_64. And the percentage is closed to "without usb-tablet" value.  Could we call this verify pass? 

Thanks,
Qunfang

Comment 7 Hans de Goede 2014-01-28 10:44:29 UTC
Yes this result is a pass. Notice the drop is from 15% cpu load (with uhci / rhel-6 behavior) to 6%, so quite a nice improvement :)

Comment 8 Qunfang Zhang 2014-01-28 10:55:07 UTC
Okay, thanks for the confirmation :)

Comment 9 Ludek Smid 2014-06-13 13:15:51 UTC
This request was resolved in Red Hat Enterprise Linux 7.0.

Contact your manager or support representative in case you have further questions about the request.

Comment 11 tbsky 2016-04-19 05:23:57 UTC
hi:
   the problem comes back again. according to the link below, the usb tablet should have "power management" tab under device manager:

   https://www.kraxel.org/blog/2014/03/qemu-and-usb-tablet-cpu-consumtion/

when I try to install new win7-sp1/2008-R2-sp1 VM with virt-manager(with default options), the usb tablet didn't have the "power management" tab under device manager. however,if I install new windows 2012-R2 vm, there will be "power management" tab under device manager.

the old win7/2008-R2 vm installed with rhel 7.0 (or maybe 7.1 I don't remember),still have the correct "power management" tab and work correctly under rhel 7.2. only the new installed win7/2008R2 vm under rhel 7.2 missing the "power management" tab. and these VMs eat cpu when idle.

    I also try install all current hotfixes and clear the two windows registry(usbflag and USB) and reboot, but still can not get the "power management" tab to appear.

    is there other windows registry I should check? or can someone take a test under rhel 7.2 to see if the problem really come back?

Comment 12 tbsky 2016-04-19 05:31:17 UTC
hi:
   I forget to mention specific the problem is under current rhel 7.2: package version below: qemu-kvm-1.5.3-105.el7_2.3

Comment 13 tbsky 2016-04-19 17:21:09 UTC
hi:
    I found two things.

1. even if I disable the tablet in windows device manager, the windows VM still consume host cpu. that's a surprise for me.

2. after comparing old and new VM, I am lucky to find out the registry key. so I just create the key:

  HKLM\SYSTEM\CurrentControlSet\Enum\USB\VID_0627&PID_0001\42\Device Parameters\SelectiveSuspendEnabled

  give a DWORD vlaue as 1. and now the "power management" tab is back. and VM consume less than 2% host cpu when idle. when using remote desktop to login to windows, you can click the button to enable/disable the usb tablet power management, and the host cpu usage will show difference immediately.

  I don't know why win7/2008R2 under rhel 7.2 won't enable power-management tab automatically. it seems everything is there, just missing the button to turn it on/off. but 2012-R2 works quite good under rhel 7.2, it will enable the button automatically.


Note You need to log in before you can comment on or make changes to this bug.