Bug 1027418

Summary: ksmtuned committed_memory() still returns "", not 0, when no qemu running
Product: Red Hat Enterprise Linux 7 Reporter: Cole Robinson <crobinso>
Component: qemu-kvmAssignee: Miroslav Rezanina <mrezanin>
Status: CLOSED CURRENTRELEASE QA Contact: Virtualization Bugs <virt-bugs>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 7.0CC: acathrow, areis, hhuang, juzhang, shu, virt-maint, xfu
Target Milestone: rc   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: qemu-kvm-1.5.3-22.el7 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 1012610 Environment:
Last Closed: 2014-06-13 10:51:35 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Cole Robinson 2013-11-06 19:08:30 UTC
+++ This bug was initially created as a clone of Bug #1012610 +++

Description of problem:
Despite the efforts in #609016 and #902688, this is still / again broken.

Version of selected components:
ksm-1.4.2-9.fc19.x86_64

How to reproduce:
Understand committed_memory() in ksmtuned, then:

$ < /dev/null awk '{ sum += $1 }; END { print sum }'

$ 

Additional info:
Please change the awk clause in line 77 of ksmtuned to the obvious and correct solution: 'END { print 0+sum }':

$ < /dev/null awk '{ sum += $1 }; END { print 0+sum }'
0
$

--- Additional comment from Cole Robinson on 2013-10-31 16:24:12 EDT ---

Thanks for the suggestion, moving to POST since there's a fix

--- Additional comment from Fedora Update System on 2013-11-05 20:27:03 EST ---

qemu-1.4.2-13.fc19 has been submitted as an update for Fedora 19.
https://admin.fedoraproject.org/updates/qemu-1.4.2-13.fc19



Here's the diff we applied in Fedora:

diff --git a/ksmtuned b/ksmtuned
index c96507c..7bc5743 100644
--- a/ksmtuned
+++ b/ksmtuned
@@ -71,10 +71,10 @@ KSMCTL () {
 committed_memory () {
     # calculate how much memory is committed to running qemu processes
     local pidlist
-    pidlist=$(pgrep -d ' ' -- '^qemu(-kvm|:.{1,11})$')
+    pidlist=$(pgrep -d ' ' -- '^qemu(-(kvm|system-.+)|:.{1,11})$')
     if [ -n "$pidlist" ]; then
         ps -p "$pidlist" -o rsz=
-    fi | awk '{ sum += $1 }; END { print sum }'
+    fi | awk '{ sum += $1 }; END { print 0+sum }'
 }
 
 free_memory () {

(covers another bug as well)

Comment 2 Michal Novotny 2013-12-17 11:14:33 UTC
Fixed in version qemu-kvm-1.5.3-22.el7.

Michal

Comment 6 Shaolong Hu 2013-12-27 09:11:22 UTC
In qemu-kvm-1.5.3-30.el7.x86_64:

committed_memory () {
    local pidlist
    pidlist=$(pgrep -d ' ' -- '^qemu(-kvm|:.{1,11})$')
    if [ -n "$pidlist" ]; then
        ps -p "$pidlist" -o rsz=
    fi | awk '{ sum += $1 }; END { print 0+sum }'
}


Here:

-    pidlist=$(pgrep -d ' ' -- '^qemu(-kvm|:.{1,11})$')
+    pidlist=$(pgrep -d ' ' -- '^qemu(-(kvm|system-.+)|:.{1,11})$')

Above patch does not apply, only:

-    fi | awk '{ sum += $1 }; END { print sum }'
+    fi | awk '{ sum += $1 }; END { print 0+sum }'


If this is intended, then verified.

Comment 7 Ludek Smid 2014-06-13 10:51:35 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.