Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(139)

Side by Side Diff: telemetry/telemetry/internal/platform/linux_platform_backend.py

Issue 3018563002: Remove Linux MSR power monitoring code (Closed)
Patch Set: Created 3 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | telemetry/telemetry/internal/platform/power_monitor/msr_power_monitor.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import logging 5 import logging
6 import os 6 import os
7 import platform 7 import platform
8 import subprocess 8 import subprocess
9 import sys 9 import sys
10 10
11 from py_utils import cloud_storage # pylint: disable=import-error 11 from py_utils import cloud_storage # pylint: disable=import-error
12 12
13 from telemetry.internal.util import binary_manager 13 from telemetry.internal.util import binary_manager
14 from telemetry.core import os_version 14 from telemetry.core import os_version
15 from telemetry.core import util 15 from telemetry.core import util
16 from telemetry import decorators 16 from telemetry import decorators
17 from telemetry.internal.platform import linux_based_platform_backend 17 from telemetry.internal.platform import linux_based_platform_backend
18 from telemetry.internal.platform import posix_platform_backend 18 from telemetry.internal.platform import posix_platform_backend
19 from telemetry.internal.platform.power_monitor import msr_power_monitor
20 19
21 20
22 _POSSIBLE_PERFHOST_APPLICATIONS = [ 21 _POSSIBLE_PERFHOST_APPLICATIONS = [
23 'perfhost_precise', 22 'perfhost_precise',
24 'perfhost_trusty', 23 'perfhost_trusty',
25 ] 24 ]
26 25
27 26
28 class LinuxPlatformBackend( 27 class LinuxPlatformBackend(
29 posix_platform_backend.PosixPlatformBackend, 28 posix_platform_backend.PosixPlatformBackend,
30 linux_based_platform_backend.LinuxBasedPlatformBackend): 29 linux_based_platform_backend.LinuxBasedPlatformBackend):
31 def __init__(self): 30 def __init__(self):
32 super(LinuxPlatformBackend, self).__init__() 31 super(LinuxPlatformBackend, self).__init__()
33 self._power_monitor = msr_power_monitor.MsrPowerMonitorLinux(self)
34 32
35 @classmethod 33 @classmethod
36 def IsPlatformBackendForHost(cls): 34 def IsPlatformBackendForHost(cls):
37 return sys.platform.startswith('linux') and not util.IsRunningOnCrosDevice() 35 return sys.platform.startswith('linux') and not util.IsRunningOnCrosDevice()
38 36
39 def IsThermallyThrottled(self): 37 def IsThermallyThrottled(self):
40 raise NotImplementedError() 38 raise NotImplementedError()
41 39
42 def HasBeenThermallyThrottled(self): 40 def HasBeenThermallyThrottled(self):
43 raise NotImplementedError() 41 raise NotImplementedError()
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 self._InstallIpfw() 91 self._InstallIpfw()
94 elif application == 'avconv': 92 elif application == 'avconv':
95 self._InstallBinary(application) 93 self._InstallBinary(application)
96 elif application in _POSSIBLE_PERFHOST_APPLICATIONS: 94 elif application in _POSSIBLE_PERFHOST_APPLICATIONS:
97 self._InstallBinary(application) 95 self._InstallBinary(application)
98 else: 96 else:
99 raise NotImplementedError( 97 raise NotImplementedError(
100 'Please teach Telemetry how to install ' + application) 98 'Please teach Telemetry how to install ' + application)
101 99
102 def CanMonitorPower(self): 100 def CanMonitorPower(self):
103 # TODO(charliea): This is a stopgap until all desktop power monitoring code
104 # can be removed. (crbug.com/763263)
105 return False 101 return False
106 102
107 def CanMeasurePerApplicationPower(self): 103 def CanMeasurePerApplicationPower(self):
108 return self._power_monitor.CanMeasurePerApplicationPower() 104 return False
109
110 def StartMonitoringPower(self, browser):
111 self._power_monitor.StartMonitoringPower(browser)
112
113 def StopMonitoringPower(self):
114 return self._power_monitor.StopMonitoringPower()
115
116 def ReadMsr(self, msr_number, start=0, length=64):
117 cmd = ['rdmsr', '-d', str(msr_number)]
118 (out, err) = subprocess.Popen(cmd,
119 stdout=subprocess.PIPE,
120 stderr=subprocess.PIPE).communicate()
121 if err:
122 raise OSError(err)
123 try:
124 result = int(out)
125 except ValueError:
126 raise OSError('Cannot interpret rdmsr output: %s' % out)
127 return result >> start & ((1 << length) - 1)
128 105
129 def _IsIpfwKernelModuleInstalled(self): 106 def _IsIpfwKernelModuleInstalled(self):
130 return 'ipfw_mod' in subprocess.Popen( 107 return 'ipfw_mod' in subprocess.Popen(
131 ['lsmod'], stdout=subprocess.PIPE).communicate()[0] 108 ['lsmod'], stdout=subprocess.PIPE).communicate()[0]
132 109
133 def _InstallIpfw(self): 110 def _InstallIpfw(self):
134 ipfw_bin = binary_manager.FindPath( 111 ipfw_bin = binary_manager.FindPath(
135 'ipfw', self.GetArchName(), self.GetOSName()) 112 'ipfw', self.GetArchName(), self.GetOSName())
136 ipfw_mod = binary_manager.FindPath( 113 ipfw_mod = binary_manager.FindPath(
137 'ipfw_mod.ko', self.GetArchName(), self.GetOSName()) 114 'ipfw_mod.ko', self.GetArchName(), self.GetOSName())
(...skipping 20 matching lines...) Expand all
158 assert self.CanLaunchApplication('ipfw'), 'Failed to install ipfw. ' \ 135 assert self.CanLaunchApplication('ipfw'), 'Failed to install ipfw. ' \
159 'ipfw provided binaries are not supported for linux kernel < 3.13. ' \ 136 'ipfw provided binaries are not supported for linux kernel < 3.13. ' \
160 'You may proceed by manually building and installing dummynet for ' \ 137 'You may proceed by manually building and installing dummynet for ' \
161 'your kernel. See: http://info.iet.unipi.it/~luigi/dummynet/' 138 'your kernel. See: http://info.iet.unipi.it/~luigi/dummynet/'
162 139
163 def _InstallBinary(self, bin_name): 140 def _InstallBinary(self, bin_name):
164 bin_path = binary_manager.FetchPath( 141 bin_path = binary_manager.FetchPath(
165 bin_name, self.GetArchName(), self.GetOSName()) 142 bin_name, self.GetArchName(), self.GetOSName())
166 os.environ['PATH'] += os.pathsep + os.path.dirname(bin_path) 143 os.environ['PATH'] += os.pathsep + os.path.dirname(bin_path)
167 assert self.CanLaunchApplication(bin_name), 'Failed to install ' + bin_name 144 assert self.CanLaunchApplication(bin_name), 'Failed to install ' + bin_name
OLDNEW
« no previous file with comments | « no previous file | telemetry/telemetry/internal/platform/power_monitor/msr_power_monitor.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698