summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorClark Williams <williams@redhat.com>2015-12-15 19:46:40 -0600
committerJohn Kacur <jkacur@redhat.com>2016-01-13 15:29:17 +0100
commitbbd5a22182f23d73a7930773d4cd562fae8dd4cd (patch)
treeded3b89f2262e52706f4c432c32c5ffd8535399d
parentfd3dde99fdaaed349c4da8879e56fc684edb2ffd (diff)
downloadrt-tests-bbd5a22182f23d73a7930773d4cd562fae8dd4cd.tar.gz
rt-tests-bbd5a22182f23d73a7930773d4cd562fae8dd4cd.tar.xz
hwlatdetect: handle hwlat_detector being builtin rather than module
Originally the hwlat_detector was built as only a module and was controlled by module parameters. The latest version uses debugfs control files so there is no real need to force it to be a module. The hwlatdetector script in rt-tests assumes that the hwlat_detector code was built as a module. This patch adds logic to detect and handle if hwlat_detector is a builtin. Signed-off-by: Clark Williams <williams@redhat.com> Signed-off-by: John Kacur <jkacur@redhat.com>
-rwxr-xr-xsrc/hwlatdetect/hwlatdetect.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/hwlatdetect/hwlatdetect.py b/src/hwlatdetect/hwlatdetect.py
index dbf3f67..2a1c562 100755
--- a/src/hwlatdetect/hwlatdetect.py
+++ b/src/hwlatdetect/hwlatdetect.py
@@ -108,6 +108,14 @@ class Kmod(object):
''' class to manage loading and unloading hwlat.ko'''
names = ("hwlat_detector", "smi_detector")
+ def __check_builtin(self):
+ for l in open(os.path.join('/lib/modules', os.uname()[2], 'modules.builtin'), "r"):
+ for m in Kmod.names:
+ if m in l:
+ debug("found %s as builtin" % m)
+ return m
+ return None
+
def __find_modname(self):
debug("looking for modules")
path = os.path.join("/lib/modules",
@@ -123,6 +131,15 @@ class Kmod(object):
def __init__(self):
self.preloaded = False
+ self.builtin = False
+
+ # check for builtin
+ self.modname = self.__check_builtin()
+ if self.modname:
+ self.builtin = True
+ return
+
+ # now look for module
f = open ('/proc/modules')
for l in f:
field = l.split()
@@ -136,6 +153,9 @@ class Kmod(object):
self.modname = self.__find_modname()
def load(self):
+ if self.builtin:
+ debug("not loading %s (builtin)" % self.modname)
+ return True
if self.preloaded:
debug("not loading %s (already loaded)" % self.modname)
return True
@@ -143,7 +163,7 @@ class Kmod(object):
return (subprocess.call(cmd) == 0)
def unload(self):
- if self.preloaded:
+ if self.preloaded or self.builtin:
debug("Not unloading %s" % self.modname)
return True
cmd = ['/sbin/modprobe', '-r', self.modname]