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