aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTodd E Brandt <todd.e.brandt@linux.intel.com>2016-12-14 13:37:05 -0500
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2017-01-27 05:25:35 -0500
commit203f1f986a0d8504f0f843b42fa7f087d0c91a29 (patch)
treecb2007ace2ee6c24e9ec1db53049f856f68218cf
parent7a308bb3016f57e5be11a677d15b821536419d36 (diff)
scripts: analyze_suspend.py: Update to upstream v4.3
- config file support added - dev mode for monitoring kernel source calls and async kernel threads - custom command support for executing a user cmd instead of suspend - proc mode support for monitoring user processes with cpu exec data - kprobe support for custom function tracing - advanced callgraph support for function debug - many bug fixes and formatting upgrades Signed-off-by: Todd Brandt <todd.e.brandt@linux.intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rwxr-xr-xscripts/analyze_suspend.py972
1 files changed, 660 insertions, 312 deletions
diff --git a/scripts/analyze_suspend.py b/scripts/analyze_suspend.py
index a0ba48fa2c5e..baf5a080cc4c 100755
--- a/scripts/analyze_suspend.py
+++ b/scripts/analyze_suspend.py
@@ -66,6 +66,8 @@ import platform
66from datetime import datetime 66from datetime import datetime
67import struct 67import struct
68import ConfigParser 68import ConfigParser
69from threading import Thread
70import subprocess
69 71
70# ----------------- CLASSES -------------------- 72# ----------------- CLASSES --------------------
71 73
@@ -75,7 +77,7 @@ import ConfigParser
75# store system values and test parameters 77# store system values and test parameters
76class SystemValues: 78class SystemValues:
77 ansi = False 79 ansi = False
78 version = '4.2' 80 version = '4.3'
79 verbose = False 81 verbose = False
80 addlogs = False 82 addlogs = False
81 mindevlen = 0.001 83 mindevlen = 0.001
@@ -117,13 +119,16 @@ class SystemValues:
117 usetracemarkers = True 119 usetracemarkers = True
118 usekprobes = True 120 usekprobes = True
119 usedevsrc = False 121 usedevsrc = False
122 useprocmon = False
120 notestrun = False 123 notestrun = False
124 mixedphaseheight = True
121 devprops = dict() 125 devprops = dict()
122 postresumetime = 0 126 predelay = 0
127 postdelay = 0
128 procexecfmt = 'ps - (?P<ps>.*)$'
123 devpropfmt = '# Device Properties: .*' 129 devpropfmt = '# Device Properties: .*'
124 tracertypefmt = '# tracer: (?P<t>.*)' 130 tracertypefmt = '# tracer: (?P<t>.*)'
125 firmwarefmt = '# fwsuspend (?P<s>[0-9]*) fwresume (?P<r>[0-9]*)$' 131 firmwarefmt = '# fwsuspend (?P<s>[0-9]*) fwresume (?P<r>[0-9]*)$'
126 postresumefmt = '# post resume time (?P<t>[0-9]*)$'
127 stampfmt = '# suspend-(?P<m>[0-9]{2})(?P<d>[0-9]{2})(?P<y>[0-9]{2})-'+\ 132 stampfmt = '# suspend-(?P<m>[0-9]{2})(?P<d>[0-9]{2})(?P<y>[0-9]{2})-'+\
128 '(?P<H>[0-9]{2})(?P<M>[0-9]{2})(?P<S>[0-9]{2})'+\ 133 '(?P<H>[0-9]{2})(?P<M>[0-9]{2})(?P<S>[0-9]{2})'+\
129 ' (?P<host>.*) (?P<mode>.*) (?P<kernel>.*)$' 134 ' (?P<host>.*) (?P<mode>.*) (?P<kernel>.*)$'
@@ -152,20 +157,22 @@ class SystemValues:
152 'CPU_OFF': { 157 'CPU_OFF': {
153 'func':'_cpu_down', 158 'func':'_cpu_down',
154 'args_x86_64': {'cpu':'%di:s32'}, 159 'args_x86_64': {'cpu':'%di:s32'},
155 'format': 'CPU_OFF[{cpu}]', 160 'format': 'CPU_OFF[{cpu}]'
156 'mask': 'CPU_.*_DOWN'
157 }, 161 },
158 'CPU_ON': { 162 'CPU_ON': {
159 'func':'_cpu_up', 163 'func':'_cpu_up',
160 'args_x86_64': {'cpu':'%di:s32'}, 164 'args_x86_64': {'cpu':'%di:s32'},
161 'format': 'CPU_ON[{cpu}]', 165 'format': 'CPU_ON[{cpu}]'
162 'mask': 'CPU_.*_UP'
163 }, 166 },
164 } 167 }
165 dev_tracefuncs = { 168 dev_tracefuncs = {
166 # general wait/delay/sleep 169 # general wait/delay/sleep
167 'msleep': { 'args_x86_64': {'time':'%di:s32'} }, 170 'msleep': { 'args_x86_64': {'time':'%di:s32'} },
171 'schedule_timeout_uninterruptible': { 'args_x86_64': {'timeout':'%di:s32'} },
172 'schedule_timeout': { 'args_x86_64': {'timeout':'%di:s32'} },
168 'udelay': { 'func':'__const_udelay', 'args_x86_64': {'loops':'%di:s32'} }, 173 'udelay': { 'func':'__const_udelay', 'args_x86_64': {'loops':'%di:s32'} },
174 'usleep_range': { 'args_x86_64': {'min':'%di:s32', 'max':'%si:s32'} },
175 'mutex_lock_slowpath': { 'func':'__mutex_lock_slowpath' },
169 'acpi_os_stall': dict(), 176 'acpi_os_stall': dict(),
170 # ACPI 177 # ACPI
171 'acpi_resume_power_resources': dict(), 178 'acpi_resume_power_resources': dict(),
@@ -175,19 +182,27 @@ class SystemValues:
175 # ATA 182 # ATA
176 'ata_eh_recover': { 'args_x86_64': {'port':'+36(%di):s32'} }, 183 'ata_eh_recover': { 'args_x86_64': {'port':'+36(%di):s32'} },
177 # i915 184 # i915
178 'i915_gem_restore_gtt_mappings': dict(), 185 'i915_gem_resume': dict(),
186 'i915_restore_state': dict(),
179 'intel_opregion_setup': dict(), 187 'intel_opregion_setup': dict(),
188 'g4x_pre_enable_dp': dict(),
189 'vlv_pre_enable_dp': dict(),
190 'chv_pre_enable_dp': dict(),
191 'g4x_enable_dp': dict(),
192 'vlv_enable_dp': dict(),
193 'intel_hpd_init': dict(),
194 'intel_opregion_register': dict(),
180 'intel_dp_detect': dict(), 195 'intel_dp_detect': dict(),
181 'intel_hdmi_detect': dict(), 196 'intel_hdmi_detect': dict(),
182 'intel_opregion_init': dict(), 197 'intel_opregion_init': dict(),
198 'intel_fbdev_set_suspend': dict(),
183 } 199 }
184 kprobes_postresume = [ 200 kprobes_postresume = [
185 { 201 {
186 'name': 'ataportrst', 202 'name': 'ataportrst',
187 'func': 'ata_eh_recover', 203 'func': 'ata_eh_recover',
188 'args': {'port':'+36(%di):s32'}, 204 'args': {'port':'+36(%di):s32'},
189 'format': 'ata{port}_port_reset', 205 'format': 'ata{port}_port_reset'
190 'mask': 'ata.*_port_reset'
191 } 206 }
192 ] 207 ]
193 kprobes = dict() 208 kprobes = dict()
@@ -214,6 +229,13 @@ class SystemValues:
214 if num < 0 or num > 6: 229 if num < 0 or num > 6:
215 return 230 return
216 self.timeformat = '%.{0}f'.format(num) 231 self.timeformat = '%.{0}f'.format(num)
232 def setOutputFolder(self, value):
233 args = dict()
234 n = datetime.now()
235 args['date'] = n.strftime('%y%m%d')
236 args['time'] = n.strftime('%H%M%S')
237 args['hostname'] = self.hostname
238 self.outdir = value.format(**args)
217 def setOutputFile(self): 239 def setOutputFile(self):
218 if((self.htmlfile == '') and (self.dmesgfile != '')): 240 if((self.htmlfile == '') and (self.dmesgfile != '')):
219 m = re.match('(?P<name>.*)_dmesg\.txt$', self.dmesgfile) 241 m = re.match('(?P<name>.*)_dmesg\.txt$', self.dmesgfile)
@@ -253,8 +275,12 @@ class SystemValues:
253 self.testdir+'/'+self.prefix+'_'+self.suspendmode+'.html' 275 self.testdir+'/'+self.prefix+'_'+self.suspendmode+'.html'
254 if not os.path.isdir(self.testdir): 276 if not os.path.isdir(self.testdir):
255 os.mkdir(self.testdir) 277 os.mkdir(self.testdir)
256 def setDeviceFilter(self, devnames): 278 def setDeviceFilter(self, value):
257 self.devicefilter = string.split(devnames) 279 self.devicefilter = []
280 if value:
281 value = value.split(',')
282 for i in value:
283 self.devicefilter.append(i.strip())
258 def rtcWakeAlarmOn(self): 284 def rtcWakeAlarmOn(self):
259 os.system('echo 0 > '+self.rtcpath+'/wakealarm') 285 os.system('echo 0 > '+self.rtcpath+'/wakealarm')
260 outD = open(self.rtcpath+'/date', 'r').read().strip() 286 outD = open(self.rtcpath+'/date', 'r').read().strip()
@@ -351,17 +377,11 @@ class SystemValues:
351 fp = open(self.tpath+'set_graph_function', 'w') 377 fp = open(self.tpath+'set_graph_function', 'w')
352 fp.write(flist) 378 fp.write(flist)
353 fp.close() 379 fp.close()
354 def kprobeMatch(self, name, target):
355 if name not in self.kprobes:
356 return False
357 if re.match(self.kprobes[name]['mask'], target):
358 return True
359 return False
360 def basicKprobe(self, name): 380 def basicKprobe(self, name):
361 self.kprobes[name] = {'name': name,'func': name,'args': dict(),'format': name,'mask': name} 381 self.kprobes[name] = {'name': name,'func': name,'args': dict(),'format': name}
362 def defaultKprobe(self, name, kdata): 382 def defaultKprobe(self, name, kdata):
363 k = kdata 383 k = kdata
364 for field in ['name', 'format', 'mask', 'func']: 384 for field in ['name', 'format', 'func']:
365 if field not in k: 385 if field not in k:
366 k[field] = name 386 k[field] = name
367 archargs = 'args_'+platform.machine() 387 archargs = 'args_'+platform.machine()
@@ -625,8 +645,8 @@ class DevProps:
625 if self.xtraclass: 645 if self.xtraclass:
626 return ' '+self.xtraclass 646 return ' '+self.xtraclass
627 if self.async: 647 if self.async:
628 return ' async' 648 return ' async_device'
629 return ' sync' 649 return ' sync_device'
630 650
631# Class: DeviceNode 651# Class: DeviceNode
632# Description: 652# Description:
@@ -671,19 +691,31 @@ class Data:
671 end = 0.0 # test end 691 end = 0.0 # test end
672 tSuspended = 0.0 # low-level suspend start 692 tSuspended = 0.0 # low-level suspend start
673 tResumed = 0.0 # low-level resume start 693 tResumed = 0.0 # low-level resume start
694 tKernSus = 0.0 # kernel level suspend start
695 tKernRes = 0.0 # kernel level resume end
674 tLow = 0.0 # time spent in low-level suspend (standby/freeze) 696 tLow = 0.0 # time spent in low-level suspend (standby/freeze)
675 fwValid