Lines Matching +full:self +full:- +full:describing
2 # SPDX-License-Identifier: GPL-2.0-only
21 # https://01.org/pm-graph
23 # git@github.com:intel/pm-graph
51 # ----------------- LIBRARIES --------------------
76 # ----------------- CLASSES --------------------
80 # A global, single-instance container used to
100 cgtest = -1
171 tmstart = 'SUSPEND START %Y%m%d-%H:%M:%S.%f'
172 tmend = 'RESUME COMPLETE %Y%m%d-%H:%M:%S.%f'
284 [0, 'pcidevices', 'lspci', '-tv'],
285 [0, 'usbdevices', 'lsusb', '-t'],
288 [2, 'gpecounts', 'sh', '-c', 'grep -v invalid /sys/firmware/acpi/interrupts/*'],
289 [2, 'suspendstats', 'sh', '-c', 'grep -v invalid /sys/power/suspend_stats/*'],
290 …[2, 'cpuidle', 'sh', '-c', 'grep -v invalid /sys/devices/system/cpu/cpu*/cpuidle/state*/s2idle/*'],
291 [2, 'battery', 'sh', '-c', 'grep -v invalid /sys/class/power_supply/*/*'],
299 def __init__(self): argument
300 self.archargs = 'args_'+platform.machine()
301 self.hostname = platform.node()
302 if(self.hostname == ''):
303 self.hostname = 'localhost'
310 self.rtcpath = rtc
312 self.ansi = True
313 self.testdir = datetime.now().strftime('suspend-%y%m%d-%H%M%S')
316 self.sudouser = os.environ['SUDO_USER']
317 def resetlog(self): argument
318 self.logmsg = ''
319 self.platinfo = []
320 def vprint(self, msg): argument
321 self.logmsg += msg+'\n'
322 if self.verbose or msg.startswith('WARNING:'):
324 def signalHandler(self, signum, frame): argument
325 if not self.result:
327 signame = self.signames[signum] if signum in self.signames else 'UNKNOWN'
329 self.outputResult({'error':msg})
331 def signalHandlerInit(self): argument
334 self.signames = dict()
339 signal.signal(signum, self.signalHandler)
342 self.signames[signum] = s
343 def rootCheck(self, fatal=True): argument
344 if(os.access(self.powerfile, os.W_OK)):
349 self.outputResult({'error':msg})
352 def rootUser(self, fatal=False): argument
358 self.outputResult({'error':msg})
361 def usable(self, file): argument
363 def getExec(self, cmd): argument
378 def setPrecision(self, num): argument
381 self.timeformat = '%.{0}f'.format(num)
382 def setOutputFolder(self, value): argument
387 args['hostname'] = args['host'] = self.hostname
388 args['mode'] = self.suspendmode
390 def setOutputFile(self): argument
391 if self.dmesgfile != '':
392 m = re.match('(?P<name>.*)_dmesg\.txt.*', self.dmesgfile)
394 self.htmlfile = m.group('name')+'.html'
395 if self.ftracefile != '':
396 m = re.match('(?P<name>.*)_ftrace\.txt.*', self.ftracefile)
398 self.htmlfile = m.group('name')+'.html'
399 def systemInfo(self, info): argument
401 if 'baseboard-manufacturer' in info:
402 m = info['baseboard-manufacturer']
403 elif 'system-manufacturer' in info:
404 m = info['system-manufacturer']
405 if 'system-product-name' in info:
406 p = info['system-product-name']
407 elif 'baseboard-product-name' in info:
408 p = info['baseboard-product-name']
409 if m[:5].lower() == 'intel' and 'baseboard-product-name' in info:
410 p = info['baseboard-product-name']
411 c = info['processor-version'] if 'processor-version' in info else ''
412 b = info['bios-version'] if 'bios-version' in info else ''
413 r = info['bios-release-date'] if 'bios-release-date' in info else ''
414 …self.sysstamp = '# sysinfo | man:%s | plat:%s | cpu:%s | bios:%s | biosdate:%s | numcpu:%d | memsz…
415 (m, p, c, b, r, self.cpucount, self.memtotal, self.memfree)
416 def printSystemInfo(self, fatal=False): argument
417 self.rootCheck(True)
418 out = dmidecode(self.mempath, fatal)
421 fmt = '%-24s: %s'
424 print(fmt % ('cpucount', ('%d' % self.cpucount)))
425 print(fmt % ('memtotal', ('%d kB' % self.memtotal)))
426 print(fmt % ('memfree', ('%d kB' % self.memfree)))
427 def cpuInfo(self): argument
428 self.cpucount = 0
431 if re.match('^processor[ \t]*:[ \t]*[0-9]*', line):
432 self.cpucount += 1
436 m = re.match('^MemTotal:[ \t]*(?P<sz>[0-9]*) *kB', line)
438 self.memtotal = int(m.group('sz'))
439 m = re.match('^MemFree:[ \t]*(?P<sz>[0-9]*) *kB', line)
441 self.memfree = int(m.group('sz'))
443 def initTestOutput(self, name): argument
444 self.prefix = self.hostname
447 fmt = name+'-%m%d%y-%H%M%S'
449 self.teststamp = \
450 '# '+testtime+' '+self.prefix+' '+self.suspendmode+' '+kver
452 if self.gzip:
454 self.dmesgfile = \
455 self.testdir+'/'+self.prefix+'_'+self.suspendmode+'_dmesg.txt'+ext
456 self.ftracefile = \
457 self.testdir+'/'+self.prefix+'_'+self.suspendmode+'_ftrace.txt'+ext
458 self.htmlfile = \
459 self.testdir+'/'+self.prefix+'_'+self.suspendmode+'.html'
460 if not os.path.isdir(self.testdir):
461 os.makedirs(self.testdir)
462 self.sudoUserchown(self.testdir)
463 def getValueList(self, value): argument
469 def setDeviceFilter(self, value): argument
470 self.devicefilter = self.getValueList(value)
471 def setCallgraphFilter(self, value): argument
472 self.cgfilter = self.getValueList(value)
473 def skipKprobes(self, value): argument
474 for k in self.getValueList(value):
475 if k in self.tracefuncs:
476 del self.tracefuncs[k]
477 if k in self.dev_tracefuncs:
478 del self.dev_tracefuncs[k]
479 def setCallgraphBlacklist(self, file): argument
480 self.cgblacklist = self.listFromFile(file)
481 def rtcWakeAlarmOn(self): argument
482 call('echo 0 > '+self.rtcpath+'/wakealarm', shell=True)
483 nowtime = open(self.rtcpath+'/since_epoch', 'r').read().strip()
489 alarm = nowtime + self.rtcwaketime
490 call('echo %d > %s/wakealarm' % (alarm, self.rtcpath), shell=True)
491 def rtcWakeAlarmOff(self): argument
492 call('echo 0 > %s/wakealarm' % self.rtcpath, shell=True)
493 def initdmesg(self): argument
502 m = re.match('[ \t]*(\[ *)(?P<ktime>[0-9\.]*)(\]) (?P<msg>.*)', line)
506 self.dmesgstart = float(ktime)
507 def getdmesg(self, testdata): argument
508 op = self.writeDatafileHeader(self.dmesgfile, testdata)
516 m = re.match('[ \t]*(\[ *)(?P<ktime>[0-9\.]*)(\]) (?P<msg>.*)', line)
520 if ktime > self.dmesgstart:
524 def listFromFile(self, file): argument
533 def addFtraceFilterFunctions(self, file): argument
534 for i in self.listFromFile(file):
537 self.tracefuncs[i] = dict()
538 def getFtraceFilterFunctions(self, current): argument
539 self.rootCheck(True)
541 call('cat '+self.tpath+'available_filter_functions', shell=True)
543 master = self.listFromFile(self.tpath+'available_filter_functions')
544 for i in sorted(self.tracefuncs):
545 if 'func' in self.tracefuncs[i]:
546 i = self.tracefuncs[i]['func']
550 print(self.colorText(i))
551 def setFtraceFilterFunctions(self, list): argument
552 master = self.listFromFile(self.tpath+'available_filter_functions')
561 fp = open(self.tpath+'set_graph_function', 'w')
564 def basicKprobe(self, name): argument
565 self.kprobes[name] = {'name': name,'func': name,'args': dict(),'format': name}
566 def defaultKprobe(self, name, kdata): argument
571 if self.archargs in k:
572 k['args'] = k[self.archargs]
576 self.kprobes[name] = k
577 def kprobeColor(self, name): argument
578 if name not in self.kprobes or 'color' not in self.kprobes[name]:
580 return self.kprobes[name]['color']
581 def kprobeDisplayName(self, name, dataraw): argument
582 if name not in self.kprobes:
583 self.basicKprobe(name)
594 fmt, args = self.kprobes[name]['format'], self.kprobes[name]['args']
609 def kprobeText(self, kname, kprobe): argument
618 if self.archargs in kprobe:
619 args = kprobe[self.archargs]
622 if re.findall('{(?P<n>[a-z,A-Z,0-9]*)}', func):
624 for arg in re.findall('{(?P<n>[a-z,A-Z,0-9]*)}', fmt):
632 def addKprobes(self, output=False): argument
633 if len(self.kprobes) < 1:
639 # sort kprobes: trace, ub-dev, custom, dev
641 linesout = len(self.kprobes)
642 for name in sorted(self.kprobes):
643 res = self.colorText('YES', 32)
644 if not self.testKprobe(name, self.kprobes[name]):
645 res = self.colorText('NO')
648 if name in self.tracefuncs:
650 elif name in self.dev_tracefuncs:
651 if 'ub' in self.dev_tracefuncs[name]:
662 self.kprobes.pop(name)
664 self.fsetVal('', 'kprobe_events')
667 kprobeevents += self.kprobeText(kp, self.kprobes[kp])
668 self.fsetVal(kprobeevents, 'kprobe_events')
670 check = self.fgetVal('kprobe_events')
671 linesack = (len(check.split('\n')) - 1) // 2
673 self.fsetVal('1', 'events/kprobes/enable')
674 def testKprobe(self, kname, kprobe): argument
675 self.fsetVal('0', 'events/kprobes/enable')
676 kprobeevents = self.kprobeText(kname, kprobe)
680 self.fsetVal(kprobeevents, 'kprobe_events')
681 check = self.fgetVal('kprobe_events')
689 def setVal(self, val, file): argument
700 def fsetVal(self, val, path): argument
701 return self.setVal(val, self.tpath+path)
702 def getVal(self, file): argument
713 def fgetVal(self, path): argument
714 return self.getVal(self.tpath+path)
715 def cleanupFtrace(self): argument
716 if(self.usecallgraph or self.usetraceevents or self.usedevsrc):
717 self.fsetVal('0', 'events/kprobes/enable')
718 self.fsetVal('', 'kprobe_events')
719 self.fsetVal('1024', 'buffer_size_kb')
720 def setupAllKprobes(self): argument
721 for name in self.tracefuncs:
722 self.defaultKprobe(name, self.tracefuncs[name])
723 for name in self.dev_tracefuncs:
724 self.defaultKprobe(name, self.dev_tracefuncs[name])
725 def isCallgraphFunc(self, name): argument
726 if len(self.tracefuncs) < 1 and self.suspendmode == 'command':
728 for i in self.tracefuncs:
729 if 'func' in self.tracefuncs[i]:
730 f = self.tracefuncs[i]['func']
736 def initFtrace(self, quiet=False): argument
741 self.fsetVal('0', 'tracing_on')
742 self.cleanupFtrace()
743 self.testVal(self.pmdpath, 'basic', '1')
745 self.fsetVal('global', 'trace_clock')
746 self.fsetVal('nop', 'current_tracer')
748 cpus = max(1, self.cpucount)
749 if self.bufsize > 0:
750 tgtsize = self.bufsize
751 elif self.usecallgraph or self.usedevsrc:
752 bmax = (1*1024*1024) if self.suspendmode in ['disk', 'command'] \
754 tgtsize = min(self.memfree, bmax)
757 while not self.fsetVal('%d' % (tgtsize // cpus), 'buffer_size_kb'):
759 tgtsize -= 65536
761 tgtsize = int(self.fgetVal('buffer_size_kb')) * cpus
763 self.vprint('Setting trace buffers to %d kB (%d kB per cpu)' % (tgtsize, tgtsize/cpus))
765 if(self.usecallgraph):
767 self.fsetVal('function_graph', 'current_tracer')
768 self.fsetVal('', 'set_ftrace_filter')
770 self.fsetVal('print-parent', 'trace_options')
771 self.fsetVal('funcgraph-abstime', 'trace_options')
772 self.fsetVal('funcgraph-cpu', 'trace_options')
773 self.fsetVal('funcgraph-duration', 'trace_options')
774 self.fsetVal('funcgraph-proc', 'trace_options')
775 self.fsetVal('funcgraph-tail', 'trace_options')
776 self.fsetVal('nofuncgraph-overhead', 'trace_options')
777 self.fsetVal('context-info', 'trace_options')
778 self.fsetVal('graph-time', 'trace_options')
779 self.fsetVal('%d' % self.max_graph_depth, 'max_graph_depth')
781 if(self.usetraceevents):
783 for fn in self.tracefuncs:
784 if 'func' in self.tracefuncs[fn]:
785 cf.append(self.tracefuncs[fn]['func'])
788 if self.ftop:
789 self.setFtraceFilterFunctions([self.ftopfunc])
791 self.setFtraceFilterFunctions(cf)
793 elif self.usekprobes:
794 for name in self.tracefuncs:
795 self.defaultKprobe(name, self.tracefuncs[name])
796 if self.usedevsrc:
797 for name in self.dev_tracefuncs:
798 self.defaultKprobe(name, self.dev_tracefuncs[name])
801 self.addKprobes(self.verbose)
802 if(self.usetraceevents):
804 events = iter(self.traceevents)
806 self.fsetVal('1', 'events/power/'+e+'/enable')
808 self.fsetVal('', 'trace')
809 def verifyFtrace(self): argument
814 tp = self.tpath
815 if(self.usecallgraph):
825 def verifyKprobes(self): argument
828 tp = self.tpath
833 def colorText(self, str, color=31): argument
834 if not self.ansi:
837 def writeDatafileHeader(self, filename, testdata): argument
838 fp = self.openlog(filename, 'w')
839 fp.write('%s\n%s\n# command | %s\n' % (self.teststamp, self.sysstamp, self.cmdline))
852 def sudoUserchown(self, dir): argument
853 if os.path.exists(dir) and self.sudouser:
854 cmd = 'chown -R {0}:{0} {1} > /dev/null 2>&1'
855 call(cmd.format(self.sudouser, dir), shell=True)
856 def outputResult(self, testdata, num=0): argument
857 if not self.result:
862 fp = open(self.result, 'a')
877 self.sudoUserchown(self.result)
878 def configFile(self, file): argument
887 def openlog(self, filename, mode): argument
888 isgz = self.gzip
899 def putlog(self, filename, text): argument
900 with self.openlog(filename, 'a') as fp:
903 def dlog(self, text): argument
904 self.putlog(self.dmesgfile, '# %s\n' % text)
905 def flog(self, text): argument
906 self.putlog(self.ftracefile, text)
907 def b64unzip(self, data): argument
913 def b64zip(self, data): argument
916 def platforminfo(self, cmdafter): argument
918 if not os.path.exists(self.ftracefile):
923 if self.suspendmode == 'command' and self.testcommand:
924 footer += '# platform-testcmd: %s\n' % (self.testcommand)
929 tf = self.openlog(self.ftracefile, 'r')
931 if tp.stampInfo(line, self):
948 dev = dirname.split('/')[-2]
950 props[dev].syspath = dirname[:-6]
994 footer += '# platform-devinfo: %s\n' % self.b64zip(out)
998 footer += '# platform-%s: %s | %s\n' % (name, cmdline, self.b64zip(info))
999 self.flog(footer)
1001 def commonPrefix(self, list): argument
1007 prefix = prefix[:len(prefix)-1]
1010 if '/' in prefix and prefix[-1] != '/':
1013 def dictify(self, text, format): argument
1030 def cmdinfo(self, begin, debug=False): argument
1033 self.cmd1 = dict()
1034 for cargs in self.infocmds:
1036 cmdline, cmdpath = ' '.join(cargs[2:]), self.getExec(cargs[2])
1039 self.dlog('[%s]' % cmdline)
1047 self.cmd1[name] = self.dictify(info, delta)
1048 elif not debug and delta and name in self.cmd1:
1049 before, after = self.cmd1[name], self.dictify(info, delta)
1051 prefix = self.commonPrefix(list(before.keys()))
1056 dinfo += '\t%s : %s -> %s\n' % \
1066 def testVal(self, file, fmt='basic', value=''): argument
1068 for f in self.cfgdef:
1071 fp.write(self.cfgdef[f])
1073 self.cfgdef = dict()
1079 self.cfgdef[file] = m.group('v')
1081 line = fp.read().strip().split('\n')[-1]
1082 m = re.match('.* (?P<v>[0-9A-Fx]*) .*', line)
1084 self.cfgdef[file] = m.group('v')
1086 self.cfgdef[file] = fp.read().strip()
1089 def haveTurbostat(self): argument
1090 if not self.tstat:
1092 cmd = self.getExec('turbostat')
1095 fp = Popen([cmd, '-v'], stdout=PIPE, stderr=PIPE).stderr
1099 self.vprint(out)
1102 def turbostat(self): argument
1103 cmd = self.getExec('turbostat')
1105 fullcmd = '%s -q -S echo freeze > %s' % (cmd, self.powerfile)
1106 fp = Popen(['sh', '-c', fullcmd], stdout=PIPE, stderr=PIPE).stderr
1119 self.vprint(errmsg)
1120 if not self.verbose:
1123 if self.verbose:
1131 def wifiDetails(self, dev): argument
1139 vals.append(prop.split('=')[-1])
1141 def checkWifi(self, dev=''): argument
1147 m = re.match(' *(?P<dev>.*): (?P<stat>[0-9a-f]*) .*', w.split('\n')[-1])
1152 def pollWifi(self, dev, timeout=60): argument
1154 while (time.time() - start) < timeout:
1155 w = self.checkWifi(dev)
1158 (self.wifiDetails(dev), max(0, time.time() - start))
1160 return '%s timeout %d' % (self.wifiDetails(dev), timeout)
1161 def errorSummary(self, errinfo, msg): argument
1166 if self.hostname not in entry['urls']:
1167 entry['urls'][self.hostname] = [self.htmlfile]
1168 elif self.htmlfile not in entry['urls'][self.hostname]:
1169 entry['urls'][self.hostname].append(self.htmlfile)
1176 if re.match('^[0-9,\-\.]*$', arr[j]):
1177 arr[j] = '[0-9,\-\.]*'
1189 'urls': {self.hostname: [self.htmlfile]}
1192 def multistat(self, start, idx, finish): argument
1193 if 'time' in self.multitest:
1194 id = '%d Duration=%dmin' % (idx+1, self.multitest['time'])
1196 id = '%d/%d' % (idx+1, self.multitest['count'])
1198 if 'start' not in self.multitest:
1199 self.multitest['start'] = self.multitest['last'] = t
1200 self.multitest['total'] = 0.0
1203 dt = t - self.multitest['last']
1205 if idx == 0 and self.multitest['delay'] > 0:
1206 self.multitest['total'] += self.multitest['delay']
1207 pprint('TEST (%s) COMPLETE -- Duration %.1fs' % (id, dt))
1209 self.multitest['total'] += dt
1210 self.multitest['last'] = t
1211 avg = self.multitest['total'] / idx
1212 if 'time' in self.multitest:
1213 left = finish - datetime.now()
1214 left -= timedelta(microseconds=left.microseconds)
1216 left = timedelta(seconds=((self.multitest['count'] - idx) * int(avg)))
1217 pprint('TEST (%s) START - Avg Duration %.1fs, Time left %s' % \
1219 def multiinit(self, c, d): argument
1222 sz, unit, c = 'time', c[-1], c[:-1]
1223 self.multitest['run'] = True
1224 self.multitest[sz] = getArgInt('multi: n d (exec count)', c, 1, 1000000, False)
1225 self.multitest['delay'] = getArgInt('multi: n d (delay between tests)', d, 0, 3600, False)
1227 self.multitest[sz] *= 1440
1229 self.multitest[sz] *= 60
1230 def displayControl(self, cmd): argument
1231 xset, ret = 'timeout 10 xset -d :0.0 {0}', 0
1232 if self.sudouser:
1233 xset = 'sudo -u %s %s' % (self.sudouser, xset)
1241 b4 = self.displayControl('stat')
1244 curr = self.displayControl('stat')
1245 self.vprint('Display Switched: %s -> %s' % (b4, curr))
1247 self.vprint('WARNING: Display failed to change to %s' % cmd)
1249 self.vprint('WARNING: Display failed to change to %s with xset' % cmd)
1262 def setRuntimeSuspend(self, before=True): argument
1265 if self.rs > 0:
1266 self.rstgt, self.rsval, self.rsdir = 'on', 'auto', 'enabled'
1268 self.rstgt, self.rsval, self.rsdir = 'auto', 'on', 'disabled'
1270 self.rslist = deviceInfo(self.rstgt)
1271 for i in self.rslist:
1272 self.setVal(self.rsval, i)
1273 pprint('runtime suspend %s on all devices (%d changed)' % (self.rsdir, len(self.rslist)))
1277 # runtime suspend re-enable or re-disable
1278 for i in self.rslist:
1279 self.setVal(self.rstgt, i)
1280 pprint('runtime suspend settings restored on %d devices' % len(self.rslist))
1297 def __init__(self): argument
1298 self.syspath = ''
1299 self.altname = ''
1300 self.isasync = True
1301 self.xtraclass = ''
1302 self.xtrainfo = ''
1303 def out(self, dev): argument
1304 return '%s,%s,%d;' % (dev, self.altname, self.isasync)
1305 def debug(self, dev): argument
1306 pprint('%s:\n\taltname = %s\n\t async = %s' % (dev, self.altname, self.isasync))
1307 def altName(self, dev): argument
1308 if not self.altname or self.altname == dev:
1310 return '%s [%s]' % (self.altname, dev)
1311 def xtraClass(self): argument
1312 if self.xtraclass:
1313 return ' '+self.xtraclass
1314 if not self.isasync:
1317 def xtraInfo(self): argument
1318 if self.xtraclass:
1319 return ' '+self.xtraclass
1320 if self.isasync:
1329 def __init__(self, nodename, nodedepth): argument
1330 self.name = nodename
1331 self.children = []
1332 self.depth = nodedepth
1340 # 10 sequential, non-overlapping phases of S/R
1381 'ACPI' : r'.*\bACPI *(?P<b>[A-Za-z]*) *Error[: ].*',
1383 'USBERR' : r'.*usb .*device .*, error [0-9-]*',
1384 'ATAERR' : r' *ata[0-9\.]*: .*failed.*',
1386 'TPMERR' : r'(?i) *tpm *tpm[0-9]*: .*error.*',
1388 def __init__(self, num): argument
1390 self.start = 0.0 # test start
1391 self.end = 0.0 # test end
1392 self.hwstart = 0 # rtc test start
1393 self.hwend = 0 # rtc test end
1394 self.tSuspended = 0.0 # low-level suspend start
1395 self.tResumed = 0.0 # low-level resume start
1396 self.tKernSus = 0.0 # kernel level suspend start
1397 self.tKernRes = 0.0 # kernel level resume end
1398 self.fwValid = False # is firmware data available
1399 self.fwSuspend = 0 # time spent in firmware suspend
1400 self.fwResume = 0 # time spent in firmware resume
1401 self.html_device_id = 0
1402 self.stamp = 0
1403 self.outfile = ''
1404 self.kerror = False
1405 self.wifi = dict()
1406 self.turbostat = 0
1407 self.enterfail = ''
1408 self.currphase = ''
1409 self.pstl = dict() # process timeline
1410 self.testnumber = num
1411 self.idstr = idchar[num]
1412 self.dmesgtext = [] # dmesg text file in memory
1413 self.dmesg = dict() # root data structure
1414 self.errorinfo = {'suspend':[],'resume':[]}
1415 self.tLow = [] # time spent in low-level suspends (standby/freeze)
1416 self.devpids = []
1417 self.devicegroups = 0
1418 def sortedPhases(self): argument
1419 return sorted(self.dmesg, key=lambda k:self.dmesg[k]['order'])
1420 def initDevicegroups(self): argument
1422 for phase in sorted(self.dmesg.keys()):
1426 self.dmesg[pnew] = self.dmesg.pop(phase)
1427 self.devicegroups = []
1428 for phase in self.sortedPhases():
1429 self.devicegroups.append([phase])
1430 def nextPhase(self, phase, offset): argument
1431 order = self.dmesg[phase]['order'] + offset
1432 for p in self.dmesg:
1433 if self.dmesg[p]['order'] == order:
1436 def lastPhase(self, depth=1): argument
1437 plist = self.sortedPhases()
1440 return plist[-1*depth]
1441 def turbostatInfo(self): argument
1444 for line in self.dmesgtext:
1450 out['syslpi'] = i.split('=')[-1]+'%'
1452 out['pkgpc10'] = i.split('=')[-1]+'%'
1455 def extractErrorInfo(self): argument
1456 lf = self.dmesgtext
1457 if len(self.dmesgtext) < 1 and sysvals.dmesgfile:
1466 m = re.match('[ \t]*(\[ *)(?P<ktime>[0-9\.]*)(\]) (?P<msg>.*)', line)
1470 if t < self.start or t > self.end:
1472 dir = 'suspend' if t < self.tSuspended else 'resume'
1476 for err in self.errlist:
1477 if re.match(self.errlist[err], msg):
1479 self.kerror = True
1484 self.errorinfo[dir].append((type, t, idx1, idx2))
1485 if self.kerror:
1487 if len(self.dmesgtext) < 1 and sysvals.dmesgfile:
1490 def setStart(self, time, msg=''): argument
1491 self.start = time
1494 self.hwstart = datetime.strptime(msg, sysvals.tmstart)
1496 self.hwstart = 0
1497 def setEnd(self, time, msg=''): argument
1498 self.end = time
1501 self.hwend = datetime.strptime(msg, sysvals.tmend)
1503 self.hwend = 0
1504 def isTraceEventOutsideDeviceCalls(self, pid, time): argument
1505 for phase in self.sortedPhases():
1506 list = self.dmesg[phase]['list']
1513 def sourcePhase(self, start): argument
1514 for phase in self.sortedPhases():
1517 pend = self.dmesg[phase]['end']
1521 def sourceDevice(self, phaselist, start, end, pid, type): argument
1524 list = self.dmesg[phase]['list']
1545 def addDeviceFunctionCall(self, displayname, kprobename, proc, pid, start, end, cdata, rdata): argument
1547 phases = self.sortedPhases()
1548 tgtdev = self.sourceDevice(phases, start, end, pid, 'device')
1551 if not tgtdev and pid in self.devpids:
1555 tgtdev = self.sourceDevice(phases, start, end, pid, 'thread')
1559 threadname = 'kthread-%d' % (pid)
1561 threadname = '%s-%d' % (proc, pid)
1562 tgtphase = self.sourcePhase(start)
1563 self.newAction(tgtphase, threadname, pid, '', start, end, '', ' kth', '')
1564 return self.addDeviceFunctionCall(displayname, kprobename, proc, pid, start, end, cdata, rdata)
1567 sysvals.vprint('[%f - %f] %s-%d %s %s %s' % \
1594 def overflowDevices(self): argument
1597 for phase in self.sortedPhases():
1598 list = self.dmesg[phase]['list']
1601 if dev['end'] > self.end:
1604 def mergeOverlapDevices(self, devlist): argument
1608 for phase in self.sortedPhases():
1609 list = self.dmesg[phase]['list']
1613 o = min(dev['end'], tdev['end']) - max(dev['start'], tdev['start'])
1621 def usurpTouchingThread(self, name, dev): argument
1623 for phase in self.sortedPhases():
1624 list = self.dmesg[phase]['list']
1627 if tdev['start'] - dev['end'] < 0.1:
1635 def stitchTouchingThreads(self, testlist): argument
1637 for phase in self.sortedPhases():
1638 list = self.dmesg[phase]['list']
1645 def optimizeDevSrc(self): argument
1647 for phase in self.sortedPhases():
1648 list = self.dmesg[phase]['list']
1660 p.length = p.end - p.time
1663 def trimTimeVal(self, t, t0, dT, left): argument
1666 if(t - dT < t0):
1668 return t - dT
1678 def trimTime(self, t0, dT, left): argument
1679 self.tSuspended = self.trimTimeVal(self.tSuspended, t0, dT, left)
1680 self.tResumed = self.trimTimeVal(self.tResumed, t0, dT, left)
1681 self.start = self.trimTimeVal(self.start, t0, dT, left)
1682 self.tKernSus = self.trimTimeVal(self.tKernSus, t0, dT, left)
1683 self.tKernRes = self.trimTimeVal(self.tKernRes, t0, dT, left)
1684 self.end = self.trimTimeVal(self.end, t0, dT, left)
1685 for phase in self.sortedPhases():
1686 p = self.dmesg[phase]
1687 p['start'] = self.trimTimeVal(p['start'], t0, dT, left)
1688 p['end'] = self.trimTimeVal(p['end'], t0, dT, left)
1692 d['start'] = self.trimTimeVal(d['start'], t0, dT, left)
1693 d['end'] = self.trimTimeVal(d['end'], t0, dT, left)
1694 d['length'] = d['end'] - d['start']
1697 cg.start = self.trimTimeVal(cg.start, t0, dT, left)
1698 cg.end = self.trimTimeVal(cg.end, t0, dT, left)
1700 line.time = self.trimTimeVal(line.time, t0, dT, left)
1703 e.time = self.trimTimeVal(e.time, t0, dT, left)
1704 e.end = self.trimTimeVal(e.end, t0, dT, left)
1705 e.length = e.end - e.time
1708 for e in self.errorinfo[dir]:
1710 tm = self.trimTimeVal(tm, t0, dT, left)
1712 self.errorinfo[dir] = list
1713 def trimFreezeTime(self, tZero): argument
1716 for phase in self.sortedPhases():
1718 tS, tR = self.dmesg[lp]['end'], self.dmesg[phase]['start']
1719 tL = tR - tS
1723 self.trimTime(tS, tL, left)
1724 if 'waking' in self.dmesg[lp]:
1725 tCnt = self.dmesg[lp]['waking'][0]
1726 if self.dmesg[lp]['waking'][1] >= 0.001:
1727 tTry = '-%.0f' % (round(self.dmesg[lp]['waking'][1] * 1000))
1729 tTry = '-%.3f' % (self.dmesg[lp]['waking'][1] * 1000)
1733 self.tLow.append(text)
1735 def getMemTime(self): argument
1736 if not self.hwstart or not self.hwend:
1738 stime = (self.tSuspended - self.start) * 1000000
1739 rtime = (self.end - self.tResumed) * 1000000
1740 hws = self.hwstart + timedelta(microseconds=stime)
1741 hwr = self.hwend - timedelta(microseconds=rtime)
1742 self.tLow.append('%.0f'%((hwr - hws).total_seconds() * 1000))
1743 def getTimeValues(self): argument
1744 sktime = (self.tSuspended - self.tKernSus) * 1000
1745 rktime = (self.tKernRes - self.tResumed) * 1000
1747 def setPhase(self, phase, ktime, isbegin, order=-1): argument
1750 if self.currphase:
1751 if 'resume_machine' not in self.currphase:
1752 sysvals.vprint('WARNING: phase %s failed to end' % self.currphase)
1753 self.dmesg[self.currphase]['end'] = ktime
1754 phases = self.dmesg.keys()
1755 color = self.phasedef[phase]['color']
1760 self.dmesg[phase] = {'list': dict(), 'start': -1.0, 'end': -1.0,
1762 self.dmesg[phase]['start'] = ktime
1763 self.currphase = phase
1766 if phase not in self.currphase:
1767 if self.currphase:
1768 sysvals.vprint('WARNING: %s ended instead of %s, ftrace corruption?' % (phase, self.currphase))
1772 phase = self.currphase
1773 self.dmesg[phase]['end'] = ktime
1774 self.currphase = ''
1776 def sortedDevices(self, phase): argument
1777 list = self.dmesg[phase]['list']
1779 def fixupInitcalls(self, phase): argument
1781 phaselist = self.dmesg[phase]['list']
1785 for p in self.sortedPhases():
1786 if self.dmesg[p]['end'] > dev['start']:
1787 dev['end'] = self.dmesg[p]['end']
1790 def deviceFilter(self, devicefilter): argument
1791 for phase in self.sortedPhases():
1792 list = self.dmesg[phase]['list']
1804 def fixupInitcallsThatDidntReturn(self): argument
1806 for phase in self.sortedPhases():
1807 self.fixupInitcalls(phase)
1808 def phaseOverlap(self, phases): argument
1811 for group in self.devicegroups:
1821 self.devicegroups.remove(group)
1822 self.devicegroups.append(newgroup)
1823 def newActionGlobal(self, name, start, end, pid=-1, color=''): argument
1825 phases = self.sortedPhases()
1831 pstart = self.dmesg[phase]['start']
1832 pend = self.dmesg[phase]['end']
1834 o = max(0, min(end, pend) - max(start, pstart))
1845 p0start = self.dmesg[phases[0]]['start']
1849 targetphase = phases[-1]
1850 if pid == -2:
1852 elif pid == -3:
1856 self.phaseOverlap(myphases)
1858 newname = self.newAction(targetphase, name, pid, '', start, end, '', htmlclass, color)
1861 def newAction(self, phase, name, pid, parent, start, end, drv, htmlclass='', color=''): argument
1863 self.html_device_id += 1
1864 devid = '%s%d' % (self.idstr, self.html_device_id)
1865 list = self.dmesg[phase]['list']
1866 length = -1.0
1868 length = end - start
1869 if pid == -2 or name not in sysvals.tracefuncs.keys():
1882 def findDevice(self, phase, name): argument
1883 list = self.dmesg[phase]['list']
1886 if name == devname or re.match('^%s\[(?P<num>[0-9]*)\]$' % name, devname):
1891 def deviceChildren(self, devname, phase): argument
1893 list = self.dmesg[phase]['list']
1898 def maxDeviceNameSize(self, phase): argument
1900 for name in self.dmesg[phase]['list']:
1904 def printDetails(self): argument
1906 sysvals.vprint(' test start: %f' % self.start)
1907 sysvals.vprint('kernel suspend start: %f' % self.tKernSus)
1909 for phase in self.sortedPhases():
1910 devlist = self.dmesg[phase]['list']
1911 dc, ps, pe = len(devlist), self.dmesg[phase]['start'], self.dmesg[phase]['end']
1912 if not tS and ps >= self.tSuspended:
1913 sysvals.vprint(' machine suspended: %f' % self.tSuspended)
1915 if not tR and ps >= self.tResumed:
1916 sysvals.vprint(' machine resumed: %f' % self.tResumed)
1918 sysvals.vprint('%20s: %f - %f (%d devices)' % (phase, ps, pe, dc))
1920 sysvals.vprint(''.join('-' for i in range(80)))
1921 maxname = '%d' % self.maxDeviceNameSize(phase)
1922 fmt = '%3d) %'+maxname+'s - %f - %f'
1929 sysvals.vprint(''.join('-' for i in range(80)))
1930 sysvals.vprint(' kernel resume end: %f' % self.tKernRes)
1931 sysvals.vprint(' test end: %f' % self.end)
1932 def deviceChildrenAllPhases(self, devname): argument
1934 for phase in self.sortedPhases():
1935 list = self.deviceChildren(devname, phase)
1940 def masterTopology(self, name, list, depth): argument
1946 clist = self.deviceChildrenAllPhases(cname)
1947 cnode = self.masterTopology(cname, clist, depth+1)
1950 def printTopology(self, node): argument
1955 for phase in self.sortedPhases():
1956 list = self.dmesg[phase]['list']
1962 info += ('<li>%s: %.3fms</li>' % (phase, (e-s)*1000))
1970 html += self.printTopology(cnode)
1973 def rootDeviceList(self): argument
1976 for phase in self.sortedPhases():
1977 list = self.dmesg[phase]['list']
1981 # list of top-most root devices
1983 for phase in self.sortedPhases():
1984 list = self.dmesg[phase]['list']
1988 if(pid < 0 or re.match('[0-9]*-[0-9]*\.[0-9]*[\.0-9]*\:[\.0-9]*$', pdev)):
1993 def deviceTopology(self): argument
1994 rootlist = self.rootDeviceList()
1995 master = self.masterTopology('', rootlist, 0)
1996 return self.printTopology(master)
1997 def selectTimelineDevices(self, widfmt, tTotal, mindevlen): argument
1999 self.tdevlist = dict()
2000 for phase in self.dmesg:
2002 list = self.dmesg[phase]['list']
2004 length = (list[dev]['end'] - list[dev]['start']) * 1000
2005 width = widfmt % (((list[dev]['end']-list[dev]['start'])*100)/tTotal)
2008 self.tdevlist[phase] = devlist
2009 def addHorizontalDivider(self, devname, devend): argument
2011 self.newAction(phase, devname, -2, '', \
2012 self.start, devend, '', ' sec', '')
2013 if phase not in self.tdevlist:
2014 self.tdevlist[phase] = []
2015 self.tdevlist[phase].append(devname)
2016 d = DevItem(0, phase, self.dmesg[phase]['list'][devname])
2018 def addProcessUsageEvent(self, name, times): argument
2022 start = -1
2023 end = -1
2028 if name in self.pstl[t]:
2029 if start == -1 or tlast < start:
2031 if end == -1 or t > end:
2034 if start == -1 or end == -1:
2037 out = self.newActionGlobal(name, start, end, -3)
2041 dev = self.dmesg[phase]['list'][devname]
2050 list = self.pstl[t]
2063 def createProcessUsageEvents(self): argument
2066 for t in sorted(self.pstl):
2067 pslist = self.pstl[t]
2074 for t in sorted(self.pstl):
2075 if t < self.tSuspended:
2083 c = self.addProcessUsageEvent(ps, tsus)
2086 c = self.addProcessUsageEvent(ps, tres)
2089 def handleEndMarker(self, time, msg=''): argument
2090 dm = self.dmesg
2091 self.setEnd(time, msg)
2092 self.initDevicegroups()
2098 np = self.nextPhase('resume_machine', 1)
2102 if self.tKernRes == 0.0:
2103 self.tKernRes = time
2105 if self.tKernSus == 0.0:
2106 self.tKernSus = time
2110 def debugPrint(self): argument
2111 for p in self.sortedPhases():
2112 list = self.dmesg[p]['list']
2122 def __init__(self, name, args, caller, ret, start, end, u, proc, pid, color): argument
2123 self.row = 0
2124 self.count = 1
2125 self.name = name
2126 self.args = args
2127 self.caller = caller
2128 self.ret = ret
2129 self.time = start
2130 self.length = end - start
2131 self.end = end
2132 self.ubiquitous = u
2133 self.proc = proc
2134 self.pid = pid
2135 self.color = color
2136 def title(self): argument
2138 if self.count > 1:
2139 cnt = '(x%d)' % self.count
2140 l = '%0.3fms' % (self.length * 1000)
2141 if self.ubiquitous:
2142 title = '%s(%s)%s <- %s, %s(%s)' % \
2143 (self.name, self.args, cnt, self.caller, self.ret, l)
2145 title = '%s(%s) %s%s(%s)' % (self.name, self.args, self.ret, cnt, l)
2147 def text(self): argument
2148 if self.count > 1:
2149 text = '%s(x%d)' % (self.name, self.count)
2151 text = self.name
2153 def repeat(self, tgt): argument
2155 dt = self.time - tgt.end
2156 # only combine calls if -all- attributes are identical
2157 if tgt.caller == self.caller and \
2158 tgt.name == self.name and tgt.args == self.args and \
2159 tgt.proc == self.proc and tgt.pid == self.pid and \
2160 tgt.ret == self.ret and dt >= 0 and \
2162 self.length < sysvals.callloopmaxlen:
2178 def __init__(self, t, m='', d=''): argument
2179 self.length = 0.0
2180 self.fcall = False
2181 self.freturn = False
2182 self.fevent = False
2183 self.fkprobe = False
2184 self.depth = 0
2185 self.name = ''
2186 self.type = ''
2187 self.time = float(t)
2202 self.name = emm.group('msg')
2203 self.type = emm.group('call')
2205 self.name = msg
2206 km = re.match('^(?P<n>.*)_cal$', self.type)
2208 self.fcall = True
2209 self.fkprobe = True
2210 self.type = km.group('n')
2212 km = re.match('^(?P<n>.*)_ret$', self.type)
2214 self.freturn = True
2215 self.fkprobe = True
2216 self.type = km.group('n')
2218 self.fevent = True
2222 self.length = float(d)/1000000
2227 self.depth = self.getDepth(match.group('d'))
2231 self.freturn = True
2236 self.name = match.group('n').strip()
2239 self.fcall = True
2241 if(m[-1] == '{'):
2244 self.name = match.group('n').strip()
2246 elif(m[-1] == ';'):
2247 self.freturn = True
2250 self.name = match.group('n').strip()
2253 self.name = m
2254 def isCall(self): argument
2255 return self.fcall and not self.freturn
2256 def isReturn(self): argument
2257 return self.freturn and not self.fcall
2258 def isLeaf(self): argument
2259 return self.fcall and self.freturn
2260 def getDepth(self, str): argument
2262 def debugPrint(self, info=''): argument
2263 if self.isLeaf():
2264 pprint(' -- %12.6f (depth=%02d): %s(); (%.3f us) %s' % (self.time, \
2265 self.depth, self.name, self.length*1000000, info))
2266 elif self.freturn:
2267 pprint(' -- %12.6f (depth=%02d): %s} (%.3f us) %s' % (self.time, \
2268 self.depth, self.name, self.length*1000000, info))
2270 pprint(' -- %12.6f (depth=%02d): %s() { (%.3f us) %s' % (self.time, \
2271 self.depth, self.name, self.length*1000000, info))
2272 def startMarker(self): argument
2274 if not self.fevent:
2277 if(self.name.startswith('SUSPEND START')):
2281 if(self.type == 'suspend_resume' and
2282 re.match('suspend_enter\[.*\] begin', self.name)):
2285 def endMarker(self): argument
2287 if not self.fevent:
2290 if(self.name.startswith('RESUME COMPLETE')):
2294 if(self.type == 'suspend_resume' and
2295 re.match('thaw_processes\[.*\] end', self.name)):
2307 def __init__(self, pid, sv): argument
2308 self.id = ''
2309 self.invalid = False
2310 self.name = ''
2311 self.partial = False
2312 self.ignore = False
2313 self.start = -1.0
2314 self.end = -1.0
2315 self.list = []
2316 self.depth = 0
2317 self.pid = pid
2318 self.sv = sv
2319 def addLine(self, line): argument
2321 if(self.invalid):
2326 if(self.depth < 0):
2327 self.invalidate(line)
2330 if self.ignore:
2331 if line.depth > self.depth:
2334 self.list[-1].freturn = True
2335 self.list[-1].length = line.time - self.list[-1].time
2336 self.ignore = False
2337 # if this is a return at self.depth, no more work is needed
2338 if line.depth == self.depth and line.isReturn():
2340 self.end = line.time
2343 # compare current depth with this lines pre-call depth
2349 if len(self.list) > 0:
2350 last = self.list[-1]
2355 mismatch = prelinedep - self.depth
2356 warning = self.sv.verbose and abs(mismatch) > 1
2361 while prelinedep < self.depth:
2362 self.depth -= 1
2365 last.depth = self.depth
2367 last.length = line.time - last.time
2372 vline.depth = self.depth
2373 vline.name = self.vfname
2375 self.list.append(vline)
2389 while prelinedep > self.depth:
2393 prelinedep -= 1
2398 vline.depth = self.depth
2399 vline.name = self.vfname
2401 self.list.append(vline)
2402 self.depth += 1
2404 self.start = vline.time
2418 md = self.sv.max_graph_depth
2421 if (md and self.depth >= md - 1) or (line.name in self.sv.cgblacklist):
2422 self.ignore = True
2424 self.depth += 1
2426 self.depth -= 1
2430 (line.name in self.sv.cgblacklist):
2431 while len(self.list) > 0 and self.list[-1].depth > line.depth:
2432 self.list.pop(-1)
2433 if len(self.list) == 0:
2434 self.invalid = True
2436 self.list[-1].freturn = True
2437 self.list[-1].length = line.time - self.list[-1].time
2438 self.list[-1].name = line.name
2440 if len(self.list) < 1:
2441 self.start = line.time
2444 if mismatch < 0 and self.list[-1].depth == 0 and self.list[-1].freturn:
2445 line = self.list[-1]
2447 res = -1
2449 self.list.append(line)
2451 if(self.start < 0):
2452 self.start = line.time
2453 self.end = line.time
2455 self.end += line.length
2456 if self.list[0].name == self.vfname:
2457 self.invalid = True
2458 if res == -1:
2459 self.partial = True
2462 def invalidate(self, line): argument
2463 if(len(self.list) > 0):
2464 first = self.list[0]
2465 self.list = []
2466 self.list.append(first)
2467 self.invalid = True
2468 id = 'task %s' % (self.pid)
2469 window = '(%f - %f)' % (self.start, line.time)
2470 if(self.depth < 0):
2476 def slice(self, dev): argument
2477 minicg = FTraceCallGraph(dev['pid'], self.sv)
2478 minicg.name = self.name
2479 mydepth = -1
2481 for l in self.list:
2491 l.depth -= mydepth
2496 def repair(self, enddepth): argument
2499 last = self.list[-1]
2504 fixed = self.addLine(t)
2506 self.end = last.time
2509 def postProcess(self): argument
2510 if len(self.list) > 0:
2511 self.name = self.list[0].name
2515 for l in self.list:
2519 if last.length > l.time - last.time:
2520 last.length = l.time - last.time
2526 if self.sv.verbose:
2532 cl.length = l.time - cl.time
2533 if cl.name == self.vfname:
2537 cnt -= 1
2543 if self.sv.verbose:
2547 return self.repair(cnt)
2548 def deviceMatch(self, pid, data): argument
2555 if(self.name in borderphase):
2556 p = borderphase[self.name]
2561 self.start <= dev['start'] and
2562 self.end >= dev['end']):
2563 cg = self.slice(dev)
2569 if(data.dmesg[p]['start'] <= self.start and
2570 self.start <= data.dmesg[p]['end']):
2575 self.start <= dev['start'] and
2576 self.end >= dev['end']):
2577 dev['ftrace'] = self
2582 def newActionFromFunction(self, data): argument
2583 name = self.name
2586 fs = self.start
2587 fe = self.end
2592 if(data.dmesg[p]['start'] <= self.start and
2593 self.start < data.dmesg[p]['end']):
2598 out = data.newActionGlobal(name, fs, fe, -2)
2601 data.dmesg[phase]['list'][myname]['ftrace'] = self
2602 def debugPrint(self, info=''): argument
2603 pprint('%s pid=%d [%f - %f] %.3f us' % \
2604 (self.name, self.pid, self.start, self.end,
2605 (self.end - self.start)*1000000))
2606 for l in self.list:
2619 def __init__(self, test, phase, dev): argument
2620 self.test = test
2621 self.phase = phase
2622 self.dev = dev
2623 def isa(self, cls): argument
2624 if 'htmlclass' in self.dev and cls in self.dev['htmlclass']:
2638 def __init__(self, rowheight, scaleheight): argument
2639 self.html = ''
2640 self.height = 0 # total timeline height
2641 self.scaleH = scaleheight # timescale (top) row height
2642 self.rowH = rowheight # device row height
2643 self.bodyH = 0 # body height
2644 self.rows = 0 # total timeline rows
2645 self.rowlines = dict()
2646 self.rowheight = dict()
2647 def createHeader(self, sv, stamp): argument
2650 self.html += '<div class="version"><a href="https://01.org/pm-graph">%s v%s</a></div>' \
2653 self.html += '<button id="showtest" class="logbtn btnfmt">log</button>'
2655 self.html += '<button id="showdmesg" class="logbtn btnfmt">dmesg</button>'
2657 self.html += '<button id="showftrace" class="logbtn btnfmt">ftrace</button>'
2659 self.html += headline_stamp.format(stamp['host'], stamp['kernel'],
2664 self.html += headline_sysinfo.format(stamp['man'], stamp['plat'], stamp['cpu'])
2673 def getDeviceRows(self, rawlist): argument
2677 item.row = -1
2703 remaining -= 1
2714 def getPhaseRows(self, devlist, row=0, sortby='length'): argument
2720 # initialize all device rows to -1 and calculate devrows
2726 dev['row'] = -1
2729 sortdict[item] = (-1*float(dev['start']), float(dev['end']) - float(dev['start']))
2732 sortdict[item] = (float(dev['end']) - float(dev['start']), item.dev['name'])
2734 dev['devrows'] = self.getDeviceRows(dev['src'])
2739 if item.dev['pid'] == -2:
2765 remaining -= 1
2769 if t not in self.rowlines or t not in self.rowheight:
2770 self.rowlines[t] = dict()
2771 self.rowheight[t] = dict()
2772 if p not in self.rowlines[t] or p not in self.rowheight[t]:
2773 self.rowlines[t][p] = dict()
2774 self.rowheight[t][p] = dict()
2775 rh = self.rowH
2781 self.rowlines[t][p][row] = rowheight
2782 self.rowheight[t][p][row] = rowheight * rh
2784 if(row > self.rows):
2785 self.rows = int(row)
2787 def phaseRowHeight(self, test, phase, row): argument
2788 return self.rowheight[test][phase][row]
2789 def phaseRowTop(self, test, phase, row): argument
2791 for i in sorted(self.rowheight[test][phase]):
2794 top += self.rowheight[test][phase][i]
2796 def calcTotalRows(self): argument
2800 for t in self.rowlines:
2801 for p in self.rowlines[t]:
2803 for i in sorted(self.rowlines[t][p]):
2804 total += self.rowlines[t][p][i]
2807 if total == len(self.rowlines[t][p]):
2809 self.height = self.scaleH + (maxrows*self.rowH)
2810 self.bodyH = self.height - self.scaleH
2813 for i in sorted(self.rowheight[t][p]):
2814 self.rowheight[t][p][i] = float(self.bodyH)/len(self.rowlines[t][p])
2815 def createZoomBox(self, mode='command', testcount=1): argument
2817 …html_zoombox = '<center><button id="zoomin">ZOOM IN +</button><button id="zoomout">ZOOM OUT -</but…
2823 self.html += html_devlist2
2824 self.html += html_devlist1.format('1')
2826 self.html += html_devlist1.format('')
2827 self.html += html_zoombox
2828 self.html += html_timeline.format('dmesg', self.height)
2839 def createTimeScale(self, m0, mMax, tTotal, mode): argument
2841 rline = '<div class="t" style="left:0;border-left:1px solid black;border-right:0;">{0}</div>\n'
2844 mTotal = mMax - m0
2851 divEdge = (mTotal - tS*(divTotal-1))*100/mTotal
2855 pos = '%0.3f' % (100 - ((float(i)*tS*100)/mTotal) - divEdge)
2856 val = '%0.fms' % (float(i-divTotal+1)*tS*1000)
2857 if(i == divTotal - 1):
2861 pos = '%0.3f' % (100 - ((float(i)*tS*100)/mTotal))
2867 self.html += output+'</div>\n'
2871 # A list of values describing the properties of these test runs
2873 stampfmt = '# [a-z]*-(?P<m>[0-9]{2})(?P<d>[0-9]{2})(?P<y>[0-9]{2})-'+\
2874 '(?P<H>[0-9]{2})(?P<M>[0-9]{2})(?P<S>[0-9]{2})'+\
2876 wififmt = '^# wifi *(?P<d>\S*) *(?P<s>\S*) *(?P<t>[0-9\.]+).*'
2883 pinfofmt = '# platform-(?P<val>[a-z,A-Z,0-9]*): (?P<info>.*)'
2885 firmwarefmt = '# fwsuspend (?P<s>[0-9]*) fwresume (?P<r>[0-9]*)$'
2886 procexecfmt = 'ps - (?P<ps>.*)$'
2888 '^ *(?P<time>[0-9\.]*) *\| *(?P<cpu>[0-9]*)\)'+\
2889 ' *(?P<proc>.*)-(?P<pid>[0-9]*) *\|'+\
2890 '[ +!#\*@$]*(?P<dur>[0-9\.]*) .*\| (?P<msg>.*)'
2892 ' *(?P<proc>.*)-(?P<pid>[0-9]*) *\[(?P<cpu>[0-9]*)\] *'+\
2893 '(?P<flags>\S*) *(?P<time>[0-9\.]*): *'+\
2896 def __init__(self): argument
2897 self.stamp = ''
2898 self.sysinfo = ''
2899 self.cmdline = ''
2900 self.testerror = []
2901 self.turbostat = []
2902 self.wifi = []
2903 self.fwdata = []
2904 self.ftrace_line_fmt = self.ftrace_line_fmt_nop
2905 self.cgformat = False
2906 self.data = 0
2907 self.ktemp = dict()
2908 def setTracerType(self, tracer): argument
2910 self.cgformat = True
2911 self.ftrace_line_fmt = self.ftrace_line_fmt_fg
2913 self.ftrace_line_fmt = self.ftrace_line_fmt_nop
2916 def stampInfo(self, line, sv): argument
2917 if re.match(self.stampfmt, line):
2918 self.stamp = line
2920 elif re.match(self.sysinfofmt, line):
2921 self.sysinfo = line
2923 elif re.match(self.tstatfmt, line):
2924 self.turbostat.append(line)
2926 elif re.match(self.wififmt, line):
2927 self.wifi.append(line)
2929 elif re.match(self.testerrfmt, line):
2930 self.testerror.append(line)
2932 elif re.match(self.firmwarefmt, line):
2933 self.fwdata.append(line)
2935 elif(re.match(self.devpropfmt, line)):
2936 self.parseDevprops(line, sv)
2938 elif(re.match(self.pinfofmt, line)):
2939 self.parsePlatformInfo(line, sv)
2941 m = re.match(self.cmdlinefmt, line)
2943 self.cmdline = m.group('cmd')
2945 m = re.match(self.tracertypefmt, line)
2947 self.setTracerType(m.group('t'))
2950 def parseStamp(self, data, sv): argument
2952 m = re.match(self.stampfmt, self.stamp)
2953 if not self.stamp or not m:
2963 if re.match(self.sysinfofmt, self.sysinfo):
2964 for f in self.sysinfo.split('|'):
2974 self.machinesuspend = 'timekeeping_freeze\[.*'
2976 self.machinesuspend = 'machine_suspend\[.*'
2987 sv.cmdline = self.cmdline
2991 if sv.suspendmode == 'mem' and len(self.fwdata) > data.testnumber:
2992 m = re.match(self.firmwarefmt, self.fwdata[data.testnumber])
2998 if len(self.turbostat) > data.testnumber:
2999 m = re.match(self.tstatfmt, self.turbostat[data.testnumber])
3003 if len(self.wifi) > data.testnumber:
3004 m = re.match(self.wififmt, self.wifi[data.testnumber])
3010 if len(self.testerror) > data.testnumber:
3011 m = re.match(self.testerrfmt, self.testerror[data.testnumber])
3014 def devprops(self, data): argument
3029 def parseDevprops(self, line, sv): argument
3033 props = self.devprops(line[idx:])
3037 def parsePlatformInfo(self, line, sv): argument
3038 m = re.match(self.pinfofmt, line)
3043 sv.devprops = self.devprops(sv.b64unzip(info))
3060 def __init__(self, dataobj): argument
3061 self.data = dataobj
3062 self.ftemp = dict()
3063 self.ttemp = dict()
3066 def __init__(self): argument
3067 self.proclist = dict()
3068 self.running = False
3069 def procstat(self): argument
3070 c = ['cat /proc/[1-9]*/stat 2>/dev/null']
3080 if pid not in self.proclist:
3081 self.proclist[pid] = {'name' : name, 'user' : user, 'kern' : kern}
3083 val = self.proclist[pid]
3084 ujiff = user - val['user']
3085 kjiff = kern - val['kern']
3094 val = self.proclist[pid]
3097 out += '%s-%s %d' % (val['name'], pid, jiffies)
3098 return 'ps - '+out
3099 def processMonitor(self, tid): argument
3100 while self.running:
3101 out = self.procstat()
3104 def start(self): argument
3105 self.thread = Thread(target=self.processMonitor, args=(0,))
3106 self.running = True
3107 self.thread.start()
3108 def stop(self): argument
3109 self.running = False
3111 # ----------------- FUNCTIONS --------------------
3216 cg = testrun[testidx].ftemp[pid][-1]
3220 if(res == -1):
3221 testrun[testidx].ftemp[pid][-1].addLine(t)
3228 if len(cg.list) < 1 or cg.invalid or (cg.end - cg.start == 0):
3330 name = val[0].replace('--', '-')
3344 testrun.ttemp['thaw_processes'][-1]['end'] = t.time
3365 # -- phase changes --
3405 t.time - data.dmesg[lp]['start']
3453 testrun.ttemp[name][-1]['end'] = t.time
3454 testrun.ttemp[name][-1]['loop'] += 1
3467 testrun.ttemp[name][-1]['end'] = t.time
3480 data.newAction(phase, n, pid, p, t.time, -1, drv)
3493 dev['length'] = t.time - dev['start']
3511 'end': -1,
3542 cg = testrun.ftemp[key][-1]
3546 if(res == -1):
3547 testrun.ftemp[key][-1].addLine(t)
3585 if i < len(testruns) - 1:
3595 if event['end'] - event['begin'] <= 0:
3610 if ke - kb < 0.000001 or tlb > kb or tle <= kb:
3622 if ke - kb < 0.000001 or tlb > kb or tle <= kb:
3632 if len(cg.list) < 1 or cg.invalid or (cg.end - cg.start == 0):
3654 …sysvals.vprint('Callgraph found for task %d: %.3fms, %s' % (cg.pid, (cg.end - cg.start)*1000, name…
3702 for i in range(tc - 1):
3724 tp.stamp = datetime.now().strftime('# suspend-%m%d%y-%H%M%S localhost mem unknown')
3735 m = re.match('[ \t]*(\[ *)(?P<ktime>[0-9\.]*)(\]) (?P<msg>.*)', line)
3746 m = re.match('.* *(?P<k>[0-9]\.[0-9]{2}\.[0-9]-.*) .*', msg)
3765 mc = re.match('.*(\[ *)(?P<t>[0-9\.]*)(\]) calling '+\
3767 mr = re.match('.*(\[ *)(?P<t>[0-9\.]*)(\]) call '+\
3800 'suspend': ['PM: Entering [a-z]* sleep.*', 'Suspending console.*'],
3804 'resume_machine': ['ACPI: Low-level resume complete.*'],
3834 'emsg': 'PM: Entering (?P<mode>[a-z,A-Z]*) sleep.*' },
3840 'emsg': 'Disabling non-boot CPUs .*' },
3843 t0 = -1.0
3844 cpu_start = -1.0
3845 prevktime = -1.0
3849 m = re.match('[ \t]*(\[ *)(?P<ktime>[0-9\.]*)(\]) (?P<msg>.*)', line)
3945 # -- device callbacks --
3955 data.newAction(phase, f, int(n), p, ktime, -1, '')
3979 actions[a][-1]['end'] = ktime
3981 if(re.match('Disabling non-boot CPUs .*', msg)):
3984 elif(re.match('Enabling non-boot CPUs .*', msg)):
3987 elif(re.match('smpboot: CPU (?P<cpu>[0-9]*) is now offline', msg)):
3989 m = re.match('smpboot: CPU (?P<cpu>[0-9]*) is now offline', msg)
3995 elif(re.match('CPU(?P<cpu>[0-9]*) is up', msg)):
3997 m = re.match('CPU(?P<cpu>[0-9]*) is up', msg)
4049 cglen = (cg.end - cg.start) * 1000
4110 tdcenter = 'text-align:center;' if center else ''
4112 <meta http-equiv="content-type" content="text/html; charset=UTF-8">\n\
4115 ….stamp {width: 100%;text-align:center;background:#888;line-height:30px;color:white;font: 25px Aria…
4116 table {width:100%;border-collapse: collapse;border:1px solid;}\n\
4120 tr.alt {background-color:#ddd;}\n\
4122 .minval {background-color:#BBFFBB;}\n\
4123 .medval {background-color:#BBBBFF;}\n\
4124 .maxval {background-color:#FFBBBB;}\n\
4125 .head a {color:#000;text-decoration: none;}\n\
4136 html = summaryCSS('Summary - SleepGraph')
4173 idx = len(list[mode]['data']) - 1
4258 iMin = iMed = iMax = [-1, -1, -1]
4261 # row classes - alternate row color
4305 html = summaryCSS('Device Summary - SleepGraph', False)
4351 # row classes - alternate row color
4372 html = summaryCSS('Issues Summary - SleepGraph', False)
4395 # row classes - alternate row color
4442 data.trimFreezeTime(testruns[-1].tSuspended)
4448 …lass="traceevent{6}" style="left:{1}%;top:{2}px;height:{3}px;width:{4}%;line-height:{3}px;{7}">{5}…
4456 …'<td class="gray" title="time spent in low-power mode with clock running">'+sysvals.suspendmode+' …
4481 tTotal = data.end - data.start
4505 rtot += data.end - data.tKernRes + (data.wifi['time'] * 1000.0)
4537 wtime = '%.0f ms'%(data.end - data.tKernRes + (data.wifi['time'] * 1000.0))
4548 tMax = testruns[-1].end
4549 tTotal = tMax - t0
4582 d = testruns[0].addHorizontalDivider(msg, testruns[-1].end)
4586 d = testruns[0].addHorizontalDivider('asynchronous kernel threads', testruns[-1].end)
4608 left = '%f' % (((m0-t0)*100.0)/tTotal)
4615 left = '%f' % ((((m0-t0)*100.0)+sysvals.srgap/2)/tTotal)
4616 mTotal = mMax - m0
4620 width = '%f' % (((mTotal*100.0)-sysvals.srgap/2)/tTotal)
4625 length = phase['end']-phase['start']
4626 left = '%f' % (((phase['start']-m0)*100.0)/mTotal)
4635 right = '%f' % (((mMax-t)*100.0)/mTotal)
4659 left = '%f' % (((dev['start']-m0)*100)/mTotal)
4660 width = '%f' % (((dev['end']-dev['start'])*100)/mTotal)
4661 length = ' (%0.3f ms) ' % ((dev['end']-dev['start'])*1000)
4683 left = '%f' % (((start-m0)*100)/mTotal)
4684 width = '%f' % ((end-start)*100/mTotal)
4696 left = '%f' % (((e.time-m0)*100)/mTotal)
4713 phasedef = testruns[-1].phasedef
4736 pscolor = 'linear-gradient(to top left, #ccc, #eee)'
4741 length = phase['end']-phase['start']
4742 left = '%.3f' % (((phase['start']-t0)*100.0)/tTotal)
4757 data = testruns[-1]
4803 hoverZ = 'z-index:8;'
4817 <meta http-equiv="content-type" content="text/html; charset=UTF-8">\n\
4820 body {overflow-y:scroll;}\n\
4821 ….stamp {width:100%;text-align:center;background:gray;line-height:30px;color:white;font:25px Arial;…
4823 .callgraph {margin-top:30px;box-shadow:5px 5px 20px black;}\n\
4824 .callgraph article * {padding-left:28px;}\n\
4829 t3 {color:black;font:20px Times;white-space:nowrap;}\n\
4830 t4 {color:black;font:bold 30px Times;line-height:60px;white-space:nowrap;}\n\
4839 .time2 {font:15px Arial;border-bottom:1px solid;border-left:1px solid;border-right:1px solid;}\n\
4841 td {text-align:center;}\n\
4847 …-width="1" fill="white"/><rect x="4" y="8" width="10" height="2" style="fill:black;stroke-width:0"…
4848 …troke="black" stroke-width="1" fill="white"/><rect x="4" y="8" width="10" height="2" style="fill:b…
4849 .pf:'+cgchk+' ~ *:not(:nth-child(2)) {display:none;}\n\
4850 …oombox {position:relative;width:100%;overflow-x:scroll;-webkit-user-select:none;-moz-user-select:n…
4851 ….timeline {position:relative;font-size:14px;cursor:pointer;width:100%; overflow:hidden;background:…
4852 …bsolute;height:0%;overflow:hidden;z-index:7;line-height:30px;font-size:14px;border:1px solid;text-…
4853 .thread.ps {border-radius:3px;background:linear-gradient(to top, #ccc, #eee);}\n\
4855 ….thread.sec,.thread.sec:hover {background:black;border:0;color:white;line-height:15px;font-size:10…
4859 .jiffie {position:absolute;pointer-events: none;z-index:8;}\n\
4860 …font-size:10px;z-index:7;overflow:hidden;color:black;text-align:center;white-space:nowrap;border-r…
4861 .traceevent:hover {color:white;font-weight:bold;border:1px solid white;}\n\
4862 .phase {position:absolute;overflow:hidden;border:0px;text-align:center;}\n\
4863 ….phaselet {float:left;overflow:hidden;border:0px;text-align:center;min-height:100px;font-size:24px…
4864 ….t {position:absolute;line-height:'+('%d'%scaleTH)+'px;pointer-events:none;top:0;height:100%;borde…
4865 …err {position:absolute;top:0%;height:100%;border-right:3px solid red;color:red;font:bold 14px Time…
4866 .legend {position:relative; width:100%; height:40px; text-align:center;margin-bottom:20px}\n\
4867 …ion:absolute;cursor:pointer;top:10px; width:0px;height:20px;border:1px solid;padding-left:20px;}\n\
4868 button {height:40px;width:200px;margin-bottom:20px;margin-top:20px;font-size:24px;}\n\
4869 …ion:relative;float:right;height:25px;width:auto;margin-top:3px;margin-bottom:0;font-size:10px;text…
4871 a:link {color:white;text-decoration:none;}\n\
4875 ….version {position:relative;float:left;color:white;font-size:10px;line-height:30px;margin-left:10p…
4876 #devicedetail {min-height:100px;box-shadow:5px 5px 20px black;}\n\
4878 .tback {position:absolute;width:100%;background:linear-gradient(#ccc, #ddd);}\n\
4879 .bg {z-index:1;}\n\
4892 tMax = testruns[-1].end * 1000
4902 ' var resolution = -1;\n'\
4905 ' var rline = \'<div class="t" style="left:0;border-left:1px solid black;border-right:0;">\';\n'\
4906 ' var tTotal = tMax - t0;\n'\
4916 ' var divEdge = (mTotal - tS*(divTotal-1))*100/mTotal;\n'\
4922 ' pos = 100 - (((j)*tS*100)/mTotal) - divEdge;\n'\
4923 ' val = (j-divTotal+1)*tS;\n'\
4924 ' if(j == divTotal - 1)\n'\
4929 ' pos = 100 - (((j)*tS*100)/mTotal);\n'\
4954 ' zoombox.scrollLeft = ((left + sh) * newval / val) - sh;\n'\
4959 ' zoombox.scrollLeft = ((left + sh) * newval / val) - sh;\n'\
4967 ' var tTotal = tMax - t0;\n'\
4971 ' if(i >= tS.length) i = tS.length - 1;\n'\
4984 ' var cpu = -1;\n'\
4985 ' if(name.match("CPU_ON\[[0-9]*\]"))\n'\
4987 ' else if(name.match("CPU_OFF\[[0-9]*\]"))\n'\
5039 ' var cpu = -1;\n'\
5040 ' if(name.match("CPU_ON\[[0-9]*\]"))\n'\
5042 ' else if(name.match("CPU_OFF\[[0-9]*\]"))\n'\
5068 ' var pname = info[info.length-1];\n'\
5069 ' pd[pname] = parseFloat(info[info.length-3].slice(1));\n'\
5093 ' var time = "<t4 style=\\"font-size:"+fs+"px\\">"+pd[phases[i].id]+" ms<br></t4>";\n'\
5094 …' var pname = "<t3 style=\\"font-size:"+fs2+"px\\">"+phases[i].id.replace(new RegExp("_", "g")…
5122 ' var name = tmp[0], phase = tmp[tmp.length-1];\n'\
5142 ' var html = \'<div style="padding-top:\'+pad+\'px"><t3> <b>\'+name+\':</b>\';\n'\
5151 …' html += \'<table class=fstat style="padding-top:\'+(maxlen*5)+\'px;"><tr><th>Function</th>\';\…
5186 ' " ul {list-style-type:circle;padding-left:10px;margin-left:10px;}"+\n'\
5230 ' zoombox.scrollLeft = dragval[1] + dragval[0] - e.clientX;\n'\
5423 return os.readlink(file).split('/')[-1]
5457 '---------------------------------------------------------------------------------------------\n'\
5462 '---------------------------------------------------------------------------------------------\n'\
5464 '---------------------------------------------------------------------------------------------')
5475 dirname = dirname[:-6]
5476 device = dirname.split('/')[-1]
5496 lines[dirname] = '%-26s %-26s %1s %1s %1s %1s %1s %10s %10s' % \
5528 modes.append('mem-%s' % memmode)
5535 modes.append('disk-%s' % m.strip('[]'))
5552 'bios-vendor': (0, 4),
5553 'bios-version': (0, 5),
5554 'bios-release-date': (0, 8),
5555 'system-manufacturer': (1, 4),
5556 'system-product-name': (1, 5),
5557 'system-version': (1, 6),
5558 'system-serial-number': (1, 7),
5559 'baseboard-manufacturer': (2, 4),
5560 'baseboard-product-name': (2, 5),
5561 'baseboard-version': (2, 6),
5562 'baseboard-serial-number': (2, 7),
5563 'chassis-manufacturer': (3, 4),
5564 'chassis-type': (3, 5),
5565 'chassis-version': (3, 6),
5566 'chassis-serial-number': (3, 7),
5567 'processor-manufacturer': (4, 7),
5568 'processor-version': (4, 16),
5612 if buf[i:i+4] == b'_SM_' and i < memsize - 16:
5642 while(count < num and i <= len(buf) - 4):
5645 while n < len(buf) - 1:
5654 if idx > 0 and idx < len(data) - 1:
5655 s = data[idx-1].decode('utf-8')
5751 recdata = fp.read(rechead[1]-8)
5783 fwData[0] = record[1] - record[0]
5838 pprint(' please choose one with -m')
5930 doError(name+': non-integer value given', True)
5949 doError(name+': non-numerical value given', True)
5979 sysvals.vprint(' %-8s : %s' % (key.upper(), sysvals.stamp[key]))
5995 sysvals.vprint('[%s - %s]' % (info[0], info[1]))
6091 num = re.search(r'[-+]?\d*\.\d+|\d+', str)
6119 m = re.match('[a-z0-9]* failed in (?P<p>\S*).*', error)
6160 m = re.match('.*waking *(?P<n>[0-9]*) *times.*', low)
6178 m = re.match(' *<div id=\"[a,0-9]*\" *title=\"(?P<title>.*)\" class=\"thread.*', line)
6181 m = re.match('(?P<n>.*) \((?P<t>[0-9,\.]*) ms\) (?P<p>.*)', m.group('title'))
6186 name = ' '.join(name.split(' ')[:-1])
6228 for arg in ['-multi ', '-info ']:
6254 # create a summary of tests in a sub-directory
6284 pprint(' summary.html - tabular list of test data found')
6285 createHTMLDeviceSummary(testruns, os.path.join(outpath, 'summary-devices.html'), title)
6286 pprint(' summary-devices.html - kernel device list sorted by total execution time')
6287 createHTMLIssuesSummary(testruns, issues, os.path.join(outpath, 'summary-issues.html'), title)
6288 pprint(' summary-issues.html - kernel issues found sorted by frequency')
6298 doError('invalid boolean --> (%s: %s), use "true/false" or "1/0"' % (name, value), True)
6328 elif(option == 'override-timeline-functions'):
6330 elif(option == 'override-dev-timeline-functions'):
6339 sysvals.rs = -1
6343 doError('invalid value --> (%s: %s), use "enable/disable"' % (option, value), True)
6347 doError('invalid value --> (%s: %s), use %s' % (option, value, disopt), True)
6365 doError('invalid phase --> (%s: %s), valid phases are %s'\
6409 elif(option == 'callloop-maxgap'):
6410 sysvals.callloopmaxgap = getArgFloat('callloop-maxgap', value, 0.0, 1.0, False)
6411 elif(option == 'callloop-maxlen'):
6412 sysvals.callloopmaxgap = getArgFloat('callloop-maxlen', value, 0.0, 1.0, False)
6417 elif(option == 'output-dir'):
6425 doError('-dev is not compatible with -f')
6427 doError('-proc is not compatible with -f')
6458 if val[0] == '[' and val[-1] == ']':
6459 for prop in val[1:-1].split(','):
6478 for arg in re.findall('{(?P<n>[a-z,A-Z,0-9]*)}', format):
6516 ' Generates output files in subdirectory: suspend-yymmdd-HHMMSS\n'\
6522 ' -h Print this help text\n'\
6523 ' -v Print the current tool version\n'\
6524 ' -config fn Pull arguments and config options from file fn\n'\
6525 ' -verbose Print extra information during execution and analysis\n'\
6526 ' -m mode Mode to initiate for suspend (default: %s)\n'\
6527 ' -o name Overrides the output subdirectory name when running a new test\n'\
6528 ' default: suspend-{date}-{time}\n'\
6529 ' -rtcwake t Wakeup t seconds after suspend, set t to "off" to disable (default: 15)\n'\
6530 ' -addlogs Add the dmesg and ftrace logs to the html output\n'\
6531 ' -noturbostat Dont use turbostat in freeze mode (default: disabled)\n'\
6532 ' -srgap Add a visible gap in the timeline between sus/res (default: disabled)\n'\
6533 …' -skiphtml Run the test and capture the trace logs, but skip the timeline (default: disabled…
6534 ' -result fn Export a results table to a text file for parsing.\n'\
6535 ' -wifi If a wifi connection is available, check that it reconnects after resume.\n'\
6537 ' -sync Sync the filesystems before starting the test\n'\
6538 ' -rs on/off Enable/disable runtime suspend for all devices, restore all after test\n'\
6539 ' -display m Change the display mode to m for the test (on/off/standby/suspend)\n'\
6541 ' -gzip Gzip the trace and dmesg logs to save space\n'\
6542 ' -cmd {s} Run the timeline over a custom command, e.g. "sync -d"\n'\
6543 ' -proc Add usermode process info into the timeline (default: disabled)\n'\
6544 ' -dev Add kernel function calls and threads to the timeline (default: disabled)\n'\
6545 ' -x2 Run two suspend/resumes back to back (default: disabled)\n'\
6546 ' -x2delay t Include t ms delay between multiple test runs (default: 0 ms)\n'\
6547 ' -predelay t Include t ms delay before 1st suspend (default: 0 ms)\n'\
6548 ' -postdelay t Include t ms delay after last resume (default: 0 ms)\n'\
6549 ' -mindev ms Discard all device blocks shorter than ms milliseconds (e.g. 0.001 for us)\n'\
6550 ' -multi n d Execute <n> consecutive tests at <d> seconds intervals. If <n> is followed\n'\
6553 ' -maxfail n Abort a -multi run after n consecutive fails (default is 0 = never abort)\n'\
6555 ' -f Use ftrace to create device callgraphs (default: disabled)\n'\
6556 ' -ftop Use ftrace on the top level call: "%s" (default: disabled)\n'\
6557 ' -maxdepth N limit the callgraph data to N call levels (default: 0=all)\n'\
6558 ' -expandcg pre-expand the callgraph data in the html output (default: disabled)\n'\
6559 ' -fadd file Add functions to be graphed in the timeline from a list in a text file\n'\
6560 ' -filter "d1,d2,..." Filter out all but this comma-delimited list of device names\n'\
6561 ' -mincg ms Discard all callgraphs shorter than ms milliseconds (e.g. 0.001 for us)\n'\
6562 ' -cgphase P Only show callgraph data for phase P (e.g. suspend_late)\n'\
6563 ' -cgtest N Only show callgraph data for test N (e.g. 0 or 1 in an x2 run)\n'\
6564 ' -timeprec N Number of significant digits in timestamps (0:S, [3:ms], 6:us)\n'\
6565 ' -cgfilter S Filter the callgraph output in the timeline\n'\
6566 ' -cgskip file Callgraph functions to skip, off to disable (default: cgskip.txt)\n'\
6567 ' -bufsize N Set trace buffer size to N kilo-bytes (default: all of free memory)\n'\
6568 ' -devdump Print out all the raw device data for each phase\n'\
6569 ' -cgdump Print out all the raw callgraph data\n'\
6572 ' -modes List available suspend modes\n'\
6573 ' -status Test to see if the system is enabled to run this tool\n'\
6574 ' -fpdt Print out the contents of the ACPI Firmware Performance Data Table\n'\
6575 ' -wificheck Print out wifi connection info\n'\
6576 ' -x<mode> Test xset by toggling the given mode (on/off/standby/suspend)\n'\
6577 ' -sysinfo Print out system info extracted from BIOS\n'\
6578 ' -devinfo Print out the pm settings of all devices which support runtime suspend\n'\
6579 ' -cmdinfo Print out all the platform info collected before and after suspend/resume\n'\
6580 ' -flist Print the list of functions currently being captured in ftrace\n'\
6581 ' -flistall Print all functions capable of being captured in ftrace\n'\
6582 ' -summary dir Create a summary of tests in this dir [-genhtml builds missing html]\n'\
6584 ' -ftrace ftracefile Create HTML output using ftrace input (used with -dmesg)\n'\
6585 ' -dmesg dmesgfile Create HTML output using dmesg (used with -ftrace)\n'\
6589 # ----------------- MAIN --------------------
6594 simplecmds = ['-sysinfo', '-modes', '-fpdt', '-flist', '-flistall',
6595 '-devinfo', '-status', '-xon', '-xoff', '-xstandby', '-xsuspend',
6596 '-xinit', '-xreset', '-xstat', '-wificheck', '-cmdinfo']
6597 if '-f' in sys.argv:
6602 if(arg == '-m'):
6612 elif(arg == '-h'):
6615 elif(arg == '-v'):
6618 elif(arg == '-x2'):
6620 elif(arg == '-x2delay'):
6621 sysvals.x2delay = getArgInt('-x2delay', args, 0, 60000)
6622 elif(arg == '-predelay'):
6623 sysvals.predelay = getArgInt('-predelay', args, 0, 60000)
6624 elif(arg == '-postdelay'):
6625 sysvals.postdelay = getArgInt('-postdelay', args, 0, 60000)
6626 elif(arg == '-f'):
6628 elif(arg == '-ftop'):
6632 elif(arg == '-skiphtml'):
6634 elif(arg == '-cgdump'):
6636 elif(arg == '-devdump'):
6638 elif(arg == '-genhtml'):
6640 elif(arg == '-addlogs'):
6642 elif(arg == '-nologs'):
6644 elif(arg == '-addlogdmesg'):
6646 elif(arg == '-addlogftrace'):
6648 elif(arg == '-noturbostat'):
6650 elif(arg == '-verbose'):
6652 elif(arg == '-proc'):
6654 elif(arg == '-dev'):
6656 elif(arg == '-sync'):
6658 elif(arg == '-wifi'):
6660 elif(arg == '-gzip'):
6662 elif(arg == '-info'):
6666 doError('-info requires one string argument', True)
6667 elif(arg == '-desc'):
6671 doError('-desc requires one string argument', True)
6672 elif(arg == '-rs'):
6676 doError('-rs requires "enable" or "disable"', True)
6679 sysvals.rs = -1
6684 elif(arg == '-display'):
6688 doError('-display requires an mode value', True)
6693 elif(arg == '-maxdepth'):
6694 sysvals.max_graph_depth = getArgInt('-maxdepth', args, 0, 1000)
6695 elif(arg == '-rtcwake'):
6704 sysvals.rtcwaketime = getArgInt('-rtcwake', val, 0, 3600, False)
6705 elif(arg == '-timeprec'):
6706 sysvals.setPrecision(getArgInt('-timeprec', args, 0, 6))
6707 elif(arg == '-mindev'):
6708 sysvals.mindevlen = getArgFloat('-mindev', args, 0.0, 10000.0)
6709 elif(arg == '-mincg'):
6710 sysvals.mincglen = getArgFloat('-mincg', args, 0.0, 10000.0)
6711 elif(arg == '-bufsize'):
6712 sysvals.bufsize = getArgInt('-bufsize', args, 1, 1024*1024*8)
6713 elif(arg == '-cgtest'):
6714 sysvals.cgtest = getArgInt('-cgtest', args, 0, 1)
6715 elif(arg == '-cgphase'):
6722 doError('invalid phase --> (%s: %s), valid phases are %s'\
6725 elif(arg == '-cgfilter'):
6731 elif(arg == '-skipkprobe'):
6737 elif(arg == '-cgskip'):
6748 elif(arg == '-callloop-maxgap'):
6749 sysvals.callloopmaxgap = getArgFloat('-callloop-maxgap', args, 0.0, 1.0)
6750 elif(arg == '-callloop-maxlen'):
6751 sysvals.callloopmaxlen = getArgFloat('-callloop-maxlen', args, 0.0, 1.0)
6752 elif(arg == '-cmd'):
6759 elif(arg == '-expandcg'):
6761 elif(arg == '-srgap'):
6763 elif(arg == '-maxfail'):
6764 sysvals.maxfail = getArgInt('-maxfail', args, 0, 1000000)
6765 elif(arg == '-multi'):
6769 doError('-multi requires two values', True)
6771 elif(arg == '-o'):
6777 elif(arg == '-config'):
6786 elif(arg == '-fadd'):
6795 elif(arg == '-dmesg'):
6804 elif(arg == '-ftrace'):
6813 elif(arg == '-summary'):
6823 elif(arg == '-filter'):
6829 elif(arg == '-result'):
6841 doError('-dev is not compatible with -f')
6843 doError('-proc is not compatible with -f')
6892 print('[%s - %s]\n%s\n' % out)
6895 # if instructed, re-analyze existing data files
6909 memmode = mode.split('-', 1)[-1] if '-' in mode else 'deep'
6918 if mode.startswith('disk-'):
6919 sysvals.diskmode = mode.split('-', 1)[-1]
6928 s = '-%dm' % sysvals.multitest['time']
6930 s = '-x%d' % sysvals.multitest['count']
6931 sysvals.outdir = datetime.now().strftime('suspend-%y%m%d-%H%M%S'+s)
6943 fmt = 'suspend-%y%m%d-%H%M%S'