linux-rt-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: John Kacur <jkacur@redhat.com>
To: rt-users <linux-rt-users@vger.kernel.org>
Cc: Clark Williams <williams@redhat.com>, John Kacur <jkacur@redhat.com>
Subject: [PATCH 1/3] hwlatdetect: handle hwlat_detector being builtin rather than module
Date: Wed, 13 Jan 2016 15:59:45 +0100	[thread overview]
Message-ID: <1452697187-14894-2-git-send-email-jkacur@redhat.com> (raw)
In-Reply-To: <1452697187-14894-1-git-send-email-jkacur@redhat.com>

From: Clark Williams <williams@redhat.com>

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>
---
 src/hwlatdetect/hwlatdetect.py | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/src/hwlatdetect/hwlatdetect.py b/src/hwlatdetect/hwlatdetect.py
index dbf3f674faba..2a1c562c2188 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]
-- 
2.4.3


  reply	other threads:[~2016-01-13 14:59 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-13 14:59 [PATCH 0/3] hwlatdetect patches John Kacur
2016-01-13 14:59 ` John Kacur [this message]
2016-01-13 14:59 ` [PATCH 2/3] hwlatdetect: modify to handle python3 prints John Kacur
2016-01-13 14:59 ` [PATCH 3/3] hwlatdetect: make reading sample date work with python2 and python3 John Kacur

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1452697187-14894-2-git-send-email-jkacur@redhat.com \
    --to=jkacur@redhat.com \
    --cc=linux-rt-users@vger.kernel.org \
    --cc=williams@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).