History

Merge branch 'pm-tools'

* pm-tools: tools/power/x86: Debug utility for intel_pstate driver AnalyzeSuspend: fix drag and zoom bug in javascript scripts: analyze_suspend.py: Update to upstream v4.5 scripts: analyze_suspend.py: Update to upstream v4.4 scripts: analyze_suspend.py: Update to upstream v4.3

Rafael J. Wysocki committed 9 years ago

Commit eee77a82 parents fccddb2 48385dd2 files · +1704 −798Browse files

Showing the changes to scripts (1 of 2 files). Show all

Unified · Split

scripts/analyze_suspend.py+1135−798
@@ -24,11 +24,6 @@ · 23 unmodified lines
2424 # https://01.org/suspendresume
2525 # Source repo
2626 # https://github.com/01org/suspendresume
27−# Documentation
28−# Getting Started
29−# https://01.org/suspendresume/documentation/getting-started
30−# Command List:
31−# https://01.org/suspendresume/documentation/command-list
3227 #
3328 # Description:
3429 # This tool is designed to assist kernel and OS developers in optimizing
@@ -66,6 +61,8 @@ import platform · 31 unmodified lines
6661 from datetime import datetime
6762 import struct
6863 import ConfigParser
64+from threading import Thread
65+from subprocess import call, Popen, PIPE
6966
7067 # ----------------- CLASSES --------------------
7168
@@ -75,11 +72,15 @@ import ConfigParser · 3 unmodified lines
7572 # store system values and test parameters
7673 class SystemValues:
7774 ansi = False
78− version = '4.2'
75+ version = '4.5'
7976 verbose = False
8077 addlogs = False
81− mindevlen = 0.001
82− mincglen = 1.0
78+ mindevlen = 0.0
79+ mincglen = 0.0
80+ cgphase = ''
81+ cgtest = -1
82+ callloopmaxgap = 0.0001
83+ callloopmaxlen = 0.005
8384 srgap = 0
8485 cgexp = False
8586 outdir = ''
@@ -92,6 +93,7 @@ class SystemValues: · 6 unmodified lines
9293 'device_pm_callback_end',
9394 'device_pm_callback_start'
9495 ]
96+ logmsg = ''
9597 testcommand = ''
9698 mempath = '/dev/mem'
9799 powerfile = '/sys/power/state'
@@ -117,19 +119,19 @@ class SystemValues: · 19 unmodified lines
117119 usetracemarkers = True
118120 usekprobes = True
119121 usedevsrc = False
122+ useprocmon = False
120123 notestrun = False
124+ mixedphaseheight = True
121125 devprops = dict()
122− postresumetime = 0
126+ predelay = 0
127+ postdelay = 0
128+ procexecfmt = 'ps - (?P<ps>.*)$'
123129 devpropfmt = '# Device Properties: .*'
124130 tracertypefmt = '# tracer: (?P<t>.*)'
125131 firmwarefmt = '# fwsuspend (?P<s>[0-9]*) fwresume (?P<r>[0-9]*)$'
126− postresumefmt = '# post resume time (?P<t>[0-9]*)$'
127132 stampfmt = '# suspend-(?P<m>[0-9]{2})(?P<d>[0-9]{2})(?P<y>[0-9]{2})-'+\
128133 '(?P<H>[0-9]{2})(?P<M>[0-9]{2})(?P<S>[0-9]{2})'+\
129134 ' (?P<host>.*) (?P<mode>.*) (?P<kernel>.*)$'
130− kprobecolor = 'rgba(204,204,204,0.5)'
131− synccolor = 'rgba(204,204,204,0.5)'
132− debugfuncs = []
133135 tracefuncs = {
134136 'sys_sync': dict(),
135137 'pm_prepare_console': dict(),
@@ -152,44 +154,66 @@ class SystemValues: · 16 unmodified lines
152154 'CPU_OFF': {
153155 'func':'_cpu_down',
154156 'args_x86_64': {'cpu':'%di:s32'},
155− 'format': 'CPU_OFF[{cpu}]',
156− 'mask': 'CPU_.*_DOWN'
157+ 'format': 'CPU_OFF[{cpu}]'
157158 },
158159 'CPU_ON': {
159160 'func':'_cpu_up',
160161 'args_x86_64': {'cpu':'%di:s32'},
161− 'format': 'CPU_ON[{cpu}]',
162− 'mask': 'CPU_.*_UP'
162+ 'format': 'CPU_ON[{cpu}]'
163163 },
164164 }
165165 dev_tracefuncs = {
166166 # general wait/delay/sleep
167− 'msleep': { 'args_x86_64': {'time':'%di:s32'} },
168− 'udelay': { 'func':'__const_udelay', 'args_x86_64': {'loops':'%di:s32'} },
169− 'acpi_os_stall': dict(),
167+ 'msleep': { 'args_x86_64': {'time':'%di:s32'}, 'ub': 1 },
168+ 'schedule_timeout_uninterruptible': { 'args_x86_64': {'timeout':'%di:s32'}, 'ub': 1 },
169+ 'schedule_timeout': { 'args_x86_64': {'timeout':'%di:s32'}, 'ub': 1 },
170+ 'udelay': { 'func':'__const_udelay', 'args_x86_64': {'loops':'%di:s32'}, 'ub': 1 },
171+ 'usleep_range': { 'args_x86_64': {'min':'%di:s32', 'max':'%si:s32'}, 'ub': 1 },
172+ 'mutex_lock_slowpath': { 'func':'__mutex_lock_slowpath', 'ub': 1 },
173+ 'acpi_os_stall': {'ub': 1},
170174 # ACPI
171175 'acpi_resume_power_resources': dict(),
172176 'acpi_ps_parse_aml': dict(),
173177 # filesystem
174178 'ext4_sync_fs': dict(),
179+ # 80211
180+ 'iwlagn_mac_start': dict(),
181+ 'iwlagn_alloc_bcast_station': dict(),
182+ 'iwl_trans_pcie_start_hw': dict(),
183+ 'iwl_trans_pcie_start_fw': dict(),
184+ 'iwl_run_init_ucode': dict(),
185+ 'iwl_load_ucode_wait_alive': dict(),
186+ 'iwl_alive_start': dict(),
187+ 'iwlagn_mac_stop': dict(),
188+ 'iwlagn_mac_suspend': dict(),
189+ 'iwlagn_mac_resume': dict(),
190+ 'iwlagn_mac_add_interface': dict(),
191+ 'iwlagn_mac_remove_interface': dict(),
192+ 'iwlagn_mac_change_interface': dict(),
193+ 'iwlagn_mac_config': dict(),
194+ 'iwlagn_configure_filter': dict(),
195+ 'iwlagn_mac_hw_scan': dict(),
196+ 'iwlagn_bss_info_changed': dict(),
197+ 'iwlagn_mac_channel_switch': dict(),
198+ 'iwlagn_mac_flush': dict(),
175199 # ATA
176200 'ata_eh_recover': { 'args_x86_64': {'port':'+36(%di):s32'} },
177201 # i915
178− 'i915_gem_restore_gtt_mappings': dict(),
202+ 'i915_gem_resume': dict(),
203+ 'i915_restore_state': dict(),
179204 'intel_opregion_setup': dict(),
205+ 'g4x_pre_enable_dp': dict(),
206+ 'vlv_pre_enable_dp': dict(),
207+ 'chv_pre_enable_dp': dict(),
208+ 'g4x_enable_dp': dict(),
209+ 'vlv_enable_dp': dict(),
210+ 'intel_hpd_init': dict(),
211+ 'intel_opregion_register': dict(),
180212 'intel_dp_detect': dict(),
181213 'intel_hdmi_detect': dict(),
182214 'intel_opregion_init': dict(),
215+ 'intel_fbdev_set_suspend': dict(),
183216 }
184− kprobes_postresume = [
185− {
186− 'name': 'ataportrst',
187− 'func': 'ata_eh_recover',
188− 'args': {'port':'+36(%di):s32'},
189− 'format': 'ata{port}_port_reset',
190− 'mask': 'ata.*_port_reset'
191− }
192− ]
193217 kprobes = dict()
194218 timeformat = '%.3f'
195219 def __init__(self):
@@ -198,6 +222,7 @@ class SystemValues: · 2 unmodified lines
198222 self.embedded = True
199223 self.addlogs = True
200224 self.htmlfile = os.environ['LOG_FILE']
225+ self.archargs = 'args_'+platform.machine()
201226 self.hostname = platform.node()
202227 if(self.hostname == ''):
203228 self.hostname = 'localhost'
@@ -214,6 +239,13 @@ class SystemValues: · 10 unmodified lines
214239 if num < 0 or num > 6:
215240 return
216241 self.timeformat = '%.{0}f'.format(num)
242+ def setOutputFolder(self, value):
243+ args = dict()
244+ n = datetime.now()
245+ args['date'] = n.strftime('%y%m%d')
246+ args['time'] = n.strftime('%H%M%S')
247+ args['hostname'] = self.hostname
248+ self.outdir = value.format(**args)
217249 def setOutputFile(self):
218250 if((self.htmlfile == '') and (self.dmesgfile != '')):
219251 m = re.match('(?P<name>.*)_dmesg\.txt$', self.dmesgfile)
@@ -253,10 +285,14 @@ class SystemValues: · 33 unmodified lines
253285 self.testdir+'/'+self.prefix+'_'+self.suspendmode+'.html'
254286 if not os.path.isdir(self.testdir):
255287 os.mkdir(self.testdir)
256− def setDeviceFilter(self, devnames):
257− self.devicefilter = string.split(devnames)
288+ def setDeviceFilter(self, value):
289+ self.devicefilter = []
290+ if value:
291+ value = value.split(',')
292+ for i in value:
293+ self.devicefilter.append(i.strip())
258294 def rtcWakeAlarmOn(self):
259− os.system('echo 0 > '+self.rtcpath+'/wakealarm')
295+ call('echo 0 > '+self.rtcpath+'/wakealarm', shell=True)
260296 outD = open(self.rtcpath+'/date', 'r').read().strip()
261297 outT = open(self.rtcpath+'/time', 'r').read().strip()
262298 mD = re.match('^(?P<y>[0-9]*)-(?P<m>[0-9]*)-(?P<d>[0-9]*)', outD)
@@ -272,12 +308,12 @@ class SystemValues: · 9 unmodified lines
272308 # if hardware time fails, use the software time
273309 nowtime = int(datetime.now().strftime('%s'))
274310 alarm = nowtime + self.rtcwaketime
275− os.system('echo %d > %s/wakealarm' % (alarm, self.rtcpath))
311+ call('echo %d > %s/wakealarm' % (alarm, self.rtcpath), shell=True)
276312 def rtcWakeAlarmOff(self):
277− os.system('echo 0 > %s/wakealarm' % self.rtcpath)
313+ call('echo 0 > %s/wakealarm' % self.rtcpath, shell=True)
278314 def initdmesg(self):
279315 # get the latest time stamp from the dmesg log
280− fp = os.popen('dmesg')
316+ fp = Popen('dmesg', stdout=PIPE).stdout
281317 ktime = '0'
282318 for line in fp:
283319 line = line.replace('\r\n', '')
@@ -291,7 +327,7 @@ class SystemValues: · 7 unmodified lines
291327 self.dmesgstart = float(ktime)
292328 def getdmesg(self):
293329 # store all new dmesg lines since initdmesg was called
294− fp = os.popen('dmesg')
330+ fp = Popen('dmesg', stdout=PIPE).stdout
295331 op = open(self.dmesgfile, 'a')
296332 for line in fp:
297333 line = line.replace('\r\n', '')
@@ -317,25 +353,18 @@ class SystemValues: · 19 unmodified lines
317353 def getFtraceFilterFunctions(self, current):
318354 rootCheck(True)
319355 if not current:
320− os.system('cat '+self.tpath+'available_filter_functions')
356+ call('cat '+self.tpath+'available_filter_functions', shell=True)
321357 return
322358 fp = open(self.tpath+'available_filter_functions')
323359 master = fp.read().split('\n')
324360 fp.close()
325− if len(self.debugfuncs) > 0:
326− for i in self.debugfuncs:
327− if i in master:
328− print i
329− else:
330− print self.colorText(i)
331− else:
332− for i in self.tracefuncs:
333− if 'func' in self.tracefuncs[i]:
334− i = self.tracefuncs[i]['func']
335− if i in master:
336− print i
337− else:
338− print self.colorText(i)
361+ for i in self.tracefuncs:
362+ if 'func' in self.tracefuncs[i]:
363+ i = self.tracefuncs[i]['func']
364+ if i in master:
365+ print i
366+ else:
367+ print self.colorText(i)
339368 def setFtraceFilterFunctions(self, list):
340369 fp = open(self.tpath+'available_filter_functions')
341370 master = fp.read().split('\n')
@@ -351,22 +380,15 @@ class SystemValues: · 9 unmodified lines
351380 fp = open(self.tpath+'set_graph_function', 'w')
352381 fp.write(flist)
353382 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
360383 def basicKprobe(self, name):
361− self.kprobes[name] = {'name': name,'func': name,'args': dict(),'format': name,'mask': name}
384+ self.kprobes[name] = {'name': name,'func': name,'args': dict(),'format': name}
362385 def defaultKprobe(self, name, kdata):
363386 k = kdata
364− for field in ['name', 'format', 'mask', 'func']:
387+ for field in ['name', 'format', 'func']:
365388 if field not in k:
366389 k[field] = name
367− archargs = 'args_'+platform.machine()
368− if archargs in k:
369− k['args'] = k[archargs]
390+ if self.archargs in k:
391+ k['args'] = k[self.archargs]
370392 else:
371393 k['args'] = dict()
372394 k['format'] = name
@@ -403,49 +425,80 @@ class SystemValues: · 30 unmodified lines
403425 out = fmt.format(**arglist)
404426 out = out.replace(' ', '_').replace('"', '')
405427 return out
406− def kprobeText(self, kprobe):
407− name, fmt, func, args = kprobe['name'], kprobe['format'], kprobe['func'], kprobe['args']
428+ def kprobeText(self, kname, kprobe):
429+ name = fmt = func = kname
430+ args = dict()
431+ if 'name' in kprobe:
432+ name = kprobe['name']
433+ if 'format' in kprobe:
434+ fmt = kprobe['format']
435+ if 'func' in kprobe:
436+ func = kprobe['func']
437+ if self.archargs in kprobe:
438+ args = kprobe[self.archargs]
439+ if 'args' in kprobe:
440+ args = kprobe['args']
408441 if re.findall('{(?P<n>[a-z,A-Z,0-9]*)}', func):
409− doError('Kprobe "%s" has format info in the function name "%s"' % (name, func), False)
442+ doError('Kprobe "%s" has format info in the function name "%s"' % (name, func))
410443 for arg in re.findall('{(?P<n>[a-z,A-Z,0-9]*)}', fmt):
411444 if arg not in args:
412− doError('Kprobe "%s" is missing argument "%s"' % (name, arg), False)
445+ doError('Kprobe "%s" is missing argument "%s"' % (name, arg))
413446 val = 'p:%s_cal %s' % (name, func)
414447 for i in sorted(args):
415448 val += ' %s=%s' % (i, args[i])
416449 val += '\nr:%s_ret %s $retval\n' % (name, func)
417450 return val
418− def addKprobes(self):
451+ def addKprobes(self, output=False):
452+ if len(sysvals.kprobes) < 1:
453+ return
454+ if output:
455+ print(' kprobe functions in this kernel:')
419456 # first test each kprobe
420− print('INITIALIZING KPROBES...')
421457 rejects = []
458+ # sort kprobes: trace, ub-dev, custom, dev
459+ kpl = [[], [], [], []]
422460 for name in sorted(self.kprobes):
423− if not self.testKprobe(self.kprobes[name]):
461+ res = self.colorText('YES', 32)
462+ if not self.testKprobe(name, self.kprobes[name]):
463+ res = self.colorText('NO')
424464 rejects.append(name)
465+ else:
466+ if name in self.tracefuncs:
467+ kpl[0].append(name)
468+ elif name in self.dev_tracefuncs:
469+ if 'ub' in self.dev_tracefuncs[name]:
470+ kpl[1].append(name)
471+ else:
472+ kpl[3].append(name)
473+ else:
474+ kpl[2].append(name)
475+ if output:
476+ print(' %s: %s' % (name, res))
477+ kplist = kpl[0] + kpl[1] + kpl[2] + kpl[3]
425478 # remove all failed ones from the list
426479 for name in rejects:
427− vprint('Skipping KPROBE: %s' % name)
428480 self.kprobes.pop(name)
481+ # set the kprobes all at once
429482 self.fsetVal('', 'kprobe_events')
430483 kprobeevents = ''
431− # set the kprobes all at once
432− for kp in self.kprobes:
433− val = self.kprobeText(self.kprobes[kp])
434− vprint('Adding KPROBE: %s\n%s' % (kp, val.strip()))
435− kprobeevents += self.kprobeText(self.kprobes[kp])
484+ for kp in kplist:
485+ kprobeevents += self.kprobeText(kp, self.kprobes[kp])
436486 self.fsetVal(kprobeevents, 'kprobe_events')
437487 # verify that the kprobes were set as ordered
438488 check = self.fgetVal('kprobe_events')
439− linesout = len(kprobeevents.split('\n'))
440− linesack = len(check.split('\n'))
441− if linesack < linesout:
442− # if not, try appending the kprobes 1 by 1
443− for kp in self.kprobes:
444− kprobeevents = self.kprobeText(self.kprobes[kp])
445− self.fsetVal(kprobeevents, 'kprobe_events', 'a')
489+ linesout = len(kprobeevents.split('\n')) - 1
490+ linesack = len(check.split('\n')) - 1
491+ if output:
492+ res = '%d/%d' % (linesack, linesout)
493+ if linesack < linesout:
494+ res = self.colorText(res, 31)
495+ else:
496+ res = self.colorText(res, 32)
497+ print(' working kprobe functions enabled: %s' % res)
446498 self.fsetVal('1', 'events/kprobes/enable')
447− def testKprobe(self, kprobe):
448− kprobeevents = self.kprobeText(kprobe)
499+ def testKprobe(self, kname, kprobe):
500+ self.fsetVal('0', 'events/kprobes/enable')
501+ kprobeevents = self.kprobeText(kname, kprobe)
449502 if not kprobeevents:
450503 return False
451504 try:
@@ -463,8 +516,9 @@ class SystemValues: · 11 unmodified lines
463516 if not os.path.exists(file):
464517 return False
465518 try:
466− fp = open(file, mode)
519+ fp = open(file, mode, 0)
467520 fp.write(val)
521+ fp.flush()
468522 fp.close()
469523 except:
470524 pass
@@ -491,21 +545,17 @@ class SystemValues: · 20 unmodified lines
491545 for name in self.dev_tracefuncs:
492546 self.defaultKprobe(name, self.dev_tracefuncs[name])
493547 def isCallgraphFunc(self, name):
494− if len(self.debugfuncs) < 1 and self.suspendmode == 'command':
495− return True
496− if name in self.debugfuncs:
548+ if len(self.tracefuncs) < 1 and self.suspendmode == 'command':
497549 return True
498− funclist = []
499550 for i in self.tracefuncs:
500551 if 'func' in self.tracefuncs[i]:
501− funclist.append(self.tracefuncs[i]['func'])
552+ f = self.tracefuncs[i]['func']
502553 else:
503− funclist.append(i)
504− if name in funclist:
505− return True
554+ f = i
555+ if name == f:
556+ return True
506557 return False
507558 def initFtrace(self, testing=False):
508− tp = self.tpath
509559 print('INITIALIZING FTRACE...')
510560 # turn trace off
511561 self.fsetVal('0', 'tracing_on')
@@ -518,18 +568,7 @@ class SystemValues: · 6 unmodified lines
518568 # go no further if this is just a status check
519569 if testing:
520570 return
521− if self.usekprobes:
522− # add tracefunc kprobes so long as were not using full callgraph
523− if(not self.usecallgraph or len(self.debugfuncs) > 0):
524− for name in self.tracefuncs:
525− self.defaultKprobe(name, self.tracefuncs[name])
526− if self.usedevsrc:
527− for name in self.dev_tracefuncs:
528− self.defaultKprobe(name, self.dev_tracefuncs[name])
529− else:
530− self.usedevsrc = False
531− self.addKprobes()
532− # initialize the callgraph trace, unless this is an x2 run
571+ # initialize the callgraph trace
533572 if(self.usecallgraph):
534573 # set trace type
535574 self.fsetVal('function_graph', 'current_tracer')
@@ -545,20 +584,24 @@ class SystemValues: · 9 unmodified lines
545584 self.fsetVal('context-info', 'trace_options')
546585 self.fsetVal('graph-time', 'trace_options')
547586 self.fsetVal('0', 'max_graph_depth')
548− if len(self.debugfuncs) > 0:
549− self.setFtraceFilterFunctions(self.debugfuncs)
550− elif self.suspendmode == 'command':
551− self.fsetVal('', 'set_graph_function')
552− else:
553− cf = ['dpm_run_callback']
554− if(self.usetraceeventsonly):
555− cf += ['dpm_prepare', 'dpm_complete']
556− for fn in self.tracefuncs:
557− if 'func' in self.tracefuncs[fn]:
558− cf.append(self.tracefuncs[fn]['func'])
559− else:
560− cf.append(fn)
561− self.setFtraceFilterFunctions(cf)
587+ cf = ['dpm_run_callback']
588+ if(self.usetraceeventsonly):
589+ cf += ['dpm_prepare', 'dpm_complete']
590+ for fn in self.tracefuncs:
591+ if 'func' in self.tracefuncs[fn]:
592+ cf.append(self.tracefuncs[fn]['func'])
593+ else:
594+ cf.append(fn)
595+ self.setFtraceFilterFunctions(cf)
596+ # initialize the kprobe trace
597+ elif self.usekprobes:
598+ for name in self.tracefuncs:
599+ self.defaultKprobe(name, self.tracefuncs[name])
600+ if self.usedevsrc:
601+ for name in self.dev_tracefuncs:
602+ self.defaultKprobe(name, self.dev_tracefuncs[name])
603+ print('INITIALIZING KPROBES...')
604+ self.addKprobes(self.verbose)
562605 if(self.usetraceevents):
563606 # turn trace events on
564607 events = iter(self.traceevents)
@@ -590,10 +633,10 @@ class SystemValues: · 25 unmodified lines
590633 if(os.path.exists(tp+f) == False):
591634 return False
592635 return True
593− def colorText(self, str):
636+ def colorText(self, str, color=31):
594637 if not self.ansi:
595638 return str
596− return '\x1B[31;40m'+str+'\x1B[m'
639+ return '\x1B[%d;40m%s\x1B[m' % (color, str)
597640
598641 sysvals = SystemValues()
599642
@@ -625,8 +668,8 @@ class DevProps: · 25 unmodified lines
625668 if self.xtraclass:
626669 return ' '+self.xtraclass
627670 if self.async:
628− return ' async'
629− return ' sync'
671+ return ' async_device'
672+ return ' sync_device'
630673
631674 # Class: DeviceNode
632675 # Description:
@@ -646,8 +689,6 @@ class DeviceNode: · 13 unmodified lines
646689 # The primary container for suspend/resume test data. There is one for
647690 # each test run. The data is organized into a cronological hierarchy:
648691 # Data.dmesg {
649−# root structure, started as dmesg & ftrace, but now only ftrace
650−# contents: times for suspend start/end, resume start/end, fwdata
651692 # phases {
652693 # 10 sequential, non-overlapping phases of S/R
653694 # contents: times for phase start/end, order/color data for html
@@ -658,7 +699,7 @@ class DeviceNode: · 4 unmodified lines
658699 # contents: start/stop times, pid/cpu/driver info
659700 # parents/children, html id for timeline/callgraph
660701 # optionally includes an ftrace callgraph
661−# optionally includes intradev trace events
702+# optionally includes dev/ps data
662703 # }
663704 # }
664705 # }
@@ -671,19 +712,24 @@ class Data: · 6 unmodified lines
671712 end = 0.0 # test end
672713 tSuspended = 0.0 # low-level suspend start
673714 tResumed = 0.0 # low-level resume start
715+ tKernSus = 0.0 # kernel level suspend start
716+ tKernRes = 0.0 # kernel level resume end
674717 tLow = 0.0 # time spent in low-level suspend (standby/freeze)
675718 fwValid = False # is firmware data available
676719 fwSuspend = 0 # time spent in firmware suspend
677720 fwResume = 0 # time spent in firmware resume
678721 dmesgtext = [] # dmesg text file in memory
722+ pstl = 0 # process timeline
679723 testnumber = 0
680724 idstr = ''
681725 html_device_id = 0
682726 stamp = 0
683727 outfile = ''
684− dev_ubiquitous = ['msleep', 'udelay']
728+ devpids = []
729+ kerror = False
685730 def __init__(self, num):
686− idchar = 'abcdefghijklmnopqrstuvwxyz'
731+ idchar = 'abcdefghij'
732+ self.pstl = dict()
687733 self.testnumber = num
688734 self.idstr = idchar[num]
689735 self.dmesgtext = []
@@ -714,16 +760,39 @@ class Data: · 24 unmodified lines
714760 self.devicegroups = []
715761 for phase in self.phases:
716762 self.devicegroups.append([phase])
717− def getStart(self):
718− return self.dmesg[self.phases[0]]['start']
763+ self.errorinfo = {'suspend':[],'resume':[]}
764+ def extractErrorInfo(self, dmesg):
765+ error = ''
766+ tm = 0.0
767+ for i in range(len(dmesg)):
768+ if 'Call Trace:' in dmesg[i]:
769+ m = re.match('[ \t]*(\[ *)(?P<ktime>[0-9\.]*)(\]) .*', dmesg[i])
770+ if not m:
771+ continue
772+ tm = float(m.group('ktime'))
773+ if tm < self.start or tm > self.end:
774+ continue
775+ for j in range(i-10, i+1):
776+ error += dmesg[j]
777+ continue
778+ if error:
779+ m = re.match('[ \t]*\[ *[0-9\.]*\] \[\<[0-9a-fA-F]*\>\] .*', dmesg[i])
780+ if m:
781+ error += dmesg[i]
782+ else:
783+ if tm < self.tSuspended:
784+ dir = 'suspend'
785+ else:
786+ dir = 'resume'
787+ error = error.replace('<', '&lt').replace('>', '&gt')
788+ vprint('kernel error found in %s at %f' % (dir, tm))
789+ self.errorinfo[dir].append((tm, error))
790+ self.kerror = True
791+ error = ''
719792 def setStart(self, time):
720793 self.start = time
721− self.dmesg[self.phases[0]]['start'] = time
722− def getEnd(self):
723− return self.dmesg[self.phases[-1]]['end']
724794 def setEnd(self, time):
725795 self.end = time
726− self.dmesg[self.phases[-1]]['end'] = time
727796 def isTraceEventOutsideDeviceCalls(self, pid, time):
728797 for phase in self.phases:
729798 list = self.dmesg[phase]['list']
@@ -733,39 +802,67 @@ class Data: · 3 unmodified lines
733802 time < d['end']):
734803 return False
735804 return True
736− def targetDevice(self, phaselist, start, end, pid=-1):
805+ def sourcePhase(self, start):
806+ for phase in self.phases:
807+ pend = self.dmesg[phase]['end']
808+ if start <= pend:
809+ return phase
810+ return 'resume_complete'
811+ def sourceDevice(self, phaselist, start, end, pid, type):
737812 tgtdev = ''
738813 for phase in phaselist:
739814 list = self.dmesg[phase]['list']
740815 for devname in list:
741816 dev = list[devname]
742− if(pid >= 0 and dev['pid'] != pid):
817+ # pid must match
818+ if dev['pid'] != pid:
743819 continue
744820 devS = dev['start']
745821 devE = dev['end']
746− if(start < devS or start >= devE or end <= devS or end > devE):
747− continue
822+ if type == 'device':
823+ # device target event is entirely inside the source boundary
824+ if(start < devS or start >= devE or end <= devS or end > devE):
825+ continue
826+ elif type == 'thread':
827+ # thread target event will expand the source boundary
828+ if start < devS:
829+ dev['start'] = start
830+ if end > devE:
831+ dev['end'] = end
748832 tgtdev = dev
749833 break
750834 return tgtdev
751835 def addDeviceFunctionCall(self, displayname, kprobename, proc, pid, start, end, cdata, rdata):
752− machstart = self.dmesg['suspend_machine']['start']
753− machend = self.dmesg['resume_machine']['end']
754− tgtdev = self.targetDevice(self.phases, start, end, pid)
755− if not tgtdev and start >= machstart and end < machend:
756− # device calls in machine phases should be serial
757− tgtdev = self.targetDevice(['suspend_machine', 'resume_machine'], start, end)
836+ # try to place the call in a device
837+ tgtdev = self.sourceDevice(self.phases, start, end, pid, 'device')
838+ # calls with device pids that occur outside device bounds are dropped
839+ # TODO: include these somehow
840+ if not tgtdev and pid in self.devpids:
841+ return False
842+ # try to place the call in a thread
758843 if not tgtdev:
759− if 'scsi_eh' in proc:
760− self.newActionGlobal(proc, start, end, pid)
761− self.addDeviceFunctionCall(displayname, kprobename, proc, pid, start, end, cdata, rdata)
844+ tgtdev = self.sourceDevice(self.phases, start, end, pid, 'thread')
845+ # create new thread blocks, expand as new calls are found
846+ if not tgtdev:
847+ if proc == '<...>':
848+ threadname = 'kthread-%d' % (pid)
762849 else:
763− vprint('IGNORE: %s[%s](%d) [%f - %f] | %s | %s | %s' % (displayname, kprobename,
764− pid, start, end, cdata, rdata, proc))
850+ threadname = '%s-%d' % (proc, pid)
851+ tgtphase = self.sourcePhase(start)
852+ self.newAction(tgtphase, threadname, pid, '', start, end, '', ' kth', '')
853+ return self.addDeviceFunctionCall(displayname, kprobename, proc, pid, start, end, cdata, rdata)
854+ # this should not happen
855+ if not tgtdev:
856+ vprint('[%f - %f] %s-%d %s %s %s' % \
857+ (start, end, proc, pid, kprobename, cdata, rdata))
765858 return False
766− # detail block fits within tgtdev
859+ # place the call data inside the src element of the tgtdev
767860 if('src' not in tgtdev):
768861 tgtdev['src'] = []
862+ dtf = sysvals.dev_tracefuncs
863+ ubiquitous = False
864+ if kprobename in dtf and 'ub' in dtf[kprobename]:
865+ ubiquitous = True
769866 title = cdata+' '+rdata
770867 mstr = '\(.*\) *(?P<args>.*) *\((?P<caller>.*)\+.* arg1=(?P<ret>.*)'
771868 m = re.match(mstr, title)
@@ -777,14 +874,81 @@ class Data: · 5 unmodified lines
777874 r = ''
778875 else:
779876 r = 'ret=%s ' % r
780− l = '%0.3fms' % ((end - start) * 1000)
781− if kprobename in self.dev_ubiquitous:
782− title = '%s(%s) <- %s, %s(%s)' % (displayname, a, c, r, l)
783− else:
784− title = '%s(%s) %s(%s)' % (displayname, a, r, l)
785− e = TraceEvent(title, kprobename, start, end - start)
877+ if ubiquitous and c in dtf and 'ub' in dtf[c]:
878+ return False
879+ color = sysvals.kprobeColor(kprobename)
880+ e = DevFunction(displayname, a, c, r, start, end, ubiquitous, proc, pid, color)
786881 tgtdev['src'].append(e)
787882 return True
883+ def overflowDevices(self):
884+ # get a list of devices that extend beyond the end of this test run
885+ devlist = []
886+ for phase in self.phases:
887+ list = self.dmesg[phase]['list']
888+ for devname in list:
889+ dev = list[devname]
890+ if dev['end'] > self.end:
891+ devlist.append(dev)
892+ return devlist
893+ def mergeOverlapDevices(self, devlist):
894+ # merge any devices that overlap devlist
895+ for dev in devlist:
896+ devname = dev['name']
897+ for phase in self.phases:
898+ list = self.dmesg[phase]['list']
899+ if devname not in list:
900+ continue
901+ tdev = list[devname]
902+ o = min(dev['end'], tdev['end']) - max(dev['start'], tdev['start'])
903+ if o <= 0:
904+ continue
905+ dev['end'] = tdev['end']
906+ if 'src' not in dev or 'src' not in tdev:
907+ continue
908+ dev['src'] += tdev['src']
909+ del list[devname]
910+ def usurpTouchingThread(self, name, dev):
911+ # the caller test has priority of this thread, give it to him
912+ for phase in self.phases:
913+ list = self.dmesg[phase]['list']
914+ if name in list:
915+ tdev = list[name]
916+ if tdev['start'] - dev['end'] < 0.1:
917+ dev['end'] = tdev['end']
918+ if 'src' not in dev:
919+ dev['src'] = []
920+ if 'src' in tdev:
921+ dev['src'] += tdev['src']
922+ del list[name]
923+ break
924+ def stitchTouchingThreads(self, testlist):
925+ # merge any threads between tests that touch
926+ for phase in self.phases:
927+ list = self.dmesg[phase]['list']
928+ for devname in list:
929+ dev = list[devname]
930+ if 'htmlclass' not in dev or 'kth' not in dev['htmlclass']:
931+ continue
932+ for data in testlist:
933+ data.usurpTouchingThread(devname, dev)
934+ def optimizeDevSrc(self):
935+ # merge any src call loops to reduce timeline size
936+ for phase in self.phases:
937+ list = self.dmesg[phase]['list']
938+ for dev in list:
939+ if 'src' not in list[dev]:
940+ continue
941+ src = list[dev]['src']
942+ p = 0
943+ for e in sorted(src, key=lambda event: event.time):
944+ if not p or not e.repeat(p):
945+ p = e
946+ continue
947+ # e is another iteration of p, move it into p
948+ p.end = e.end
949+ p.length = p.end - p.time
950+ p.count += 1
951+ src.remove(e)
788952 def trimTimeVal(self, t, t0, dT, left):
789953 if left:
790954 if(t > t0):
@@ -804,6 +968,8 @@ class Data: · 13 unmodified lines
804968 self.tSuspended = self.trimTimeVal(self.tSuspended, t0, dT, left)
805969 self.tResumed = self.trimTimeVal(self.tResumed, t0, dT, left)
806970 self.start = self.trimTimeVal(self.start, t0, dT, left)
971+ self.tKernSus = self.trimTimeVal(self.tKernSus, t0, dT, left)
972+ self.tKernRes = self.trimTimeVal(self.tKernRes, t0, dT, left)
807973 self.end = self.trimTimeVal(self.end, t0, dT, left)
808974 for phase in self.phases:
809975 p = self.dmesg[phase]
@@ -832,36 +998,6 @@ class Data: · 22 unmodified lines
832998 else:
833999 self.trimTime(self.tSuspended, \
8341000 self.tResumed-self.tSuspended, False)
835− def newPhaseWithSingleAction(self, phasename, devname, start, end, color):
836− for phase in self.phases:
837− self.dmesg[phase]['order'] += 1
838− self.html_device_id += 1
839− devid = '%s%d' % (self.idstr, self.html_device_id)
840− list = dict()
841− list[devname] = \
842− {'start': start, 'end': end, 'pid': 0, 'par': '',
843− 'length': (end-start), 'row': 0, 'id': devid, 'drv': '' };
844− self.dmesg[phasename] = \
845− {'list': list, 'start': start, 'end': end,
846− 'row': 0, 'color': color, 'order': 0}
847− self.phases = self.sortedPhases()
848− def newPhase(self, phasename, start, end, color, order):
849− if(order < 0):
850− order = len(self.phases)
851− for phase in self.phases[order:]:
852− self.dmesg[phase]['order'] += 1
853− if(order > 0):
854− p = self.phases[order-1]
855− self.dmesg[p]['end'] = start
856− if(order < len(self.phases)):
857− p = self.phases[order]
858− self.dmesg[p]['start'] = end
859− list = dict()
860− self.dmesg[phasename] = \
861− {'list': list, 'start': start, 'end': end,
862− 'row': 0, 'color': color, 'order': order}
863− self.phases = self.sortedPhases()
864− self.devicegroups.append([phasename])
8651001 def setPhase(self, phase, ktime, isbegin):
8661002 if(isbegin):
8671003 self.dmesg[phase]['start'] = ktime
@@ -881,7 +1017,7 @@ class Data: · 13 unmodified lines
8811017 for t in sorted(tmp):
8821018 slist.append(tmp[t])
8831019 return slist
884− def fixupInitcalls(self, phase, end):
1020+ def fixupInitcalls(self, phase):
8851021 # if any calls never returned, clip them at system resume end
8861022 phaselist = self.dmesg[phase]['list']
8871023 for devname in phaselist:
@@ -893,37 +1029,23 @@ class Data: · 5 unmodified lines
8931029 break
8941030 vprint('%s (%s): callback didnt return' % (devname, phase))
8951031 def deviceFilter(self, devicefilter):
896− # remove all by the relatives of the filter devnames
897− filter = []
898− for phase in self.phases:
899− list = self.dmesg[phase]['list']
900− for name in devicefilter:
901− dev = name
902− while(dev in list):
903− if(dev not in filter):
904− filter.append(dev)
905− dev = list[dev]['par']
906− children = self.deviceDescendants(name, phase)
907− for dev in children:
908− if(dev not in filter):
909− filter.append(dev)
9101032 for phase in self.phases:
9111033 list = self.dmesg[phase]['list']
9121034 rmlist = []
9131035 for name in list:
914− pid = list[name]['pid']
915− if(name not in filter and pid >= 0):
1036+ keep = False
1037+ for filter in devicefilter:
1038+ if filter in name or \
1039+ ('drv' in list[name] and filter in list[name]['drv']):
1040+ keep = True
1041+ if not keep:
9161042 rmlist.append(name)
9171043 for name in rmlist:
9181044 del list[name]
9191045 def fixupInitcallsThatDidntReturn(self):
9201046 # if any calls never returned, clip them at system resume end
9211047 for phase in self.phases:
922− self.fixupInitcalls(phase, self.getEnd())
923− def isInsideTimeline(self, start, end):
924− if(self.start <= start and self.end > start):
925− return True
926− return False
1048+ self.fixupInitcalls(phase)
9271049 def phaseOverlap(self, phases):
9281050 rmgroups = []
9291051 newgroup = []
@@ -940,30 +1062,35 @@ class Data: · 10 unmodified lines
9401062 self.devicegroups.remove(group)
9411063 self.devicegroups.append(newgroup)
9421064 def newActionGlobal(self, name, start, end, pid=-1, color=''):
943− # if event starts before timeline start, expand timeline
944− if(start < self.start):
945− self.setStart(start)
946− # if event ends after timeline end, expand the timeline
947− if(end > self.end):
948− self.setEnd(end)
949− # which phase is this device callback or action "in"
950− targetphase = "none"
1065+ # which phase is this device callback or action in
1066+ targetphase = 'none'
9511067 htmlclass = ''
9521068 overlap = 0.0
9531069 phases = []
9541070 for phase in self.phases:
9551071 pstart = self.dmesg[phase]['start']
9561072 pend = self.dmesg[phase]['end']
1073+ # see if the action overlaps this phase
9571074 o = max(0, min(end, pend) - max(start, pstart))
9581075 if o > 0:
9591076 phases.append(phase)
1077+ # set the target phase to the one that overlaps most
9601078 if o > overlap:
9611079 if overlap > 0 and phase == 'post_resume':
9621080 continue
9631081 targetphase = phase
9641082 overlap = o
1083+ # if no target phase was found, pin it to the edge
1084+ if targetphase == 'none':
1085+ p0start = self.dmesg[self.phases[0]]['start']
1086+ if start <= p0start:
1087+ targetphase = self.phases[0]
1088+ else:
1089+ targetphase = self.phases[-1]
9651090 if pid == -2:
9661091 htmlclass = ' bg'
1092+ elif pid == -3:
1093+ htmlclass = ' ps'
9671094 if len(phases) > 1:
9681095 htmlclass = ' bg'
9691096 self.phaseOverlap(phases)
@@ -985,29 +1112,13 @@ class Data: · 15 unmodified lines
9851112 while(name in list):
9861113 name = '%s[%d]' % (origname, i)
9871114 i += 1
988− list[name] = {'start': start, 'end': end, 'pid': pid, 'par': parent,
989− 'length': length, 'row': 0, 'id': devid, 'drv': drv }
1115+ list[name] = {'name': name, 'start': start, 'end': end, 'pid': pid,
1116+ 'par': parent, 'length': length, 'row': 0, 'id': devid, 'drv': drv }
9901117 if htmlclass:
9911118 list[name]['htmlclass'] = htmlclass
9921119 if color:
9931120 list[name]['color'] = color
9941121 return name
995− def deviceIDs(self, devlist, phase):
996− idlist = []
997− list = self.dmesg[phase]['list']
998− for devname in list:
999− if devname in devlist:
1000− idlist.append(list[devname]['id'])
1001− return idlist
1002− def deviceParentID(self, devname, phase):
1003− pdev = ''
1004− pdevid = ''
1005− list = self.dmesg[phase]['list']
1006− if devname in list:
1007− pdev = list[devname]['par']
1008− if pdev in list:
1009− return list[pdev]['id']
1010− return pdev
10111122 def deviceChildren(self, devname, phase):
10121123 devlist = []
10131124 list = self.dmesg[phase]['list']
@@ -1015,21 +1126,15 @@ class Data: · 1 unmodified line
10151126 if(list[child]['par'] == devname):
10161127 devlist.append(child)
10171128 return devlist
1018− def deviceDescendants(self, devname, phase):
1019− children = self.deviceChildren(devname, phase)
1020− family = children
1021− for child in children:
1022− family += self.deviceDescendants(child, phase)
1023− return family
1024− def deviceChildrenIDs(self, devname, phase):
1025− devlist = self.deviceChildren(devname, phase)
1026− return self.deviceIDs(devlist, phase)
10271129 def printDetails(self):
1130+ vprint('Timeline Details:')
10281131 vprint(' test start: %f' % self.start)
1132+ vprint('kernel suspend start: %f' % self.tKernSus)
10291133 for phase in self.phases:
10301134 dc = len(self.dmesg[phase]['list'])
10311135 vprint(' %16s: %f - %f (%d devices)' % (phase, \
10321136 self.dmesg[phase]['start'], self.dmesg[phase]['end'], dc))
1137+ vprint(' kernel resume end: %f' % self.tKernRes)
10331138 vprint(' test end: %f' % self.end)
10341139 def deviceChildrenAllPhases(self, devname):
10351140 devlist = []
@@ -1108,21 +1213,134 @@ class Data: · 72 unmodified lines
11081213 if width != '0.000000' and length >= mindevlen:
11091214 devlist.append(dev)
11101215 self.tdevlist[phase] = devlist
1111−
1112−# Class: TraceEvent
1216+ def addHorizontalDivider(self, devname, devend):
1217+ phase = 'suspend_prepare'
1218+ self.newAction(phase, devname, -2, '', \
1219+ self.start, devend, '', ' sec', '')
1220+ if phase not in self.tdevlist:
1221+ self.tdevlist[phase] = []
1222+ self.tdevlist[phase].append(devname)
1223+ d = DevItem(0, phase, self.dmesg[phase]['list'][devname])
1224+ return d
1225+ def addProcessUsageEvent(self, name, times):
1226+ # get the start and end times for this process
1227+ maxC = 0
1228+ tlast = 0
1229+ start = -1
1230+ end = -1
1231+ for t in sorted(times):
1232+ if tlast == 0:
1233+ tlast = t
1234+ continue
1235+ if name in self.pstl[t]:
1236+ if start == -1 or tlast < start:
1237+ start = tlast
1238+ if end == -1 or t > end:
1239+ end = t
1240+ tlast = t
1241+ if start == -1 or end == -1:
1242+ return 0
1243+ # add a new action for this process and get the object
1244+ out = self.newActionGlobal(name, start, end, -3)
1245+ if not out:
1246+ return 0
1247+ phase, devname = out
1248+ dev = self.dmesg[phase]['list'][devname]
1249+ # get the cpu exec data
1250+ tlast = 0
1251+ clast = 0
1252+ cpuexec = dict()
1253+ for t in sorted(times):
1254+ if tlast == 0 or t <= start or t > end:
1255+ tlast = t
1256+ continue
1257+ list = self.pstl[t]
1258+ c = 0
1259+ if name in list:
1260+ c = list[name]
1261+ if c > maxC:
1262+ maxC = c
1263+ if c != clast:
1264+ key = (tlast, t)
1265+ cpuexec[key] = c
1266+ tlast = t
1267+ clast = c
1268+ dev['cpuexec'] = cpuexec
1269+ return maxC
1270+ def createProcessUsageEvents(self):
1271+ # get an array of process names
1272+ proclist = []
1273+ for t in self.pstl:
1274+ pslist = self.pstl[t]
1275+ for ps in pslist:
1276+ if ps not in proclist:
1277+ proclist.append(ps)
1278+ # get a list of data points for suspend and resume
1279+ tsus = []
1280+ tres = []
1281+ for t in sorted(self.pstl):
1282+ if t < self.tSuspended:
1283+ tsus.append(t)
1284+ else:
1285+ tres.append(t)
1286+ # process the events for suspend and resume
1287+ if len(proclist) > 0:
1288+ vprint('Process Execution:')
1289+ for ps in proclist:
1290+ c = self.addProcessUsageEvent(ps, tsus)
1291+ if c > 0:
1292+ vprint('%25s (sus): %d' % (ps, c))
1293+ c = self.addProcessUsageEvent(ps, tres)
1294+ if c > 0:
1295+ vprint('%25s (res): %d' % (ps, c))
1296+
1297+# Class: DevFunction
11131298 # Description:
1114−# A container for trace event data found in the ftrace file
1115−class TraceEvent:
1116− text = ''
1117− time = 0.0
1118− length = 0.0
1119− title = ''
1299+# A container for kprobe function data we want in the dev timeline
1300+class DevFunction:
11201301 row = 0
1121− def __init__(self, a, n, t, l):
1122− self.title = a
1123− self.text = n
1124− self.time = t
1125− self.length = l
1302+ count = 1
1303+ def __init__(self, name, args, caller, ret, start, end, u, proc, pid, color):
1304+ self.name = name
1305+ self.args = args
1306+ self.caller = caller
1307+ self.ret = ret
1308+ self.time = start
1309+ self.length = end - start
1310+ self.end = end
1311+ self.ubiquitous = u
1312+ self.proc = proc
1313+ self.pid = pid
1314+ self.color = color
1315+ def title(self):
1316+ cnt = ''
1317+ if self.count > 1:
1318+ cnt = '(x%d)' % self.count
1319+ l = '%0.3fms' % (self.length * 1000)
1320+ if self.ubiquitous:
1321+ title = '%s(%s)%s <- %s, %s(%s)' % \
1322+ (self.name, self.args, cnt, self.caller, self.ret, l)
1323+ else:
1324+ title = '%s(%s) %s%s(%s)' % (self.name, self.args, self.ret, cnt, l)
1325+ return title.replace('"', '')
1326+ def text(self):
1327+ if self.count > 1:
1328+ text = '%s(x%d)' % (self.name, self.count)
1329+ else:
1330+ text = self.name
1331+ return text
1332+ def repeat(self, tgt):
1333+ # is the tgt call just a repeat of this call (e.g. are we in a loop)
1334+ dt = self.time - tgt.end
1335+ # only combine calls if -all- attributes are identical
1336+ if tgt.caller == self.caller and \
1337+ tgt.name == self.name and tgt.args == self.args and \
1338+ tgt.proc == self.proc and tgt.pid == self.pid and \
1339+ tgt.ret == self.ret and dt >= 0 and \
1340+ dt <= sysvals.callloopmaxgap and \
1341+ self.length < sysvals.callloopmaxlen:
1342+ return True
1343+ return False
11261344
11271345 # Class: FTraceLine
11281346 # Description:
@@ -1226,7 +1444,6 @@ class FTraceLine: · 97 unmodified lines
12261444 print('%s -- %f (%02d): %s() { (%.3f us)' % (dev, self.time, \
12271445 self.depth, self.name, self.length*1000000))
12281446 def startMarker(self):
1229− global sysvals
12301447 # Is this the starting line of a suspend?
12311448 if not self.fevent:
12321449 return False
@@ -1506,6 +1723,16 @@ class FTraceCallGraph: · 273 unmodified lines
15061723 l.depth, l.name, l.length*1000000))
15071724 print(' ')
15081725
1726+class DevItem:
1727+ def __init__(self, test, phase, dev):
1728+ self.test = test
1729+ self.phase = phase
1730+ self.dev = dev
1731+ def isa(self, cls):
1732+ if 'htmlclass' in self.dev and cls in self.dev['htmlclass']:
1733+ return True
1734+ return False
1735+
15091736 # Class: Timeline
15101737 # Description:
15111738 # A container for a device timeline which calculates
@@ -1517,12 +1744,11 @@ class Timeline: · 5 unmodified lines
15171744 rowH = 30 # device row height
15181745 bodyH = 0 # body height
15191746 rows = 0 # total timeline rows
1520− phases = []
1521− rowmaxlines = dict()
1522− rowcount = dict()
1747+ rowlines = dict()
15231748 rowheight = dict()
1524− def __init__(self, rowheight):
1749+ def __init__(self, rowheight, scaleheight):
15251750 self.rowH = rowheight
1751+ self.scaleH = scaleheight
15261752 self.html = {
15271753 'header': '',
15281754 'timeline': '',
@@ -1537,21 +1763,19 @@ class Timeline: · 8 unmodified lines
15371763 # The total number of rows needed to display this phase of the timeline
15381764 def getDeviceRows(self, rawlist):
15391765 # clear all rows and set them to undefined
1540− lendict = dict()
1766+ sortdict = dict()
15411767 for item in rawlist:
15421768 item.row = -1
1543− lendict[item] = item.length
1544− list = []
1545− for i in sorted(lendict, key=lendict.get, reverse=True):
1546− list.append(i)
1547− remaining = len(list)
1769+ sortdict[item] = item.length
1770+ sortlist = sorted(sortdict, key=sortdict.get, reverse=True)
1771+ remaining = len(sortlist)
15481772 rowdata = dict()
15491773 row = 1
15501774 # try to pack each row with as many ranges as possible
15511775 while(remaining > 0):
15521776 if(row not in rowdata):
15531777 rowdata[row] = []
1554− for i in list:
1778+ for i in sortlist:
15551779 if(i.row >= 0):
15561780 continue
15571781 s = i.time
@@ -1575,81 +1799,86 @@ class Timeline: · 17 unmodified lines
15751799 # Organize the timeline entries into the smallest
15761800 # number of rows possible, with no entry overlapping
15771801 # Arguments:
1578− # list: the list of devices/actions for a single phase
1579− # devlist: string list of device names to use
1802+ # devlist: the list of devices/actions in a group of contiguous phases
15801803 # Output:
15811804 # The total number of rows needed to display this phase of the timeline
1582− def getPhaseRows(self, dmesg, devlist):
1805+ def getPhaseRows(self, devlist, row=0):
15831806 # clear all rows and set them to undefined
15841807 remaining = len(devlist)
15851808 rowdata = dict()
1586− row = 0
1587− lendict = dict()
1809+ sortdict = dict()
15881810 myphases = []
1811+ # initialize all device rows to -1 and calculate devrows
15891812 for item in devlist:
1590− if item[0] not in self.phases:
1591− self.phases.append(item[0])
1592− if item[0] not in myphases:
1593− myphases.append(item[0])
1594− self.rowmaxlines[item[0]] = dict()
1595− self.rowheight[item[0]] = dict()
1596− dev = dmesg[item[0]]['list'][item[1]]
1813+ dev = item.dev
1814+ tp = (item.test, item.phase)
1815+ if tp not in myphases:
1816+ myphases.append(tp)
15971817 dev['row'] = -1
1598− lendict[item] = float(dev['end']) - float(dev['start'])
1818+ # sort by length 1st, then name 2nd
1819+ sortdict[item] = (float(dev['end']) - float(dev['start']), item.dev['name'])
15991820 if 'src' in dev:
16001821 dev['devrows'] = self.getDeviceRows(dev['src'])
1601− lenlist = []
1602− for i in sorted(lendict, key=lendict.get, reverse=True):
1603− lenlist.append(i)
1822+ # sort the devlist by length so that large items graph on top
1823+ sortlist = sorted(sortdict, key=sortdict.get, reverse=True)
16041824 orderedlist = []
1605− for item in lenlist:
1606− dev = dmesg[item[0]]['list'][item[1]]
1607− if dev['pid'] == -2:
1825+ for item in sortlist:
1826+ if item.dev['pid'] == -2:
16081827 orderedlist.append(item)
1609− for item in lenlist:
1828+ for item in sortlist:
16101829 if item not in orderedlist:
16111830 orderedlist.append(item)
1612− # try to pack each row with as many ranges as possible
1831+ # try to pack each row with as many devices as possible
16131832 while(remaining > 0):
16141833 rowheight = 1
16151834 if(row not in rowdata):
16161835 rowdata[row] = []
16171836 for item in orderedlist:
1618− dev = dmesg[item[0]]['list'][item[1]]
1837+ dev = item.dev
16191838 if(dev['row'] < 0):
16201839 s = dev['start']
16211840 e = dev['end']
16221841 valid = True
16231842 for ritem in rowdata[row]:
1624− rs = ritem['start']
1625− re = ritem['end']
1843+ rs = ritem.dev['start']
1844+ re = ritem.dev['end']
16261845 if(not (((s <= rs) and (e <= rs)) or
16271846 ((s >= re) and (e >= re)))):
16281847 valid = False
16291848 break
16301849 if(valid):
1631− rowdata[row].append(dev)
1850+ rowdata[row].append(item)
16321851 dev['row'] = row
16331852 remaining -= 1
16341853 if 'devrows' in dev and dev['devrows'] > rowheight:
16351854 rowheight = dev['devrows']
1636− for phase in myphases:
1637− self.rowmaxlines[phase][row] = rowheight
1638− self.rowheight[phase][row] = rowheight * self.rowH
1855+ for t, p in myphases:
1856+ if t not in self.rowlines or t not in self.rowheight:
1857+ self.rowlines[t] = dict()
1858+ self.rowheight[t] = dict()
1859+ if p not in self.rowlines[t] or p not in self.rowheight[t]:
1860+ self.rowlines[t][p] = dict()
1861+ self.rowheight[t][p] = dict()
1862+ rh = self.rowH
1863+ # section headers should use a different row height
1864+ if len(rowdata[row]) == 1 and \
1865+ 'htmlclass' in rowdata[row][0].dev and \
1866+ 'sec' in rowdata[row][0].dev['htmlclass']:
1867+ rh = 15
1868+ self.rowlines[t][p][row] = rowheight
1869+ self.rowheight[t][p][row] = rowheight * rh
16391870 row += 1
16401871 if(row > self.rows):
16411872 self.rows = int(row)
1642− for phase in myphases:
1643− self.rowcount[phase] = row
16441873 return row
1645− def phaseRowHeight(self, phase, row):
1646− return self.rowheight[phase][row]
1647− def phaseRowTop(self, phase, row):
1874+ def phaseRowHeight(self, test, phase, row):
1875+ return self.rowheight[test][phase][row]
1876+ def phaseRowTop(self, test, phase, row):
16481877 top = 0
1649− for i in sorted(self.rowheight[phase]):
1878+ for i in sorted(self.rowheight[test][phase]):
16501879 if i >= row:
16511880 break
1652− top += self.rowheight[phase][i]
1881+ top += self.rowheight[test][phase][i]
16531882 return top
16541883 # Function: calcTotalRows
16551884 # Description:
@@ -1657,19 +1886,21 @@ class Timeline: · 1 unmodified line
16571886 def calcTotalRows(self):
16581887 maxrows = 0
16591888 standardphases = []
1660− for phase in self.phases:
1661− total = 0
1662− for i in sorted(self.rowmaxlines[phase]):
1663− total += self.rowmaxlines[phase][i]
1664− if total > maxrows:
1665− maxrows = total
1666− if total == self.rowcount[phase]:
1667− standardphases.append(phase)
1889+ for t in self.rowlines:
1890+ for p in self.rowlines[t]:
1891+ total = 0
1892+ for i in sorted(self.rowlines[t][p]):
1893+ total += self.rowlines[t][p][i]
1894+ if total > maxrows:
1895+ maxrows = total
1896+ if total == len(self.rowlines[t][p]):
1897+ standardphases.append((t, p))
16681898 self.height = self.scaleH + (maxrows*self.rowH)
16691899 self.bodyH = self.height - self.scaleH
1670− for phase in standardphases:
1671− for i in sorted(self.rowheight[phase]):
1672− self.rowheight[phase][i] = self.bodyH/self.rowcount[phase]
1900+ # if there is 1 line per row, draw them the standard way
1901+ for t, p in standardphases:
1902+ for i in sorted(self.rowheight[t][p]):
1903+ self.rowheight[t][p][i] = self.bodyH/len(self.rowlines[t][p])
16731904 # Function: createTimeScale
16741905 # Description:
16751906 # Create the timescale for a timeline block
@@ -1716,7 +1947,6 @@ class Timeline: · 40 unmodified lines
17161947 # A list of values describing the properties of these test runs
17171948 class TestProps:
17181949 stamp = ''
1719− tracertype = ''
17201950 S0i3 = False
17211951 fwdata = []
17221952 ftrace_line_fmt_fg = \
@@ -1734,14 +1964,13 @@ class TestProps: · 11 unmodified lines
17341964 def __init__(self):
17351965 self.ktemp = dict()
17361966 def setTracerType(self, tracer):
1737− self.tracertype = tracer
17381967 if(tracer == 'function_graph'):
17391968 self.cgformat = True
17401969 self.ftrace_line_fmt = self.ftrace_line_fmt_fg
17411970 elif(tracer == 'nop'):
17421971 self.ftrace_line_fmt = self.ftrace_line_fmt_nop
17431972 else:
1744− doError('Invalid tracer format: [%s]' % tracer, False)
1973+ doError('Invalid tracer format: [%s]' % tracer)
17451974
17461975 # Class: TestRun
17471976 # Description:
@@ -1756,6 +1985,51 @@ class TestRun: · 8 unmodified lines
17561985 self.ftemp = dict()
17571986 self.ttemp = dict()
17581987
1988+class ProcessMonitor:
1989+ proclist = dict()
1990+ running = False
1991+ def procstat(self):
1992+ c = ['cat /proc/[1-9]*/stat 2>/dev/null']
1993+ process = Popen(c, shell=True, stdout=PIPE)
1994+ running = dict()
1995+ for line in process.stdout:
1996+ data = line.split()
1997+ pid = data[0]
1998+ name = re.sub('[()]', '', data[1])
1999+ user = int(data[13])
2000+ kern = int(data[14])
2001+ kjiff = ujiff = 0
2002+ if pid not in self.proclist:
2003+ self.proclist[pid] = {'name' : name, 'user' : user, 'kern' : kern}
2004+ else:
2005+ val = self.proclist[pid]
2006+ ujiff = user - val['user']
2007+ kjiff = kern - val['kern']
2008+ val['user'] = user
2009+ val['kern'] = kern
2010+ if ujiff > 0 or kjiff > 0:
2011+ running[pid] = ujiff + kjiff
2012+ result = process.wait()
2013+ out = ''
2014+ for pid in running:
2015+ jiffies = running[pid]
2016+ val = self.proclist[pid]
2017+ if out:
2018+ out += ','
2019+ out += '%s-%s %d' % (val['name'], pid, jiffies)
2020+ return 'ps - '+out
2021+ def processMonitor(self, tid):
2022+ while self.running:
2023+ out = self.procstat()
2024+ if out:
2025+ sysvals.fsetVal(out, 'trace_marker')
2026+ def start(self):
2027+ self.thread = Thread(target=self.processMonitor, args=(0,))
2028+ self.running = True
2029+ self.thread.start()
2030+ def stop(self):
2031+ self.running = False
2032+
17592033 # ----------------- FUNCTIONS --------------------
17602034
17612035 # Function: vprint
@@ -1764,7 +2038,7 @@ class TestRun: · 2 unmodified lines
17642038 # Arguments:
17652039 # msg: the debug/log message to print
17662040 def vprint(msg):
1767− global sysvals
2041+ sysvals.logmsg += msg+'\n'
17682042 if(sysvals.verbose):
17692043 print(msg)
17702044
@@ -1775,8 +2049,6 @@ def vprint(msg): · 4 unmodified lines
17752049 # Arguments:
17762050 # m: the valid re.match output for the stamp line
17772051 def parseStamp(line, data):
1778− global sysvals
1779−
17802052 m = re.match(sysvals.stampfmt, line)
17812053 data.stamp = {'time': '', 'host': '', 'mode': ''}
17822054 dt = datetime(int(m.group('y'))+2000, int(m.group('m')),
@@ -1788,6 +2060,14 @@ def parseStamp(line, data): · 5 unmodified lines
17882060 data.stamp['kernel'] = m.group('kernel')
17892061 sysvals.hostname = data.stamp['host']
17902062 sysvals.suspendmode = data.stamp['mode']
2063+ if sysvals.suspendmode == 'command' and sysvals.ftracefile != '':
2064+ modes = ['on', 'freeze', 'standby', 'mem']
2065+ out = Popen(['grep', 'suspend_enter', sysvals.ftracefile],
2066+ stderr=PIPE, stdout=PIPE).stdout.read()
2067+ m = re.match('.* suspend_enter\[(?P<mode>.*)\]', out)
2068+ if m and m.group('mode') in ['1', '2', '3']:
2069+ sysvals.suspendmode = modes[int(m.group('mode'))]
2070+ data.stamp['mode'] = sysvals.suspendmode
17912071 if not sysvals.stamp:
17922072 sysvals.stamp = data.stamp
17932073
@@ -1817,18 +2097,17 @@ def diffStamp(stamp1, stamp2): · 23 unmodified lines
18172097 # required for primary parsing. Set the usetraceevents and/or
18182098 # usetraceeventsonly flags in the global sysvals object
18192099 def doesTraceLogHaveTraceEvents():
1820− global sysvals
1821−
18222100 # check for kprobes
18232101 sysvals.usekprobes = False
1824− out = os.system('grep -q "_cal: (" '+sysvals.ftracefile)
2102+ out = call('grep -q "_cal: (" '+sysvals.ftracefile, shell=True)
18252103 if(out == 0):
18262104 sysvals.usekprobes = True
18272105 # check for callgraph data on trace event blocks
1828− out = os.system('grep -q "_cpu_down()" '+sysvals.ftracefile)
2106+ out = call('grep -q "_cpu_down()" '+sysvals.ftracefile, shell=True)
18292107 if(out == 0):
18302108 sysvals.usekprobes = True
1831− out = os.popen('head -1 '+sysvals.ftracefile).read().replace('\n', '')
2109+ out = Popen(['head', '-1', sysvals.ftracefile],
2110+ stderr=PIPE, stdout=PIPE).stdout.read().replace('\n', '')
18322111 m = re.match(sysvals.stampfmt, out)
18332112 if m and m.group('mode') == 'command':
18342113 sysvals.usetraceeventsonly = True
@@ -1838,14 +2117,14 @@ def doesTraceLogHaveTraceEvents(): · 3 unmodified lines
18382117 sysvals.usetraceeventsonly = True
18392118 sysvals.usetraceevents = False
18402119 for e in sysvals.traceevents:
1841− out = os.system('grep -q "'+e+': " '+sysvals.ftracefile)
2120+ out = call('grep -q "'+e+': " '+sysvals.ftracefile, shell=True)
18422121 if(out != 0):
18432122 sysvals.usetraceeventsonly = False
18442123 if(e == 'suspend_resume' and out == 0):
18452124 sysvals.usetraceevents = True
18462125 # determine is this log is properly formatted
18472126 for e in ['SUSPEND START', 'RESUME COMPLETE']:
1848− out = os.system('grep -q "'+e+'" '+sysvals.ftracefile)
2127+ out = call('grep -q "'+e+'" '+sysvals.ftracefile, shell=True)
18492128 if(out != 0):
18502129 sysvals.usetracemarkers = False
18512130
@@ -1860,8 +2139,6 @@ def doesTraceLogHaveTraceEvents(): · 8 unmodified lines
18602139 # Arguments:
18612140 # testruns: the array of Data objects obtained from parseKernelLog
18622141 def appendIncompleteTraceLog(testruns):
1863− global sysvals
1864−
18652142 # create TestRun vessels for ftrace parsing
18662143 testcnt = len(testruns)
18672144 testidx = 0
@@ -2052,8 +2329,7 @@ def appendIncompleteTraceLog(testruns): · 184 unmodified lines
20522329 dev['ftrace'] = cg
20532330 break
20542331
2055− if(sysvals.verbose):
2056− test.data.printDetails()
2332+ test.data.printDetails()
20572333
20582334 # Function: parseTraceLog
20592335 # Description:
@@ -2064,14 +2340,12 @@ def appendIncompleteTraceLog(testruns): · 4 unmodified lines
20642340 # Output:
20652341 # An array of Data objects
20662342 def parseTraceLog():
2067− global sysvals
2068−
20692343 vprint('Analyzing the ftrace data...')
20702344 if(os.path.exists(sysvals.ftracefile) == False):
2071− doError('%s does not exist' % sysvals.ftracefile, False)
2345+ doError('%s does not exist' % sysvals.ftracefile)
20722346
20732347 sysvals.setupAllKprobes()
2074− tracewatch = ['suspend_enter']
2348+ tracewatch = []
20752349 if sysvals.usekprobes:
20762350 tracewatch += ['sync_filesystems', 'freeze_processes', 'syscore_suspend',
20772351 'syscore_resume', 'resume_console', 'thaw_processes', 'CPU_ON', 'CPU_OFF']
@@ -2102,17 +2376,13 @@ def parseTraceLog(): · 24 unmodified lines
21022376 if(m):
21032377 tp.setTracerType(m.group('t'))
21042378 continue
2105− # post resume time line: did this test run include post-resume data
2106− m = re.match(sysvals.postresumefmt, line)
2107− if(m):
2108− t = int(m.group('t'))
2109− if(t > 0):
2110− sysvals.postresumetime = t
2111− continue
21122379 # device properties line
21132380 if(re.match(sysvals.devpropfmt, line)):
21142381 devProps(line)
21152382 continue
2383+ # ignore all other commented lines
2384+ if line[0] == '#':
2385+ continue
21162386 # ftrace line: parse only valid lines
21172387 m = re.match(tp.ftrace_line_fmt, line)
21182388 if(not m):
@@ -2142,20 +2412,36 @@ def parseTraceLog(): · 23 unmodified lines
21422412 testrun = TestRun(data)
21432413 testruns.append(testrun)
21442414 parseStamp(tp.stamp, data)
2145− if len(tp.fwdata) > data.testnumber:
2146− data.fwSuspend, data.fwResume = tp.fwdata[data.testnumber]
2147− if(data.fwSuspend > 0 or data.fwResume > 0):
2148− data.fwValid = True
21492415 data.setStart(t.time)
2416+ data.tKernSus = t.time
21502417 continue
21512418 if(not data):
21522419 continue
2420+ # process cpu exec line
2421+ if t.type == 'tracing_mark_write':
2422+ m = re.match(sysvals.procexecfmt, t.name)
2423+ if(m):
2424+ proclist = dict()
2425+ for ps in m.group('ps').split(','):
2426+ val = ps.split()
2427+ if not val:
2428+ continue
2429+ name = val[0].replace('--', '-')
2430+ proclist[name] = int(val[1])
2431+ data.pstl[t.time] = proclist
2432+ continue
21532433 # find the end of resume
21542434 if(t.endMarker()):
2155− if(sysvals.usetracemarkers and sysvals.postresumetime > 0):
2156− phase = 'post_resume'
2157− data.newPhase(phase, t.time, t.time, '#F0F0F0', -1)
21582435 data.setEnd(t.time)
2436+ if data.tKernRes == 0.0:
2437+ data.tKernRes = t.time
2438+ if data.dmesg['resume_complete']['end'] < 0:
2439+ data.dmesg['resume_complete']['end'] = t.time
2440+ if sysvals.suspendmode == 'mem' and len(tp.fwdata) > data.testnumber:
2441+ data.fwSuspend, data.fwResume = tp.fwdata[data.testnumber]
2442+ if(data.tSuspended != 0 and data.tResumed != 0 and \
2443+ (data.fwSuspend > 0 or data.fwResume > 0)):
2444+ data.fwValid = True
21592445 if(not sysvals.usetracemarkers):
21602446 # no trace markers? then quit and be sure to finish recording
21612447 # the event we used to trigger resume end
@@ -2190,8 +2476,14 @@ def parseTraceLog(): · 28 unmodified lines
21902476 if(name.split('[')[0] in tracewatch):
21912477 continue
21922478 # -- phase changes --
2479+ # start of kernel suspend
2480+ if(re.match('suspend_enter\[.*', t.name)):
2481+ if(isbegin):
2482+ data.dmesg[phase]['start'] = t.time
2483+ data.tKernSus = t.time
2484+ continue
21932485 # suspend_prepare start
2194− if(re.match('dpm_prepare\[.*', t.name)):
2486+ elif(re.match('dpm_prepare\[.*', t.name)):
21952487 phase = 'suspend_prepare'
21962488 if(not isbegin):
21972489 data.dmesg[phase]['end'] = t.time
@@ -2291,6 +2583,8 @@ def parseTraceLog(): · 93 unmodified lines
22912583 p = m.group('p')
22922584 if(n and p):
22932585 data.newAction(phase, n, pid, p, t.time, -1, drv)
2586+ if pid not in data.devpids:
2587+ data.devpids.append(pid)
22942588 # device callback finish
22952589 elif(t.type == 'device_pm_callback_end'):
22962590 m = re.match('(?P<drv>.*) (?P<d>.*), err.*', t.name);
@@ -2332,6 +2626,12 @@ def parseTraceLog(): · 35 unmodified lines
23322626 else:
23332627 e['end'] = t.time
23342628 e['rdata'] = kprobedata
2629+ # end of kernel resume
2630+ if(kprobename == 'pm_notifier_call_chain' or \
2631+ kprobename == 'pm_restore_console'):
2632+ data.dmesg[phase]['end'] = t.time
2633+ data.tKernRes = t.time
2634+
23352635 # callgraph processing
23362636 elif sysvals.usecallgraph:
23372637 # create a callgraph object for the data
@@ -2348,24 +2648,37 @@ def parseTraceLog(): · 10 unmodified lines
23482648 if sysvals.suspendmode == 'command':
23492649 for test in testruns:
23502650 for p in test.data.phases:
2351− if p == 'resume_complete':
2651+ if p == 'suspend_prepare':
23522652 test.data.dmesg[p]['start'] = test.data.start
23532653 test.data.dmesg[p]['end'] = test.data.end
23542654 else:
2355− test.data.dmesg[p]['start'] = test.data.start
2356− test.data.dmesg[p]['end'] = test.data.start
2357− test.data.tSuspended = test.data.start
2358− test.data.tResumed = test.data.start
2655+ test.data.dmesg[p]['start'] = test.data.end
2656+ test.data.dmesg[p]['end'] = test.data.end
2657+ test.data.tSuspended = test.data.end
2658+ test.data.tResumed = test.data.end
23592659 test.data.tLow = 0
23602660 test.data.fwValid = False
23612661
2362− for test in testruns:
2662+ # dev source and procmon events can be unreadable with mixed phase height
2663+ if sysvals.usedevsrc or sysvals.useprocmon:
2664+ sysvals.mixedphaseheight = False
2665+
2666+ for i in range(len(testruns)):
2667+ test = testruns[i]
2668+ data = test.data
2669+ # find the total time range for this test (begin, end)
2670+ tlb, tle = data.start, data.end
2671+ if i < len(testruns) - 1:
2672+ tle = testruns[i+1].data.start
2673+ # add the process usage data to the timeline
2674+ if sysvals.useprocmon:
2675+ data.createProcessUsageEvents()
23632676 # add the traceevent data to the device hierarchy
23642677 if(sysvals.usetraceevents):
23652678 # add actual trace funcs
23662679 for name in test.ttemp:
23672680 for event in test.ttemp[name]:
2368− test.data.newActionGlobal(name, event['begin'], event['end'], event['pid'])
2681+ data.newActionGlobal(name, event['begin'], event['end'], event['pid'])
23692682 # add the kprobe based virtual tracefuncs as actual devices
23702683 for key in tp.ktemp:
23712684 name, pid = key
@@ -2373,24 +2686,20 @@ def parseTraceLog(): · 1 unmodified line
23732686 continue
23742687 for e in tp.ktemp[key]:
23752688 kb, ke = e['begin'], e['end']
2376− if kb == ke or not test.data.isInsideTimeline(kb, ke):
2689+ if kb == ke or tlb > kb or tle <= kb:
23772690 continue
2378− test.data.newActionGlobal(e['name'], kb, ke, pid)
2691+ color = sysvals.kprobeColor(name)
2692+ data.newActionGlobal(e['name'], kb, ke, pid, color)
23792693 # add config base kprobes and dev kprobes
2380− for key in tp.ktemp:
2381− name, pid = key
2382− if name in sysvals.tracefuncs:
2383− continue
2384− for e in tp.ktemp[key]:
2385− kb, ke = e['begin'], e['end']
2386− if kb == ke or not test.data.isInsideTimeline(kb, ke):
2694+ if sysvals.usedevsrc:
2695+ for key in tp.ktemp:
2696+ name, pid = key
2697+ if name in sysvals.tracefuncs or name not in sysvals.dev_tracefuncs:
23872698 continue
2388− color = sysvals.kprobeColor(e['name'])
2389− if name not in sysvals.dev_tracefuncs:
2390− # config base kprobe
2391− test.data.newActionGlobal(e['name'], kb, ke, -2, color)
2392− elif sysvals.usedevsrc:
2393− # dev kprobe
2699+ for e in tp.ktemp[key]:
2700+ kb, ke = e['begin'], e['end']
2701+ if kb == ke or tlb > kb or tle <= kb:
2702+ continue
23942703 data.addDeviceFunctionCall(e['name'], name, e['proc'], pid, kb,
23952704 ke, e['cdata'], e['rdata'])
23962705 if sysvals.usecallgraph:
@@ -2407,7 +2716,7 @@ def parseTraceLog(): · 10 unmodified lines
24072716 id+', ignoring this callback')
24082717 continue
24092718 # match cg data to devices
2410− if sysvals.suspendmode == 'command' or not cg.deviceMatch(pid, test.data):
2719+ if sysvals.suspendmode == 'command' or not cg.deviceMatch(pid, data):
24112720 sortkey = '%f%f%d' % (cg.start, cg.end, pid)
24122721 sortlist[sortkey] = cg
24132722 # create blocks for orphan cg data
@@ -2416,12 +2725,11 @@ def parseTraceLog(): · 2 unmodified lines
24162725 name = cg.list[0].name
24172726 if sysvals.isCallgraphFunc(name):
24182727 vprint('Callgraph found for task %d: %.3fms, %s' % (cg.pid, (cg.end - cg.start)*1000, name))
2419− cg.newActionFromFunction(test.data)
2728+ cg.newActionFromFunction(data)
24202729
24212730 if sysvals.suspendmode == 'command':
2422− if(sysvals.verbose):
2423− for data in testdata:
2424− data.printDetails()
2731+ for data in testdata:
2732+ data.printDetails()
24252733 return testdata
24262734
24272735 # fill in any missing phases
@@ -2429,7 +2737,7 @@ def parseTraceLog(): · 1 unmodified line
24292737 lp = data.phases[0]
24302738 for p in data.phases:
24312739 if(data.dmesg[p]['start'] < 0 and data.dmesg[p]['end'] < 0):
2432− print('WARNING: phase "%s" is missing!' % p)
2740+ vprint('WARNING: phase "%s" is missing!' % p)
24332741 if(data.dmesg[p]['start'] < 0):
24342742 data.dmesg[p]['start'] = data.dmesg[lp]['end']
24352743 if(p == 'resume_machine'):
@@ -2438,60 +2746,27 @@ def parseTraceLog(): · 2 unmodified lines
24382746 data.tLow = 0
24392747 if(data.dmesg[p]['end'] < 0):
24402748 data.dmesg[p]['end'] = data.dmesg[p]['start']
2749+ if(p != lp and not ('machine' in p and 'machine' in lp)):
2750+ data.dmesg[lp]['end'] = data.dmesg[p]['start']
24412751 lp = p
24422752
24432753 if(len(sysvals.devicefilter) > 0):
24442754 data.deviceFilter(sysvals.devicefilter)
24452755 data.fixupInitcallsThatDidntReturn()
2446− if(sysvals.verbose):
2447− data.printDetails()
2756+ if sysvals.usedevsrc:
2757+ data.optimizeDevSrc()
2758+ data.printDetails()
24482759
2760+ # x2: merge any overlapping devices between test runs
2761+ if sysvals.usedevsrc and len(testdata) > 1:
2762+ tc = len(testdata)
2763+ for i in range(tc - 1):
2764+ devlist = testdata[i].overflowDevices()
2765+ for j in range(i + 1, tc):
2766+ testdata[j].mergeOverlapDevices(devlist)
2767+ testdata[0].stitchTouchingThreads(testdata[1:])
24492768 return testdata
24502769
2451−# Function: loadRawKernelLog
2452−# Description:
2453−# Load a raw kernel log that wasn't created by this tool, it might be
2454−# possible to extract a valid suspend/resume log
2455−def loadRawKernelLog(dmesgfile):
2456− global sysvals
2457−
2458− stamp = {'time': '', 'host': '', 'mode': 'mem', 'kernel': ''}
2459− stamp['time'] = datetime.now().strftime('%B %d %Y, %I:%M:%S %p')
2460− stamp['host'] = sysvals.hostname
2461−
2462− testruns = []
2463− data = 0
2464− lf = open(dmesgfile, 'r')
2465− for line in lf:
2466− line = line.replace('\r\n', '')
2467− idx = line.find('[')
2468− if idx > 1:
2469− line = line[idx:]
2470− m = re.match('[ \t]*(\[ *)(?P<ktime>[0-9\.]*)(\]) (?P<msg>.*)', line)
2471− if(not m):
2472− continue
2473− msg = m.group("msg")
2474− m = re.match('PM: Syncing filesystems.*', msg)
2475− if(m):
2476− if(data):
2477− testruns.append(data)
2478− data = Data(len(testruns))
2479− data.stamp = stamp
2480− if(data):
2481− m = re.match('.* *(?P<k>[0-9]\.[0-9]{2}\.[0-9]-.*) .*', msg)
2482− if(m):
2483− stamp['kernel'] = m.group('k')
2484− m = re.match('PM: Preparing system for (?P<m>.*) sleep', msg)
2485− if(m):
2486− stamp['mode'] = m.group('m')
2487− data.dmesgtext.append(line)
2488− if(data):
2489− testruns.append(data)
2490− sysvals.stamp = stamp
2491− sysvals.suspendmode = stamp['mode']
2492− lf.close()
2493− return testruns
2494−
24952770 # Function: loadKernelLog
24962771 # Description:
24972772 # [deprecated for kernel 3.15.0 or newer]
@@ -2499,15 +2774,16 @@ def loadRawKernelLog(dmesgfile): · 1 unmodified line
24992774 # The dmesg filename is taken from sysvals
25002775 # Output:
25012776 # An array of empty Data objects with only their dmesgtext attributes set
2502−def loadKernelLog():
2503− global sysvals
2504−
2777+def loadKernelLog(justtext=False):
25052778 vprint('Analyzing the dmesg data...')
25062779 if(os.path.exists(sysvals.dmesgfile) == False):
2507− doError('%s does not exist' % sysvals.dmesgfile, False)
2780+ doError('%s does not exist' % sysvals.dmesgfile)
25082781
2782+ if justtext:
2783+ dmesgtext = []
25092784 # there can be multiple test runs in a single file
25102785 tp = TestProps()
2786+ tp.stamp = datetime.now().strftime('# suspend-%m%d%y-%H%M%S localhost mem unknown')
25112787 testruns = []
25122788 data = 0
25132789 lf = open(sysvals.dmesgfile, 'r')
@@ -2528,6 +2804,9 @@ def loadKernelLog(): · 14 unmodified lines
25282804 if(not m):
25292805 continue
25302806 msg = m.group("msg")
2807+ if justtext:
2808+ dmesgtext.append(line)
2809+ continue
25312810 if(re.match('PM: Syncing filesystems.*', msg)):
25322811 if(data):
25332812 testruns.append(data)
@@ -2537,24 +2816,24 @@ def loadKernelLog(): · 3 unmodified lines
25372816 data.fwSuspend, data.fwResume = tp.fwdata[data.testnumber]
25382817 if(data.fwSuspend > 0 or data.fwResume > 0):
25392818 data.fwValid = True
2540− if(re.match('ACPI: resume from mwait', msg)):
2541− print('NOTE: This suspend appears to be freeze rather than'+\
2542− ' %s, it will be treated as such' % sysvals.suspendmode)
2543− sysvals.suspendmode = 'freeze'
25442819 if(not data):
25452820 continue
2821+ m = re.match('.* *(?P<k>[0-9]\.[0-9]{2}\.[0-9]-.*) .*', msg)
2822+ if(m):
2823+ sysvals.stamp['kernel'] = m.group('k')
2824+ m = re.match('PM: Preparing system for (?P<m>.*) sleep', msg)
2825+ if(m):
2826+ sysvals.stamp['mode'] = sysvals.suspendmode = m.group('m')
25462827 data.dmesgtext.append(line)
2547− if(data):
2548− testruns.append(data)
25492828 lf.close()
25502829
2551− if(len(testruns) < 1):
2552− # bad log, but see if you can extract something meaningful anyway
2553− testruns = loadRawKernelLog(sysvals.dmesgfile)
2554−
2555− if(len(testruns) < 1):
2556− doError(' dmesg log is completely unreadable: %s' \
2557− % sysvals.dmesgfile, False)
2830+ if justtext:
2831+ return dmesgtext
2832+ if data:
2833+ testruns.append(data)
2834+ if len(testruns) < 1:
2835+ doError(' dmesg log has no suspend/resume data: %s' \
2836+ % sysvals.dmesgfile)
25582837
25592838 # fix lines with same timestamp/function with the call and return swapped
25602839 for data in testruns:
@@ -2586,8 +2865,6 @@ def loadKernelLog(): · 25 unmodified lines
25862865 # Output:
25872866 # The filled Data object
25882867 def parseKernelLog(data):
2589− global sysvals
2590−
25912868 phase = 'suspend_runtime'
25922869
25932870 if(data.fwValid):
@@ -2645,7 +2922,6 @@ def parseKernelLog(data): · 51 unmodified lines
26452922 prevktime = -1.0
26462923 actions = dict()
26472924 for line in data.dmesgtext:
2648− # -- preprocessing --
26492925 # parse each dmesg line into the time and message
26502926 m = re.match('[ \t]*(\[ *)(?P<ktime>[0-9\.]*)(\]) (?P<msg>.*)', line)
26512927 if(m):
@@ -2653,8 +2929,6 @@ def parseKernelLog(data): · 1 unmodified line
26532929 try:
26542930 ktime = float(val)
26552931 except:
2656− doWarning('INVALID DMESG LINE: '+\
2657− line.replace('\n', ''), 'dmesg')
26582932 continue
26592933 msg = m.group('msg')
26602934 # initialize data start to first line time
@@ -2672,12 +2946,12 @@ def parseKernelLog(data): · 11 unmodified lines
26722946 phase = 'resume_noirq'
26732947 data.dmesg[phase]['start'] = ktime
26742948
2675− # -- phase changes --
26762949 # suspend start
26772950 if(re.match(dm['suspend_prepare'], msg)):
26782951 phase = 'suspend_prepare'
26792952 data.dmesg[phase]['start'] = ktime
26802953 data.setStart(ktime)
2954+ data.tKernSus = ktime
26812955 # suspend start
26822956 elif(re.match(dm['suspend'], msg)):
26832957 data.dmesg['suspend_prepare']['end'] = ktime
@@ -2734,7 +3008,7 @@ def parseKernelLog(data): · 50 unmodified lines
27343008 elif(re.match(dm['post_resume'], msg)):
27353009 data.dmesg['resume_complete']['end'] = ktime
27363010 data.setEnd(ktime)
2737− phase = 'post_resume'
3011+ data.tKernRes = ktime
27383012 break
27393013
27403014 # -- device callbacks --
@@ -2761,7 +3035,6 @@ def parseKernelLog(data): · 20 unmodified lines
27613035 dev['length'] = int(t)
27623036 dev['end'] = ktime
27633037
2764− # -- non-devicecallback actions --
27653038 # if trace events are not available, these are better than nothing
27663039 if(not sysvals.usetraceevents):
27673040 # look for known actions
@@ -2821,8 +3094,7 @@ def parseKernelLog(data): · 53 unmodified lines
28213094 for event in actions[name]:
28223095 data.newActionGlobal(name, event['begin'], event['end'])
28233096
2824− if(sysvals.verbose):
2825− data.printDetails()
3097+ data.printDetails()
28263098 if(len(sysvals.devicefilter) > 0):
28273099 data.deviceFilter(sysvals.devicefilter)
28283100 data.fixupInitcallsThatDidntReturn()
@@ -2834,8 +3106,6 @@ def parseKernelLog(data): · 5 unmodified lines
28343106 # Arguments:
28353107 # testruns: array of Data objects from parseTraceLog
28363108 def createHTMLSummarySimple(testruns, htmlfile):
2837− global sysvals
2838−
28393109 # print out the basic summary of all the tests
28403110 hf = open(htmlfile, 'w')
28413111
@@ -2960,7 +3230,6 @@ def createHTMLSummarySimple(testruns, htmlfile): · 118 unmodified lines
29603230 hf.close()
29613231
29623232 def htmlTitle():
2963− global sysvals
29643233 modename = {
29653234 'freeze': 'Freeze (S0)',
29663235 'standby': 'Standby (S1)',
@@ -2993,13 +3262,14 @@ def ordinal(value): · 26 unmodified lines
29933262 # Output:
29943263 # True if the html file was created, false if it failed
29953264 def createHTML(testruns):
2996− global sysvals
2997−
29983265 if len(testruns) < 1:
29993266 print('ERROR: Not enough test data to build a timeline')
30003267 return
30013268
3269+ kerror = False
30023270 for data in testruns:
3271+ if data.kerror:
3272+ kerror = True
30033273 data.normalizeTime(testruns[-1].tSuspended)
30043274
30053275 x2changes = ['', 'absolute']
@@ -3009,53 +3279,59 @@ def createHTML(testruns): · 3 unmodified lines
30093279 headline_version = '<div class="version"><a href="https://01.org/suspendresume">AnalyzeSuspend v%s</a></div>' % sysvals.version
30103280 headline_stamp = '<div class="stamp">{0} {1} {2} {3}</div>\n'
30113281 html_devlist1 = '<button id="devlist1" class="devlist" style="float:left;">Device Detail%s</button>' % x2changes[0]
3012− html_zoombox = '<center><button id="zoomin">ZOOM IN</button><button id="zoomout">ZOOM OUT</button><button id="zoomdef">ZOOM 1:1</button></center>\n'
3282+ html_zoombox = '<center><button id="zoomin">ZOOM IN +</button><button id="zoomout">ZOOM OUT -</button><button id="zoomdef">ZOOM 1:1</button></center>\n'
30133283 html_devlist2 = '<button id="devlist2" class="devlist" style="float:right;">Device Detail2</button>\n'
30143284 html_timeline = '<div id="dmesgzoombox" class="zoombox">\n<div id="{0}" class="timeline" style="height:{1}px">\n'
3015− html_tblock = '<div id="block{0}" class="tblock" style="left:{1}%;width:{2}%;">\n'
3285+ html_tblock = '<div id="block{0}" class="tblock" style="left:{1}%;width:{2}%;"><div class="tback" style="height:{3}px"></div>\n'
30163286 html_device = '<div id="{0}" title="{1}" class="thread{7}" style="left:{2}%;top:{3}px;height:{4}px;width:{5}%;{8}">{6}</div>\n'
3017− html_traceevent = '<div title="{0}" class="traceevent" style="left:{1}%;top:{2}px;height:{3}px;width:{4}%;line-height:{3}px;">{5}</div>\n'
3287+ html_error = '<div id="{1}" title="kernel error/warning" class="err" style="right:{0}%">ERROR&rarr;</div>\n'
3288+ html_traceevent = '<div title="{0}" class="traceevent{6}" style="left:{1}%;top:{2}px;height:{3}px;width:{4}%;line-height:{3}px;{7}">{5}</div>\n'
3289+ html_cpuexec = '<div class="jiffie" style="left:{0}%;top:{1}px;height:{2}px;width:{3}%;background:{4};"></div>\n'
30183290 html_phase = '<div class="phase" style="left:{0}%;width:{1}%;top:{2}px;height:{3}px;background-color:{4}">{5}</div>\n'
3019− html_phaselet = '<div id="{0}" class="phaselet" style="left:{1}%;width:{2}%;background-color:{3}"></div>\n'
3291+ html_phaselet = '<div id="{0}" class="phaselet" style="left:{1}%;width:{2}%;background:{3}"></div>\n'
30203292 html_legend = '<div id="p{3}" class="square" style="left:{0}%;background-color:{1}">&nbsp;{2}</div>\n'
30213293 html_timetotal = '<table class="time1">\n<tr>'\
3022− '<td class="green">{2} Suspend Time: <b>{0} ms</b></td>'\
3023− '<td class="yellow">{2} Resume Time: <b>{1} ms</b></td>'\
3294+ '<td class="green" title="{3}">{2} Suspend Time: <b>{0} ms</b></td>'\
3295+ '<td class="yellow" title="{4}">{2} Resume Time: <b>{1} ms</b></td>'\
30243296 '</tr>\n</table>\n'
30253297 html_timetotal2 = '<table class="time1">\n<tr>'\
3026− '<td class="green">{3} Suspend Time: <b>{0} ms</b></td>'\
3027− '<td class="gray">'+sysvals.suspendmode+' time: <b>{1} ms</b></td>'\
3028− '<td class="yellow">{3} Resume Time: <b>{2} ms</b></td>'\
3298+ '<td class="green" title="{4}">{3} Suspend Time: <b>{0} ms</b></td>'\
3299+ '<td class="gray" title="time spent in low-power mode with clock running">'+sysvals.suspendmode+' time: <b>{1} ms</b></td>'\
3300+ '<td class="yellow" title="{5}">{3} Resume Time: <b>{2} ms</b></td>'\
30293301 '</tr>\n</table>\n'
30303302 html_timetotal3 = '<table class="time1">\n<tr>'\
30313303 '<td class="green">Execution Time: <b>{0} ms</b></td>'\
30323304 '<td class="yellow">Command: <b>{1}</b></td>'\
30333305 '</tr>\n</table>\n'
30343306 html_timegroups = '<table class="time2">\n<tr>'\
3035− '<td class="green">{4}Kernel Suspend: {0} ms</td>'\
3307+ '<td class="green" title="time from kernel enter_state({5}) to firmware mode [kernel time only]">{4}Kernel Suspend: {0} ms</td>'\
30363308 '<td class="purple">{4}Firmware Suspend: {1} ms</td>'\
30373309 '<td class="purple">{4}Firmware Resume: {2} ms</td>'\
3038− '<td class="yellow">{4}Kernel Resume: {3} ms</td>'\
3310+ '<td class="yellow" title="time from firmware mode to return from kernel enter_state({5}) [kernel time only]">{4}Kernel Resume: {3} ms</td>'\
30393311 '</tr>\n</table>\n'
30403312
30413313 # html format variables
3042− rowheight = 30
3043− devtextS = '14px'
3044− devtextH = '30px'
3045− hoverZ = 'z-index:10;'
3046−
3314+ hoverZ = 'z-index:8;'
30473315 if sysvals.usedevsrc:
30483316 hoverZ = ''
3317+ scaleH = 20
3318+ scaleTH = 20
3319+ if kerror:
3320+ scaleH = 40
3321+ scaleTH = 60
30493322
30503323 # device timeline
30513324 vprint('Creating Device Timeline...')
30523325
3053− devtl = Timeline(rowheight)
3326+ devtl = Timeline(30, scaleH)
30543327
30553328 # Generate the header for this timeline
30563329 for data in testruns:
30573330 tTotal = data.end - data.start
3058− tEnd = data.dmesg['resume_complete']['end']
3331+ sktime = (data.dmesg['suspend_machine']['end'] - \
3332+ data.tKernSus) * 1000
3333+ rktime = (data.dmesg['resume_complete']['end'] - \
3334+ data.dmesg['resume_machine']['start']) * 1000
30593335 if(tTotal == 0):
30603336 print('ERROR: No timeline data')
30613337 sys.exit()
@@ -3072,59 +3348,85 @@ def createHTML(testruns): · 10 unmodified lines
30723348 thtml = html_timetotal3.format(run_time, testdesc)
30733349 devtl.html['header'] += thtml
30743350 elif data.fwValid:
3075− suspend_time = '%.0f'%((data.tSuspended-data.start)*1000 + \
3076− (data.fwSuspend/1000000.0))
3077− resume_time = '%.0f'%((tEnd-data.tSuspended)*1000 + \
3078− (data.fwResume/1000000.0))
3351+ suspend_time = '%.0f'%(sktime + (data.fwSuspend/1000000.0))
3352+ resume_time = '%.0f'%(rktime + (data.fwResume/1000000.0))
30793353 testdesc1 = 'Total'
30803354 testdesc2 = ''
3355+ stitle = 'time from kernel enter_state(%s) to low-power mode [kernel & firmware time]' % sysvals.suspendmode
3356+ rtitle = 'time from low-power mode to return from kernel enter_state(%s) [firmware & kernel time]' % sysvals.suspendmode
30813357 if(len(testruns) > 1):
30823358 testdesc1 = testdesc2 = ordinal(data.testnumber+1)
30833359 testdesc2 += ' '
30843360 if(data.tLow == 0):
30853361 thtml = html_timetotal.format(suspend_time, \
3086− resume_time, testdesc1)
3362+ resume_time, testdesc1, stitle, rtitle)
30873363 else:
30883364 thtml = html_timetotal2.format(suspend_time, low_time, \
3089− resume_time, testdesc1)
3365+ resume_time, testdesc1, stitle, rtitle)
30903366 devtl.html['header'] += thtml
3091− sktime = '%.3f'%((data.dmesg['suspend_machine']['end'] - \
3092− data.getStart())*1000)
30933367 sftime = '%.3f'%(data.fwSuspend / 1000000.0)
30943368 rftime = '%.3f'%(data.fwResume / 1000000.0)
3095− rktime = '%.3f'%((data.dmesg['resume_complete']['end'] - \
3096− data.dmesg['resume_machine']['start'])*1000)
3097− devtl.html['header'] += html_timegroups.format(sktime, \
3098− sftime, rftime, rktime, testdesc2)
3369+ devtl.html['header'] += html_timegroups.format('%.3f'%sktime, \
3370+ sftime, rftime, '%.3f'%rktime, testdesc2, sysvals.suspendmode)
30993371 else:
3100− suspend_time = '%.0f'%((data.tSuspended-data.start)*1000)
3101− resume_time = '%.0f'%((tEnd-data.tSuspended)*1000)
3372+ suspend_time = '%.3f' % sktime
3373+ resume_time = '%.3f' % rktime
31023374 testdesc = 'Kernel'
3375+ stitle = 'time from kernel enter_state(%s) to firmware mode [kernel time only]' % sysvals.suspendmode
3376+ rtitle = 'time from firmware mode to return from kernel enter_state(%s) [kernel time only]' % sysvals.suspendmode
31033377 if(len(testruns) > 1):
31043378 testdesc = ordinal(data.testnumber+1)+' '+testdesc
31053379 if(data.tLow == 0):
31063380 thtml = html_timetotal.format(suspend_time, \
3107− resume_time, testdesc)
3381+ resume_time, testdesc, stitle, rtitle)
31083382 else:
31093383 thtml = html_timetotal2.format(suspend_time, low_time, \
3110− resume_time, testdesc)
3384+ resume_time, testdesc, stitle, rtitle)
31113385 devtl.html['header'] += thtml
31123386
31133387 # time scale for potentially multiple datasets
31143388 t0 = testruns[0].start
31153389 tMax = testruns[-1].end
3116− tSuspended = testruns[-1].tSuspended
31173390 tTotal = tMax - t0
31183391
31193392 # determine the maximum number of rows we need to draw
3393+ fulllist = []
3394+ threadlist = []
3395+ pscnt = 0
3396+ devcnt = 0
31203397 for data in testruns:
31213398 data.selectTimelineDevices('%f', tTotal, sysvals.mindevlen)
31223399 for group in data.devicegroups:
31233400 devlist = []
31243401 for phase in group:
31253402 for devname in data.tdevlist[phase]:
3126− devlist.append((phase,devname))
3127− devtl.getPhaseRows(data.dmesg, devlist)
3403+ d = DevItem(data.testnumber, phase, data.dmesg[phase]['list'][devname])
3404+ devlist.append(d)
3405+ if d.isa('kth'):
3406+ threadlist.append(d)
3407+ else:
3408+ if d.isa('ps'):
3409+ pscnt += 1
3410+ else:
3411+ devcnt += 1
3412+ fulllist.append(d)
3413+ if sysvals.mixedphaseheight:
3414+ devtl.getPhaseRows(devlist)
3415+ if not sysvals.mixedphaseheight:
3416+ if len(threadlist) > 0 and len(fulllist) > 0:
3417+ if pscnt > 0 and devcnt > 0:
3418+ msg = 'user processes & device pm callbacks'
3419+ elif pscnt > 0:
3420+ msg = 'user processes'
3421+ else:
3422+ msg = 'device pm callbacks'
3423+ d = testruns[0].addHorizontalDivider(msg, testruns[-1].end)
3424+ fulllist.insert(0, d)
3425+ devtl.getPhaseRows(fulllist)
3426+ if len(threadlist) > 0:
3427+ d = testruns[0].addHorizontalDivider('asynchronous kernel threads', testruns[-1].end)
3428+ threadlist.insert(0, d)
3429+ devtl.getPhaseRows(threadlist, devtl.rows)
31283430 devtl.calcTotalRows()
31293431
31303432 # create bounding box, add buttons
@@ -3145,18 +3447,6 @@ def createHTML(testruns): · 14 unmodified lines
31453447
31463448 # draw each test run chronologically
31473449 for data in testruns:
3148− # if nore than one test, draw a block to represent user mode
3149− if(data.testnumber > 0):
3150− m0 = testruns[data.testnumber-1].end
3151− mMax = testruns[data.testnumber].start
3152− mTotal = mMax - m0
3153− name = 'usermode%d' % data.testnumber
3154− top = '%d' % devtl.scaleH
3155− left = '%f' % (((m0-t0)*100.0)/tTotal)
3156− width = '%f' % ((mTotal*100.0)/tTotal)
3157− title = 'user mode (%0.3f ms) ' % (mTotal*1000)
3158− devtl.html['timeline'] += html_device.format(name, \
3159− title, left, top, '%d'%devtl.bodyH, width, '', '', '')
31603450 # now draw the actual timeline blocks
31613451 for dir in phases:
31623452 # draw suspend and resume blocks separately
@@ -3169,13 +3459,16 @@ def createHTML(testruns): · 6 unmodified lines
31693459 else:
31703460 m0 = testruns[data.testnumber].tSuspended
31713461 mMax = testruns[data.testnumber].end
3462+ # in an x2 run, remove any gap between blocks
3463+ if len(testruns) > 1 and data.testnumber == 0:
3464+ mMax = testruns[1].start
31723465 mTotal = mMax - m0
31733466 left = '%f' % ((((m0-t0)*100.0)+sysvals.srgap/2)/tTotal)
31743467 # if a timeline block is 0 length, skip altogether
31753468 if mTotal == 0:
31763469 continue
31773470 width = '%f' % (((mTotal*100.0)-sysvals.srgap/2)/tTotal)
3178− devtl.html['timeline'] += html_tblock.format(bname, left, width)
3471+ devtl.html['timeline'] += html_tblock.format(bname, left, width, devtl.scaleH)
31793472 for b in sorted(phases[dir]):
31803473 # draw the phase color background
31813474 phase = data.dmesg[b]
@@ -3185,6 +3478,12 @@ def createHTML(testruns): · 3 unmodified lines
31853478 devtl.html['timeline'] += html_phase.format(left, width, \
31863479 '%.3f'%devtl.scaleH, '%.3f'%devtl.bodyH, \
31873480 data.dmesg[b]['color'], '')
3481+ for e in data.errorinfo[dir]:
3482+ # draw red lines for any kernel errors found
3483+ t, err = e
3484+ right = '%f' % (((mMax-t)*100.0)/mTotal)
3485+ devtl.html['timeline'] += html_error.format(right, err)
3486+ for b in sorted(phases[dir]):
31883487 # draw the devices for this phase
31893488 phaselist = data.dmesg[b]['list']
31903489 for d in data.tdevlist[b]:
@@ -3196,46 +3495,62 @@ def createHTML(testruns): · 5 unmodified lines
31963495 xtrastyle = ''
31973496 if 'htmlclass' in dev:
31983497 xtraclass = dev['htmlclass']
3199− xtrainfo = dev['htmlclass']
32003498 if 'color' in dev:
32013499 xtrastyle = 'background-color:%s;' % dev['color']
32023500 if(d in sysvals.devprops):
32033501 name = sysvals.devprops[d].altName(d)
32043502 xtraclass = sysvals.devprops[d].xtraClass()
32053503 xtrainfo = sysvals.devprops[d].xtraInfo()
3504+ elif xtraclass == ' kth':
3505+ xtrainfo = ' kernel_thread'
32063506 if('drv' in dev and dev['drv']):
32073507 drv = ' {%s}' % dev['drv']
3208− rowheight = devtl.phaseRowHeight(b, dev['row'])
3209− rowtop = devtl.phaseRowTop(b, dev['row'])
3508+ rowheight = devtl.phaseRowHeight(data.testnumber, b, dev['row'])
3509+ rowtop = devtl.phaseRowTop(data.testnumber, b, dev['row'])
32103510 top = '%.3f' % (rowtop + devtl.scaleH)
32113511 left = '%f' % (((dev['start']-m0)*100)/mTotal)
32123512 width = '%f' % (((dev['end']-dev['start'])*100)/mTotal)
32133513 length = ' (%0.3f ms) ' % ((dev['end']-dev['start'])*1000)
3514+ title = name+drv+xtrainfo+length
32143515 if sysvals.suspendmode == 'command':
3215− title = name+drv+xtrainfo+length+'cmdexec'
3516+ title += sysvals.testcommand
3517+ elif xtraclass == ' ps':
3518+ if 'suspend' in b:
3519+ title += 'pre_suspend_process'
3520+ else:
3521+ title += 'post_resume_process'
32163522 else:
3217− title = name+drv+xtrainfo+length+b
3523+ title += b
32183524 devtl.html['timeline'] += html_device.format(dev['id'], \
32193525 title, left, top, '%.3f'%rowheight, width, \
32203526 d+drv, xtraclass, xtrastyle)
3527+ if('cpuexec' in dev):
3528+ for t in sorted(dev['cpuexec']):
3529+ start, end = t
3530+ j = float(dev['cpuexec'][t]) / 5
3531+ if j > 1.0:
3532+ j = 1.0
3533+ height = '%.3f' % (rowheight/3)
3534+ top = '%.3f' % (rowtop + devtl.scaleH + 2*rowheight/3)
3535+ left = '%f' % (((start-m0)*100)/mTotal)
3536+ width = '%f' % ((end-start)*100/mTotal)
3537+ color = 'rgba(255, 0, 0, %f)' % j
3538+ devtl.html['timeline'] += \
3539+ html_cpuexec.format(left, top, height, width, color)
32213540 if('src' not in dev):
32223541 continue
32233542 # draw any trace events for this device
3224− vprint('Debug trace events found for device %s' % d)
3225− vprint('%20s %20s %10s %8s' % ('title', \
3226− 'name', 'time(ms)', 'length(ms)'))
32273543 for e in dev['src']:
3228− vprint('%20s %20s %10.3f %8.3f' % (e.title, \
3229− e.text, e.time*1000, e.length*1000))
3230− height = devtl.rowH
3544+ height = '%.3f' % devtl.rowH
32313545 top = '%.3f' % (rowtop + devtl.scaleH + (e.row*devtl.rowH))
32323546 left = '%f' % (((e.time-m0)*100)/mTotal)
32333547 width = '%f' % (e.length*100/mTotal)
3234− color = 'rgba(204,204,204,0.5)'
3548+ xtrastyle = ''
3549+ if e.color:
3550+ xtrastyle = 'background:%s;' % e.color
32353551 devtl.html['timeline'] += \
3236− html_traceevent.format(e.title, \
3237− left, top, '%.3f'%height, \
3238− width, e.text)
3552+ html_traceevent.format(e.title(), \
3553+ left, top, height, width, e.text(), '', xtrastyle)
32393554 # draw the time scale, try to make the number of labels readable
32403555 devtl.html['timeline'] += devtl.createTimeScale(m0, mMax, tTotal, dir)
32413556 devtl.html['timeline'] += '</div>\n'
@@ -3284,8 +3599,7 @@ def createHTML(testruns): · 42 unmodified lines
32843599 t2 {color:black;font:25px Times;}\n\
32853600 t3 {color:black;font:20px Times;white-space:nowrap;}\n\
32863601 t4 {color:black;font:bold 30px Times;line-height:60px;white-space:nowrap;}\n\
3287− cS {color:blue;font:bold 11px Times;}\n\
3288− cR {color:red;font:bold 11px Times;}\n\
3602+ cS {font:bold 13px Times;}\n\
32893603 table {width:100%;}\n\
32903604 .gray {background-color:rgba(80,80,80,0.1);}\n\
32913605 .green {background-color:rgba(204,255,204,0.4);}\n\
@@ -3302,20 +3616,22 @@ def createHTML(testruns): · 10 unmodified lines
33023616 .pf:'+cgchk+' + label {background:url(\'data:image/svg+xml;utf,<?xml version="1.0" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" height="18" width="18" version="1.1"><circle cx="9" cy="9" r="8" stroke="black" stroke-width="1" fill="white"/><rect x="4" y="8" width="10" height="2" style="fill:black;stroke-width:0"/><rect x="8" y="4" width="2" height="10" style="fill:black;stroke-width:0"/></svg>\') no-repeat left center;}\n\
33033617 .pf:'+cgnchk+' ~ label {background:url(\'data:image/svg+xml;utf,<?xml version="1.0" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" height="18" width="18" version="1.1"><circle cx="9" cy="9" r="8" stroke="black" stroke-width="1" fill="white"/><rect x="4" y="8" width="10" height="2" style="fill:black;stroke-width:0"/></svg>\') no-repeat left center;}\n\
33043618 .pf:'+cgchk+' ~ *:not(:nth-child(2)) {display:none;}\n\
3305− .zoombox {position:relative;width:100%;overflow-x:scroll;}\n\
3619+ .zoombox {position:relative;width:100%;overflow-x:scroll;-webkit-user-select:none;-moz-user-select:none;user-select:none;}\n\
33063620 .timeline {position:relative;font-size:14px;cursor:pointer;width:100%; overflow:hidden;background:linear-gradient(#cccccc, white);}\n\
3307− .thread {position:absolute;height:0%;overflow:hidden;line-height:'+devtextH+';font-size:'+devtextS+';border:1px solid;text-align:center;white-space:nowrap;background-color:rgba(204,204,204,0.5);}\n\
3308− .thread.sync {background-color:'+sysvals.synccolor+';}\n\
3309− .thread.bg {background-color:'+sysvals.kprobecolor+';}\n\
3621+ .thread {position:absolute;height:0%;overflow:hidden;z-index:7;line-height:30px;font-size:14px;border:1px solid;text-align:center;white-space:nowrap;}\n\
3622+ .thread.ps {border-radius:3px;background:linear-gradient(to top, #ccc, #eee);}\n\
33103623 .thread:hover {background-color:white;border:1px solid red;'+hoverZ+'}\n\
3624+ .thread.sec,.thread.sec:hover {background-color:black;border:0;color:white;line-height:15px;font-size:10px;}\n\
33113625 .hover {background-color:white;border:1px solid red;'+hoverZ+'}\n\
33123626 .hover.sync {background-color:white;}\n\
3313− .hover.bg {background-color:white;}\n\
3314− .traceevent {position:absolute;font-size:10px;overflow:hidden;color:black;text-align:center;white-space:nowrap;border-radius:5px;border:1px solid black;background:linear-gradient(to bottom right,rgba(204,204,204,1),rgba(150,150,150,1));}\n\
3315− .traceevent:hover {background:white;}\n\
3627+ .hover.bg,.hover.kth,.hover.sync,.hover.ps {background-color:white;}\n\
3628+ .jiffie {position:absolute;pointer-events: none;z-index:8;}\n\
3629+ .traceevent {position:absolute;font-size:10px;z-index:7;overflow:hidden;color:black;text-align:center;white-space:nowrap;border-radius:5px;border:1px solid black;background:linear-gradient(to bottom right,#CCC,#969696);}\n\
3630+ .traceevent:hover {color:white;font-weight:bold;border:1px solid white;}\n\
33163631 .phase {position:absolute;overflow:hidden;border:0px;text-align:center;}\n\
33173632 .phaselet {position:absolute;overflow:hidden;border:0px;text-align:center;height:100px;font-size:24px;}\n\
3318− .t {z-index:2;position:absolute;pointer-events:none;top:0%;height:100%;border-right:1px solid black;}\n\
3633+ .t {position:absolute;line-height:'+('%d'%scaleTH)+'px;pointer-events:none;top:0;height:100%;border-right:1px solid black;z-index:6;}\n\
3634+ .err {position:absolute;top:0%;height:100%;border-right:3px solid red;color:red;font:bold 14px Times;line-height:18px;}\n\
33193635 .legend {position:relative; width:100%; height:40px; text-align:center;margin-bottom:20px}\n\
33203636 .legend .square {position:absolute;cursor:pointer;top:10px; width:0px;height:20px;border:1px solid;padding-left:20px;}\n\
33213637 button {height:40px;width:200px;margin-bottom:20px;margin-top:20px;font-size:24px;}\n\
@@ -3327,7 +3643,8 @@ def createHTML(testruns): · 5 unmodified lines
33273643 a:active {color:white;}\n\
33283644 .version {position:relative;float:left;color:white;font-size:10px;line-height:30px;margin-left:10px;}\n\
33293645 #devicedetail {height:100px;box-shadow:5px 5px 20px black;}\n\
3330− .tblock {position:absolute;height:100%;}\n\
3646+ .tblock {position:absolute;height:100%;background-color:#ddd;}\n\
3647+ .tback {position:absolute;width:100%;background:linear-gradient(#ccc, #ddd);}\n\
33313648 .bg {z-index:1;}\n\
33323649 </style>\n</head>\n<body>\n'
33333650
@@ -3342,6 +3659,8 @@ def createHTML(testruns): · 8 unmodified lines
33423659 # write the test title and general info header
33433660 if(sysvals.stamp['time'] != ""):
33443661 hf.write(headline_version)
3662+ if sysvals.logmsg:
3663+ hf.write('<button id="showtest" class="logbtn">log</button>')
33453664 if sysvals.addlogs and sysvals.dmesgfile:
33463665 hf.write('<button id="showdmesg" class="logbtn">dmesg</button>')
33473666 if sysvals.addlogs and sysvals.ftracefile:
@@ -3359,6 +3678,9 @@ def createHTML(testruns): · 11 unmodified lines
33593678 # draw the colored boxes for the device detail section
33603679 for data in testruns:
33613680 hf.write('<div id="devicedetail%d">\n' % data.testnumber)
3681+ pscolor = 'linear-gradient(to top left, #ccc, #eee)'
3682+ hf.write(html_phaselet.format('pre_suspend_process', \
3683+ '0', '0', pscolor))
33623684 for b in data.phases:
33633685 phase = data.dmesg[b]
33643686 length = phase['end']-phase['start']
@@ -3366,14 +3688,18 @@ def createHTML(testruns): · 1 unmodified line
33663688 width = '%.3f' % ((length*100.0)/tTotal)
33673689 hf.write(html_phaselet.format(b, left, width, \
33683690 data.dmesg[b]['color']))
3691+ hf.write(html_phaselet.format('post_resume_process', \
3692+ '0', '0', pscolor))
33693693 if sysvals.suspendmode == 'command':
3370− hf.write(html_phaselet.format('cmdexec', '0', '0', \
3371− data.dmesg['resume_complete']['color']))
3694+ hf.write(html_phaselet.format('cmdexec', '0', '0', pscolor))
33723695 hf.write('</div>\n')
33733696 hf.write('</div>\n')
33743697
33753698 # write the ftrace data (callgraph)
3376− data = testruns[-1]
3699+ if sysvals.cgtest >= 0 and len(testruns) > sysvals.cgtest:
3700+ data = testruns[sysvals.cgtest]
3701+ else:
3702+ data = testruns[-1]
33773703 if(sysvals.usecallgraph and not sysvals.embedded):
33783704 hf.write('<section id="callgraphs" class="callgraph">\n')
33793705 # write out the ftrace data converted to html
@@ -3383,6 +3709,8 @@ def createHTML(testruns): · 3 unmodified lines
33833709 html_func_leaf = '<article>{0} {1}</article>\n'
33843710 num = 0
33853711 for p in data.phases:
3712+ if sysvals.cgphase and p != sysvals.cgphase:
3713+ continue
33863714 list = data.dmesg[p]['list']
33873715 for devname in data.sortedDevices(p):
33883716 if('ftrace' not in list[devname]):
@@ -3420,11 +3748,15 @@ def createHTML(testruns): · 31 unmodified lines
34203748 hf.write(html_func_end)
34213749 hf.write('\n\n </section>\n')
34223750
3751+ # add the test log as a hidden div
3752+ if sysvals.logmsg:
3753+ hf.write('<div id="testlog" style="display:none;">\n'+sysvals.logmsg+'</div>\n')
34233754 # add the dmesg log as a hidden div
34243755 if sysvals.addlogs and sysvals.dmesgfile:
34253756 hf.write('<div id="dmesglog" style="display:none;">\n')
34263757 lf = open(sysvals.dmesgfile, 'r')
34273758 for line in lf:
3759+ line = line.replace('<', '&lt').replace('>', '&gt')
34283760 hf.write(line)
34293761 lf.close()
34303762 hf.write('</div>\n')
@@ -3475,8 +3807,9 @@ def addScriptCode(hf, testruns): · 44 unmodified lines
34753807 script_code = \
34763808 '<script type="text/javascript">\n'+detail+\
34773809 ' var resolution = -1;\n'\
3810+ ' var dragval = [0, 0];\n'\
34783811 ' function redrawTimescale(t0, tMax, tS) {\n'\
3479− ' var rline = \'<div class="t" style="left:0;border-left:1px solid black;border-right:0;"><cR><-R</cR></div>\';\n'\
3812+ ' var rline = \'<div class="t" style="left:0;border-left:1px solid black;border-right:0;"><cS>&larr;R</cS></div>\';\n'\
34803813 ' var tTotal = tMax - t0;\n'\
34813814 ' var list = document.getElementsByClassName("tblock");\n'\
34823815 ' for (var i = 0; i < list.length; i++) {\n'\
@@ -3501,7 +3834,7 @@ def addScriptCode(hf, testruns): · 18 unmodified lines
35013834 ' pos = 100 - (((j)*tS*100)/mTotal) - divEdge;\n'\
35023835 ' val = (j-divTotal+1)*tS;\n'\
35033836 ' if(j == divTotal - 1)\n'\
3504− ' htmlline = \'<div class="t" style="right:\'+pos+\'%"><cS>S-></cS></div>\';\n'\
3837+ ' htmlline = \'<div class="t" style="right:\'+pos+\'%"><cS>S&rarr;</cS></div>\';\n'\
35053838 ' else\n'\
35063839 ' htmlline = \'<div class="t" style="right:\'+pos+\'%">\'+val+\'ms</div>\';\n'\
35073840 ' }\n'\
@@ -3513,6 +3846,7 @@ def addScriptCode(hf, testruns): · 5 unmodified lines
35133846 ' function zoomTimeline() {\n'\
35143847 ' var dmesg = document.getElementById("dmesg");\n'\
35153848 ' var zoombox = document.getElementById("dmesgzoombox");\n'\
3849+ ' var left = zoombox.scrollLeft;\n'\
35163850 ' var val = parseFloat(dmesg.style.width);\n'\
35173851 ' var newval = 100;\n'\
35183852 ' var sh = window.outerWidth / 2;\n'\
@@ -3520,12 +3854,12 @@ def addScriptCode(hf, testruns): · 1 unmodified line
35203854 ' newval = val * 1.2;\n'\
35213855 ' if(newval > 910034) newval = 910034;\n'\
35223856 ' dmesg.style.width = newval+"%";\n'\
3523− ' zoombox.scrollLeft = ((zoombox.scrollLeft + sh) * newval / val) - sh;\n'\
3857+ ' zoombox.scrollLeft = ((left + sh) * newval / val) - sh;\n'\
35243858 ' } else if (this.id == "zoomout") {\n'\
35253859 ' newval = val / 1.2;\n'\
35263860 ' if(newval < 100) newval = 100;\n'\
35273861 ' dmesg.style.width = newval+"%";\n'\
3528− ' zoombox.scrollLeft = ((zoombox.scrollLeft + sh) * newval / val) - sh;\n'\
3862+ ' zoombox.scrollLeft = ((left + sh) * newval / val) - sh;\n'\
35293863 ' } else {\n'\
35303864 ' zoombox.scrollLeft = 0;\n'\
35313865 ' dmesg.style.width = "100%";\n'\
@@ -3542,8 +3876,12 @@ def addScriptCode(hf, testruns): · 10 unmodified lines
35423876 ' resolution = tS[i];\n'\
35433877 ' redrawTimescale(t0, tMax, tS[i]);\n'\
35443878 ' }\n'\
3879+ ' function deviceName(title) {\n'\
3880+ ' var name = title.slice(0, title.indexOf(" ("));\n'\
3881+ ' return name;\n'\
3882+ ' }\n'\
35453883 ' function deviceHover() {\n'\
3546− ' var name = this.title.slice(0, this.title.indexOf(" ("));\n'\
3884+ ' var name = deviceName(this.title);\n'\
35473885 ' var dmesg = document.getElementById("dmesg");\n'\
35483886 ' var dev = dmesg.getElementsByClassName("thread");\n'\
35493887 ' var cpu = -1;\n'\
@@ -3552,7 +3890,7 @@ def addScriptCode(hf, testruns): · 2 unmodified lines
35523890 ' else if(name.match("CPU_OFF\[[0-9]*\]"))\n'\
35533891 ' cpu = parseInt(name.slice(8));\n'\
35543892 ' for (var i = 0; i < dev.length; i++) {\n'\
3555− ' dname = dev[i].title.slice(0, dev[i].title.indexOf(" ("));\n'\
3893+ ' dname = deviceName(dev[i].title);\n'\
35563894 ' var cname = dev[i].className.slice(dev[i].className.indexOf("thread"));\n'\
35573895 ' if((cpu >= 0 && dname.match("CPU_O[NF]*\\\[*"+cpu+"\\\]")) ||\n'\
35583896 ' (name == dname))\n'\
@@ -3578,7 +3916,7 @@ def addScriptCode(hf, testruns): · 19 unmodified lines
35783916 ' total[2] = (total[2]+total[4])/2;\n'\
35793917 ' }\n'\
35803918 ' var devtitle = document.getElementById("devicedetailtitle");\n'\
3581− ' var name = title.slice(0, title.indexOf(" ("));\n'\
3919+ ' var name = deviceName(title);\n'\
35823920 ' if(cpu >= 0) name = "CPU"+cpu;\n'\
35833921 ' var driver = "";\n'\
35843922 ' var tS = "<t2>(</t2>";\n'\
@@ -3600,7 +3938,7 @@ def addScriptCode(hf, testruns): · 15 unmodified lines
36003938 ' function deviceDetail() {\n'\
36013939 ' var devinfo = document.getElementById("devicedetail");\n'\
36023940 ' devinfo.style.display = "block";\n'\
3603− ' var name = this.title.slice(0, this.title.indexOf(" ("));\n'\
3941+ ' var name = deviceName(this.title);\n'\
36043942 ' var cpu = -1;\n'\
36053943 ' if(name.match("CPU_ON\[[0-9]*\]"))\n'\
36063944 ' cpu = parseInt(name.slice(7));\n'\
@@ -3615,7 +3953,7 @@ def addScriptCode(hf, testruns): · 8 unmodified lines
36153953 ' var pd = pdata[0];\n'\
36163954 ' var total = [0.0, 0.0, 0.0];\n'\
36173955 ' for (var i = 0; i < dev.length; i++) {\n'\
3618− ' dname = dev[i].title.slice(0, dev[i].title.indexOf(" ("));\n'\
3956+ ' dname = deviceName(dev[i].title);\n'\
36193957 ' if((cpu >= 0 && dname.match("CPU_O[NF]*\\\[*"+cpu+"\\\]")) ||\n'\
36203958 ' (name == dname))\n'\
36213959 ' {\n'\
@@ -3656,7 +3994,7 @@ def addScriptCode(hf, testruns): · 34 unmodified lines
36563994 ' phases[i].title = phases[i].id+" "+pd[phases[i].id]+" ms";\n'\
36573995 ' left += w;\n'\
36583996 ' var time = "<t4 style=\\"font-size:"+fs+"px\\">"+pd[phases[i].id]+" ms<br></t4>";\n'\
3659− ' var pname = "<t3 style=\\"font-size:"+fs2+"px\\">"+phases[i].id.replace("_", " ")+"</t3>";\n'\
3997+ ' var pname = "<t3 style=\\"font-size:"+fs2+"px\\">"+phases[i].id.replace(new RegExp("_", "g"), " ")+"</t3>";\n'\
36603998 ' phases[i].innerHTML = time+pname;\n'\
36613999 ' } else {\n'\
36624000 ' phases[i].style.width = "0%";\n'\
@@ -3677,12 +4015,7 @@ def addScriptCode(hf, testruns): · 14 unmodified lines
36774015 ' }\n'\
36784016 ' }\n'\
36794017 ' function devListWindow(e) {\n'\
3680− ' var sx = e.clientX;\n'\
3681− ' if(sx > window.innerWidth - 440)\n'\
3682− ' sx = window.innerWidth - 440;\n'\
3683− ' var cfg="top="+e.screenY+", left="+sx+", width=440, height=720, scrollbars=yes";\n'\
3684− ' var win = window.open("", "_blank", cfg);\n'\
3685− ' if(window.chrome) win.moveBy(sx, 0);\n'\
4018+ ' var win = window.open();\n'\
36864019 ' var html = "<title>"+e.target.innerHTML+"</title>"+\n'\
36874020 ' "<style type=\\"text/css\\">"+\n'\
36884021 ' " ul {list-style-type:circle;padding-left:10px;margin-left:10px;}"+\n'\
@@ -3692,6 +4025,12 @@ def addScriptCode(hf, testruns): · 3 unmodified lines
36924025 ' dt = devtable[1];\n'\
36934026 ' win.document.write(html+dt);\n'\
36944027 ' }\n'\
4028+ ' function errWindow() {\n'\
4029+ ' var text = this.id;\n'\
4030+ ' var win = window.open();\n'\
4031+ ' win.document.write("<pre>"+text+"</pre>");\n'\
4032+ ' win.document.close();\n'\
4033+ ' }\n'\
36954034 ' function logWindow(e) {\n'\
36964035 ' var name = e.target.id.slice(4);\n'\
36974036 ' var win = window.open();\n'\
@@ -3702,16 +4041,46 @@ def addScriptCode(hf, testruns): · 4 unmodified lines
37024041 ' }\n'\
37034042 ' function onClickPhase(e) {\n'\
37044043 ' }\n'\
4044+ ' function onMouseDown(e) {\n'\
4045+ ' dragval[0] = e.clientX;\n'\
4046+ ' dragval[1] = document.getElementById("dmesgzoombox").scrollLeft;\n'\
4047+ ' document.onmousemove = onMouseMove;\n'\
4048+ ' }\n'\
4049+ ' function onMouseMove(e) {\n'\
4050+ ' var zoombox = document.getElementById("dmesgzoombox");\n'\
4051+ ' zoombox.scrollLeft = dragval[1] + dragval[0] - e.clientX;\n'\
4052+ ' }\n'\
4053+ ' function onMouseUp(e) {\n'\
4054+ ' document.onmousemove = null;\n'\
4055+ ' }\n'\
4056+ ' function onKeyPress(e) {\n'\
4057+ ' var c = e.charCode;\n'\
4058+ ' if(c != 42 && c != 43 && c != 45) return;\n'\
4059+ ' var click = document.createEvent("Events");\n'\
4060+ ' click.initEvent("click", true, false);\n'\
4061+ ' if(c == 43) \n'\
4062+ ' document.getElementById("zoomin").dispatchEvent(click);\n'\
4063+ ' else if(c == 45)\n'\
4064+ ' document.getElementById("zoomout").dispatchEvent(click);\n'\
4065+ ' else if(c == 42)\n'\
4066+ ' document.getElementById("zoomdef").dispatchEvent(click);\n'\
4067+ ' }\n'\
37054068 ' window.addEventListener("resize", function () {zoomTimeline();});\n'\
37064069 ' window.addEventListener("load", function () {\n'\
37074070 ' var dmesg = document.getElementById("dmesg");\n'\
37084071 ' dmesg.style.width = "100%"\n'\
4072+ ' dmesg.onmousedown = onMouseDown;\n'\
4073+ ' document.onmouseup = onMouseUp;\n'\
4074+ ' document.onkeypress = onKeyPress;\n'\
37094075 ' document.getElementById("zoomin").onclick = zoomTimeline;\n'\
37104076 ' document.getElementById("zoomout").onclick = zoomTimeline;\n'\
37114077 ' document.getElementById("zoomdef").onclick = zoomTimeline;\n'\
37124078 ' var list = document.getElementsByClassName("square");\n'\
37134079 ' for (var i = 0; i < list.length; i++)\n'\
37144080 ' list[i].onclick = onClickPhase;\n'\
4081+ ' var list = document.getElementsByClassName("err");\n'\
4082+ ' for (var i = 0; i < list.length; i++)\n'\
4083+ ' list[i].onclick = errWindow;\n'\
37154084 ' var list = document.getElementsByClassName("logbtn");\n'\
37164085 ' for (var i = 0; i < list.length; i++)\n'\
37174086 ' list[i].onclick = logWindow;\n'\
@@ -3734,9 +4103,7 @@ def addScriptCode(hf, testruns): · 16 unmodified lines
37344103 # Execute system suspend through the sysfs interface, then copy the output
37354104 # dmesg and ftrace files to the test output directory.
37364105 def executeSuspend():
3737− global sysvals
3738−
3739− t0 = time.time()*1000
4106+ pm = ProcessMonitor()
37404107 tp = sysvals.tpath
37414108 fwdata = []
37424109 # mark the start point in the kernel ring buffer just as we start
@@ -3745,30 +4112,39 @@ def executeSuspend(): · 2 unmodified lines
37454112 if(sysvals.usecallgraph or sysvals.usetraceevents):
37464113 print('START TRACING')
37474114 sysvals.fsetVal('1', 'tracing_on')
4115+ if sysvals.useprocmon:
4116+ pm.start()
37484117 # execute however many s/r runs requested
37494118 for count in range(1,sysvals.execcount+1):
3750− # if this is test2 and there's a delay, start here
4119+ # x2delay in between test runs
37514120 if(count > 1 and sysvals.x2delay > 0):
3752− tN = time.time()*1000
3753− while (tN - t0) < sysvals.x2delay:
3754− tN = time.time()*1000
3755− time.sleep(0.001)
3756− # initiate suspend
3757− if(sysvals.usecallgraph or sysvals.usetraceevents):
3758− sysvals.fsetVal('SUSPEND START', 'trace_marker')
3759− if sysvals.suspendmode == 'command':
4121+ sysvals.fsetVal('WAIT %d' % sysvals.x2delay, 'trace_marker')
4122+ time.sleep(sysvals.x2delay/1000.0)
4123+ sysvals.fsetVal('WAIT END', 'trace_marker')
4124+ # start message
4125+ if sysvals.testcommand != '':
37604126 print('COMMAND START')
3761− if(sysvals.rtcwake):
3762− print('will issue an rtcwake in %d seconds' % sysvals.rtcwaketime)
3763− sysvals.rtcWakeAlarmOn()
3764− os.system(sysvals.testcommand)
37654127 else:
37664128 if(sysvals.rtcwake):
37674129 print('SUSPEND START')
3768− print('will autoresume in %d seconds' % sysvals.rtcwaketime)
3769− sysvals.rtcWakeAlarmOn()
37704130 else:
37714131 print('SUSPEND START (press a key to resume)')
4132+ # set rtcwake
4133+ if(sysvals.rtcwake):
4134+ print('will issue an rtcwake in %d seconds' % sysvals.rtcwaketime)
4135+ sysvals.rtcWakeAlarmOn()
4136+ # start of suspend trace marker
4137+ if(sysvals.usecallgraph or sysvals.usetraceevents):
4138+ sysvals.fsetVal('SUSPEND START', 'trace_marker')
4139+ # predelay delay
4140+ if(count == 1 and sysvals.predelay > 0):
4141+ sysvals.fsetVal('WAIT %d' % sysvals.predelay, 'trace_marker')
4142+ time.sleep(sysvals.predelay/1000.0)
4143+ sysvals.fsetVal('WAIT END', 'trace_marker')
4144+ # initiate suspend or command
4145+ if sysvals.testcommand != '':
4146+ call(sysvals.testcommand+' 2>&1', shell=True);
4147+ else:
37724148 pf = open(sysvals.powerfile, 'w')
37734149 pf.write(sysvals.suspendmode)
37744150 # execution will pause here
@@ -3776,26 +4152,27 @@ def executeSuspend(): · 1 unmodified line
37764152 pf.close()
37774153 except:
37784154 pass
3779− t0 = time.time()*1000
37804155 if(sysvals.rtcwake):
37814156 sysvals.rtcWakeAlarmOff()
4157+ # postdelay delay
4158+ if(count == sysvals.execcount and sysvals.postdelay > 0):
4159+ sysvals.fsetVal('WAIT %d' % sysvals.postdelay, 'trace_marker')
4160+ time.sleep(sysvals.postdelay/1000.0)
4161+ sysvals.fsetVal('WAIT END', 'trace_marker')
37824162 # return from suspend
37834163 print('RESUME COMPLETE')
37844164 if(sysvals.usecallgraph or sysvals.usetraceevents):
37854165 sysvals.fsetVal('RESUME COMPLETE', 'trace_marker')
3786− if(sysvals.suspendmode == 'mem'):
4166+ if(sysvals.suspendmode == 'mem' or sysvals.suspendmode == 'command'):
37874167 fwdata.append(getFPDT(False))
3788− # look for post resume events after the last test run
3789− t = sysvals.postresumetime
3790− if(t > 0):
3791− print('Waiting %d seconds for POST-RESUME trace events...' % t)
3792− time.sleep(t)
37934168 # stop ftrace
37944169 if(sysvals.usecallgraph or sysvals.usetraceevents):
4170+ if sysvals.useprocmon:
4171+ pm.stop()
37954172 sysvals.fsetVal('0', 'tracing_on')
37964173 print('CAPTURING TRACE')
37974174 writeDatafileHeader(sysvals.ftracefile, fwdata)
3798− os.system('cat '+tp+'trace >> '+sysvals.ftracefile)
4175+ call('cat '+tp+'trace >> '+sysvals.ftracefile, shell=True)
37994176 sysvals.fsetVal('', 'trace')
38004177 devProps()
38014178 # grab a copy of the dmesg output
@@ -3804,17 +4181,12 @@ def executeSuspend(): · 2 unmodified lines
38044181 sysvals.getdmesg()
38054182
38064183 def writeDatafileHeader(filename, fwdata):
3807− global sysvals
3808−
3809− prt = sysvals.postresumetime
38104184 fp = open(filename, 'a')
38114185 fp.write(sysvals.teststamp+'\n')
3812− if(sysvals.suspendmode == 'mem'):
4186+ if(sysvals.suspendmode == 'mem' or sysvals.suspendmode == 'command'):
38134187 for fw in fwdata:
38144188 if(fw):
38154189 fp.write('# fwsuspend %u fwresume %u\n' % (fw[0], fw[1]))
3816− if(prt > 0):
3817− fp.write('# post resume time %u\n' % prt)
38184190 fp.close()
38194191
38204192 # Function: setUSBDevicesAuto
@@ -3824,18 +4196,16 @@ def writeDatafileHeader(filename, fwdata): · 3 unmodified lines
38244196 # to always-on since the kernel cant determine if the device can
38254197 # properly autosuspend
38264198 def setUSBDevicesAuto():
3827− global sysvals
3828−
38294199 rootCheck(True)
38304200 for dirname, dirnames, filenames in os.walk('/sys/devices'):
38314201 if(re.match('.*/usb[0-9]*.*', dirname) and
38324202 'idVendor' in filenames and 'idProduct' in filenames):
3833− os.system('echo auto > %s/power/control' % dirname)
4203+ call('echo auto > %s/power/control' % dirname, shell=True)
38344204 name = dirname.split('/')[-1]
3835− desc = os.popen('cat %s/product 2>/dev/null' % \
3836− dirname).read().replace('\n', '')
3837− ctrl = os.popen('cat %s/power/control 2>/dev/null' % \
3838− dirname).read().replace('\n', '')
4205+ desc = Popen(['cat', '%s/product' % dirname],
4206+ stderr=PIPE, stdout=PIPE).stdout.read().replace('\n', '')
4207+ ctrl = Popen(['cat', '%s/power/control' % dirname],
4208+ stderr=PIPE, stdout=PIPE).stdout.read().replace('\n', '')
38394209 print('control is %s for %6s: %s' % (ctrl, name, desc))
38404210
38414211 # Function: yesno
@@ -3872,8 +4242,6 @@ def ms2nice(val): · 30 unmodified lines
38724242 # Detect all the USB hosts and devices currently connected and add
38734243 # a list of USB device names to sysvals for better timeline readability
38744244 def detectUSB():
3875− global sysvals
3876−
38774245 field = {'idVendor':'', 'idProduct':'', 'product':'', 'speed':''}
38784246 power = {'async':'', 'autosuspend':'', 'autosuspend_delay_ms':'',
38794247 'control':'', 'persist':'', 'runtime_enabled':'',
@@ -3899,12 +4267,12 @@ def detectUSB(): · 19 unmodified lines
38994267 if(re.match('.*/usb[0-9]*.*', dirname) and
39004268 'idVendor' in filenames and 'idProduct' in filenames):
39014269 for i in field:
3902− field[i] = os.popen('cat %s/%s 2>/dev/null' % \
3903− (dirname, i)).read().replace('\n', '')
4270+ field[i] = Popen(['cat', '%s/%s' % (dirname, i)],
4271+ stderr=PIPE, stdout=PIPE).stdout.read().replace('\n', '')
39044272 name = dirname.split('/')[-1]
39054273 for i in power:
3906− power[i] = os.popen('cat %s/power/%s 2>/dev/null' % \
3907− (dirname, i)).read().replace('\n', '')
4274+ power[i] = Popen(['cat', '%s/power/%s' % (dirname, i)],
4275+ stderr=PIPE, stdout=PIPE).stdout.read().replace('\n', '')
39084276 if(re.match('usb[0-9]*', name)):
39094277 first = '%-8s' % name
39104278 else:
@@ -3928,7 +4296,6 @@ def detectUSB(): · 17 unmodified lines
39284296 # Description:
39294297 # Retrieve a list of properties for all devices in the trace log
39304298 def devProps(data=0):
3931− global sysvals
39324299 props = dict()
39334300
39344301 if data:
@@ -3953,7 +4320,7 @@ def devProps(data=0): · 18 unmodified lines
39534320 return
39544321
39554322 if(os.path.exists(sysvals.ftracefile) == False):
3956− doError('%s does not exist' % sysvals.ftracefile, False)
4323+ doError('%s does not exist' % sysvals.ftracefile)
39574324
39584325 # first get the list of devices we need properties for
39594326 msghead = 'Additional data added by AnalyzeSuspend'
@@ -3976,7 +4343,7 @@ def devProps(data=0): · 16 unmodified lines
39764343 m = re.match('.*: (?P<drv>.*) (?P<d>.*), parent: *(?P<p>.*), .*', m.group('msg'));
39774344 if(not m):
39784345 continue
3979− drv, dev, par = m.group('drv'), m.group('d'), m.group('p')
4346+ dev = m.group('d')
39804347 if dev not in props:
39814348 props[dev] = DevProps()
39824349 tf.close()
@@ -4052,7 +4419,6 @@ def devProps(data=0): · 69 unmodified lines
40524419 # Output:
40534420 # A string list of the available modes
40544421 def getModes():
4055− global sysvals
40564422 modes = ''
40574423 if(os.path.exists(sysvals.powerfile)):
40584424 fp = open(sysvals.powerfile, 'r')
@@ -4066,8 +4432,6 @@ def getModes(): · 7 unmodified lines
40664432 # Arguments:
40674433 # output: True to output the info to stdout, False otherwise
40684434 def getFPDT(output):
4069− global sysvals
4070−
40714435 rectype = {}
40724436 rectype[0] = 'Firmware Basic Boot Performance Record'
40734437 rectype[1] = 'S3 Performance Table Record'
@@ -4078,19 +4442,19 @@ def getFPDT(output): · 4 unmodified lines
40784442 rootCheck(True)
40794443 if(not os.path.exists(sysvals.fpdtpath)):
40804444 if(output):
4081− doError('file does not exist: %s' % sysvals.fpdtpath, False)
4445+ doError('file does not exist: %s' % sysvals.fpdtpath)
40824446 return False
40834447 if(not os.access(sysvals.fpdtpath, os.R_OK)):
40844448 if(output):
4085− doError('file is not readable: %s' % sysvals.fpdtpath, False)
4449+ doError('file is not readable: %s' % sysvals.fpdtpath)
40864450 return False
40874451 if(not os.path.exists(sysvals.mempath)):
40884452 if(output):
4089− doError('file does not exist: %s' % sysvals.mempath, False)
4453+ doError('file does not exist: %s' % sysvals.mempath)
40904454 return False
40914455 if(not os.access(sysvals.mempath, os.R_OK)):
40924456 if(output):
4093− doError('file is not readable: %s' % sysvals.mempath, False)
4457+ doError('file is not readable: %s' % sysvals.mempath)
40944458 return False
40954459
40964460 fp = open(sysvals.fpdtpath, 'rb')
@@ -4100,7 +4464,7 @@ def getFPDT(output): · 3 unmodified lines
41004464 if(len(buf) < 36):
41014465 if(output):
41024466 doError('Invalid FPDT table data, should '+\
4103− 'be at least 36 bytes', False)
4467+ 'be at least 36 bytes')
41044468 return False
41054469
41064470 table = struct.unpack('4sIBB6s8sI4sI', buf[0:36])
@@ -4199,7 +4563,6 @@ def getFPDT(output): · 92 unmodified lines
41994563 # Output:
42004564 # True if the test will work, False if not
42014565 def statusCheck(probecheck=False):
4202− global sysvals
42034566 status = True
42044567
42054568 print('Checking this system (%s)...' % platform.node())
@@ -4282,37 +4645,14 @@ def statusCheck(probecheck=False): · 76 unmodified lines
42824645 if not probecheck:
42834646 return status
42844647
4285− if (sysvals.usecallgraph and len(sysvals.debugfuncs) > 0) or len(sysvals.kprobes) > 0:
4286− sysvals.initFtrace(True)
4287−
4288− # verify callgraph debugfuncs
4289− if sysvals.usecallgraph and len(sysvals.debugfuncs) > 0:
4290− print(' verifying these ftrace callgraph functions work:')
4291− sysvals.setFtraceFilterFunctions(sysvals.debugfuncs)
4292− fp = open(sysvals.tpath+'set_graph_function', 'r')
4293− flist = fp.read().split('\n')
4294− fp.close()
4295− for func in sysvals.debugfuncs:
4296− res = sysvals.colorText('NO')
4297− if func in flist:
4298− res = 'YES'
4299− else:
4300− for i in flist:
4301− if ' [' in i and func == i.split(' ')[0]:
4302− res = 'YES'
4303− break
4304− print(' %s: %s' % (func, res))
4305−
43064648 # verify kprobes
4307− if len(sysvals.kprobes) > 0:
4308− print(' verifying these kprobes work:')
4309− for name in sorted(sysvals.kprobes):
4310− if name in sysvals.tracefuncs:
4311− continue
4312− res = sysvals.colorText('NO')
4313− if sysvals.testKprobe(sysvals.kprobes[name]):
4314− res = 'YES'
4315− print(' %s: %s' % (name, res))
4649+ if sysvals.usekprobes:
4650+ for name in sysvals.tracefuncs:
4651+ sysvals.defaultKprobe(name, sysvals.tracefuncs[name])
4652+ if sysvals.usedevsrc:
4653+ for name in sysvals.dev_tracefuncs:
4654+ sysvals.defaultKprobe(name, sysvals.dev_tracefuncs[name])
4655+ sysvals.addKprobes(True)
43164656
43174657 return status
43184658
@@ -4322,33 +4662,20 @@ def statusCheck(probecheck=False): · 3 unmodified lines
43224662 # Arguments:
43234663 # msg: the error message to print
43244664 # help: True if printHelp should be called after, False otherwise
4325−def doError(msg, help):
4665+def doError(msg, help=False):
43264666 if(help == True):
43274667 printHelp()
43284668 print('ERROR: %s\n') % msg
43294669 sys.exit()
43304670
4331−# Function: doWarning
4332−# Description:
4333−# generic warning function for non-catastrophic anomalies
4334−# Arguments:
4335−# msg: the warning message to print
4336−# file: If not empty, a filename to request be sent to the owner for debug
4337−def doWarning(msg, file=''):
4338− print('/* %s */') % msg
4339− if(file):
4340− print('/* For a fix, please send this'+\
4341− ' %s file to <todd.e.brandt@intel.com> */' % file)
4342−
43434671 # Function: rootCheck
43444672 # Description:
43454673 # quick check to see if we have root access
43464674 def rootCheck(fatal):
4347− global sysvals
43484675 if(os.access(sysvals.powerfile, os.W_OK)):
43494676 return True
43504677 if fatal:
4351− doError('This command must be run as root', False)
4678+ doError('This command must be run as root')
43524679 return False
43534680
43544681 # Function: getArgInt
@@ -4389,71 +4716,61 @@ def getArgFloat(name, args, min, max, main=True): · 34 unmodified lines
43894716 doError(name+': value should be between %f and %f' % (min, max), True)
43904717 return val
43914718
4392−# Function: rerunTest
4393−# Description:
4394−# generate an output from an existing set of ftrace/dmesg logs
4395−def rerunTest():
4396− global sysvals
4397−
4398− if(sysvals.ftracefile != ''):
4399− doesTraceLogHaveTraceEvents()
4400− if(sysvals.dmesgfile == '' and not sysvals.usetraceeventsonly):
4401− doError('recreating this html output '+\
4402− 'requires a dmesg file', False)
4403− sysvals.setOutputFile()
4404− vprint('Output file: %s' % sysvals.htmlfile)
4719+def processData():
44054720 print('PROCESSING DATA')
44064721 if(sysvals.usetraceeventsonly):
44074722 testruns = parseTraceLog()
4723+ if sysvals.dmesgfile:
4724+ dmesgtext = loadKernelLog(True)
4725+ for data in testruns:
4726+ data.extractErrorInfo(dmesgtext)
44084727 else:
44094728 testruns = loadKernelLog()
44104729 for data in testruns:
44114730 parseKernelLog(data)
4412− if(sysvals.ftracefile != ''):
4731+ if(sysvals.ftracefile and (sysvals.usecallgraph or sysvals.usetraceevents)):
44134732 appendIncompleteTraceLog(testruns)
44144733 createHTML(testruns)
44154734
4735+# Function: rerunTest
4736+# Description:
4737+# generate an output from an existing set of ftrace/dmesg logs
4738+def rerunTest():
4739+ if sysvals.ftracefile:
4740+ doesTraceLogHaveTraceEvents()
4741+ if not sysvals.dmesgfile and not sysvals.usetraceeventsonly:
4742+ doError('recreating this html output requires a dmesg file')
4743+ sysvals.setOutputFile()
4744+ vprint('Output file: %s' % sysvals.htmlfile)
4745+ if(os.path.exists(sysvals.htmlfile) and not os.access(sysvals.htmlfile, os.W_OK)):
4746+ doError('missing permission to write to %s' % sysvals.htmlfile)
4747+ processData()
4748+
44164749 # Function: runTest
44174750 # Description:
44184751 # execute a suspend/resume, gather the logs, and generate the output
44194752 def runTest(subdir, testpath=''):
4420− global sysvals
4421−
44224753 # prepare for the test
44234754 sysvals.initFtrace()
44244755 sysvals.initTestOutput(subdir, testpath)
4425−
4426− vprint('Output files:\n %s' % sysvals.dmesgfile)
4427− if(sysvals.usecallgraph or
4428− sysvals.usetraceevents or
4429− sysvals.usetraceeventsonly):
4430− vprint(' %s' % sysvals.ftracefile)
4431− vprint(' %s' % sysvals.htmlfile)
4756+ vprint('Output files:\n\t%s\n\t%s\n\t%s' % \
4757+ (sysvals.dmesgfile, sysvals.ftracefile, sysvals.htmlfile))
44324758
44334759 # execute the test
44344760 executeSuspend()
44354761 sysvals.cleanupFtrace()
4762+ processData()
44364763
4437− # analyze the data and create the html output
4438− print('PROCESSING DATA')
4439− if(sysvals.usetraceeventsonly):
4440− # data for kernels 3.15 or newer is entirely in ftrace
4441− testruns = parseTraceLog()
4442− else:
4443− # data for kernels older than 3.15 is primarily in dmesg
4444− testruns = loadKernelLog()
4445− for data in testruns:
4446− parseKernelLog(data)
4447− if(sysvals.usecallgraph or sysvals.usetraceevents):
4448− appendIncompleteTraceLog(testruns)
4449− createHTML(testruns)
4764+ # if running as root, change output dir owner to sudo_user
4765+ if os.path.isdir(sysvals.testdir) and os.getuid() == 0 and \
4766+ 'SUDO_USER' in os.environ:
4767+ cmd = 'chown -R {0}:{0} {1} > /dev/null 2>&1'
4768+ call(cmd.format(os.environ['SUDO_USER'], sysvals.testdir), shell=True)
44504769
44514770 # Function: runSummary
44524771 # Description:
44534772 # create a summary of tests in a sub-directory
44544773 def runSummary(subdir, output):
4455− global sysvals
4456−
44574774 # get a list of ftrace output files
44584775 files = []
44594776 for dirname, dirnames, filenames in os.walk(subdir):
@@ -4509,12 +4826,12 @@ def checkArgBool(value): · 49 unmodified lines
45094826 # Description:
45104827 # Configure the script via the info in a config file
45114828 def configFromFile(file):
4512− global sysvals
45134829 Config = ConfigParser.ConfigParser()
45144830
4515− ignorekprobes = False
45164831 Config.read(file)
45174832 sections = Config.sections()
4833+ overridekprobes = False
4834+ overridedevkprobes = False
45184835 if 'Settings' in sections:
45194836 for opt in Config.options('Settings'):
45204837 value = Config.get('Settings', opt).lower()
@@ -4524,19 +4841,19 @@ def configFromFile(file): · 3 unmodified lines
45244841 sysvals.addlogs = checkArgBool(value)
45254842 elif(opt.lower() == 'dev'):
45264843 sysvals.usedevsrc = checkArgBool(value)
4527− elif(opt.lower() == 'ignorekprobes'):
4528− ignorekprobes = checkArgBool(value)
4844+ elif(opt.lower() == 'proc'):
4845+ sysvals.useprocmon = checkArgBool(value)
45294846 elif(opt.lower() == 'x2'):
45304847 if checkArgBool(value):
45314848 sysvals.execcount = 2
45324849 elif(opt.lower() == 'callgraph'):
45334850 sysvals.usecallgraph = checkArgBool(value)
4534− elif(opt.lower() == 'callgraphfunc'):
4535− sysvals.debugfuncs = []
4536− if value:
4537− value = value.split(',')
4538− for i in value:
4539− sysvals.debugfuncs.append(i.strip())
4851+ elif(opt.lower() == 'override-timeline-functions'):
4852+ overridekprobes = checkArgBool(value)
4853+ elif(opt.lower() == 'override-dev-timeline-functions'):
4854+ overridedevkprobes = checkArgBool(value)
4855+ elif(opt.lower() == 'devicefilter'):
4856+ sysvals.setDeviceFilter(value)
45404857 elif(opt.lower() == 'expandcg'):
45414858 sysvals.cgexp = checkArgBool(value)
45424859 elif(opt.lower() == 'srgap'):
@@ -4548,8 +4865,10 @@ def configFromFile(file): · 5 unmodified lines
45484865 sysvals.testcommand = value
45494866 elif(opt.lower() == 'x2delay'):
45504867 sysvals.x2delay = getArgInt('-x2delay', value, 0, 60000, False)
4551− elif(opt.lower() == 'postres'):
4552− sysvals.postresumetime = getArgInt('-postres', value, 0, 3600, False)
4868+ elif(opt.lower() == 'predelay'):
4869+ sysvals.predelay = getArgInt('-predelay', value, 0, 60000, False)
4870+ elif(opt.lower() == 'postdelay'):
4871+ sysvals.postdelay = getArgInt('-postdelay', value, 0, 60000, False)
45534872 elif(opt.lower() == 'rtcwake'):
45544873 sysvals.rtcwake = True
45554874 sysvals.rtcwaketime = getArgInt('-rtcwake', value, 0, 3600, False)
@@ -4557,53 +4876,50 @@ def configFromFile(file): · 1 unmodified line
45574876 sysvals.setPrecision(getArgInt('-timeprec', value, 0, 6, False))
45584877 elif(opt.lower() == 'mindev'):
45594878 sysvals.mindevlen = getArgFloat('-mindev', value, 0.0, 10000.0, False)
4879+ elif(opt.lower() == 'callloop-maxgap'):
4880+ sysvals.callloopmaxgap = getArgFloat('-callloop-maxgap', value, 0.0, 1.0, False)
4881+ elif(opt.lower() == 'callloop-maxlen'):
4882+ sysvals.callloopmaxgap = getArgFloat('-callloop-maxlen', value, 0.0, 1.0, False)
45604883 elif(opt.lower() == 'mincg'):
45614884 sysvals.mincglen = getArgFloat('-mincg', value, 0.0, 10000.0, False)
4562− elif(opt.lower() == 'kprobecolor'):
4563− try:
4564− val = int(value, 16)
4565− sysvals.kprobecolor = '#'+value
4566− except:
4567− sysvals.kprobecolor = value
4568− elif(opt.lower() == 'synccolor'):
4569− try:
4570− val = int(value, 16)
4571− sysvals.synccolor = '#'+value
4572− except:
4573− sysvals.synccolor = value
45744885 elif(opt.lower() == 'output-dir'):
4575− args = dict()
4576− n = datetime.now()
4577− args['date'] = n.strftime('%y%m%d')
4578− args['time'] = n.strftime('%H%M%S')
4579− args['hostname'] = sysvals.hostname
4580− sysvals.outdir = value.format(**args)
4886+ sysvals.setOutputFolder(value)
45814887
45824888 if sysvals.suspendmode == 'command' and not sysvals.testcommand:
4583− doError('No command supplied for mode "command"', False)
4889+ doError('No command supplied for mode "command"')
4890+
4891+ # compatibility errors
45844892 if sysvals.usedevsrc and sysvals.usecallgraph:
4585− doError('dev and callgraph cannot both be true', False)
4586− if sysvals.usecallgraph and sysvals.execcount > 1:
4587− doError('-x2 is not compatible with -f', False)
4893+ doError('-dev is not compatible with -f')
4894+ if sysvals.usecallgraph and sysvals.useprocmon:
4895+ doError('-proc is not compatible with -f')
45884896
4589− if ignorekprobes:
4590− return
4897+ if overridekprobes:
4898+ sysvals.tracefuncs = dict()
4899+ if overridedevkprobes:
4900+ sysvals.dev_tracefuncs = dict()
45914901
45924902 kprobes = dict()
4593− archkprobe = 'Kprobe_'+platform.machine()
4594− if archkprobe in sections:
4595− for name in Config.options(archkprobe):
4596− kprobes[name] = Config.get(archkprobe, name)
4597− if 'Kprobe' in sections:
4598− for name in Config.options('Kprobe'):
4599− kprobes[name] = Config.get('Kprobe', name)
4903+ kprobesec = 'dev_timeline_functions_'+platform.machine()
4904+ if kprobesec in sections:
4905+ for name in Config.options(kprobesec):
4906+ text = Config.get(kprobesec, name)
4907+ kprobes[name] = (text, True)
4908+ kprobesec = 'timeline_functions_'+platform.machine()
4909+ if kprobesec in sections:
4910+ for name in Config.options(kprobesec):
4911+ if name in kprobes:
4912+ doError('Duplicate timeline function found "%s"' % (name))
4913+ text = Config.get(kprobesec, name)
4914+ kprobes[name] = (text, False)
46004915
46014916 for name in kprobes:
46024917 function = name
46034918 format = name
46044919 color = ''
46054920 args = dict()
4606− data = kprobes[name].split()
4921+ text, dev = kprobes[name]
4922+ data = text.split()
46074923 i = 0
46084924 for val in data:
46094925 # bracketted strings are special formatting, read them separately
@@ -4626,28 +4942,30 @@ def configFromFile(file): · 16 unmodified lines
46264942 args[d[0]] = d[1]
46274943 i += 1
46284944 if not function or not format:
4629− doError('Invalid kprobe: %s' % name, False)
4945+ doError('Invalid kprobe: %s' % name)
46304946 for arg in re.findall('{(?P<n>[a-z,A-Z,0-9]*)}', format):
46314947 if arg not in args:
4632− doError('Kprobe "%s" is missing argument "%s"' % (name, arg), False)
4633− if name in sysvals.kprobes:
4634− doError('Duplicate kprobe found "%s"' % (name), False)
4635− vprint('Adding KPROBE: %s %s %s %s' % (name, function, format, args))
4636− sysvals.kprobes[name] = {
4948+ doError('Kprobe "%s" is missing argument "%s"' % (name, arg))
4949+ if (dev and name in sysvals.dev_tracefuncs) or (not dev and name in sysvals.tracefuncs):
4950+ doError('Duplicate timeline function found "%s"' % (name))
4951+
4952+ kp = {
46374953 'name': name,
46384954 'func': function,
46394955 'format': format,
4640− 'args': args,
4641− 'mask': re.sub('{(?P<n>[a-z,A-Z,0-9]*)}', '.*', format)
4956+ sysvals.archargs: args
46424957 }
46434958 if color:
4644− sysvals.kprobes[name]['color'] = color
4959+ kp['color'] = color
4960+ if dev:
4961+ sysvals.dev_tracefuncs[name] = kp
4962+ else:
4963+ sysvals.tracefuncs[name] = kp
46454964
46464965 # Function: printHelp
46474966 # Description:
46484967 # print out the help text
46494968 def printHelp():
4650− global sysvals
46514969 modes = getModes()
46524970
46534971 print('')
@@ -4670,44 +4988,47 @@ def printHelp(): · 16 unmodified lines
46704988 print('')
46714989 print('Options:')
46724990 print(' [general]')
4673− print(' -h Print this help text')
4674− print(' -v Print the current tool version')
4675− print(' -config file Pull arguments and config options from a file')
4676− print(' -verbose Print extra information during execution and analysis')
4677− print(' -status Test to see if the system is enabled to run this tool')
4678− print(' -modes List available suspend modes')
4679− print(' -m mode Mode to initiate for suspend %s (default: %s)') % (modes, sysvals.suspendmode)
4680− print(' -o subdir Override the output subdirectory')
4991+ print(' -h Print this help text')
4992+ print(' -v Print the current tool version')
4993+ print(' -config fn Pull arguments and config options from file fn')
4994+ print(' -verbose Print extra information during execution and analysis')
4995+ print(' -status Test to see if the system is enabled to run this tool')
4996+ print(' -modes List available suspend modes')
4997+ print(' -m mode Mode to initiate for suspend %s (default: %s)') % (modes, sysvals.suspendmode)
4998+ print(' -o subdir Override the output subdirectory')
4999+ print(' -rtcwake t Use rtcwake to autoresume after <t> seconds (default: disabled)')
5000+ print(' -addlogs Add the dmesg and ftrace logs to the html output')
5001+ print(' -srgap Add a visible gap in the timeline between sus/res (default: disabled)')
46815002 print(' [advanced]')
4682− print(' -rtcwake t Use rtcwake to autoresume after <t> seconds (default: disabled)')
4683− print(' -addlogs Add the dmesg and ftrace logs to the html output')
4684− print(' -multi n d Execute <n> consecutive tests at <d> seconds intervals. The outputs will')
5003+ print(' -cmd {s} Run the timeline over a custom command, e.g. "sync -d"')
5004+ print(' -proc Add usermode process info into the timeline (default: disabled)')
5005+ print(' -dev Add kernel function calls and threads to the timeline (default: disabled)')
5006+ print(' -x2 Run two suspend/resumes back to back (default: disabled)')
5007+ print(' -x2delay t Include t ms delay between multiple test runs (default: 0 ms)')
5008+ print(' -predelay t Include t ms delay before 1st suspend (default: 0 ms)')
5009+ print(' -postdelay t Include t ms delay after last resume (default: 0 ms)')
5010+ print(' -mindev ms Discard all device blocks shorter than ms milliseconds (e.g. 0.001 for us)')
5011+ print(' -multi n d Execute <n> consecutive tests at <d> seconds intervals. The outputs will')
46855012 print(' be created in a new subdirectory with a summary page.')
4686− print(' -srgap Add a visible gap in the timeline between sus/res (default: disabled)')
4687− print(' -cmd {s} Instead of suspend/resume, run a command, e.g. "sync -d"')
4688− print(' -mindev ms Discard all device blocks shorter than ms milliseconds (e.g. 0.001 for us)')
4689− print(' -mincg ms Discard all callgraphs shorter than ms milliseconds (e.g. 0.001 for us)')
4690− print(' -timeprec N Number of significant digits in timestamps (0:S, [3:ms], 6:us)')
46915013 print(' [debug]')
4692− print(' -f Use ftrace to create device callgraphs (default: disabled)')
4693− print(' -expandcg pre-expand the callgraph data in the html output (default: disabled)')
4694− print(' -flist Print the list of functions currently being captured in ftrace')
4695− print(' -flistall Print all functions capable of being captured in ftrace')
4696− print(' -fadd file Add functions to be graphed in the timeline from a list in a text file')
4697− print(' -filter "d1 d2 ..." Filter out all but this list of device names')
4698− print(' -dev Display common low level functions in the timeline')
4699− print(' [post-resume task analysis]')
4700− print(' -x2 Run two suspend/resumes back to back (default: disabled)')
4701− print(' -x2delay t Minimum millisecond delay <t> between the two test runs (default: 0 ms)')
4702− print(' -postres t Time after resume completion to wait for post-resume events (default: 0 S)')
5014+ print(' -f Use ftrace to create device callgraphs (default: disabled)')
5015+ print(' -expandcg pre-expand the callgraph data in the html output (default: disabled)')
5016+ print(' -flist Print the list of functions currently being captured in ftrace')
5017+ print(' -flistall Print all functions capable of being captured in ftrace')
5018+ print(' -fadd file Add functions to be graphed in the timeline from a list in a text file')
5019+ print(' -filter "d1,d2,..." Filter out all but this comma-delimited list of device names')
5020+ print(' -mincg ms Discard all callgraphs shorter than ms milliseconds (e.g. 0.001 for us)')
5021+ print(' -cgphase P Only show callgraph data for phase P (e.g. suspend_late)')
5022+ print(' -cgtest N Only show callgraph data for test N (e.g. 0 or 1 in an x2 run)')
5023+ print(' -timeprec N Number of significant digits in timestamps (0:S, [3:ms], 6:us)')
47035024 print(' [utilities]')
4704− print(' -fpdt Print out the contents of the ACPI Firmware Performance Data Table')
4705− print(' -usbtopo Print out the current USB topology with power info')
4706− print(' -usbauto Enable autosuspend for all connected USB devices')
5025+ print(' -fpdt Print out the contents of the ACPI Firmware Performance Data Table')
5026+ print(' -usbtopo Print out the current USB topology with power info')
5027+ print(' -usbauto Enable autosuspend for all connected USB devices')
47075028 print(' [re-analyze data from previous runs]')
4708− print(' -ftrace ftracefile Create HTML output using ftrace input')
4709− print(' -dmesg dmesgfile Create HTML output using dmesg (not needed for kernel >= 3.15)')
4710− print(' -summary directory Create a summary of all test in this dir')
5029+ print(' -ftrace ftracefile Create HTML output using ftrace input')
5030+ print(' -dmesg dmesgfile Create HTML output using dmesg (not needed for kernel >= 3.15)')
5031+ print(' -summary directory Create a summary of all test in this dir')
47115032 print('')
47125033 return True
47135034
@@ -4739,26 +5060,22 @@ if __name__ == '__main__': · 25 unmodified lines
47395060 sys.exit()
47405061 elif(arg == '-x2'):
47415062 sysvals.execcount = 2
4742− if(sysvals.usecallgraph):
4743− doError('-x2 is not compatible with -f', False)
47445063 elif(arg == '-x2delay'):
47455064 sysvals.x2delay = getArgInt('-x2delay', args, 0, 60000)
4746− elif(arg == '-postres'):
4747− sysvals.postresumetime = getArgInt('-postres', args, 0, 3600)
5065+ elif(arg == '-predelay'):
5066+ sysvals.predelay = getArgInt('-predelay', args, 0, 60000)
5067+ elif(arg == '-postdelay'):
5068+ sysvals.postdelay = getArgInt('-postdelay', args, 0, 60000)
47485069 elif(arg == '-f'):
47495070 sysvals.usecallgraph = True
4750− if(sysvals.execcount > 1):
4751− doError('-x2 is not compatible with -f', False)
4752− if(sysvals.usedevsrc):
4753− doError('-dev is not compatible with -f', False)
47545071 elif(arg == '-addlogs'):
47555072 sysvals.addlogs = True
47565073 elif(arg == '-verbose'):
47575074 sysvals.verbose = True
5075+ elif(arg == '-proc'):
5076+ sysvals.useprocmon = True
47585077 elif(arg == '-dev'):
47595078 sysvals.usedevsrc = True
4760− if(sysvals.usecallgraph):
4761− doError('-dev is not compatible with -f', False)
47625079 elif(arg == '-rtcwake'):
47635080 sysvals.rtcwake = True
47645081 sysvals.rtcwaketime = getArgInt('-rtcwake', args, 0, 3600)
@@ -4768,6 +5085,21 @@ if __name__ == '__main__': · 3 unmodified lines
47685085 sysvals.mindevlen = getArgFloat('-mindev', args, 0.0, 10000.0)
47695086 elif(arg == '-mincg'):
47705087 sysvals.mincglen = getArgFloat('-mincg', args, 0.0, 10000.0)
5088+ elif(arg == '-cgtest'):
5089+ sysvals.cgtest = getArgInt('-cgtest', args, 0, 1)
5090+ elif(arg == '-cgphase'):
5091+ try:
5092+ val = args.next()
5093+ except:
5094+ doError('No phase name supplied', True)
5095+ d = Data(0)
5096+ if val not in d.phases:
5097+ doError('Invalid phase, valid phaess are %s' % d.phases, True)
5098+ sysvals.cgphase = val
5099+ elif(arg == '-callloop-maxgap'):
5100+ sysvals.callloopmaxgap = getArgFloat('-callloop-maxgap', args, 0.0, 1.0)
5101+ elif(arg == '-callloop-maxlen'):
5102+ sysvals.callloopmaxlen = getArgFloat('-callloop-maxlen', args, 0.0, 1.0)
47715103 elif(arg == '-cmd'):
47725104 try:
47735105 val = args.next()
@@ -4788,14 +5120,14 @@ if __name__ == '__main__': · 14 unmodified lines
47885120 val = args.next()
47895121 except:
47905122 doError('No subdirectory name supplied', True)
4791− sysvals.outdir = val
5123+ sysvals.setOutputFolder(val)
47925124 elif(arg == '-config'):
47935125 try:
47945126 val = args.next()
47955127 except:
47965128 doError('No text file supplied', True)
47975129 if(os.path.exists(val) == False):
4798− doError('%s does not exist' % val, False)
5130+ doError('%s does not exist' % val)
47995131 configFromFile(val)
48005132 elif(arg == '-fadd'):
48015133 try:
@@ -4803,7 +5135,7 @@ if __name__ == '__main__': · 1 unmodified line
48035135 except:
48045136 doError('No text file supplied', True)
48055137 if(os.path.exists(val) == False):
4806− doError('%s does not exist' % val, False)
5138+ doError('%s does not exist' % val)
48075139 sysvals.addFtraceFilterFunctions(val)
48085140 elif(arg == '-dmesg'):
48095141 try:
@@ -4813,7 +5145,7 @@ if __name__ == '__main__': · 3 unmodified lines
48135145 sysvals.notestrun = True
48145146 sysvals.dmesgfile = val
48155147 if(os.path.exists(sysvals.dmesgfile) == False):
4816− doError('%s does not exist' % sysvals.dmesgfile, False)
5148+ doError('%s does not exist' % sysvals.dmesgfile)
48175149 elif(arg == '-ftrace'):
48185150 try:
48195151 val = args.next()
@@ -4822,7 +5154,7 @@ if __name__ == '__main__': · 2 unmodified lines
48225154 sysvals.notestrun = True
48235155 sysvals.ftracefile = val
48245156 if(os.path.exists(sysvals.ftracefile) == False):
4825− doError('%s does not exist' % sysvals.ftracefile, False)
5157+ doError('%s does not exist' % sysvals.ftracefile)
48265158 elif(arg == '-summary'):
48275159 try:
48285160 val = args.next()
@@ -4832,7 +5164,7 @@ if __name__ == '__main__': · 3 unmodified lines
48325164 cmdarg = val
48335165 sysvals.notestrun = True
48345166 if(os.path.isdir(val) == False):
4835− doError('%s is not accesible' % val, False)
5167+ doError('%s is not accesible' % val)
48365168 elif(arg == '-filter'):
48375169 try:
48385170 val = args.next()
@@ -4842,6 +5174,12 @@ if __name__ == '__main__': · 3 unmodified lines
48425174 else:
48435175 doError('Invalid argument: '+arg, True)
48445176
5177+ # compatibility errors
5178+ if(sysvals.usecallgraph and sysvals.usedevsrc):
5179+ doError('-dev is not compatible with -f')
5180+ if(sysvals.usecallgraph and sysvals.useprocmon):
5181+ doError('-proc is not compatible with -f')
5182+
48455183 # callgraph size cannot exceed device size
48465184 if sysvals.mincglen < sysvals.mindevlen:
48475185 sysvals.mincglen = sysvals.mindevlen
@@ -4855,8 +5193,7 @@ if __name__ == '__main__': · 7 unmodified lines
48555193 elif(cmd == 'usbtopo'):
48565194 detectUSB()
48575195 elif(cmd == 'modes'):
4858− modes = getModes()
4859− print modes
5196+ print getModes()
48605197 elif(cmd == 'flist'):
48615198 sysvals.getFtraceFilterFunctions(True)
48625199 elif(cmd == 'flistall'):

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t