diff options
author | Clark Williams <williams@redhat.com> | 2010-02-08 15:31:57 -0600 |
---|---|---|
committer | Clark Williams <williams@redhat.com> | 2010-02-08 15:31:57 -0600 |
commit | 1e781f5634904789b4e3a45e432c85a94fdc0a82 (patch) | |
tree | b82637ba2465f0b2f04c3900217b1ae67113aa67 | |
parent | 7635870be8d1be2dc08e56f91497db940b757d21 (diff) | |
download | rt-tests-1e781f5634904789b4e3a45e432c85a94fdc0a82.tar.gz |
[hwlatdetect] workaround for borken smi_detector.ko module
Add a workaround to hwlatdetect to deal with a broken block of
code in drivers/misc/smi_detector.ko, where whenever you enable
the module (write a 1 to debugfs/smi_detector/enable) the stats
initialization routine resets the threshold from whatever it was
set to to 1us. This workaround checks the threshold after enabling
the module and resets it to what we want.
Signed-off-by: Clark Williams <williams@redhat.com>
-rwxr-xr-x | src/hwlatdetect/hwlatdetect.py | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/hwlatdetect/hwlatdetect.py b/src/hwlatdetect/hwlatdetect.py index 45c9d5f..66e66a2 100755 --- a/src/hwlatdetect/hwlatdetect.py +++ b/src/hwlatdetect/hwlatdetect.py @@ -193,7 +193,8 @@ class Detector(object): def start(self): count = 0 - debug("enabling detector module") + threshold = self.get("threshold") + debug("enabling detector module (threshold: %d)" % threshold) self.detector.set("enable", 1) debug("first attempt at enable") while self.detector.get("enable") == 0: @@ -202,7 +203,10 @@ class Detector(object): time.sleep(0.1) debug("retrying enable of detector module (%d)" % count) self.detector.set("enable", 1) - debug("detector module enabled") + if self.get("threshold") != threshold: + debug("start: threshold reset by start, fixing") + self.set("threshold", threshold) + debug("detector module enabled (threshold: %d)" % self.get("threshold")) def stop(self): count = 0 @@ -291,10 +295,15 @@ class Smi(object): return int(self.debugfs.getval(os.path.join("smi_detector", field))) def __set(self, field, value): + debug("__set: %s <-- %d" % (field, value)) self.debugfs.putval(os.path.join("smi_detector", field), str(value)) + if self.__get(field) != value: + raise RuntimeError, "Error setting %s to %d (%d)" % (field, value, self.__get(field)) def get(self, field): name = Smi.field_translate[field] + if name != field: + debug("get: %s translated to %s" % (field, name)) if field == "window": return self.get_window() elif field == "width": @@ -307,7 +316,6 @@ class Smi(object): interval = ms2us(self.__get('ms_between_samples')) return sample + interval - def set_window(self, window): width = ms2us(int(self.__get('ms_per_sample'))) interval = window - width @@ -317,6 +325,8 @@ class Smi(object): def set(self, field, val): name = Smi.field_translate[field] + if name != field: + debug ("set: %s translated to %s" % (field, name)) if field == "enable" and val: val = 1 if field == "window": @@ -334,6 +344,7 @@ class Smi(object): self.samples = [] testend = time.time() + duration threshold = self.get("threshold") + debug("detect: threshold %d" % threshold) pollcnt = 0 try: while time.time() < testend: @@ -341,7 +352,7 @@ class Smi(object): val = self.get_sample() if int(val) >= threshold: self.samples.append(val.strip()) - debug("got a latency sample: %s" % val.strip()) + debug("got a latency sample: %s (threshold: %d)" % (val.strip(), self.get("threshold"))) time.sleep(0.1) except KeyboardInterrupt, e: print "interrupted" |