Bug 1027420 - ksmtuned can’t handle libvirt WITH set_process_name=1
ksmtuned can’t handle libvirt WITH set_process_name=1
Status: CLOSED CURRENTRELEASE
Product: Red Hat Enterprise Linux 7
Classification: Red Hat
Component: qemu-kvm (Show other bugs)
7.0
All Unspecified
unspecified Severity unspecified
: rc
: ---
Assigned To: Miroslav Rezanina
Virtualization Bugs
: Reopened
: 976336 (view as bug list)
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2013-11-06 14:10 EST by Cole Robinson
Modified: 2014-06-17 23:41 EDT (History)
8 users (show)

See Also:
Fixed In Version: qemu-kvm-1.5.3-22.el7
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: 1012604
Environment:
Last Closed: 2014-06-13 06:20:01 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Cole Robinson 2013-11-06 14:10:18 EST
+++ This bug was initially created as a clone of Bug #1012604 +++

Description of problem:
This time around ksmtuned doesn’t find qemu processes when set_process_name in /etc/libvirt/qemu.conf is NOT changed from the default 0.

This is because qemu was recently changed to incorporate qemu-kvm, and the qemu-kvm program now just exec-s the respective qemu-system-* binary with the right arguments. The process list will therefore show only qemu-system-* processes as representing the VMs.

With ksmtuned looking for processes of either "qemu-kvm" or "qemu:something" (with "something" being the respective VM name, as it happens when set_process_name=1), these qemu-system-* processes will slip through.

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

Additional info:
There doesn’t seem to exist a functional specification as to which qemu processes ksmtuned should take into account, i.e. only those started by libvirt or also those started by other means, and by what criteria is should apply to tell them apart.

However, to find qemu-system.* processes in addition to all those that were previously found, the regexp on line 74 of ksmtuned can simply be changed to read ^qemu(-(kvm|system-.+)|:.{1,11})$

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

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

--- Additional comment from Fedora Update System on 2013-11-05 20:26:55 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 (fixes another bug as well):

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 () {
Comment 2 Miroslav Rezanina 2013-11-18 02:44:16 EST
This patch is not needed for RHEL 7 as it uses qemu-kvm binary and no qemu-system-* is present.
Comment 3 Miroslav Rezanina 2013-11-18 03:09:36 EST
Reopen and rename. As we have problem with set_process_name=1 and need fix introduce to fedora with bz 955230 (that cause problem fixed with bz 1012604).

Patch:
 
 committed_memory () {
     # calculate how much memory is committed to running qemu processes
-    local progname
-    progname=${1:-qemu-kvm}
-    ps -C "$progname" -o rsz | awk '{ sum += $1 }; END { print sum }'
+    local pidlist
+    pidlist=$(pgrep -d ' ' -- '^qemu(-kvm|:.{1,11})$')
+    if [ -n "$pidlist" ]; then
+        ps -p "$pidlist" -o rsz=
+    fi | awk '{ sum += $1 }; END { print sum }'
 }
 
 free_memory () {
Comment 4 Miroslav Rezanina 2013-11-20 04:28:11 EST
*** Bug 976336 has been marked as a duplicate of this bug. ***
Comment 9 Shaolong Hu 2013-12-27 04:29:05 EST
Verified on qemu-kvm-1.5.3-30.el7.x86_64:

#/usr/sbin/ksmtuned

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 }'
}

Patch applied, just in bug 1027418, there is update:

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

Verified.
Comment 10 Ludek Smid 2014-06-13 06:20:01 EDT
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.

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