Bug 747010

Summary: ksmtuned uses "vsz" instead of "rsz" when calculating qemu-kvm mem usage ( KSM turn on too early )
Product: Red Hat Enterprise Linux 6 Reporter: Attila Darazs <adarazs>
Component: qemu-kvmAssignee: Justin M. Forbes <jforbes>
Status: CLOSED ERRATA QA Contact: Virtualization Bugs <virt-bugs>
Severity: high Docs Contact:
Priority: unspecified    
Version: 6.2CC: acathrow, areis, danken, iheim, juzhang, michen, minovotn, mkenneth, oramraz, shuang, shu, tburke, virt-bugs, virt-maint, ykaul
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Linux   
Whiteboard:
Fixed In Version: qemu-kvm-0.12.1.2-2.240.el6 Doc Type: Bug Fix
Doc Text:
Cause: Incorrect value has been used to calculate qemu-kvm memory usage (and turn on KSM). Consequence: KSM (Kernel Samepage Merging) turned on too early. Fix: Use real memory size instead of virtual memory size for calculating qemu-kvm memory usage. Result: Turning on KSM is more optimized
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-06-20 11:35:14 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:
Attachments:
Description Flags
Upstream patch for this none

Description Attila Darazs 2011-10-18 15:06:27 UTC
Description of problem:
In ksmtuned there's this line:
ps -C "$progname" -o vsz= | awk '{ sum += $1 }; END { print sum }'

"vsz" in not a good way to estimate the mem usage, this line makes KSM turn on way too early.

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

Comment 8 Justin M. Forbes 2012-03-05 17:11:41 UTC
Created attachment 567690 [details]
Upstream patch for this

This patch has been upstream for quite some time and should fix the issue.

Comment 11 Shaolong Hu 2012-03-15 09:32:27 UTC
Verified on qemu-kvm-0.12.1.2-2.248.el6.x86_64:

1. edit /etc/ksmtuned.conf
# uncomment the following if you want ksmtuned debug info
 LOGFILE=/var/log/ksmtuned
 DEBUG=1
2. #service ksmtuned restart
3. check "committed memory" at /var/log/ksmtuned


Test suggest that, on a 8G host, boot guest of 4G, ksm is activated until the 8th guest boot up.


However, i find a little flaw:

Thu Mar 15 23:37:44 CST 2012: total 7379492
Thu Mar 15 23:37:44 CST 2012: sleep 22
Thu Mar 15 23:37:44 CST 2012: thres 1475898
...
Thu Mar 15 23:47:45 CST 2012: 7005790 > 7379492, start ksm
Thu Mar 15 23:47:45 CST 2012: 1467916 < 1475898, boost
Thu Mar 15 23:47:45 CST 2012: KSMCTL start 300 22

here "7005790 > 7379492", ksm is activated when:

[ $[committed + thres] -lt $total -a $free -gt $thres ] is false

But after use rsz instead of vsz, free < thres will always happen before committed + thres > total, for there are other processes taking memory, this won't affect ksm functioning, just log confuses people, worth fixing?

Comment 12 Shaolong Hu 2012-03-23 08:49:51 UTC
Since qemu-kvm 262 removes kvm-ksmtuned-should-use-rsz-instead-of-vsz.patch from rpm spec file, move this back to assigned.

Comment 13 Michal Novotny 2012-04-02 08:04:24 UTC
(In reply to comment #12)
> Since qemu-kvm 262 removes kvm-ksmtuned-should-use-rsz-instead-of-vsz.patch
> from rpm spec file, move this back to assigned.

The patch is for the SPEC file and it has been applied manually so moving back to ON_QA. Nothing changed but the patch file is no longer here because it's not necessary to have it here.

Michal

Comment 14 Shaolong Hu 2012-04-27 02:52:11 UTC
Ok, then only the log problem, if it's not important, i am willing to verify this bug.

Comment 16 Michal Novotny 2012-05-04 08:00:34 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:
Incorrect value has been used to start ksmtuned.

Consequence:
KSM (Kernel Samepage Merging) turned on too early.

Fix:
Use real memory size instead of virtual memory size for calculating qemu-kvm memory usage.

Result:
Turning on KSM is more optimized

Comment 17 Michal Novotny 2012-05-04 08:01:29 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,5 +1,5 @@
 Cause:
-Incorrect value has been used to start ksmtuned.
+Incorrect value has been used to calculate qemu-kvm memory usage (and turn on KSM).
 
 Consequence:
 KSM (Kernel Samepage Merging) turned on too early.

Comment 18 errata-xmlrpc 2012-06-20 11:35:14 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