1""" 2Lockstat is the basic tool used to control the kernel's Lockmeter 3functionality: e.g., turning the kernel's data gathering on or off, and 4retrieving that data from the kernel so that Lockstat can massage it and 5produce printed reports. See http://oss.sgi.com/projects/lockmeter for 6details. 7 8NOTE: if you get compile errors from config.h, referring you to a FAQ, 9you might need to do 'cat < /dev/null > /usr/include/linux/config.h'. 10But read the FAQ first. 11""" 12import os 13from autotest_lib.client.bin import utils, profiler 14 15class lockmeter(profiler.profiler): 16 version = 1 17 18# ftp://oss.sgi.com/projects/lockmeter/download/lockstat-1.4.11.tar.gz 19# patched with lockstat.diff 20# ftp://oss.sgi.com/projects/lockmeter/download/v2.6/patch.2.6.14-lockmeter-1.gz 21# is the kernel patch 22 23 def setup(self, tarball = 'lockstat-1.4.11.tar.bz2'): 24 self.tarball = utils.unmap_url(self.bindir, tarball, self.tmpdir) 25 utils.extract_tarball_to_dir(self.tarball, self.srcdir) 26 os.chdir(self.srcdir) 27 28 utils.make() 29 self.cmd = self.srcdir + '/lockstat' 30 31 32 def initialize(self): 33 self.job.require_gcc() 34 35 if not os.path.exists('/proc/lockmeter'): 36 msg = ('Lockmeter is not compiled into your kernel' 37 'Please fix and try again') 38 print msg 39 raise AssertionError(msg) 40 41 42 def start(self, test): 43 utils.system(self.cmd + ' off') 44 utils.system(self.cmd + ' reset') 45 utils.system(self.cmd + ' on') 46 47 48 def stop(self, test): 49 utils.system(self.cmd + ' off') 50 51 52 def report(self, test): 53 args = ' -m ' + utils.get_systemmap() 54 self.output = self.profdir + '/results/lockstat' 55 utils.system(self.cmd + args + ' print > ' + self.output) 56