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
99 cgtest = -1
169 tmstart = 'SUSPEND START %Y%m%d-%H:%M:%S.%f'
170 tmend = 'RESUME COMPLETE %Y%m%d-%H:%M:%S.%f'
282 [0, 'pcidevices', 'lspci', '-tv'],
283 [0, 'usbdevices', 'lsusb', '-t'],
286 [2, 'gpecounts', 'sh', '-c', 'grep -v invalid /sys/firmware/acpi/interrupts/*'],
287 [2, 'suspendstats', 'sh', '-c', 'grep -v invalid /sys/power/suspend_stats/*'],
288 …[2, 'cpuidle', 'sh', '-c', 'grep -v invalid /sys/devices/system/cpu/cpu*/cpuidle/state*/s2idle/*'],
289 [2, 'battery', 'sh', '-c', 'grep -v invalid /sys/class/power_supply/*/*'],
297 def __init__(self): argument
298 self.archargs = 'args_'+platform.machine()
299 self.hostname = platform.node()
300 if(self.hostname == ''):
301 self.hostname = 'localhost'
308 self.rtcpath = rtc
310 self.ansi = True
311 self.testdir = datetime.now().strftime('suspend-%y%m%d-%H%M%S')
314 self.sudouser = os.environ['SUDO_USER']
315 def resetlog(self): argument
316 self.logmsg = ''
317 self.platinfo = []
318 def vprint(self, msg): argument
319 self.logmsg += msg+'\n'
320 if self.verbose or msg.startswith('WARNING:'):
322 def signalHandler(self, signum, frame): argument
323 if not self.result:
325 signame = self.signames[signum] if signum in self.signames else 'UNKNOWN'
327 self.outputResult({'error':msg})
329 def signalHandlerInit(self): argument
332 self.signames = dict()
337 signal.signal(signum, self.signalHandler)
340 self.signames[signum] = s
341 def rootCheck(self, fatal=True): argument
342 if(os.access(self.powerfile, os.W_OK)):
347 self.outputResult({'error':msg})
350 def rootUser(self, fatal=False): argument
356 self.outputResult({'error':msg})
359 def usable(self, file): argument
361 def getExec(self, cmd): argument
376 def setPrecision(self, num): argument
379 self.timeformat = '%.{0}f'.format(num)
380 def setOutputFolder(self, value): argument
385 args['hostname'] = args['host'] = self.hostname
386 args['mode'] = self.suspendmode
388 def setOutputFile(self): argument
389 if self.dmesgfile != '':
390 m = re.match('(?P<name>.*)_dmesg\.txt.*', self.dmesgfile)
392 self.htmlfile = m.group('name')+'.html'
393 if self.ftracefile != '':
394 m = re.match('(?P<name>.*)_ftrace\.txt.*', self.ftracefile)
396 self.htmlfile = m.group('name')+'.html'
397 def systemInfo(self, info): argument
399 if 'baseboard-manufacturer' in info:
400 m = info['baseboard-manufacturer']
401 elif 'system-manufacturer' in info:
402 m = info['system-manufacturer']
403 if 'system-product-name' in info:
404 p = info['system-product-name']
405 elif 'baseboard-product-name' in info:
406 p = info['baseboard-product-name']
407 if m[:5].lower() == 'intel' and 'baseboard-product-name' in info:
408 p = info['baseboard-product-name']
409 c = info['processor-version'] if 'processor-version' in info else ''
410 b = info['bios-version'] if 'bios-version' in info else ''
411 r = info['bios-release-date'] if 'bios-release-date' in info else ''
412 …self.sysstamp = '# sysinfo | man:%s | plat:%s | cpu:%s | bios:%s | biosdate:%s | numcpu:%d | memsz…
413 (m, p, c, b, r, self.cpucount, self.memtotal, self.memfree)
414 def printSystemInfo(self, fatal=False): argument
415 self.rootCheck(True)
416 out = dmidecode(self.mempath, fatal)
419 fmt = '%-24s: %s'
422 print(fmt % ('cpucount', ('%d' % self.cpucount)))
423 print(fmt % ('memtotal', ('%d kB' % self.memtotal)))
424 print(fmt % ('memfree', ('%d kB' % self.memfree)))
425 def cpuInfo(self): argument
426 self.cpucount = 0
429 if re.match('^processor[ \t]*:[ \t]*[0-9]*', line):
430 self.cpucount += 1
434 m = re.match('^MemTotal:[ \t]*(?P<sz>[0-9]*) *kB', line)
436 self.memtotal = int(m.group('sz'))
437 m = re.match('^MemFree:[ \t]*(?P<sz>[0-9]*) *kB', line)
439 self.memfree = int(m.group('sz'))
441 def initTestOutput(self, name): argument
442 self.prefix = self.hostname
445 fmt = name+'-%m%d%y-%H%M%S'
447 self.teststamp = \
448 '# '+testtime+' '+self.prefix+' '+self.suspendmode+' '+kver
450 if self.gzip:
452 self.dmesgfile = \
453 self.testdir+'/'+self.prefix+'_'+self.suspendmode+'_dmesg.txt'+ext
454 self.ftracefile = \
455 self.testdir+'/'+self.prefix+'_'+self.suspendmode+'_ftrace.txt'+ext
456 self.htmlfile = \
457 self.testdir+'/'+self.prefix+'_'+self.suspendmode+'.html'
458 if not os.path.isdir(self.testdir):
459 os.makedirs(self.testdir)
460 self.sudoUserchown(self.testdir)
461 def getValueList(self, value): argument
467 def setDeviceFilter(self, value): argument
468 self.devicefilter = self.getValueList(value)
469 def setCallgraphFilter(self, value): argument
470 self.cgfilter = self.getValueList(value)
471 def skipKprobes(self, value): argument
472 for k in self.getValueList(value):
473 if k in self.tracefuncs:
474 del self.tracefuncs[k]
475 if k in self.dev_tracefuncs:
476 del self.dev_tracefuncs[k]
477 def setCallgraphBlacklist(self, file): argument
478 self.cgblacklist = self.listFromFile(file)
479 def rtcWakeAlarmOn(self): argument
480 call('echo 0 > '+self.rtcpath+'/wakealarm', shell=True)
481 nowtime = open(self.rtcpath+'/since_epoch', 'r').read().strip()
487 alarm = nowtime + self.rtcwaketime
488 call('echo %d > %s/wakealarm' % (alarm, self.rtcpath), shell=True)
489 def rtcWakeAlarmOff(self): argument
490 call('echo 0 > %s/wakealarm' % self.rtcpath, shell=True)
491 def initdmesg(self): argument
500 m = re.match('[ \t]*(\[ *)(?P<ktime>[0-9\.]*)(\]) (?P<msg>.*)', line)
504 self.dmesgstart = float(ktime)
505 def getdmesg(self, testdata): argument
506 op = self.writeDatafileHeader(self.dmesgfile, testdata)
514 m = re.match('[ \t]*(\[ *)(?P<ktime>[0-9\.]*)(\]) (?P<msg>.*)', line)
518 if ktime > self.dmesgstart:
522 def listFromFile(self, file): argument
531 def addFtraceFilterFunctions(self, file): argument
532 for i in self.listFromFile(file):
535 self.tracefuncs[i] = dict()
536 def getFtraceFilterFunctions(self, current): argument
537 self.rootCheck(True)
539 call('cat '+self.tpath+'available_filter_functions', shell=True)
541 master = self.listFromFile(self.tpath+'available_filter_functions')
542 for i in sorted(self.tracefuncs):
543 if 'func' in self.tracefuncs[i]:
544 i = self.tracefuncs[i]['func']
548 print(self.colorText(i))
549 def setFtraceFilterFunctions(self, list): argument
550 master = self.listFromFile(self.tpath+'available_filter_functions')
559 fp = open(self.tpath+'set_graph_function', 'w')
562 def basicKprobe(self, name): argument
563 self.kprobes[name] = {'name': name,'func': name,'args': dict(),'format': name}
564 def defaultKprobe(self, name, kdata): argument
569 if self.archargs in k:
570 k['args'] = k[self.archargs]
574 self.kprobes[name] = k
575 def kprobeColor(self, name): argument
576 if name not in self.kprobes or 'color' not in self.kprobes[name]:
578 return self.kprobes[name]['color']
579 def kprobeDisplayName(self, name, dataraw): argument
580 if name not in self.kprobes:
581 self.basicKprobe(name)
592 fmt, args = self.kprobes[name]['format'], self.kprobes[name]['args']
607 def kprobeText(self, kname, kprobe): argument
616 if self.archargs in kprobe:
617 args = kprobe[self.archargs]
620 if re.findall('{(?P<n>[a-z,A-Z,0-9]*)}', func):
622 for arg in re.findall('{(?P<n>[a-z,A-Z,0-9]*)}', fmt):
630 def addKprobes(self, output=False): argument
631 if len(self.kprobes) < 1:
637 # sort kprobes: trace, ub-dev, custom, dev
639 linesout = len(self.kprobes)
640 for name in sorted(self.kprobes):
641 res = self.colorText('YES', 32)
642 if not self.testKprobe(name, self.kprobes[name]):
643 res = self.colorText('NO')
646 if name in self.tracefuncs:
648 elif name in self.dev_tracefuncs:
649 if 'ub' in self.dev_tracefuncs[name]:
660 self.kprobes.pop(name)
662 self.fsetVal('', 'kprobe_events')
665 kprobeevents += self.kprobeText(kp, self.kprobes[kp])
666 self.fsetVal(kprobeevents, 'kprobe_events')
668 check = self.fgetVal('kprobe_events')
669 linesack = (len(check.split('\n')) - 1) // 2
671 self.fsetVal('1', 'events/kprobes/enable')
672 def testKprobe(self, kname, kprobe): argument
673 self.fsetVal('0', 'events/kprobes/enable')
674 kprobeevents = self.kprobeText(kname, kprobe)
678 self.fsetVal(kprobeevents, 'kprobe_events')
679 check = self.fgetVal('kprobe_events')
687 def setVal(self, val, file): argument
698 def fsetVal(self, val, path): argument
699 return self.setVal(val, self.tpath+path)
700 def getVal(self, file): argument
711 def fgetVal(self, path): argument
712 return self.getVal(self.tpath+path)
713 def cleanupFtrace(self): argument
714 if(self.usecallgraph or self.usetraceevents or self.usedevsrc):
715 self.fsetVal('0', 'events/kprobes/enable')
716 self.fsetVal('', 'kprobe_events')
717 self.fsetVal('1024', 'buffer_size_kb')
718 if self.pmdebug:
719 self.setVal(self.pmdebug, self.pmdpath)
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()
744 pv = self.getVal(self.pmdpath)
746 self.setVal('1', self.pmdpath)
747 self.pmdebug = pv
749 self.fsetVal('global', 'trace_clock')
750 self.fsetVal('nop', 'current_tracer')
752 cpus = max(1, self.cpucount)
753 if self.bufsize > 0:
754 tgtsize = self.bufsize
755 elif self.usecallgraph or self.usedevsrc:
756 bmax = (1*1024*1024) if self.suspendmode in ['disk', 'command'] \
758 tgtsize = min(self.memfree, bmax)
761 while not self.fsetVal('%d' % (tgtsize // cpus), 'buffer_size_kb'):
763 tgtsize -= 65536
765 tgtsize = int(self.fgetVal('buffer_size_kb')) * cpus
767 self.vprint('Setting trace buffers to %d kB (%d kB per cpu)' % (tgtsize, tgtsize/cpus))
769 if(self.usecallgraph):
771 self.fsetVal('function_graph', 'current_tracer')
772 self.fsetVal('', 'set_ftrace_filter')
774 self.fsetVal('print-parent', 'trace_options')
775 self.fsetVal('funcgraph-abstime', 'trace_options')
776 self.fsetVal('funcgraph-cpu', 'trace_options')
777 self.fsetVal('funcgraph-duration', 'trace_options')
778 self.fsetVal('funcgraph-proc', 'trace_options')
779 self.fsetVal('funcgraph-tail', 'trace_options')
780 self.fsetVal('nofuncgraph-overhead', 'trace_options')
781 self.fsetVal('context-info', 'trace_options')
782 self.fsetVal('graph-time', 'trace_options')
783 self.fsetVal('%d' % self.max_graph_depth, 'max_graph_depth')
785 if(self.usetraceevents):
787 for fn in self.tracefuncs:
788 if 'func' in self.tracefuncs[fn]:
789 cf.append(self.tracefuncs[fn]['func'])
792 if self.ftop:
793 self.setFtraceFilterFunctions([self.ftopfunc])
795 self.setFtraceFilterFunctions(cf)
797 elif self.usekprobes:
798 for name in self.tracefuncs:
799 self.defaultKprobe(name, self.tracefuncs[name])
800 if self.usedevsrc:
801 for name in self.dev_tracefuncs:
802 self.defaultKprobe(name, self.dev_tracefuncs[name])
805 self.addKprobes(self.verbose)
806 if(self.usetraceevents):
808 events = iter(self.traceevents)
810 self.fsetVal('1', 'events/power/'+e+'/enable')
812 self.fsetVal('', 'trace')
813 def verifyFtrace(self): argument
818 tp = self.tpath
819 if(self.usecallgraph):
829 def verifyKprobes(self): argument
832 tp = self.tpath
837 def colorText(self, str, color=31): argument
838 if not self.ansi:
841 def writeDatafileHeader(self, filename, testdata): argument
842 fp = self.openlog(filename, 'w')
843 fp.write('%s\n%s\n# command | %s\n' % (self.teststamp, self.sysstamp, self.cmdline))
856 def sudoUserchown(self, dir): argument
857 if os.path.exists(dir) and self.sudouser:
858 cmd = 'chown -R {0}:{0} {1} > /dev/null 2>&1'
859 call(cmd.format(self.sudouser, dir), shell=True)
860 def outputResult(self, testdata, num=0): argument
861 if not self.result:
866 fp = open(self.result, 'a')
881 self.sudoUserchown(self.result)
882 def configFile(self, file): argument
891 def openlog(self, filename, mode): argument
892 isgz = self.gzip
903 def b64unzip(self, data): argument
909 def b64zip(self, data): argument
912 def platforminfo(self, cmdafter): argument
914 if not os.path.exists(self.ftracefile):
919 if self.suspendmode == 'command' and self.testcommand:
920 footer += '# platform-testcmd: %s\n' % (self.testcommand)
925 tf = self.openlog(self.ftracefile, 'r')
927 if tp.stampInfo(line, self):
944 dev = dirname.split('/')[-2]
946 props[dev].syspath = dirname[:-6]
990 footer += '# platform-devinfo: %s\n' % self.b64zip(out)
994 footer += '# platform-%s: %s | %s\n' % (name, cmdline, self.b64zip(info))
996 with self.openlog(self.ftracefile, 'a') as fp:
999 def commonPrefix(self, list): argument
1005 prefix = prefix[:len(prefix)-1]
1008 if '/' in prefix and prefix[-1] != '/':
1011 def dictify(self, text, format): argument
1028 def cmdinfo(self, begin, debug=False): argument
1031 self.cmd1 = dict()
1032 for cargs in self.infocmds:
1034 cmdline, cmdpath = ' '.join(cargs[2:]), self.getExec(cargs[2])
1044 self.cmd1[name] = self.dictify(info, delta)
1045 elif not debug and delta and name in self.cmd1:
1046 before, after = self.cmd1[name], self.dictify(info, delta)
1048 prefix = self.commonPrefix(list(before.keys()))
1053 dinfo += '\t%s : %s -> %s\n' % \
1063 def haveTurbostat(self): argument
1064 if not self.tstat:
1066 cmd = self.getExec('turbostat')
1069 fp = Popen([cmd, '-v'], stdout=PIPE, stderr=PIPE).stderr
1073 self.vprint(out)
1076 def turbostat(self): argument
1077 cmd = self.getExec('turbostat')
1079 fullcmd = '%s -q -S echo freeze > %s' % (cmd, self.powerfile)
1080 fp = Popen(['sh', '-c', fullcmd], stdout=PIPE, stderr=PIPE).stderr
1093 self.vprint(errmsg)
1094 if not self.verbose:
1097 if self.verbose:
1105 def wifiDetails(self, dev): argument
1113 vals.append(prop.split('=')[-1])
1115 def checkWifi(self, dev=''): argument
1121 m = re.match(' *(?P<dev>.*): (?P<stat>[0-9a-f]*) .*', w.split('\n')[-1])
1126 def pollWifi(self, dev, timeout=60): argument
1128 while (time.time() - start) < timeout:
1129 w = self.checkWifi(dev)
1132 (self.wifiDetails(dev), max(0, time.time() - start))
1134 return '%s timeout %d' % (self.wifiDetails(dev), timeout)
1135 def errorSummary(self, errinfo, msg): argument
1140 if self.hostname not in entry['urls']:
1141 entry['urls'][self.hostname] = [self.htmlfile]
1142 elif self.htmlfile not in entry['urls'][self.hostname]:
1143 entry['urls'][self.hostname].append(self.htmlfile)
1150 if re.match('^[0-9,\-\.]*$', arr[j]):
1151 arr[j] = '[0-9,\-\.]*'
1163 'urls': {self.hostname: [self.htmlfile]}
1166 def multistat(self, start, idx, finish): argument
1167 if 'time' in self.multitest:
1168 id = '%d Duration=%dmin' % (idx+1, self.multitest['time'])
1170 id = '%d/%d' % (idx+1, self.multitest['count'])
1172 if 'start' not in self.multitest:
1173 self.multitest['start'] = self.multitest['last'] = t
1174 self.multitest['total'] = 0.0
1177 dt = t - self.multitest['last']
1179 if idx == 0 and self.multitest['delay'] > 0:
1180 self.multitest['total'] += self.multitest['delay']
1181 pprint('TEST (%s) COMPLETE -- Duration %.1fs' % (id, dt))
1183 self.multitest['total'] += dt
1184 self.multitest['last'] = t
1185 avg = self.multitest['total'] / idx
1186 if 'time' in self.multitest:
1187 left = finish - datetime.now()
1188 left -= timedelta(microseconds=left.microseconds)
1190 left = timedelta(seconds=((self.multitest['count'] - idx) * int(avg)))
1191 pprint('TEST (%s) START - Avg Duration %.1fs, Time left %s' % \
1193 def multiinit(self, c, d): argument
1196 sz, unit, c = 'time', c[-1], c[:-1]
1197 self.multitest['run'] = True
1198 self.multitest[sz] = getArgInt('multi: n d (exec count)', c, 1, 1000000, False)
1199 self.multitest['delay'] = getArgInt('multi: n d (delay between tests)', d, 0, 3600, False)
1201 self.multitest[sz] *= 1440
1203 self.multitest[sz] *= 60
1220 def __init__(self): argument
1221 self.syspath = ''
1222 self.altname = ''
1223 self.isasync = True
1224 self.xtraclass = ''
1225 self.xtrainfo = ''
1226 def out(self, dev): argument
1227 return '%s,%s,%d;' % (dev, self.altname, self.isasync)
1228 def debug(self, dev): argument
1229 pprint('%s:\n\taltname = %s\n\t async = %s' % (dev, self.altname, self.isasync))
1230 def altName(self, dev): argument
1231 if not self.altname or self.altname == dev:
1233 return '%s [%s]' % (self.altname, dev)
1234 def xtraClass(self): argument
1235 if self.xtraclass:
1236 return ' '+self.xtraclass
1237 if not self.isasync:
1240 def xtraInfo(self): argument
1241 if self.xtraclass:
1242 return ' '+self.xtraclass
1243 if self.isasync:
1252 def __init__(self, nodename, nodedepth): argument
1253 self.name = nodename
1254 self.children = []
1255 self.depth = nodedepth
1263 # 10 sequential, non-overlapping phases of S/R
1304 'ACPI' : r'.*\bACPI *(?P<b>[A-Za-z]*) *Error[: ].*',
1306 'USBERR' : r'.*usb .*device .*, error [0-9-]*',
1307 'ATAERR' : r' *ata[0-9\.]*: .*failed.*',
1309 'TPMERR' : r'(?i) *tpm *tpm[0-9]*: .*error.*',
1311 def __init__(self, num): argument
1313 self.start = 0.0 # test start
1314 self.end = 0.0 # test end
1315 self.hwstart = 0 # rtc test start
1316 self.hwend = 0 # rtc test end
1317 self.tSuspended = 0.0 # low-level suspend start
1318 self.tResumed = 0.0 # low-level resume start
1319 self.tKernSus = 0.0 # kernel level suspend start
1320 self.tKernRes = 0.0 # kernel level resume end
1321 self.fwValid = False # is firmware data available
1322 self.fwSuspend = 0 # time spent in firmware suspend
1323 self.fwResume = 0 # time spent in firmware resume
1324 self.html_device_id = 0
1325 self.stamp = 0
1326 self.outfile = ''
1327 self.kerror = False
1328 self.wifi = dict()
1329 self.turbostat = 0
1330 self.enterfail = ''
1331 self.currphase = ''
1332 self.pstl = dict() # process timeline
1333 self.testnumber = num
1334 self.idstr = idchar[num]
1335 self.dmesgtext = [] # dmesg text file in memory
1336 self.dmesg = dict() # root data structure
1337 self.errorinfo = {'suspend':[],'resume':[]}
1338 self.tLow = [] # time spent in low-level suspends (standby/freeze)
1339 self.devpids = []
1340 self.devicegroups = 0
1341 def sortedPhases(self): argument
1342 return sorted(self.dmesg, key=lambda k:self.dmesg[k]['order'])
1343 def initDevicegroups(self): argument
1345 for phase in sorted(self.dmesg.keys()):
1349 self.dmesg[pnew] = self.dmesg.pop(phase)
1350 self.devicegroups = []
1351 for phase in self.sortedPhases():
1352 self.devicegroups.append([phase])
1353 def nextPhase(self, phase, offset): argument
1354 order = self.dmesg[phase]['order'] + offset
1355 for p in self.dmesg:
1356 if self.dmesg[p]['order'] == order:
1359 def lastPhase(self, depth=1): argument
1360 plist = self.sortedPhases()
1363 return plist[-1*depth]
1364 def turbostatInfo(self): argument
1367 for line in self.dmesgtext:
1373 out['syslpi'] = i.split('=')[-1]+'%'
1375 out['pkgpc10'] = i.split('=')[-1]+'%'
1378 def extractErrorInfo(self): argument
1379 lf = self.dmesgtext
1380 if len(self.dmesgtext) < 1 and sysvals.dmesgfile:
1389 m = re.match('[ \t]*(\[ *)(?P<ktime>[0-9\.]*)(\]) (?P<msg>.*)', line)
1393 if t < self.start or t > self.end:
1395 dir = 'suspend' if t < self.tSuspended else 'resume'
1399 for err in self.errlist:
1400 if re.match(self.errlist[err], msg):
1402 self.kerror = True
1407 self.errorinfo[dir].append((type, t, idx1, idx2))
1408 if self.kerror:
1410 if len(self.dmesgtext) < 1 and sysvals.dmesgfile:
1413 def setStart(self, time, msg=''): argument
1414 self.start = time
1417 self.hwstart = datetime.strptime(msg, sysvals.tmstart)
1419 self.hwstart = 0
1420 def setEnd(self, time, msg=''): argument
1421 self.end = time
1424 self.hwend = datetime.strptime(msg, sysvals.tmend)
1426 self.hwend = 0
1427 def isTraceEventOutsideDeviceCalls(self, pid, time): argument
1428 for phase in self.sortedPhases():
1429 list = self.dmesg[phase]['list']
1436 def sourcePhase(self, start): argument
1437 for phase in self.sortedPhases():
1440 pend = self.dmesg[phase]['end']
1444 def sourceDevice(self, phaselist, start, end, pid, type): argument
1447 list = self.dmesg[phase]['list']
1468 def addDeviceFunctionCall(self, displayname, kprobename, proc, pid, start, end, cdata, rdata): argument
1470 phases = self.sortedPhases()
1471 tgtdev = self.sourceDevice(phases, start, end, pid, 'device')
1474 if not tgtdev and pid in self.devpids:
1478 tgtdev = self.sourceDevice(phases, start, end, pid, 'thread')
1482 threadname = 'kthread-%d' % (pid)
1484 threadname = '%s-%d' % (proc, pid)
1485 tgtphase = self.sourcePhase(start)
1486 self.newAction(tgtphase, threadname, pid, '', start, end, '', ' kth', '')
1487 return self.addDeviceFunctionCall(displayname, kprobename, proc, pid, start, end, cdata, rdata)
1490 sysvals.vprint('[%f - %f] %s-%d %s %s %s' % \
1517 def overflowDevices(self): argument
1520 for phase in self.sortedPhases():
1521 list = self.dmesg[phase]['list']
1524 if dev['end'] > self.end:
1527 def mergeOverlapDevices(self, devlist): argument
1531 for phase in self.sortedPhases():
1532 list = self.dmesg[phase]['list']
1536 o = min(dev['end'], tdev['end']) - max(dev['start'], tdev['start'])
1544 def usurpTouchingThread(self, name, dev): argument
1546 for phase in self.sortedPhases():
1547 list = self.dmesg[phase]['list']
1550 if tdev['start'] - dev['end'] < 0.1:
1558 def stitchTouchingThreads(self, testlist): argument
1560 for phase in self.sortedPhases():
1561 list = self.dmesg[phase]['list']
1568 def optimizeDevSrc(self): argument
1570 for phase in self.sortedPhases():
1571 list = self.dmesg[phase]['list']
1583 p.length = p.end - p.time
1586 def trimTimeVal(self, t, t0, dT, left): argument
1589 if(t - dT < t0):
1591 return t - dT
1601 def trimTime(self, t0, dT, left): argument
1602 self.tSuspended = self.trimTimeVal(self.tSuspended, t0, dT, left)
1603 self.tResumed = self.trimTimeVal(self.tResumed, t0, dT, left)
1604 self.start = self.trimTimeVal(self.start, t0, dT, left)
1605 self.tKernSus = self.trimTimeVal(self.tKernSus, t0, dT, left)
1606 self.tKernRes = self.trimTimeVal(self.tKernRes, t0, dT, left)
1607 self.end = self.trimTimeVal(self.end, t0, dT, left)
1608 for phase in self.sortedPhases():
1609 p = self.dmesg[phase]
1610 p['start'] = self.trimTimeVal(p['start'], t0, dT, left)
1611 p['end'] = self.trimTimeVal(p['end'], t0, dT, left)
1615 d['start'] = self.trimTimeVal(d['start'], t0, dT, left)
1616 d['end'] = self.trimTimeVal(d['end'], t0, dT, left)
1617 d['length'] = d['end'] - d['start']
1620 cg.start = self.trimTimeVal(cg.start, t0, dT, left)
1621 cg.end = self.trimTimeVal(cg.end, t0, dT, left)
1623 line.time = self.trimTimeVal(line.time, t0, dT, left)
1626 e.time = self.trimTimeVal(e.time, t0, dT, left)
1627 e.end = self.trimTimeVal(e.end, t0, dT, left)
1628 e.length = e.end - e.time
1631 for e in self.errorinfo[dir]:
1633 tm = self.trimTimeVal(tm, t0, dT, left)
1635 self.errorinfo[dir] = list
1636 def trimFreezeTime(self, tZero): argument
1639 for phase in self.sortedPhases():
1641 tS, tR = self.dmesg[lp]['end'], self.dmesg[phase]['start']
1642 tL = tR - tS
1645 self.trimTime(tS, tL, left)
1646 if 'trying' in self.dmesg[lp] and self.dmesg[lp]['trying'] >= 0.001:
1647 tTry = round(self.dmesg[lp]['trying'] * 1000)
1648 text = '%.0f (-%.0f waking)' % (tL * 1000, tTry)
1651 self.tLow.append(text)
1653 def getMemTime(self): argument
1654 if not self.hwstart or not self.hwend:
1656 stime = (self.tSuspended - self.start) * 1000000
1657 rtime = (self.end - self.tResumed) * 1000000
1658 hws = self.hwstart + timedelta(microseconds=stime)
1659 hwr = self.hwend - timedelta(microseconds=rtime)
1660 self.tLow.append('%.0f'%((hwr - hws).total_seconds() * 1000))
1661 def getTimeValues(self): argument
1662 sktime = (self.tSuspended - self.tKernSus) * 1000
1663 rktime = (self.tKernRes - self.tResumed) * 1000
1665 def setPhase(self, phase, ktime, isbegin, order=-1): argument
1668 if self.currphase:
1669 if 'resume_machine' not in self.currphase:
1670 sysvals.vprint('WARNING: phase %s failed to end' % self.currphase)
1671 self.dmesg[self.currphase]['end'] = ktime
1672 phases = self.dmesg.keys()
1673 color = self.phasedef[phase]['color']
1678 self.dmesg[phase] = {'list': dict(), 'start': -1.0, 'end': -1.0,
1680 self.dmesg[phase]['start'] = ktime
1681 self.currphase = phase
1684 if phase not in self.currphase:
1685 if self.currphase:
1686 sysvals.vprint('WARNING: %s ended instead of %s, ftrace corruption?' % (phase, self.currphase))
1690 phase = self.currphase
1691 self.dmesg[phase]['end'] = ktime
1692 self.currphase = ''
1694 def sortedDevices(self, phase): argument
1695 list = self.dmesg[phase]['list']
1697 def fixupInitcalls(self, phase): argument
1699 phaselist = self.dmesg[phase]['list']
1703 for p in self.sortedPhases():
1704 if self.dmesg[p]['end'] > dev['start']:
1705 dev['end'] = self.dmesg[p]['end']
1708 def deviceFilter(self, devicefilter): argument
1709 for phase in self.sortedPhases():
1710 list = self.dmesg[phase]['list']
1722 def fixupInitcallsThatDidntReturn(self): argument
1724 for phase in self.sortedPhases():
1725 self.fixupInitcalls(phase)
1726 def phaseOverlap(self, phases): argument
1729 for group in self.devicegroups:
1739 self.devicegroups.remove(group)
1740 self.devicegroups.append(newgroup)
1741 def newActionGlobal(self, name, start, end, pid=-1, color=''): argument
1743 phases = self.sortedPhases()
1749 pstart = self.dmesg[phase]['start']
1750 pend = self.dmesg[phase]['end']
1752 o = max(0, min(end, pend) - max(start, pstart))
1763 p0start = self.dmesg[phases[0]]['start']
1767 targetphase = phases[-1]
1768 if pid == -2:
1770 elif pid == -3:
1774 self.phaseOverlap(myphases)
1776 newname = self.newAction(targetphase, name, pid, '', start, end, '', htmlclass, color)
1779 def newAction(self, phase, name, pid, parent, start, end, drv, htmlclass='', color=''): argument
1781 self.html_device_id += 1
1782 devid = '%s%d' % (self.idstr, self.html_device_id)
1783 list = self.dmesg[phase]['list']
1784 length = -1.0
1786 length = end - start
1787 if pid == -2 or name not in sysvals.tracefuncs.keys():
1800 def findDevice(self, phase, name): argument
1801 list = self.dmesg[phase]['list']
1804 if name == devname or re.match('^%s\[(?P<num>[0-9]*)\]$' % name, devname):
1809 def deviceChildren(self, devname, phase): argument
1811 list = self.dmesg[phase]['list']
1816 def maxDeviceNameSize(self, phase): argument
1818 for name in self.dmesg[phase]['list']:
1822 def printDetails(self): argument
1824 sysvals.vprint(' test start: %f' % self.start)
1825 sysvals.vprint('kernel suspend start: %f' % self.tKernSus)
1827 for phase in self.sortedPhases():
1828 devlist = self.dmesg[phase]['list']
1829 dc, ps, pe = len(devlist), self.dmesg[phase]['start'], self.dmesg[phase]['end']
1830 if not tS and ps >= self.tSuspended:
1831 sysvals.vprint(' machine suspended: %f' % self.tSuspended)
1833 if not tR and ps >= self.tResumed:
1834 sysvals.vprint(' machine resumed: %f' % self.tResumed)
1836 sysvals.vprint('%20s: %f - %f (%d devices)' % (phase, ps, pe, dc))
1838 sysvals.vprint(''.join('-' for i in range(80)))
1839 maxname = '%d' % self.maxDeviceNameSize(phase)
1840 fmt = '%3d) %'+maxname+'s - %f - %f'
1847 sysvals.vprint(''.join('-' for i in range(80)))
1848 sysvals.vprint(' kernel resume end: %f' % self.tKernRes)
1849 sysvals.vprint(' test end: %f' % self.end)
1850 def deviceChildrenAllPhases(self, devname): argument
1852 for phase in self.sortedPhases():
1853 list = self.deviceChildren(devname, phase)
1858 def masterTopology(self, name, list, depth): argument
1864 clist = self.deviceChildrenAllPhases(cname)
1865 cnode = self.masterTopology(cname, clist, depth+1)
1868 def printTopology(self, node): argument
1873 for phase in self.sortedPhases():
1874 list = self.dmesg[phase]['list']
1880 info += ('<li>%s: %.3fms</li>' % (phase, (e-s)*1000))
1888 html += self.printTopology(cnode)
1891 def rootDeviceList(self): argument
1894 for phase in self.sortedPhases():
1895 list = self.dmesg[phase]['list']
1899 # list of top-most root devices
1901 for phase in self.sortedPhases():
1902 list = self.dmesg[phase]['list']
1906 if(pid < 0 or re.match('[0-9]*-[0-9]*\.[0-9]*[\.0-9]*\:[\.0-9]*$', pdev)):
1911 def deviceTopology(self): argument
1912 rootlist = self.rootDeviceList()
1913 master = self.masterTopology('', rootlist, 0)
1914 return self.printTopology(master)
1915 def selectTimelineDevices(self, widfmt, tTotal, mindevlen): argument
1917 self.tdevlist = dict()
1918 for phase in self.dmesg:
1920 list = self.dmesg[phase]['list']
1922 length = (list[dev]['end'] - list[dev]['start']) * 1000
1923 width = widfmt % (((list[dev]['end']-list[dev]['start'])*100)/tTotal)
1926 self.tdevlist[phase] = devlist
1927 def addHorizontalDivider(self, devname, devend): argument
1929 self.newAction(phase, devname, -2, '', \
1930 self.start, devend, '', ' sec', '')
1931 if phase not in self.tdevlist:
1932 self.tdevlist[phase] = []
1933 self.tdevlist[phase].append(devname)
1934 d = DevItem(0, phase, self.dmesg[phase]['list'][devname])
1936 def addProcessUsageEvent(self, name, times): argument
1940 start = -1
1941 end = -1
1946 if name in self.pstl[t]:
1947 if start == -1 or tlast < start:
1949 if end == -1 or t > end:
1952 if start == -1 or end == -1:
1955 out = self.newActionGlobal(name, start, end, -3)
1959 dev = self.dmesg[phase]['list'][devname]
1968 list = self.pstl[t]
1981 def createProcessUsageEvents(self): argument
1984 for t in sorted(self.pstl):
1985 pslist = self.pstl[t]
1992 for t in sorted(self.pstl):
1993 if t < self.tSuspended:
2001 c = self.addProcessUsageEvent(ps, tsus)
2004 c = self.addProcessUsageEvent(ps, tres)
2007 def handleEndMarker(self, time, msg=''): argument
2008 dm = self.dmesg
2009 self.setEnd(time, msg)
2010 self.initDevicegroups()
2016 np = self.nextPhase('resume_machine', 1)
2020 if self.tKernRes == 0.0:
2021 self.tKernRes = time
2023 if self.tKernSus == 0.0:
2024 self.tKernSus = time
2028 def debugPrint(self): argument
2029 for p in self.sortedPhases():
2030 list = self.dmesg[p]['list']
2040 def __init__(self, name, args, caller, ret, start, end, u, proc, pid, color): argument
2041 self.row = 0
2042 self.count = 1
2043 self.name = name
2044 self.args = args
2045 self.caller = caller
2046 self.ret = ret
2047 self.time = start
2048 self.length = end - start
2049 self.end = end
2050 self.ubiquitous = u
2051 self.proc = proc
2052 self.pid = pid
2053 self.color = color
2054 def title(self): argument
2056 if self.count > 1:
2057 cnt = '(x%d)' % self.count
2058 l = '%0.3fms' % (self.length * 1000)
2059 if self.ubiquitous:
2060 title = '%s(%s)%s <- %s, %s(%s)' % \
2061 (self.name, self.args, cnt, self.caller, self.ret, l)
2063 title = '%s(%s) %s%s(%s)' % (self.name, self.args, self.ret, cnt, l)
2065 def text(self): argument
2066 if self.count > 1:
2067 text = '%s(x%d)' % (self.name, self.count)
2069 text = self.name
2071 def repeat(self, tgt): argument
2073 dt = self.time - tgt.end
2074 # only combine calls if -all- attributes are identical
2075 if tgt.caller == self.caller and \
2076 tgt.name == self.name and tgt.args == self.args and \
2077 tgt.proc == self.proc and tgt.pid == self.pid and \
2078 tgt.ret == self.ret and dt >= 0 and \
2080 self.length < sysvals.callloopmaxlen:
2096 def __init__(self, t, m='', d=''): argument
2097 self.length = 0.0
2098 self.fcall = False
2099 self.freturn = False
2100 self.fevent = False
2101 self.fkprobe = False
2102 self.depth = 0
2103 self.name = ''
2104 self.type = ''
2105 self.time = float(t)
2120 self.name = emm.group('msg')
2121 self.type = emm.group('call')
2123 self.name = msg
2124 km = re.match('^(?P<n>.*)_cal$', self.type)
2126 self.fcall = True
2127 self.fkprobe = True
2128 self.type = km.group('n')
2130 km = re.match('^(?P<n>.*)_ret$', self.type)
2132 self.freturn = True
2133 self.fkprobe = True
2134 self.type = km.group('n')
2136 self.fevent = True
2140 self.length = float(d)/1000000
2145 self.depth = self.getDepth(match.group('d'))
2149 self.freturn = True
2154 self.name = match.group('n').strip()
2157 self.fcall = True
2159 if(m[-1] == '{'):
2162 self.name = match.group('n').strip()
2164 elif(m[-1] == ';'):
2165 self.freturn = True
2168 self.name = match.group('n').strip()
2171 self.name = m
2172 def isCall(self): argument
2173 return self.fcall and not self.freturn
2174 def isReturn(self): argument
2175 return self.freturn and not self.fcall
2176 def isLeaf(self): argument
2177 return self.fcall and self.freturn
2178 def getDepth(self, str): argument
2180 def debugPrint(self, info=''): argument
2181 if self.isLeaf():
2182 pprint(' -- %12.6f (depth=%02d): %s(); (%.3f us) %s' % (self.time, \
2183 self.depth, self.name, self.length*1000000, info))
2184 elif self.freturn:
2185 pprint(' -- %12.6f (depth=%02d): %s} (%.3f us) %s' % (self.time, \
2186 self.depth, self.name, self.length*1000000, info))
2188 pprint(' -- %12.6f (depth=%02d): %s() { (%.3f us) %s' % (self.time, \
2189 self.depth, self.name, self.length*1000000, info))
2190 def startMarker(self): argument
2192 if not self.fevent:
2195 if(self.name.startswith('SUSPEND START')):
2199 if(self.type == 'suspend_resume' and
2200 re.match('suspend_enter\[.*\] begin', self.name)):
2203 def endMarker(self): argument
2205 if not self.fevent:
2208 if(self.name.startswith('RESUME COMPLETE')):
2212 if(self.type == 'suspend_resume' and
2213 re.match('thaw_processes\[.*\] end', self.name)):
2225 def __init__(self, pid, sv): argument
2226 self.id = ''
2227 self.invalid = False
2228 self.name = ''
2229 self.partial = False
2230 self.ignore = False
2231 self.start = -1.0
2232 self.end = -1.0
2233 self.list = []
2234 self.depth = 0
2235 self.pid = pid
2236 self.sv = sv
2237 def addLine(self, line): argument
2239 if(self.invalid):
2244 if(self.depth < 0):
2245 self.invalidate(line)
2248 if self.ignore:
2249 if line.depth > self.depth:
2252 self.list[-1].freturn = True
2253 self.list[-1].length = line.time - self.list[-1].time
2254 self.ignore = False
2255 # if this is a return at self.depth, no more work is needed
2256 if line.depth == self.depth and line.isReturn():
2258 self.end = line.time
2261 # compare current depth with this lines pre-call depth
2267 if len(self.list) > 0:
2268 last = self.list[-1]
2273 mismatch = prelinedep - self.depth
2274 warning = self.sv.verbose and abs(mismatch) > 1
2279 while prelinedep < self.depth:
2280 self.depth -= 1
2283 last.depth = self.depth
2285 last.length = line.time - last.time
2290 vline.depth = self.depth
2291 vline.name = self.vfname
2293 self.list.append(vline)
2307 while prelinedep > self.depth:
2311 prelinedep -= 1
2316 vline.depth = self.depth
2317 vline.name = self.vfname
2319 self.list.append(vline)
2320 self.depth += 1
2322 self.start = vline.time
2336 md = self.sv.max_graph_depth
2339 if (md and self.depth >= md - 1) or (line.name in self.sv.cgblacklist):
2340 self.ignore = True
2342 self.depth += 1
2344 self.depth -= 1
2348 (line.name in self.sv.cgblacklist):
2349 while len(self.list) > 0 and self.list[-1].depth > line.depth:
2350 self.list.pop(-1)
2351 if len(self.list) == 0:
2352 self.invalid = True
2354 self.list[-1].freturn = True
2355 self.list[-1].length = line.time - self.list[-1].time
2356 self.list[-1].name = line.name
2358 if len(self.list) < 1:
2359 self.start = line.time
2362 if mismatch < 0 and self.list[-1].depth == 0 and self.list[-1].freturn:
2363 line = self.list[-1]
2365 res = -1
2367 self.list.append(line)
2369 if(self.start < 0):
2370 self.start = line.time
2371 self.end = line.time
2373 self.end += line.length
2374 if self.list[0].name == self.vfname:
2375 self.invalid = True
2376 if res == -1:
2377 self.partial = True
2380 def invalidate(self, line): argument
2381 if(len(self.list) > 0):
2382 first = self.list[0]
2383 self.list = []
2384 self.list.append(first)
2385 self.invalid = True
2386 id = 'task %s' % (self.pid)
2387 window = '(%f - %f)' % (self.start, line.time)
2388 if(self.depth < 0):
2394 def slice(self, dev): argument
2395 minicg = FTraceCallGraph(dev['pid'], self.sv)
2396 minicg.name = self.name
2397 mydepth = -1
2399 for l in self.list:
2409 l.depth -= mydepth
2414 def repair(self, enddepth): argument
2417 last = self.list[-1]
2422 fixed = self.addLine(t)
2424 self.end = last.time
2427 def postProcess(self): argument
2428 if len(self.list) > 0:
2429 self.name = self.list[0].name
2433 for l in self.list:
2437 if last.length > l.time - last.time:
2438 last.length = l.time - last.time
2444 if self.sv.verbose:
2450 cl.length = l.time - cl.time
2451 if cl.name == self.vfname:
2455 cnt -= 1
2461 if self.sv.verbose:
2465 return self.repair(cnt)
2466 def deviceMatch(self, pid, data): argument
2473 if(self.name in borderphase):
2474 p = borderphase[self.name]
2479 self.start <= dev['start'] and
2480 self.end >= dev['end']):
2481 cg = self.slice(dev)
2487 if(data.dmesg[p]['start'] <= self.start and
2488 self.start <= data.dmesg[p]['end']):
2493 self.start <= dev['start'] and
2494 self.end >= dev['end']):
2495 dev['ftrace'] = self
2500 def newActionFromFunction(self, data): argument
2501 name = self.name
2504 fs = self.start
2505 fe = self.end
2510 if(data.dmesg[p]['start'] <= self.start and
2511 self.start < data.dmesg[p]['end']):
2516 out = data.newActionGlobal(name, fs, fe, -2)
2519 data.dmesg[phase]['list'][myname]['ftrace'] = self
2520 def debugPrint(self, info=''): argument
2521 pprint('%s pid=%d [%f - %f] %.3f us' % \
2522 (self.name, self.pid, self.start, self.end,
2523 (self.end - self.start)*1000000))
2524 for l in self.list:
2537 def __init__(self, test, phase, dev): argument
2538 self.test = test
2539 self.phase = phase
2540 self.dev = dev
2541 def isa(self, cls): argument
2542 if 'htmlclass' in self.dev and cls in self.dev['htmlclass']:
2556 def __init__(self, rowheight, scaleheight): argument
2557 self.html = ''
2558 self.height = 0 # total timeline height
2559 self.scaleH = scaleheight # timescale (top) row height
2560 self.rowH = rowheight # device row height
2561 self.bodyH = 0 # body height
2562 self.rows = 0 # total timeline rows
2563 self.rowlines = dict()
2564 self.rowheight = dict()
2565 def createHeader(self, sv, stamp): argument
2568 self.html += '<div class="version"><a href="https://01.org/pm-graph">%s v%s</a></div>' \
2571 self.html += '<button id="showtest" class="logbtn btnfmt">log</button>'
2573 self.html += '<button id="showdmesg" class="logbtn btnfmt">dmesg</button>'
2575 self.html += '<button id="showftrace" class="logbtn btnfmt">ftrace</button>'
2577 self.html += headline_stamp.format(stamp['host'], stamp['kernel'],
2582 self.html += headline_sysinfo.format(stamp['man'], stamp['plat'], stamp['cpu'])
2591 def getDeviceRows(self, rawlist): argument
2595 item.row = -1
2621 remaining -= 1
2632 def getPhaseRows(self, devlist, row=0, sortby='length'): argument
2638 # initialize all device rows to -1 and calculate devrows
2644 dev['row'] = -1
2647 sortdict[item] = (-1*float(dev['start']), float(dev['end']) - float(dev['start']))
2650 sortdict[item] = (float(dev['end']) - float(dev['start']), item.dev['name'])
2652 dev['devrows'] = self.getDeviceRows(dev['src'])
2657 if item.dev['pid'] == -2:
2683 remaining -= 1
2687 if t not in self.rowlines or t not in self.rowheight:
2688 self.rowlines[t] = dict()
2689 self.rowheight[t] = dict()
2690 if p not in self.rowlines[t] or p not in self.rowheight[t]:
2691 self.rowlines[t][p] = dict()
2692 self.rowheight[t][p] = dict()
2693 rh = self.rowH
2699 self.rowlines[t][p][row] = rowheight
2700 self.rowheight[t][p][row] = rowheight * rh
2702 if(row > self.rows):
2703 self.rows = int(row)
2705 def phaseRowHeight(self, test, phase, row): argument
2706 return self.rowheight[test][phase][row]
2707 def phaseRowTop(self, test, phase, row): argument
2709 for i in sorted(self.rowheight[test][phase]):
2712 top += self.rowheight[test][phase][i]
2714 def calcTotalRows(self): argument
2718 for t in self.rowlines:
2719 for p in self.rowlines[t]:
2721 for i in sorted(self.rowlines[t][p]):
2722 total += self.rowlines[t][p][i]
2725 if total == len(self.rowlines[t][p]):
2727 self.height = self.scaleH + (maxrows*self.rowH)
2728 self.bodyH = self.height - self.scaleH
2731 for i in sorted(self.rowheight[t][p]):
2732 self.rowheight[t][p][i] = float(self.bodyH)/len(self.rowlines[t][p])
2733 def createZoomBox(self, mode='command', testcount=1): argument
2735 …html_zoombox = '<center><button id="zoomin">ZOOM IN +</button><button id="zoomout">ZOOM OUT -</but…
2741 self.html += html_devlist2
2742 self.html += html_devlist1.format('1')
2744 self.html += html_devlist1.format('')
2745 self.html += html_zoombox
2746 self.html += html_timeline.format('dmesg', self.height)
2757 def createTimeScale(self, m0, mMax, tTotal, mode): argument
2759 rline = '<div class="t" style="left:0;border-left:1px solid black;border-right:0;">{0}</div>\n'
2762 mTotal = mMax - m0
2769 divEdge = (mTotal - tS*(divTotal-1))*100/mTotal
2773 pos = '%0.3f' % (100 - ((float(i)*tS*100)/mTotal) - divEdge)
2774 val = '%0.fms' % (float(i-divTotal+1)*tS*1000)
2775 if(i == divTotal - 1):
2779 pos = '%0.3f' % (100 - ((float(i)*tS*100)/mTotal))
2785 self.html += output+'</div>\n'
2789 # A list of values describing the properties of these test runs
2791 stampfmt = '# [a-z]*-(?P<m>[0-9]{2})(?P<d>[0-9]{2})(?P<y>[0-9]{2})-'+\
2792 '(?P<H>[0-9]{2})(?P<M>[0-9]{2})(?P<S>[0-9]{2})'+\
2794 wififmt = '^# wifi *(?P<d>\S*) *(?P<s>\S*) *(?P<t>[0-9\.]+).*'
2801 pinfofmt = '# platform-(?P<val>[a-z,A-Z,0-9]*): (?P<info>.*)'
2803 firmwarefmt = '# fwsuspend (?P<s>[0-9]*) fwresume (?P<r>[0-9]*)$'
2804 procexecfmt = 'ps - (?P<ps>.*)$'
2806 '^ *(?P<time>[0-9\.]*) *\| *(?P<cpu>[0-9]*)\)'+\
2807 ' *(?P<proc>.*)-(?P<pid>[0-9]*) *\|'+\
2808 '[ +!#\*@$]*(?P<dur>[0-9\.]*) .*\| (?P<msg>.*)'
2810 ' *(?P<proc>.*)-(?P<pid>[0-9]*) *\[(?P<cpu>[0-9]*)\] *'+\
2811 '(?P<flags>\S*) *(?P<time>[0-9\.]*): *'+\
2814 def __init__(self): argument
2815 self.stamp = ''
2816 self.sysinfo = ''
2817 self.cmdline = ''
2818 self.testerror = []
2819 self.turbostat = []
2820 self.wifi = []
2821 self.fwdata = []
2822 self.ftrace_line_fmt = self.ftrace_line_fmt_nop
2823 self.cgformat = False
2824 self.data = 0
2825 self.ktemp = dict()
2826 def setTracerType(self, tracer): argument
2828 self.cgformat = True
2829 self.ftrace_line_fmt = self.ftrace_line_fmt_fg
2831 self.ftrace_line_fmt = self.ftrace_line_fmt_nop
2834 def stampInfo(self, line, sv): argument
2835 if re.match(self.stampfmt, line):
2836 self.stamp = line
2838 elif re.match(self.sysinfofmt, line):
2839 self.sysinfo = line
2841 elif re.match(self.tstatfmt, line):
2842 self.turbostat.append(line)
2844 elif re.match(self.wififmt, line):
2845 self.wifi.append(line)
2847 elif re.match(self.testerrfmt, line):
2848 self.testerror.append(line)
2850 elif re.match(self.firmwarefmt, line):
2851 self.fwdata.append(line)
2853 elif(re.match(self.devpropfmt, line)):
2854 self.parseDevprops(line, sv)
2856 elif(re.match(self.pinfofmt, line)):
2857 self.parsePlatformInfo(line, sv)
2859 m = re.match(self.cmdlinefmt, line)
2861 self.cmdline = m.group('cmd')
2863 m = re.match(self.tracertypefmt, line)
2865 self.setTracerType(m.group('t'))
2868 def parseStamp(self, data, sv): argument
2870 m = re.match(self.stampfmt, self.stamp)
2871 if not self.stamp or not m:
2881 if re.match(self.sysinfofmt, self.sysinfo):
2882 for f in self.sysinfo.split('|'):
2892 self.machinesuspend = 'timekeeping_freeze\[.*'
2894 self.machinesuspend = 'machine_suspend\[.*'
2905 sv.cmdline = self.cmdline
2909 if sv.suspendmode == 'mem' and len(self.fwdata) > data.testnumber:
2910 m = re.match(self.firmwarefmt, self.fwdata[data.testnumber])
2916 if len(self.turbostat) > data.testnumber:
2917 m = re.match(self.tstatfmt, self.turbostat[data.testnumber])
2921 if len(self.wifi) > data.testnumber:
2922 m = re.match(self.wififmt, self.wifi[data.testnumber])
2928 if len(self.testerror) > data.testnumber:
2929 m = re.match(self.testerrfmt, self.testerror[data.testnumber])
2932 def devprops(self, data): argument
2947 def parseDevprops(self, line, sv): argument
2951 props = self.devprops(line[idx:])
2955 def parsePlatformInfo(self, line, sv): argument
2956 m = re.match(self.pinfofmt, line)
2961 sv.devprops = self.devprops(sv.b64unzip(info))
2978 def __init__(self, dataobj): argument
2979 self.data = dataobj
2980 self.ftemp = dict()
2981 self.ttemp = dict()
2984 def __init__(self): argument
2985 self.proclist = dict()
2986 self.running = False
2987 def procstat(self): argument
2988 c = ['cat /proc/[1-9]*/stat 2>/dev/null']
2998 if pid not in self.proclist:
2999 self.proclist[pid] = {'name' : name, 'user' : user, 'kern' : kern}
3001 val = self.proclist[pid]
3002 ujiff = user - val['user']
3003 kjiff = kern - val['kern']
3012 val = self.proclist[pid]
3015 out += '%s-%s %d' % (val['name'], pid, jiffies)
3016 return 'ps - '+out
3017 def processMonitor(self, tid): argument
3018 while self.running:
3019 out = self.procstat()
3022 def start(self): argument
3023 self.thread = Thread(target=self.processMonitor, args=(0,))
3024 self.running = True
3025 self.thread.start()
3026 def stop(self): argument
3027 self.running = False
3029 # ----------------- FUNCTIONS --------------------
3134 cg = testrun[testidx].ftemp[pid][-1]
3138 if(res == -1):
3139 testrun[testidx].ftemp[pid][-1].addLine(t)
3146 if len(cg.list) < 1 or cg.invalid or (cg.end - cg.start == 0):
3248 name = val[0].replace('--', '-')
3262 testrun.ttemp['thaw_processes'][-1]['end'] = t.time
3283 # -- phase changes --
3322 t.time - data.dmesg[lp]['start']
3370 testrun.ttemp[name][-1]['end'] = t.time
3371 testrun.ttemp[name][-1]['loop'] += 1
3384 testrun.ttemp[name][-1]['end'] = t.time
3397 data.newAction(phase, n, pid, p, t.time, -1, drv)
3410 dev['length'] = t.time - dev['start']
3428 'end': -1,
3459 cg = testrun.ftemp[key][-1]
3463 if(res == -1):
3464 testrun.ftemp[key][-1].addLine(t)
3502 if i < len(testruns) - 1:
3512 if event['end'] - event['begin'] <= 0:
3527 if ke - kb < 0.000001 or tlb > kb or tle <= kb:
3539 if ke - kb < 0.000001 or tlb > kb or tle <= kb:
3549 if len(cg.list) < 1 or cg.invalid or (cg.end - cg.start == 0):
3571 …sysvals.vprint('Callgraph found for task %d: %.3fms, %s' % (cg.pid, (cg.end - cg.start)*1000, name…
3619 for i in range(tc - 1):
3641 tp.stamp = datetime.now().strftime('# suspend-%m%d%y-%H%M%S localhost mem unknown')
3652 m = re.match('[ \t]*(\[ *)(?P<ktime>[0-9\.]*)(\]) (?P<msg>.*)', line)
3663 m = re.match('.* *(?P<k>[0-9]\.[0-9]{2}\.[0-9]-.*) .*', msg)
3682 mc = re.match('.*(\[ *)(?P<t>[0-9\.]*)(\]) calling '+\
3684 mr = re.match('.*(\[ *)(?P<t>[0-9\.]*)(\]) call '+\
3717 'suspend': ['PM: Entering [a-z]* sleep.*', 'Suspending console.*'],
3721 'resume_machine': ['ACPI: Low-level resume complete.*'],
3751 'emsg': 'PM: Entering (?P<mode>[a-z,A-Z]*) sleep.*' },
3757 'emsg': 'Disabling non-boot CPUs .*' },
3760 t0 = -1.0
3761 cpu_start = -1.0
3762 prevktime = -1.0
3766 m = re.match('[ \t]*(\[ *)(?P<ktime>[0-9\.]*)(\]) (?P<msg>.*)', line)
3862 # -- device callbacks --
3872 data.newAction(phase, f, int(n), p, ktime, -1, '')
3896 actions[a][-1]['end'] = ktime
3898 if(re.match('Disabling non-boot CPUs .*', msg)):
3901 elif(re.match('Enabling non-boot CPUs .*', msg)):
3904 elif(re.match('smpboot: CPU (?P<cpu>[0-9]*) is now offline', msg)):
3906 m = re.match('smpboot: CPU (?P<cpu>[0-9]*) is now offline', msg)
3912 elif(re.match('CPU(?P<cpu>[0-9]*) is up', msg)):
3914 m = re.match('CPU(?P<cpu>[0-9]*) is up', msg)
3966 cglen = (cg.end - cg.start) * 1000
4027 tdcenter = 'text-align:center;' if center else ''
4029 <meta http-equiv="content-type" content="text/html; charset=UTF-8">\n\
4032 ….stamp {width: 100%;text-align:center;background:#888;line-height:30px;color:white;font: 25px Aria…
4033 table {width:100%;border-collapse: collapse;border:1px solid;}\n\
4037 tr.alt {background-color:#ddd;}\n\
4039 .minval {background-color:#BBFFBB;}\n\
4040 .medval {background-color:#BBBBFF;}\n\
4041 .maxval {background-color:#FFBBBB;}\n\
4042 .head a {color:#000;text-decoration: none;}\n\
4053 html = summaryCSS('Summary - SleepGraph')
4090 idx = len(list[mode]['data']) - 1
4175 iMin = iMed = iMax = [-1, -1, -1]
4178 # row classes - alternate row color
4222 html = summaryCSS('Device Summary - SleepGraph', False)
4268 # row classes - alternate row color
4289 html = summaryCSS('Issues Summary - SleepGraph', False)
4312 # row classes - alternate row color
4359 data.trimFreezeTime(testruns[-1].tSuspended)
4365 …lass="traceevent{6}" style="left:{1}%;top:{2}px;height:{3}px;width:{4}%;line-height:{3}px;{7}">{5}…
4373 …'<td class="gray" title="time spent in low-power mode with clock running">'+sysvals.suspendmode+' …
4398 tTotal = data.end - data.start
4422 rtot += data.end - data.tKernRes + (data.wifi['time'] * 1000.0)
4454 wtime = '%.0f ms'%(data.end - data.tKernRes + (data.wifi['time'] * 1000.0))
4465 tMax = testruns[-1].end
4466 tTotal = tMax - t0
4499 d = testruns[0].addHorizontalDivider(msg, testruns[-1].end)
4503 d = testruns[0].addHorizontalDivider('asynchronous kernel threads', testruns[-1].end)
4525 left = '%f' % (((m0-t0)*100.0)/tTotal)
4532 left = '%f' % ((((m0-t0)*100.0)+sysvals.srgap/2)/tTotal)
4533 mTotal = mMax - m0
4537 width = '%f' % (((mTotal*100.0)-sysvals.srgap/2)/tTotal)
4542 length = phase['end']-phase['start']
4543 left = '%f' % (((phase['start']-m0)*100.0)/mTotal)
4552 right = '%f' % (((mMax-t)*100.0)/mTotal)
4576 left = '%f' % (((dev['start']-m0)*100)/mTotal)
4577 width = '%f' % (((dev['end']-dev['start'])*100)/mTotal)
4578 length = ' (%0.3f ms) ' % ((dev['end']-dev['start'])*1000)
4600 left = '%f' % (((start-m0)*100)/mTotal)
4601 width = '%f' % ((end-start)*100/mTotal)
4613 left = '%f' % (((e.time-m0)*100)/mTotal)
4630 phasedef = testruns[-1].phasedef
4653 pscolor = 'linear-gradient(to top left, #ccc, #eee)'
4658 length = phase['end']-phase['start']
4659 left = '%.3f' % (((phase['start']-t0)*100.0)/tTotal)
4674 data = testruns[-1]
4720 hoverZ = 'z-index:8;'
4734 <meta http-equiv="content-type" content="text/html; charset=UTF-8">\n\
4737 body {overflow-y:scroll;}\n\
4738 ….stamp {width:100%;text-align:center;background:gray;line-height:30px;color:white;font:25px Arial;…
4740 .callgraph {margin-top:30px;box-shadow:5px 5px 20px black;}\n\
4741 .callgraph article * {padding-left:28px;}\n\
4746 t3 {color:black;font:20px Times;white-space:nowrap;}\n\
4747 t4 {color:black;font:bold 30px Times;line-height:60px;white-space:nowrap;}\n\
4756 .time2 {font:15px Arial;border-bottom:1px solid;border-left:1px solid;border-right:1px solid;}\n\
4758 td {text-align:center;}\n\
4764 …-width="1" fill="white"/><rect x="4" y="8" width="10" height="2" style="fill:black;stroke-width:0"…
4765 …troke="black" stroke-width="1" fill="white"/><rect x="4" y="8" width="10" height="2" style="fill:b…
4766 .pf:'+cgchk+' ~ *:not(:nth-child(2)) {display:none;}\n\
4767 …oombox {position:relative;width:100%;overflow-x:scroll;-webkit-user-select:none;-moz-user-select:n…
4768 ….timeline {position:relative;font-size:14px;cursor:pointer;width:100%; overflow:hidden;background:…
4769 …bsolute;height:0%;overflow:hidden;z-index:7;line-height:30px;font-size:14px;border:1px solid;text-…
4770 .thread.ps {border-radius:3px;background:linear-gradient(to top, #ccc, #eee);}\n\
4772 ….thread.sec,.thread.sec:hover {background:black;border:0;color:white;line-height:15px;font-size:10…
4776 .jiffie {position:absolute;pointer-events: none;z-index:8;}\n\
4777 …font-size:10px;z-index:7;overflow:hidden;color:black;text-align:center;white-space:nowrap;border-r…
4778 .traceevent:hover {color:white;font-weight:bold;border:1px solid white;}\n\
4779 .phase {position:absolute;overflow:hidden;border:0px;text-align:center;}\n\
4780 ….phaselet {float:left;overflow:hidden;border:0px;text-align:center;min-height:100px;font-size:24px…
4781 ….t {position:absolute;line-height:'+('%d'%scaleTH)+'px;pointer-events:none;top:0;height:100%;borde…
4782 …err {position:absolute;top:0%;height:100%;border-right:3px solid red;color:red;font:bold 14px Time…
4783 .legend {position:relative; width:100%; height:40px; text-align:center;margin-bottom:20px}\n\
4784 …ion:absolute;cursor:pointer;top:10px; width:0px;height:20px;border:1px solid;padding-left:20px;}\n\
4785 button {height:40px;width:200px;margin-bottom:20px;margin-top:20px;font-size:24px;}\n\
4786 …ion:relative;float:right;height:25px;width:auto;margin-top:3px;margin-bottom:0;font-size:10px;text…
4788 a:link {color:white;text-decoration:none;}\n\
4792 ….version {position:relative;float:left;color:white;font-size:10px;line-height:30px;margin-left:10p…
4793 #devicedetail {min-height:100px;box-shadow:5px 5px 20px black;}\n\
4795 .tback {position:absolute;width:100%;background:linear-gradient(#ccc, #ddd);}\n\
4796 .bg {z-index:1;}\n\
4809 tMax = testruns[-1].end * 1000
4819 ' var resolution = -1;\n'\
4822 ' var rline = \'<div class="t" style="left:0;border-left:1px solid black;border-right:0;">\';\n'\
4823 ' var tTotal = tMax - t0;\n'\
4833 ' var divEdge = (mTotal - tS*(divTotal-1))*100/mTotal;\n'\
4839 ' pos = 100 - (((j)*tS*100)/mTotal) - divEdge;\n'\
4840 ' val = (j-divTotal+1)*tS;\n'\
4841 ' if(j == divTotal - 1)\n'\
4846 ' pos = 100 - (((j)*tS*100)/mTotal);\n'\
4871 ' zoombox.scrollLeft = ((left + sh) * newval / val) - sh;\n'\
4876 ' zoombox.scrollLeft = ((left + sh) * newval / val) - sh;\n'\
4884 ' var tTotal = tMax - t0;\n'\
4888 ' if(i >= tS.length) i = tS.length - 1;\n'\
4901 ' var cpu = -1;\n'\
4902 ' if(name.match("CPU_ON\[[0-9]*\]"))\n'\
4904 ' else if(name.match("CPU_OFF\[[0-9]*\]"))\n'\
4956 ' var cpu = -1;\n'\
4957 ' if(name.match("CPU_ON\[[0-9]*\]"))\n'\
4959 ' else if(name.match("CPU_OFF\[[0-9]*\]"))\n'\
4985 ' var pname = info[info.length-1];\n'\
4986 ' pd[pname] = parseFloat(info[info.length-3].slice(1));\n'\
5010 ' var time = "<t4 style=\\"font-size:"+fs+"px\\">"+pd[phases[i].id]+" ms<br></t4>";\n'\
5011 …' var pname = "<t3 style=\\"font-size:"+fs2+"px\\">"+phases[i].id.replace(new RegExp("_", "g")…
5039 ' var name = tmp[0], phase = tmp[tmp.length-1];\n'\
5059 ' var html = \'<div style="padding-top:\'+pad+\'px"><t3> <b>\'+name+\':</b>\';\n'\
5068 …' html += \'<table class=fstat style="padding-top:\'+(maxlen*5)+\'px;"><tr><th>Function</th>\';\…
5103 ' " ul {list-style-type:circle;padding-left:10px;margin-left:10px;}"+\n'\
5147 ' zoombox.scrollLeft = dragval[1] + dragval[0] - e.clientX;\n'\
5216 # runtime suspend re-enable or re-disable
5350 return os.readlink(file).split('/')[-1]
5384 '---------------------------------------------------------------------------------------------\n'\
5389 '---------------------------------------------------------------------------------------------\n'\
5391 '---------------------------------------------------------------------------------------------')
5402 dirname = dirname[:-6]
5403 device = dirname.split('/')[-1]
5423 lines[dirname] = '%-26s %-26s %1s %1s %1s %1s %1s %10s %10s' % \
5455 modes.append('mem-%s' % memmode)
5462 modes.append('disk-%s' % m.strip('[]'))
5479 'bios-vendor': (0, 4),
5480 'bios-version': (0, 5),
5481 'bios-release-date': (0, 8),
5482 'system-manufacturer': (1, 4),
5483 'system-product-name': (1, 5),
5484 'system-version': (1, 6),
5485 'system-serial-number': (1, 7),
5486 'baseboard-manufacturer': (2, 4),
5487 'baseboard-product-name': (2, 5),
5488 'baseboard-version': (2, 6),
5489 'baseboard-serial-number': (2, 7),
5490 'chassis-manufacturer': (3, 4),
5491 'chassis-type': (3, 5),
5492 'chassis-version': (3, 6),
5493 'chassis-serial-number': (3, 7),
5494 'processor-manufacturer': (4, 7),
5495 'processor-version': (4, 16),
5539 if buf[i:i+4] == b'_SM_' and i < memsize - 16:
5569 while(count < num and i <= len(buf) - 4):
5572 while n < len(buf) - 1:
5581 if idx > 0 and idx < len(data) - 1:
5582 s = data[idx-1].decode('utf-8')
5590 xset, ret = 'timeout 10 xset -d :0.0 {0}', 0
5592 xset = 'sudo -u %s %s' % (sysvals.sudouser, xset)
5604 sysvals.vprint('Display Switched: %s -> %s' % (b4, curr))
5711 recdata = fp.read(rechead[1]-8)
5743 fwData[0] = record[1] - record[0]
5798 pprint(' please choose one with -m')
5890 doError(name+': non-integer value given', True)
5909 doError(name+': non-numerical value given', True)
5939 sysvals.vprint(' %-8s : %s' % (key.upper(), sysvals.stamp[key]))
5955 sysvals.vprint('[%s - %s]' % (info[0], info[1]))
6040 num = re.search(r'[-+]?\d*\.\d+|\d+', str)
6068 m = re.match('[a-z0-9]* failed in (?P<p>\S*).*', error)
6119 m = re.match(' *<div id=\"[a,0-9]*\" *title=\"(?P<title>.*)\" class=\"thread.*', line)
6122 m = re.match('(?P<n>.*) \((?P<t>[0-9,\.]*) ms\) (?P<p>.*)', m.group('title'))
6127 name = ' '.join(name.split(' ')[:-1])
6169 for arg in ['-multi ', '-info ']:
6195 # create a summary of tests in a sub-directory
6225 pprint(' summary.html - tabular list of test data found')
6226 createHTMLDeviceSummary(testruns, os.path.join(outpath, 'summary-devices.html'), title)
6227 pprint(' summary-devices.html - kernel device list sorted by total execution time')
6228 createHTMLIssuesSummary(testruns, issues, os.path.join(outpath, 'summary-issues.html'), title)
6229 pprint(' summary-issues.html - kernel issues found sorted by frequency')
6239 doError('invalid boolean --> (%s: %s), use "true/false" or "1/0"' % (name, value), True)
6269 elif(option == 'override-timeline-functions'):
6271 elif(option == 'override-dev-timeline-functions'):
6280 sysvals.rs = -1
6284 doError('invalid value --> (%s: %s), use "enable/disable"' % (option, value), True)
6288 doError('invalid value --> (%s: %s), use %s' % (option, value, disopt), True)
6306 doError('invalid phase --> (%s: %s), valid phases are %s'\
6350 elif(option == 'callloop-maxgap'):
6351 sysvals.callloopmaxgap = getArgFloat('callloop-maxgap', value, 0.0, 1.0, False)
6352 elif(option == 'callloop-maxlen'):
6353 sysvals.callloopmaxgap = getArgFloat('callloop-maxlen', value, 0.0, 1.0, False)
6358 elif(option == 'output-dir'):
6366 doError('-dev is not compatible with -f')
6368 doError('-proc is not compatible with -f')
6399 if val[0] == '[' and val[-1] == ']':
6400 for prop in val[1:-1].split(','):
6419 for arg in re.findall('{(?P<n>[a-z,A-Z,0-9]*)}', format):
6457 ' Generates output files in subdirectory: suspend-yymmdd-HHMMSS\n'\
6463 ' -h Print this help text\n'\
6464 ' -v Print the current tool version\n'\
6465 ' -config fn Pull arguments and config options from file fn\n'\
6466 ' -verbose Print extra information during execution and analysis\n'\
6467 ' -m mode Mode to initiate for suspend (default: %s)\n'\
6468 ' -o name Overrides the output subdirectory name when running a new test\n'\
6469 ' default: suspend-{date}-{time}\n'\
6470 ' -rtcwake t Wakeup t seconds after suspend, set t to "off" to disable (default: 15)\n'\
6471 ' -addlogs Add the dmesg and ftrace logs to the html output\n'\
6472 ' -noturbostat Dont use turbostat in freeze mode (default: disabled)\n'\
6473 ' -srgap Add a visible gap in the timeline between sus/res (default: disabled)\n'\
6474 …' -skiphtml Run the test and capture the trace logs, but skip the timeline (default: disabled…
6475 ' -result fn Export a results table to a text file for parsing.\n'\
6476 ' -wifi If a wifi connection is available, check that it reconnects after resume.\n'\
6478 ' -sync Sync the filesystems before starting the test\n'\
6479 ' -rs on/off Enable/disable runtime suspend for all devices, restore all after test\n'\
6480 ' -display m Change the display mode to m for the test (on/off/standby/suspend)\n'\
6482 ' -gzip Gzip the trace and dmesg logs to save space\n'\
6483 ' -cmd {s} Run the timeline over a custom command, e.g. "sync -d"\n'\
6484 ' -proc Add usermode process info into the timeline (default: disabled)\n'\
6485 ' -dev Add kernel function calls and threads to the timeline (default: disabled)\n'\
6486 ' -x2 Run two suspend/resumes back to back (default: disabled)\n'\
6487 ' -x2delay t Include t ms delay between multiple test runs (default: 0 ms)\n'\
6488 ' -predelay t Include t ms delay before 1st suspend (default: 0 ms)\n'\
6489 ' -postdelay t Include t ms delay after last resume (default: 0 ms)\n'\
6490 ' -mindev ms Discard all device blocks shorter than ms milliseconds (e.g. 0.001 for us)\n'\
6491 ' -multi n d Execute <n> consecutive tests at <d> seconds intervals. If <n> is followed\n'\
6494 ' -maxfail n Abort a -multi run after n consecutive fails (default is 0 = never abort)\n'\
6496 ' -f Use ftrace to create device callgraphs (default: disabled)\n'\
6497 ' -ftop Use ftrace on the top level call: "%s" (default: disabled)\n'\
6498 ' -maxdepth N limit the callgraph data to N call levels (default: 0=all)\n'\
6499 ' -expandcg pre-expand the callgraph data in the html output (default: disabled)\n'\
6500 ' -fadd file Add functions to be graphed in the timeline from a list in a text file\n'\
6501 ' -filter "d1,d2,..." Filter out all but this comma-delimited list of device names\n'\
6502 ' -mincg ms Discard all callgraphs shorter than ms milliseconds (e.g. 0.001 for us)\n'\
6503 ' -cgphase P Only show callgraph data for phase P (e.g. suspend_late)\n'\
6504 ' -cgtest N Only show callgraph data for test N (e.g. 0 or 1 in an x2 run)\n'\
6505 ' -timeprec N Number of significant digits in timestamps (0:S, [3:ms], 6:us)\n'\
6506 ' -cgfilter S Filter the callgraph output in the timeline\n'\
6507 ' -cgskip file Callgraph functions to skip, off to disable (default: cgskip.txt)\n'\
6508 ' -bufsize N Set trace buffer size to N kilo-bytes (default: all of free memory)\n'\
6509 ' -devdump Print out all the raw device data for each phase\n'\
6510 ' -cgdump Print out all the raw callgraph data\n'\
6513 ' -modes List available suspend modes\n'\
6514 ' -status Test to see if the system is enabled to run this tool\n'\
6515 ' -fpdt Print out the contents of the ACPI Firmware Performance Data Table\n'\
6516 ' -wificheck Print out wifi connection info\n'\
6517 ' -x<mode> Test xset by toggling the given mode (on/off/standby/suspend)\n'\
6518 ' -sysinfo Print out system info extracted from BIOS\n'\
6519 ' -devinfo Print out the pm settings of all devices which support runtime suspend\n'\
6520 ' -cmdinfo Print out all the platform info collected before and after suspend/resume\n'\
6521 ' -flist Print the list of functions currently being captured in ftrace\n'\
6522 ' -flistall Print all functions capable of being captured in ftrace\n'\
6523 ' -summary dir Create a summary of tests in this dir [-genhtml builds missing html]\n'\
6525 ' -ftrace ftracefile Create HTML output using ftrace input (used with -dmesg)\n'\
6526 ' -dmesg dmesgfile Create HTML output using dmesg (used with -ftrace)\n'\
6530 # ----------------- MAIN --------------------
6535 simplecmds = ['-sysinfo', '-modes', '-fpdt', '-flist', '-flistall',
6536 '-devinfo', '-status', '-xon', '-xoff', '-xstandby', '-xsuspend',
6537 '-xinit', '-xreset', '-xstat', '-wificheck', '-cmdinfo']
6538 if '-f' in sys.argv:
6543 if(arg == '-m'):
6553 elif(arg == '-h'):
6556 elif(arg == '-v'):
6559 elif(arg == '-x2'):
6561 elif(arg == '-x2delay'):
6562 sysvals.x2delay = getArgInt('-x2delay', args, 0, 60000)
6563 elif(arg == '-predelay'):
6564 sysvals.predelay = getArgInt('-predelay', args, 0, 60000)
6565 elif(arg == '-postdelay'):
6566 sysvals.postdelay = getArgInt('-postdelay', args, 0, 60000)
6567 elif(arg == '-f'):
6569 elif(arg == '-ftop'):
6573 elif(arg == '-skiphtml'):
6575 elif(arg == '-cgdump'):
6577 elif(arg == '-devdump'):
6579 elif(arg == '-genhtml'):
6581 elif(arg == '-addlogs'):
6583 elif(arg == '-nologs'):
6585 elif(arg == '-addlogdmesg'):
6587 elif(arg == '-addlogftrace'):
6589 elif(arg == '-noturbostat'):
6591 elif(arg == '-verbose'):
6593 elif(arg == '-proc'):
6595 elif(arg == '-dev'):
6597 elif(arg == '-sync'):
6599 elif(arg == '-wifi'):
6601 elif(arg == '-gzip'):
6603 elif(arg == '-info'):
6607 doError('-info requires one string argument', True)
6608 elif(arg == '-rs'):
6612 doError('-rs requires "enable" or "disable"', True)
6615 sysvals.rs = -1
6620 elif(arg == '-display'):
6624 doError('-display requires an mode value', True)
6629 elif(arg == '-maxdepth'):
6630 sysvals.max_graph_depth = getArgInt('-maxdepth', args, 0, 1000)
6631 elif(arg == '-rtcwake'):
6640 sysvals.rtcwaketime = getArgInt('-rtcwake', val, 0, 3600, False)
6641 elif(arg == '-timeprec'):
6642 sysvals.setPrecision(getArgInt('-timeprec', args, 0, 6))
6643 elif(arg == '-mindev'):
6644 sysvals.mindevlen = getArgFloat('-mindev', args, 0.0, 10000.0)
6645 elif(arg == '-mincg'):
6646 sysvals.mincglen = getArgFloat('-mincg', args, 0.0, 10000.0)
6647 elif(arg == '-bufsize'):
6648 sysvals.bufsize = getArgInt('-bufsize', args, 1, 1024*1024*8)
6649 elif(arg == '-cgtest'):
6650 sysvals.cgtest = getArgInt('-cgtest', args, 0, 1)
6651 elif(arg == '-cgphase'):
6658 doError('invalid phase --> (%s: %s), valid phases are %s'\
6661 elif(arg == '-cgfilter'):
6667 elif(arg == '-skipkprobe'):
6673 elif(arg == '-cgskip'):
6684 elif(arg == '-callloop-maxgap'):
6685 sysvals.callloopmaxgap = getArgFloat('-callloop-maxgap', args, 0.0, 1.0)
6686 elif(arg == '-callloop-maxlen'):
6687 sysvals.callloopmaxlen = getArgFloat('-callloop-maxlen', args, 0.0, 1.0)
6688 elif(arg == '-cmd'):
6695 elif(arg == '-expandcg'):
6697 elif(arg == '-srgap'):
6699 elif(arg == '-maxfail'):
6700 sysvals.maxfail = getArgInt('-maxfail', args, 0, 1000000)
6701 elif(arg == '-multi'):
6705 doError('-multi requires two values', True)
6707 elif(arg == '-o'):
6713 elif(arg == '-config'):
6722 elif(arg == '-fadd'):
6731 elif(arg == '-dmesg'):
6740 elif(arg == '-ftrace'):
6749 elif(arg == '-summary'):
6759 elif(arg == '-filter'):
6765 elif(arg == '-result'):
6777 doError('-dev is not compatible with -f')
6779 doError('-proc is not compatible with -f')
6828 print('[%s - %s]\n%s\n' % out)
6831 # if instructed, re-analyze existing data files
6845 memmode = mode.split('-', 1)[-1] if '-' in mode else 'deep'
6854 if mode.startswith('disk-'):
6855 sysvals.diskmode = mode.split('-', 1)[-1]
6868 s = '-%dm' % sysvals.multitest['time']
6870 s = '-x%d' % sysvals.multitest['count']
6871 sysvals.outdir = datetime.now().strftime('suspend-%y%m%d-%H%M%S'+s)
6883 fmt = 'suspend-%y%m%d-%H%M%S'