Bug 789417

Summary: Fix memory leak in register save load due to xsave support
Product: Red Hat Enterprise Linux 6 Reporter: Alex Williamson <alex.williamson>
Component: qemu-kvmAssignee: Alex Williamson <alex.williamson>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: urgent Docs Contact:
Priority: urgent    
Version: 6.2CC: acathrow, bsarathy, ddugger, desktop-qa-list, djasa, jcody, jpallich, juzhang, michen, minovotn, mkenneth, shu, virt-maint, xfu
Target Milestone: rcKeywords: TestBlocker, ZStream
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: qemu-kvm-0.12.1.2-2.228.el6 Doc Type: Bug Fix
Doc Text:
Cause: Missing free in managing xSave processor state. Consequence: qemu-kvm leaks memory when guest makes use of processor xSave functionality. Fix: Free buffers used for managing xSave support. Result: qemu-kvm no longer leaks memory.
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-06-20 11:39:15 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 805550    

Description Alex Williamson 2012-02-10 18:17:21 UTC
Description of problem:
xsave support leaks memory at a very high rate.  This can be seen using a Linux guest with -vga std and interacting with a graphical desktop.

Version-Release number of selected component (if applicable):
qemu-kvm-0.12.1.2-2.198.el6

How reproducible:
100%

Steps to Reproduce:
1. Start a Linux guest with graphical desktop
2. Watch top
3.
  
Actual results:
VM resident memory grows and grows

Expected results:
No memory leaks, grows to fixed amount and stops

Additional info:
Problem identified by Jeff Cody

Bisected and upstream patch identified

Comment 4 David Jaša 2012-03-13 14:34:01 UTC
*** Bug 757768 has been marked as a duplicate of this bug. ***

Comment 5 David Jaša 2012-03-13 14:35:51 UTC
Adding a TestBlocker keyword from duplicate bug.

Comment 7 FuXiangChun 2012-03-15 15:27:19 UTC
I am trying to verify it, I will update soon result to this when verifying it.

Comment 8 FuXiangChun 2012-03-19 06:43:48 UTC
1.reproduce bug with qemu-kvm-0.12.1.2-2.209.el6.x86_64

Steps to Reproduce:
1.1. install fedora 16 in a VM on sandy bridge host
    /usr/libexec/qemu-kvm -M rhel6.2.0 -m 2G -smp 4 -netdev tap,id=hostnet0 -device rtl8139,netdev=hostnet0,id=net0,mac=52:54:00:94:a3:8b -uuid 7c73a852-c316-4d61-b913-9dde17367a30  -drive file=fedora16.qcow2,if=none,id=drive-virtio-disk0,format=qcow2 -device virtio-blk-pci,drive=drive-virtio-disk0,id=virtio-blk-pci0 -boot n -monitor stdio -spice disable-ticketing,port=5913 -vga qxl

1.2. log into gnome shell
1.3. watch VM usage of host memory
1.4. launch four windows and move it back and forth

testing result:
(1)VM resident(7.2G) memory grows and grows 
Mem:   7879396k total,  7773728k used,   105668k free,      284k buffers
Swap:  1048568k total,    34208k used,  1014360k free,    83444k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                                                                    
22174 root      20   0 9251m 7.2g 4336 S 19.3 96.3   2:52.82 qemu-kvm 

(2) memory leak lead to qemu exit 

2.verify bug with qemu-kvm-0.12.1.2-2.236.el6.x86_64
  
  Use the same steps with above

testing result:
(1) resident host memory about 827m and don't appear memory leak.

Mem:   7879396k total,  1876656k used,  6002740k free,    18532k buffers
Swap:  1048568k total,    14948k used,  1033620k free,   854036k cached

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND                                                                                                                    
21945 root      20   0 2844m 827m 5056 S  0.7 10.8   2:19.41 qemu-kvm 

additional info: I tested Fedora 16 and rhel6.2 guest, rhel6.2 haven't this issue. 

base on above testing result, I think this bug is fixed.

Comment 9 David Jaša 2012-03-20 15:48:28 UTC
Hi XiangChun, could you also update the bug state to VERIFIED so the z-stream process can start ASAP? Thank you.

Comment 12 Michal Novotny 2012-05-04 09:58:48 UTC
    Technical note added. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    New Contents:
Cause:
Missing free in loading and saving KVM registers.

Consequence:
When doing many migrations, the guest memory leaks a lot.

Fix:
Freeing of xSave registers has been added.

Result:
Guest doesn't memory leak anymore.

Comment 13 Alex Williamson 2012-05-04 13:36:54 UTC
    Technical note updated. If any revisions are required, please edit the "Technical Notes" field
    accordingly. All revisions will be proofread by the Engineering Content Services team.
    
    Diffed Contents:
@@ -1,11 +1,11 @@
 Cause:
-Missing free in loading and saving KVM registers.
+Missing free in managing xSave processor state.
 
 Consequence:
-When doing many migrations, the guest memory leaks a lot.
+qemu-kvm leaks memory when guest makes use of processor xSave functionality.
 
 Fix:
-Freeing of xSave registers has been added.
+Free buffers used for managing xSave support.
 
 Result:
-Guest doesn't memory leak anymore.+qemu-kvm no longer leaks memory.

Comment 14 errata-xmlrpc 2012-06-20 11:39:15 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

http://rhn.redhat.com/errata/RHBA-2012-0746.html