Laszlo Hornyak has uploaded a new change for review.

Change subject: start ksm and ksmtuned when vdsm starts
......................................................................

start ksm and ksmtuned when vdsm starts

this patch
 - separates the check against ksm and ksmtuned
 - invokes the functions to check and start ksm and ksmtuned from the
   monitor thread

Change-Id: Ia50087aae112069b2a427fca12168aff975b443e
Bug-Url: https://bugzilla.redhat.com/854027
Signed-off-by: Laszlo Hornyak <[email protected]>
---
M vdsm/ksm.py
1 file changed, 23 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/57/8357/1

diff --git a/vdsm/ksm.py b/vdsm/ksm.py
index f93007a..ba4166e 100644
--- a/vdsm/ksm.py
+++ b/vdsm/ksm.py
@@ -20,6 +20,7 @@
 
 import threading, time
 import os
+import logging
 from vdsm import constants
 from vdsm import utils
 from vdsm.config import config
@@ -36,9 +37,12 @@
                                  raw=False, sudo=False)[1]
             if pids:
                 self._pid = pids[0].strip()
+                self._cif.log.info('starting ksm monitor thread, ksm pid is 
%s', self._pid)
                 self.start()
             else:
                 self._cif.log.error('failed to find ksmd thread')
+        else:
+           self._cif.log.info('ksm monitor thread disabled, not starting')
         self.cpuUsage = 0
 
     def _getKsmdJiffies(self):
@@ -46,6 +50,7 @@
                                     .read().split()[13:15]))
 
     def run(self):
+        ksm_start()
         try:
             self.state, self.pages = self.readState()
             KSM_MONITOR_INTERVAL = 60
@@ -58,9 +63,10 @@
                 jiff0 = jiff1
         except:
             self._cif.log.error("Error monitoring KSM", exc_info=True)
+        ksm_stop()
 
     def readState(self):
-        return running(), npages()
+        return ksm_running(), npages()
 
     def adjust(self):
         """adjust ksm state according to configuration and current memory 
stress
@@ -80,10 +86,19 @@
         except:
             return 0
 
-def running():
+def ksm_running():
     try:
         state = int(file('/sys/kernel/mm/ksm/run').read()) & 1 == 1
         return state
+    except:
+        return False
+
+def ksmtuned_running():
+    try:
+        logging.debug('checking ksmtuned')
+        ret = utils.execCmd([constants.EXT_SERVICE, 'ksmtuned', 'status'], 
sudo=True)[1][0]
+        logging.info('ksmtuned: %s', ret)
+        return ret != "ksmtuned is stopped"
     except:
         return False
 
@@ -94,14 +109,16 @@
     except:
         return 0
 
-def start():
-    if not running():
+def ksm_start():
+    if not ksmtuned_running():
         utils.execCmd([constants.EXT_SERVICE, 'ksmtuned', 'start'], sudo=True)
+    if not ksm_running():
         utils.execCmd([constants.EXT_SERVICE, 'ksm', 'start'], sudo=True)
 
-def stop():
-    if running():
+def ksm_stop():
+    if ksmtuned_running():
         utils.execCmd([constants.EXT_SERVICE, 'ksmtuned', 'stop'], sudo=True)
+    if ksm_running():
         utils.execCmd([constants.EXT_SERVICE, 'ksm', 'stop'], sudo=True)
 
 


--
To view, visit http://gerrit.ovirt.org/8357
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia50087aae112069b2a427fca12168aff975b443e
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: Laszlo Hornyak <[email protected]>
_______________________________________________
vdsm-patches mailing list
[email protected]
https://lists.fedorahosted.org/mailman/listinfo/vdsm-patches

Reply via email to