From b1c507531db2a4bdfe2708d2576ad02bbe47abd0 Mon Sep 17 00:00:00 2001 From: Clark Williams Date: Fri, 28 Aug 2015 14:54:19 -0500 Subject: hwlatdetect: initial cut at tracking the amount of SMIs that occurred during a run Signed-off-by: Clark Williams Signed-off-by: John Kacur --- src/hwlatdetect/hwlatdetect.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/hwlatdetect/hwlatdetect.py b/src/hwlatdetect/hwlatdetect.py index 867856a..dbf3f67 100755 --- a/src/hwlatdetect/hwlatdetect.py +++ b/src/hwlatdetect/hwlatdetect.py @@ -1,5 +1,6 @@ #!/usr/bin/python +# (C) 2015 Clark Williams # (C) 2009 Clark Williams # # This program is free software; you can redistribute it and/or @@ -11,6 +12,7 @@ import os import time import subprocess import errno +import os.path version = "0.6" debugging = False @@ -164,6 +166,19 @@ class Detector(object): self.detector = Smi(self.debugfs) self.samples = [] self.testduration = 10 # ten seconds + self.have_msr = False + self.initsmi = [] + if os.path.exists('/usr/sbin/rdmsr'): + self.have_msr = True + self.initsmi = self.getsmicounts() + + def getsmicounts(self): + counts = [] + if self.have_msr: + p = subprocess.Popen(['/usr/sbin/rdmsr', '-a', '-d', '0x34'], stdout=subprocess.PIPE) + p.wait() + counts = [ int(x.strip()) for x in p.stdout.readlines()] + return counts def force_cleanup(self): debug("forcing unload of hwlat module") @@ -530,6 +545,16 @@ if __name__ == '__main__': info("Samples recorded: %d" % len(detect.samples)) info("Samples exceeding threshold: %d" % exceeding) + if detect.have_msr: + finishsmi = detect.getsmicounts() + total_smis = 0 + for i,count in enumerate(finishsmi): + if count > detect.initsmi[i]: + smis = count - detect.initsmi[i] + total_smis += smis + print "%d SMIs occured on cpu %d" % (smis, i) + info("SMIs during run: %d" % total_smis) + if reportfile: count = 0 f = open(reportfile, "w") -- cgit 1.2.3-korg