Lines Matching +full:self +full:- +full:power

2 # SPDX-License-Identifier: GPL-2.0-only
21 # https://01.org/pm-graph
23 # git@github.com:intel/pm-graph
51 # ----------------- LIBRARIES --------------------
73 print('[%09.3f] %s' % (time.time()-mystarttime, msg))
81 # ----------------- CLASSES --------------------
85 # A global, single-instance container used to
107 cgtest = -1
125 epath = '/sys/kernel/tracing/events/power/'
126 pmdpath = '/sys/power/pm_debug_messages'
140 powerfile = '/sys/power/state'
141 mempowerfile = '/sys/power/mem_sleep'
142 diskpowerfile = '/sys/power/disk'
182 tmstart = 'SUSPEND START %Y%m%d-%H:%M:%S.%f'
183 tmend = 'RESUME COMPLETE %Y%m%d-%H:%M:%S.%f'
294 [0, 'sysinfo', 'uname', '-a'],
295 [0, 'cpuinfo', 'head', '-7', '/proc/cpuinfo'],
298 [0, 'pcidevices', 'lspci', '-tv'],
299 [0, 'usbdevices', 'lsusb', '-tv'],
300 [0, 'acpidevices', 'sh', '-c', 'ls -l /sys/bus/acpi/devices/*/physical_node'],
307 [2, 'gpecounts', 'sh', '-c', 'grep -v invalid /sys/firmware/acpi/interrupts/*'],
308 [2, 'suspendstats', 'sh', '-c', 'grep -v invalid /sys/power/suspend_stats/*'],
309 …[2, 'cpuidle', 'sh', '-c', 'grep -v invalid /sys/devices/system/cpu/cpu*/cpuidle/state*/s2idle/*'],
310 [2, 'battery', 'sh', '-c', 'grep -v invalid /sys/class/power_supply/*/*'],
311 [2, 'thermal', 'sh', '-c', 'grep . /sys/class/thermal/thermal_zone*/temp'],
319 def __init__(self): argument
320 self.archargs = 'args_'+platform.machine()
321 self.hostname = platform.node()
322 if(self.hostname == ''):
323 self.hostname = 'localhost'
330 self.rtcpath = rtc
332 self.ansi = True
333 self.testdir = datetime.now().strftime('suspend-%y%m%d-%H%M%S')
336 self.sudouser = os.environ['SUDO_USER']
337 def resetlog(self): argument
338 self.logmsg = ''
339 self.platinfo = []
340 def vprint(self, msg): argument
341 self.logmsg += msg+'\n'
342 if self.verbose or msg.startswith('WARNING:'):
344 def signalHandler(self, signum, frame): argument
345 if not self.result:
347 signame = self.signames[signum] if signum in self.signames else 'UNKNOWN'
349 self.outputResult({'error':msg})
351 def signalHandlerInit(self): argument
354 self.signames = dict()
359 signal.signal(signum, self.signalHandler)
362 self.signames[signum] = s
363 def rootCheck(self, fatal=True): argument
364 if(os.access(self.powerfile, os.W_OK)):
369 self.outputResult({'error':msg})
372 def rootUser(self, fatal=False): argument
378 self.outputResult({'error':msg})
381 def usable(self, file, ishtml=False): argument
394 def getExec(self, cmd): argument
409 def setPrecision(self, num): argument
412 self.timeformat = '%.{0}f'.format(num)
413 def setOutputFolder(self, value): argument
418 args['hostname'] = args['host'] = self.hostname
419 args['mode'] = self.suspendmode
421 def setOutputFile(self): argument
422 if self.dmesgfile != '':
423 m = re.match('(?P<name>.*)_dmesg\.txt.*', self.dmesgfile)
425 self.htmlfile = m.group('name')+'.html'
426 if self.ftracefile != '':
427 m = re.match('(?P<name>.*)_ftrace\.txt.*', self.ftracefile)
429 self.htmlfile = m.group('name')+'.html'
430 def systemInfo(self, info): argument
432 if 'baseboard-manufacturer' in info:
433 m = info['baseboard-manufacturer']
434 elif 'system-manufacturer' in info:
435 m = info['system-manufacturer']
436 if 'system-product-name' in info:
437 p = info['system-product-name']
438 elif 'baseboard-product-name' in info:
439 p = info['baseboard-product-name']
440 if m[:5].lower() == 'intel' and 'baseboard-product-name' in info:
441 p = info['baseboard-product-name']
442 c = info['processor-version'] if 'processor-version' in info else ''
443 b = info['bios-version'] if 'bios-version' in info else ''
444 r = info['bios-release-date'] if 'bios-release-date' in info else ''
445self.sysstamp = '# sysinfo | man:%s | plat:%s | cpu:%s | bios:%s | biosdate:%s | numcpu:%d | memsz…
446 (m, p, c, b, r, self.cpucount, self.memtotal, self.memfree)
447 if self.osversion:
448 self.sysstamp += ' | os:%s' % self.osversion
449 def printSystemInfo(self, fatal=False): argument
450 self.rootCheck(True)
451 out = dmidecode(self.mempath, fatal)
454 fmt = '%-24s: %s'
455 if self.osversion:
456 print(fmt % ('os-version', self.osversion))
459 print(fmt % ('cpucount', ('%d' % self.cpucount)))
460 print(fmt % ('memtotal', ('%d kB' % self.memtotal)))
461 print(fmt % ('memfree', ('%d kB' % self.memfree)))
462 def cpuInfo(self): argument
463 self.cpucount = 0
467 if re.match('^processor[ \t]*:[ \t]*[0-9]*', line):
468 self.cpucount += 1
472 m = re.match('^MemTotal:[ \t]*(?P<sz>[0-9]*) *kB', line)
474 self.memtotal = int(m.group('sz'))
475 m = re.match('^MemFree:[ \t]*(?P<sz>[0-9]*) *kB', line)
477 self.memfree = int(m.group('sz'))
478 if os.path.exists('/etc/os-release'):
479 with open('/etc/os-release', 'r') as fp:
482 self.osversion = line[12:].strip().replace('"', '')
483 def initTestOutput(self, name): argument
484 self.prefix = self.hostname
487 fmt = name+'-%m%d%y-%H%M%S'
489 self.teststamp = \
490 '# '+testtime+' '+self.prefix+' '+self.suspendmode+' '+kver
492 if self.gzip:
494 self.dmesgfile = \
495 self.testdir+'/'+self.prefix+'_'+self.suspendmode+'_dmesg.txt'+ext
496 self.ftracefile = \
497 self.testdir+'/'+self.prefix+'_'+self.suspendmode+'_ftrace.txt'+ext
498 self.htmlfile = \
499 self.testdir+'/'+self.prefix+'_'+self.suspendmode+'.html'
500 if not os.path.isdir(self.testdir):
501 os.makedirs(self.testdir)
502 self.sudoUserchown(self.testdir)
503 def getValueList(self, value): argument
509 def setDeviceFilter(self, value): argument
510 self.devicefilter = self.getValueList(value)
511 def setCallgraphFilter(self, value): argument
512 self.cgfilter = self.getValueList(value)
513 def skipKprobes(self, value): argument
514 for k in self.getValueList(value):
515 if k in self.tracefuncs:
516 del self.tracefuncs[k]
517 if k in self.dev_tracefuncs:
518 del self.dev_tracefuncs[k]
519 def setCallgraphBlacklist(self, file): argument
520 self.cgblacklist = self.listFromFile(file)
521 def rtcWakeAlarmOn(self): argument
522 call('echo 0 > '+self.rtcpath+'/wakealarm', shell=True)
523 nowtime = open(self.rtcpath+'/since_epoch', 'r').read().strip()
529 alarm = nowtime + self.rtcwaketime
530 call('echo %d > %s/wakealarm' % (alarm, self.rtcpath), shell=True)
531 def rtcWakeAlarmOff(self): argument
532 call('echo 0 > %s/wakealarm' % self.rtcpath, shell=True)
533 def initdmesg(self): argument
542 m = re.match('[ \t]*(\[ *)(?P<ktime>[0-9\.]*)(\]) (?P<msg>.*)', line)
546 self.dmesgstart = float(ktime)
547 def getdmesg(self, testdata): argument
548 op = self.writeDatafileHeader(self.dmesgfile, testdata)
556 m = re.match('[ \t]*(\[ *)(?P<ktime>[0-9\.]*)(\]) (?P<msg>.*)', line)
560 if ktime > self.dmesgstart:
564 def listFromFile(self, file): argument
573 def addFtraceFilterFunctions(self, file): argument
574 for i in self.listFromFile(file):
577 self.tracefuncs[i] = dict()
578 def getFtraceFilterFunctions(self, current): argument
579 self.rootCheck(True)
581 call('cat '+self.tpath+'available_filter_functions', shell=True)
583 master = self.listFromFile(self.tpath+'available_filter_functions')
584 for i in sorted(self.tracefuncs):
585 if 'func' in self.tracefuncs[i]:
586 i = self.tracefuncs[i]['func']
590 print(self.colorText(i))
591 def setFtraceFilterFunctions(self, list): argument
592 master = self.listFromFile(self.tpath+'available_filter_functions')
601 fp = open(self.tpath+'set_graph_function', 'w')
604 def basicKprobe(self, name): argument
605 self.kprobes[name] = {'name': name,'func': name,'args': dict(),'format': name}
606 def defaultKprobe(self, name, kdata): argument
611 if self.archargs in k:
612 k['args'] = k[self.archargs]
616 self.kprobes[name] = k
617 def kprobeColor(self, name): argument
618 if name not in self.kprobes or 'color' not in self.kprobes[name]:
620 return self.kprobes[name]['color']
621 def kprobeDisplayName(self, name, dataraw): argument
622 if name not in self.kprobes:
623 self.basicKprobe(name)
634 fmt, args = self.kprobes[name]['format'], self.kprobes[name]['args']
649 def kprobeText(self, kname, kprobe): argument
658 if self.archargs in kprobe:
659 args = kprobe[self.archargs]
662 if re.findall('{(?P<n>[a-z,A-Z,0-9]*)}', func):
664 for arg in re.findall('{(?P<n>[a-z,A-Z,0-9]*)}', fmt):
672 def addKprobes(self, output=False): argument
673 if len(self.kprobes) < 1:
679 # sort kprobes: trace, ub-dev, custom, dev
681 linesout = len(self.kprobes)
682 for name in sorted(self.kprobes):
683 res = self.colorText('YES', 32)
684 if not self.testKprobe(name, self.kprobes[name]):
685 res = self.colorText('NO')
688 if name in self.tracefuncs:
690 elif name in self.dev_tracefuncs:
691 if 'ub' in self.dev_tracefuncs[name]:
702 self.kprobes.pop(name)
704 self.fsetVal('', 'kprobe_events')
707 kprobeevents += self.kprobeText(kp, self.kprobes[kp])
708 self.fsetVal(kprobeevents, 'kprobe_events')
710 check = self.fgetVal('kprobe_events')
711 linesack = (len(check.split('\n')) - 1) // 2
713 self.fsetVal('1', 'events/kprobes/enable')
714 def testKprobe(self, kname, kprobe): argument
715 self.fsetVal('0', 'events/kprobes/enable')
716 kprobeevents = self.kprobeText(kname, kprobe)
720 self.fsetVal(kprobeevents, 'kprobe_events')
721 check = self.fgetVal('kprobe_events')
729 def setVal(self, val, file): argument
740 def fsetVal(self, val, path): argument
741 if not self.useftrace:
743 return self.setVal(val, self.tpath+path)
744 def getVal(self, file): argument
755 def fgetVal(self, path): argument
756 if not self.useftrace:
758 return self.getVal(self.tpath+path)
759 def cleanupFtrace(self): argument
760 if self.useftrace:
761 self.fsetVal('0', 'events/kprobes/enable')
762 self.fsetVal('', 'kprobe_events')
763 self.fsetVal('1024', 'buffer_size_kb')
764 def setupAllKprobes(self): argument
765 for name in self.tracefuncs:
766 self.defaultKprobe(name, self.tracefuncs[name])
767 for name in self.dev_tracefuncs:
768 self.defaultKprobe(name, self.dev_tracefuncs[name])
769 def isCallgraphFunc(self, name): argument
770 if len(self.tracefuncs) < 1 and self.suspendmode == 'command':
772 for i in self.tracefuncs:
773 if 'func' in self.tracefuncs[i]:
774 f = self.tracefuncs[i]['func']
780 def initFtrace(self, quiet=False): argument
781 if not self.useftrace:
787 self.fsetVal('0', 'tracing_on')
788 self.cleanupFtrace()
790 self.fsetVal('global', 'trace_clock')
791 self.fsetVal('nop', 'current_tracer')
793 cpus = max(1, self.cpucount)
794 if self.bufsize > 0:
795 tgtsize = self.bufsize
796 elif self.usecallgraph or self.usedevsrc:
797 bmax = (1*1024*1024) if self.suspendmode in ['disk', 'command'] \
799 tgtsize = min(self.memfree, bmax)
802 while not self.fsetVal('%d' % (tgtsize // cpus), 'buffer_size_kb'):
804 tgtsize -= 65536
806 tgtsize = int(self.fgetVal('buffer_size_kb')) * cpus
808 self.vprint('Setting trace buffers to %d kB (%d kB per cpu)' % (tgtsize, tgtsize/cpus))
810 if(self.usecallgraph):
812 self.fsetVal('function_graph', 'current_tracer')
813 self.fsetVal('', 'set_ftrace_filter')
815 fp = open(self.tpath+'set_ftrace_notrace', 'w')
819 self.fsetVal('print-parent', 'trace_options')
820 self.fsetVal('funcgraph-abstime', 'trace_options')
821 self.fsetVal('funcgraph-cpu', 'trace_options')
822 self.fsetVal('funcgraph-duration', 'trace_options')
823 self.fsetVal('funcgraph-proc', 'trace_options')
824 self.fsetVal('funcgraph-tail', 'trace_options')
825 self.fsetVal('nofuncgraph-overhead', 'trace_options')
826 self.fsetVal('context-info', 'trace_options')
827 self.fsetVal('graph-time', 'trace_options')
828 self.fsetVal('%d' % self.max_graph_depth, 'max_graph_depth')
830 if(self.usetraceevents):
832 for fn in self.tracefuncs:
833 if 'func' in self.tracefuncs[fn]:
834 cf.append(self.tracefuncs[fn]['func'])
837 if self.ftop:
838 self.setFtraceFilterFunctions([self.ftopfunc])
840 self.setFtraceFilterFunctions(cf)
842 elif self.usekprobes:
843 for name in self.tracefuncs:
844 self.defaultKprobe(name, self.tracefuncs[name])
845 if self.usedevsrc:
846 for name in self.dev_tracefuncs:
847 self.defaultKprobe(name, self.dev_tracefuncs[name])
850 self.addKprobes(self.verbose)
851 if(self.usetraceevents):
853 events = iter(self.traceevents)
855 self.fsetVal('1', 'events/power/'+e+'/enable')
857 self.fsetVal('', 'trace')
858 def verifyFtrace(self): argument
863 tp = self.tpath
864 if(self.usecallgraph):
874 def verifyKprobes(self): argument
877 tp = self.tpath
882 def colorText(self, str, color=31): argument
883 if not self.ansi:
886 def writeDatafileHeader(self, filename, testdata): argument
887 fp = self.openlog(filename, 'w')
888 fp.write('%s\n%s\n# command | %s\n' % (self.teststamp, self.sysstamp, self.cmdline))
903 def sudoUserchown(self, dir): argument
904 if os.path.exists(dir) and self.sudouser:
905 cmd = 'chown -R {0}:{0} {1} > /dev/null 2>&1'
906 call(cmd.format(self.sudouser, dir), shell=True)
907 def outputResult(self, testdata, num=0): argument
908 if not self.result:
913 fp = open(self.result, 'a')
930 self.sudoUserchown(self.result)
931 def configFile(self, file): argument
940 def openlog(self, filename, mode): argument
941 isgz = self.gzip
952 def putlog(self, filename, text): argument
953 with self.openlog(filename, 'a') as fp:
956 def dlog(self, text): argument
957 if not self.dmesgfile:
959 self.putlog(self.dmesgfile, '# %s\n' % text)
960 def flog(self, text): argument
961 self.putlog(self.ftracefile, text)
962 def b64unzip(self, data): argument
968 def b64zip(self, data): argument
971 def platforminfo(self, cmdafter): argument
973 if not os.path.exists(self.ftracefile):
978 if self.suspendmode == 'command' and self.testcommand:
979 footer += '# platform-testcmd: %s\n' % (self.testcommand)
984 tf = self.openlog(self.ftracefile, 'r')
986 if tp.stampInfo(line, self):
1002 if(re.match('.*/power', dirname) and 'async' in filenames):
1003 dev = dirname.split('/')[-2]
1005 props[dev].syspath = dirname[:-6]
1013 if os.path.exists(dirname+'/power/async'):
1014 fp = open(dirname+'/power/async')
1046 footer += '# platform-devinfo: %s\n' % self.b64zip(out)
1050 footer += '# platform-%s: %s | %s\n' % (name, cmdline, self.b64zip(info))
1051 self.flog(footer)
1053 def commonPrefix(self, list): argument
1059 prefix = prefix[:len(prefix)-1]
1062 if '/' in prefix and prefix[-1] != '/':
1065 def dictify(self, text, format): argument
1082 def cmdinfovar(self, arg): argument
1085 cmd = [self.getExec('ip'), '-4', '-o', '-br', 'addr']
1096 def cmdinfo(self, begin, debug=False): argument
1099 self.cmd1 = dict()
1100 for cargs in self.infocmds:
1103 if args[i][0] == '{' and args[i][-1] == '}':
1104 args[i] = self.cmdinfovar(args[i][1:-1])
1105 cmdline, cmdpath = ' '.join(args[0:]), self.getExec(args[0])
1108 self.dlog('[%s]' % cmdline)
1116 self.cmd1[name] = self.dictify(info, delta)
1117 elif not debug and delta and name in self.cmd1:
1118 before, after = self.cmd1[name], self.dictify(info, delta)
1120 prefix = self.commonPrefix(list(before.keys()))
1125 dinfo += '\t%s : %s -> %s\n' % \
1135 def testVal(self, file, fmt='basic', value=''): argument
1137 for f in self.cfgdef:
1140 fp.write(self.cfgdef[f])
1142 self.cfgdef = dict()
1148 self.cfgdef[file] = m.group('v')
1150 line = fp.read().strip().split('\n')[-1]
1151 m = re.match('.* (?P<v>[0-9A-Fx]*) .*', line)
1153 self.cfgdef[file] = m.group('v')
1155 self.cfgdef[file] = fp.read().strip()
1158 def s0ixSupport(self): argument
1159 if not os.path.exists(self.s0ixres) or not os.path.exists(self.mempowerfile):
1167 def haveTurbostat(self): argument
1168 if not self.tstat:
1170 cmd = self.getExec('turbostat')
1173 fp = Popen([cmd, '-v'], stdout=PIPE, stderr=PIPE).stderr
1177 self.vprint(out)
1180 def turbostat(self, s0ixready): argument
1181 cmd = self.getExec('turbostat')
1183 fullcmd = '%s -q -S echo freeze > %s' % (cmd, self.powerfile)
1184 fp = Popen(['sh', '-c', fullcmd], stdout=PIPE, stderr=PIPE).stderr
1197 self.vprint(errmsg)
1198 if not self.verbose:
1201 if self.verbose:
1211 def netfixon(self, net='both'): argument
1212 cmd = self.getExec('netfix')
1215 fp = Popen([cmd, '-s', net, 'on'], stdout=PIPE, stderr=PIPE).stdout
1219 def wifiDetails(self, dev): argument
1227 vals.append(prop.split('=')[-1])
1229 def checkWifi(self, dev=''): argument
1235 m = re.match(' *(?P<dev>.*): (?P<stat>[0-9a-f]*) .*', line)
1240 def pollWifi(self, dev, timeout=10): argument
1242 while (time.time() - start) < timeout:
1243 w = self.checkWifi(dev)
1246 (self.wifiDetails(dev), max(0, time.time() - start))
1248 return '%s timeout %d' % (self.wifiDetails(dev), timeout)
1249 def errorSummary(self, errinfo, msg): argument
1254 if self.hostname not in entry['urls']:
1255 entry['urls'][self.hostname] = [self.htmlfile]
1256 elif self.htmlfile not in entry['urls'][self.hostname]:
1257 entry['urls'][self.hostname].append(self.htmlfile)
1264 if re.match('^[0-9,\-\.]*$', arr[j]):
1265 arr[j] = '[0-9,\-\.]*'
1277 'urls': {self.hostname: [self.htmlfile]}
1280 def multistat(self, start, idx, finish): argument
1281 if 'time' in self.multitest:
1282 id = '%d Duration=%dmin' % (idx+1, self.multitest['time'])
1284 id = '%d/%d' % (idx+1, self.multitest['count'])
1286 if 'start' not in self.multitest:
1287 self.multitest['start'] = self.multitest['last'] = t
1288 self.multitest['total'] = 0.0
1291 dt = t - self.multitest['last']
1293 if idx == 0 and self.multitest['delay'] > 0:
1294 self.multitest['total'] += self.multitest['delay']
1295 pprint('TEST (%s) COMPLETE -- Duration %.1fs' % (id, dt))
1297 self.multitest['total'] += dt
1298 self.multitest['last'] = t
1299 avg = self.multitest['total'] / idx
1300 if 'time' in self.multitest:
1301 left = finish - datetime.now()
1302 left -= timedelta(microseconds=left.microseconds)
1304 left = timedelta(seconds=((self.multitest['count'] - idx) * int(avg)))
1305 pprint('TEST (%s) START - Avg Duration %.1fs, Time left %s' % \
1307 def multiinit(self, c, d): argument
1310 sz, unit, c = 'time', c[-1], c[:-1]
1311 self.multitest['run'] = True
1312 self.multitest[sz] = getArgInt('multi: n d (exec count)', c, 1, 1000000, False)
1313 self.multitest['delay'] = getArgInt('multi: n d (delay between tests)', d, 0, 3600, False)
1315 self.multitest[sz] *= 1440
1317 self.multitest[sz] *= 60
1318 def displayControl(self, cmd): argument
1319 xset, ret = 'timeout 10 xset -d :0.0 {0}', 0
1320 if self.sudouser:
1321 xset = 'sudo -u %s %s' % (self.sudouser, xset)
1329 b4 = self.displayControl('stat')
1332 curr = self.displayControl('stat')
1333 self.vprint('Display Switched: %s -> %s' % (b4, curr))
1335 self.vprint('WARNING: Display failed to change to %s' % cmd)
1337 self.vprint('WARNING: Display failed to change to %s with xset' % cmd)
1350 def setRuntimeSuspend(self, before=True): argument
1353 if self.rs > 0:
1354 self.rstgt, self.rsval, self.rsdir = 'on', 'auto', 'enabled'
1356 self.rstgt, self.rsval, self.rsdir = 'auto', 'on', 'disabled'
1358 self.rslist = deviceInfo(self.rstgt)
1359 for i in self.rslist:
1360 self.setVal(self.rsval, i)
1361 pprint('runtime suspend %s on all devices (%d changed)' % (self.rsdir, len(self.rslist)))
1365 # runtime suspend re-enable or re-disable
1366 for i in self.rslist:
1367 self.setVal(self.rstgt, i)
1368 pprint('runtime suspend settings restored on %d devices' % len(self.rslist))
1369 def start(self, pm): argument
1370 if self.useftrace:
1371 self.dlog('start ftrace tracing')
1372 self.fsetVal('1', 'tracing_on')
1373 if self.useprocmon:
1374 self.dlog('start the process monitor')
1376 def stop(self, pm): argument
1377 if self.useftrace:
1378 if self.useprocmon:
1379 self.dlog('stop the process monitor')
1381 self.dlog('stop ftrace tracing')
1382 self.fsetVal('0', 'tracing_on')
1399 def __init__(self): argument
1400 self.syspath = ''
1401 self.altname = ''
1402 self.isasync = True
1403 self.xtraclass = ''
1404 self.xtrainfo = ''
1405 def out(self, dev): argument
1406 return '%s,%s,%d;' % (dev, self.altname, self.isasync)
1407 def debug(self, dev): argument
1408 pprint('%s:\n\taltname = %s\n\t async = %s' % (dev, self.altname, self.isasync))
1409 def altName(self, dev): argument
1410 if not self.altname or self.altname == dev:
1412 return '%s [%s]' % (self.altname, dev)
1413 def xtraClass(self): argument
1414 if self.xtraclass:
1415 return ' '+self.xtraclass
1416 if not self.isasync:
1419 def xtraInfo(self): argument
1420 if self.xtraclass:
1421 return ' '+self.xtraclass
1422 if self.isasync:
1431 def __init__(self, nodename, nodedepth): argument
1432 self.name = nodename
1433 self.children = []
1434 self.depth = nodedepth
1442 # 10 sequential, non-overlapping phases of S/R
1484 'ACPI' : r'.*\bACPI *(?P<b>[A-Za-z]*) *Error[: ].*',
1486 'USBERR' : r'.*usb .*device .*, error [0-9-]*',
1487 'ATAERR' : r' *ata[0-9\.]*: .*failed.*',
1489 'TPMERR' : r'(?i) *tpm *tpm[0-9]*: .*error.*',
1491 def __init__(self, num): argument
1493 self.start = 0.0 # test start
1494 self.end = 0.0 # test end
1495 self.hwstart = 0 # rtc test start
1496 self.hwend = 0 # rtc test end
1497 self.tSuspended = 0.0 # low-level suspend start
1498 self.tResumed = 0.0 # low-level resume start
1499 self.tKernSus = 0.0 # kernel level suspend start
1500 self.tKernRes = 0.0 # kernel level resume end
1501 self.fwValid = False # is firmware data available
1502 self.fwSuspend = 0 # time spent in firmware suspend
1503 self.fwResume = 0 # time spent in firmware resume
1504 self.html_device_id = 0
1505 self.stamp = 0
1506 self.outfile = ''
1507 self.kerror = False
1508 self.wifi = dict()
1509 self.turbostat = 0
1510 self.enterfail = ''
1511 self.currphase = ''
1512 self.pstl = dict() # process timeline
1513 self.testnumber = num
1514 self.idstr = idchar[num]
1515 self.dmesgtext = [] # dmesg text file in memory
1516 self.dmesg = dict() # root data structure
1517 self.errorinfo = {'suspend':[],'resume':[]}
1518 self.tLow = [] # time spent in low-level suspends (standby/freeze)
1519 self.devpids = []
1520 self.devicegroups = 0
1521 def sortedPhases(self): argument
1522 return sorted(self.dmesg, key=lambda k:self.dmesg[k]['order'])
1523 def initDevicegroups(self): argument
1525 for phase in sorted(self.dmesg.keys()):
1529 self.dmesg[pnew] = self.dmesg.pop(phase)
1530 self.devicegroups = []
1531 for phase in self.sortedPhases():
1532 self.devicegroups.append([phase])
1533 def nextPhase(self, phase, offset): argument
1534 order = self.dmesg[phase]['order'] + offset
1535 for p in self.dmesg:
1536 if self.dmesg[p]['order'] == order:
1539 def lastPhase(self, depth=1): argument
1540 plist = self.sortedPhases()
1543 return plist[-1*depth]
1544 def turbostatInfo(self): argument
1547 for line in self.dmesgtext:
1553 out['syslpi'] = i.split('=')[-1]+'%'
1555 out['pkgpc10'] = i.split('=')[-1]+'%'
1558 def extractErrorInfo(self): argument
1559 lf = self.dmesgtext
1560 if len(self.dmesgtext) < 1 and sysvals.dmesgfile:
1569 m = re.match('[ \t]*(\[ *)(?P<ktime>[0-9\.]*)(\]) (?P<msg>.*)', line)
1573 if t < self.start or t > self.end:
1575 dir = 'suspend' if t < self.tSuspended else 'resume'
1579 for err in self.errlist:
1580 if re.match(self.errlist[err], msg):
1582 self.kerror = True
1587 self.errorinfo[dir].append((type, t, idx1, idx2))
1588 if self.kerror:
1590 if len(self.dmesgtext) < 1 and sysvals.dmesgfile:
1593 def setStart(self, time, msg=''): argument
1594 self.start = time
1597 self.hwstart = datetime.strptime(msg, sysvals.tmstart)
1599 self.hwstart = 0
1600 def setEnd(self, time, msg=''): argument
1601 self.end = time
1604 self.hwend = datetime.strptime(msg, sysvals.tmend)
1606 self.hwend = 0
1607 def isTraceEventOutsideDeviceCalls(self, pid, time): argument
1608 for phase in self.sortedPhases():
1609 list = self.dmesg[phase]['list']
1616 def sourcePhase(self, start): argument
1617 for phase in self.sortedPhases():
1620 pend = self.dmesg[phase]['end']
1623 return 'resume_complete' if 'resume_complete' in self.dmesg else ''
1624 def sourceDevice(self, phaselist, start, end, pid, type): argument
1627 list = self.dmesg[phase]['list']
1648 def addDeviceFunctionCall(self, displayname, kprobename, proc, pid, start, end, cdata, rdata): argument
1650 phases = self.sortedPhases()
1651 tgtdev = self.sourceDevice(phases, start, end, pid, 'device')
1654 if not tgtdev and pid in self.devpids:
1658 tgtdev = self.sourceDevice(phases, start, end, pid, 'thread')
1662 threadname = 'kthread-%d' % (pid)
1664 threadname = '%s-%d' % (proc, pid)
1665 tgtphase = self.sourcePhase(start)
1668 self.newAction(tgtphase, threadname, pid, '', start, end, '', ' kth', '')
1669 return self.addDeviceFunctionCall(displayname, kprobename, proc, pid, start, end, cdata, rdata)
1672 sysvals.vprint('[%f - %f] %s-%d %s %s %s' % \
1700 def overflowDevices(self): argument
1703 for phase in self.sortedPhases():
1704 list = self.dmesg[phase]['list']
1707 if dev['end'] > self.end:
1710 def mergeOverlapDevices(self, devlist): argument
1714 for phase in self.sortedPhases():
1715 list = self.dmesg[phase]['list']
1719 o = min(dev['end'], tdev['end']) - max(dev['start'], tdev['start'])
1727 def usurpTouchingThread(self, name, dev): argument
1729 for phase in self.sortedPhases():
1730 list = self.dmesg[phase]['list']
1733 if tdev['start'] - dev['end'] < 0.1:
1741 def stitchTouchingThreads(self, testlist): argument
1743 for phase in self.sortedPhases():
1744 list = self.dmesg[phase]['list']
1751 def optimizeDevSrc(self): argument
1753 for phase in self.sortedPhases():
1754 list = self.dmesg[phase]['list']
1766 p.length = p.end - p.time
1769 def trimTimeVal(self, t, t0, dT, left): argument
1772 if(t - dT < t0):
1774 return t - dT
1784 def trimTime(self, t0, dT, left): argument
1785 self.tSuspended = self.trimTimeVal(self.tSuspended, t0, dT, left)
1786 self.tResumed = self.trimTimeVal(self.tResumed, t0, dT, left)
1787 self.start = self.trimTimeVal(self.start, t0, dT, left)
1788 self.tKernSus = self.trimTimeVal(self.tKernSus, t0, dT, left)
1789 self.tKernRes = self.trimTimeVal(self.tKernRes, t0, dT, left)
1790 self.end = self.trimTimeVal(self.end, t0, dT, left)
1791 for phase in self.sortedPhases():
1792 p = self.dmesg[phase]
1793 p['start'] = self.trimTimeVal(p['start'], t0, dT, left)
1794 p['end'] = self.trimTimeVal(p['end'], t0, dT, left)
1798 d['start'] = self.trimTimeVal(d['start'], t0, dT, left)
1799 d['end'] = self.trimTimeVal(d['end'], t0, dT, left)
1800 d['length'] = d['end'] - d['start']
1803 cg.start = self.trimTimeVal(cg.start, t0, dT, left)
1804 cg.end = self.trimTimeVal(cg.end, t0, dT, left)
1806 line.time = self.trimTimeVal(line.time, t0, dT, left)
1809 e.time = self.trimTimeVal(e.time, t0, dT, left)
1810 e.end = self.trimTimeVal(e.end, t0, dT, left)
1811 e.length = e.end - e.time
1816 c0 = self.trimTimeVal(c0, t0, dT, left)
1817 cN = self.trimTimeVal(cN, t0, dT, left)
1822 for e in self.errorinfo[dir]:
1824 tm = self.trimTimeVal(tm, t0, dT, left)
1826 self.errorinfo[dir] = list
1827 def trimFreezeTime(self, tZero): argument
1830 for phase in self.sortedPhases():
1832 tS, tR = self.dmesg[lp]['end'], self.dmesg[phase]['start']
1833 tL = tR - tS
1837 self.trimTime(tS, tL, left)
1838 if 'waking' in self.dmesg[lp]:
1839 tCnt = self.dmesg[lp]['waking'][0]
1840 if self.dmesg[lp]['waking'][1] >= 0.001:
1841 tTry = '%.0f' % (round(self.dmesg[lp]['waking'][1] * 1000))
1843 tTry = '%.3f' % (self.dmesg[lp]['waking'][1] * 1000)
1847 self.tLow.append(text)
1849 def getMemTime(self): argument
1850 if not self.hwstart or not self.hwend:
1852 stime = (self.tSuspended - self.start) * 1000000
1853 rtime = (self.end - self.tResumed) * 1000000
1854 hws = self.hwstart + timedelta(microseconds=stime)
1855 hwr = self.hwend - timedelta(microseconds=rtime)
1856 self.tLow.append('%.0f'%((hwr - hws).total_seconds() * 1000))
1857 def getTimeValues(self): argument
1858 s = (self.tSuspended - self.tKernSus) * 1000
1859 r = (self.tKernRes - self.tResumed) * 1000
1861 def setPhase(self, phase, ktime, isbegin, order=-1): argument
1864 if self.currphase:
1865 if 'resume_machine' not in self.currphase:
1866 sysvals.vprint('WARNING: phase %s failed to end' % self.currphase)
1867 self.dmesg[self.currphase]['end'] = ktime
1868 phases = self.dmesg.keys()
1869 color = self.phasedef[phase]['color']
1874 self.dmesg[phase] = {'list': dict(), 'start': -1.0, 'end': -1.0,
1876 self.dmesg[phase]['start'] = ktime
1877 self.currphase = phase
1880 if phase not in self.currphase:
1881 if self.currphase:
1882 sysvals.vprint('WARNING: %s ended instead of %s, ftrace corruption?' % (phase, self.currphase))
1886 phase = self.currphase
1887 self.dmesg[phase]['end'] = ktime
1888 self.currphase = ''
1890 def sortedDevices(self, phase): argument
1891 list = self.dmesg[phase]['list']
1893 def fixupInitcalls(self, phase): argument
1895 phaselist = self.dmesg[phase]['list']
1899 for p in self.sortedPhases():
1900 if self.dmesg[p]['end'] > dev['start']:
1901 dev['end'] = self.dmesg[p]['end']
1904 def deviceFilter(self, devicefilter): argument
1905 for phase in self.sortedPhases():
1906 list = self.dmesg[phase]['list']
1918 def fixupInitcallsThatDidntReturn(self): argument
1920 for phase in self.sortedPhases():
1921 self.fixupInitcalls(phase)
1922 def phaseOverlap(self, phases): argument
1925 for group in self.devicegroups:
1935 self.devicegroups.remove(group)
1936 self.devicegroups.append(newgroup)
1937 def newActionGlobal(self, name, start, end, pid=-1, color=''): argument
1939 phases = self.sortedPhases()
1945 pstart = self.dmesg[phase]['start']
1946 pend = self.dmesg[phase]['end']
1948 o = max(0, min(end, pend) - max(start, pstart))
1959 p0start = self.dmesg[phases[0]]['start']
1963 targetphase = phases[-1]
1964 if pid == -2:
1966 elif pid == -3:
1970 self.phaseOverlap(myphases)
1972 newname = self.newAction(targetphase, name, pid, '', start, end, '', htmlclass, color)
1975 def newAction(self, phase, name, pid, parent, start, end, drv, htmlclass='', color=''): argument
1977 self.html_device_id += 1
1978 devid = '%s%d' % (self.idstr, self.html_device_id)
1979 list = self.dmesg[phase]['list']
1980 length = -1.0
1982 length = end - start
1983 if pid == -2 or name not in sysvals.tracefuncs.keys():
1996 def findDevice(self, phase, name): argument
1997 list = self.dmesg[phase]['list']
2000 if name == devname or re.match('^%s\[(?P<num>[0-9]*)\]$' % name, devname):
2005 def deviceChildren(self, devname, phase): argument
2007 list = self.dmesg[phase]['list']
2012 def maxDeviceNameSize(self, phase): argument
2014 for name in self.dmesg[phase]['list']:
2018 def printDetails(self): argument
2020 sysvals.vprint(' test start: %f' % self.start)
2021 sysvals.vprint('kernel suspend start: %f' % self.tKernSus)
2023 for phase in self.sortedPhases():
2024 devlist = self.dmesg[phase]['list']
2025 dc, ps, pe = len(devlist), self.dmesg[phase]['start'], self.dmesg[phase]['end']
2026 if not tS and ps >= self.tSuspended:
2027 sysvals.vprint(' machine suspended: %f' % self.tSuspended)
2029 if not tR and ps >= self.tResumed:
2030 sysvals.vprint(' machine resumed: %f' % self.tResumed)
2032 sysvals.vprint('%20s: %f - %f (%d devices)' % (phase, ps, pe, dc))
2034 sysvals.vprint(''.join('-' for i in range(80)))
2035 maxname = '%d' % self.maxDeviceNameSize(phase)
2036 fmt = '%3d) %'+maxname+'s - %f - %f'
2043 sysvals.vprint(''.join('-' for i in range(80)))
2044 sysvals.vprint(' kernel resume end: %f' % self.tKernRes)
2045 sysvals.vprint(' test end: %f' % self.end)
2046 def deviceChildrenAllPhases(self, devname): argument
2048 for phase in self.sortedPhases():
2049 list = self.deviceChildren(devname, phase)
2054 def masterTopology(self, name, list, depth): argument
2060 clist = self.deviceChildrenAllPhases(cname)
2061 cnode = self.masterTopology(cname, clist, depth+1)
2064 def printTopology(self, node): argument
2069 for phase in self.sortedPhases():
2070 list = self.dmesg[phase]['list']
2076 info += ('<li>%s: %.3fms</li>' % (phase, (e-s)*1000))
2084 html += self.printTopology(cnode)
2087 def rootDeviceList(self): argument
2090 for phase in self.sortedPhases():
2091 list = self.dmesg[phase]['list']
2095 # list of top-most root devices
2097 for phase in self.sortedPhases():
2098 list = self.dmesg[phase]['list']
2102 if(pid < 0 or re.match('[0-9]*-[0-9]*\.[0-9]*[\.0-9]*\:[\.0-9]*$', pdev)):
2107 def deviceTopology(self): argument
2108 rootlist = self.rootDeviceList()
2109 master = self.masterTopology('', rootlist, 0)
2110 return self.printTopology(master)
2111 def selectTimelineDevices(self, widfmt, tTotal, mindevlen): argument
2113 self.tdevlist = dict()
2114 for phase in self.dmesg:
2116 list = self.dmesg[phase]['list']
2118 length = (list[dev]['end'] - list[dev]['start']) * 1000
2119 width = widfmt % (((list[dev]['end']-list[dev]['start'])*100)/tTotal)
2122 self.tdevlist[phase] = devlist
2123 def addHorizontalDivider(self, devname, devend): argument
2125 self.newAction(phase, devname, -2, '', \
2126 self.start, devend, '', ' sec', '')
2127 if phase not in self.tdevlist:
2128 self.tdevlist[phase] = []
2129 self.tdevlist[phase].append(devname)
2130 d = DevItem(0, phase, self.dmesg[phase]['list'][devname])
2132 def addProcessUsageEvent(self, name, times): argument
2135 tlast = start = end = -1
2140 if name in self.pstl[t] and self.pstl[t][name] > 0:
2144 maxj = (t - tlast) * 1024.0
2145 cpuexec[key] = min(1.0, float(self.pstl[t][name]) / maxj)
2150 out = self.newActionGlobal(name, start, end, -3)
2153 dev = self.dmesg[phase]['list'][devname]
2155 def createProcessUsageEvents(self): argument
2159 for t in sorted(self.pstl):
2160 dir = 'sus' if t < self.tSuspended else 'res'
2161 for ps in sorted(self.pstl[t]):
2170 self.addProcessUsageEvent(ps, tdata[dir])
2171 def handleEndMarker(self, time, msg=''): argument
2172 dm = self.dmesg
2173 self.setEnd(time, msg)
2174 self.initDevicegroups()
2180 np = self.nextPhase('resume_machine', 1)
2184 if self.tKernRes == 0.0:
2185 self.tKernRes = time
2187 if self.tKernSus == 0.0:
2188 self.tKernSus = time
2192 def initcall_debug_call(self, line, quick=False): argument
2193 m = re.match('.*(\[ *)(?P<t>[0-9\.]*)(\]) .* (?P<f>.*)\: '+\
2196 m = re.match('.*(\[ *)(?P<t>[0-9\.]*)(\]) .* (?P<f>.*)\: '+\
2199 m = re.match('.*(\[ *)(?P<t>[0-9\.]*)(\]) calling '+\
2204 def initcall_debug_return(self, line, quick=False): argument
2205 m = re.match('.*(\[ *)(?P<t>[0-9\.]*)(\]) .* (?P<f>.*)\: PM: '+\
2206 '.* returned (?P<r>[0-9]*) after (?P<dt>[0-9]*) usecs', line)
2208 m = re.match('.*(\[ *)(?P<t>[0-9\.]*)(\]) .* (?P<f>.*)\: '+\
2209 '.* returned (?P<r>[0-9]*) after (?P<dt>[0-9]*) usecs', line)
2211 m = re.match('.*(\[ *)(?P<t>[0-9\.]*)(\]) call '+\
2216 def debugPrint(self): argument
2217 for p in self.sortedPhases():
2218 list = self.dmesg[p]['list']
2228 def __init__(self, name, args, caller, ret, start, end, u, proc, pid, color): argument
2229 self.row = 0
2230 self.count = 1
2231 self.name = name
2232 self.args = args
2233 self.caller = caller
2234 self.ret = ret
2235 self.time = start
2236 self.length = end - start
2237 self.end = end
2238 self.ubiquitous = u
2239 self.proc = proc
2240 self.pid = pid
2241 self.color = color
2242 def title(self): argument
2244 if self.count > 1:
2245 cnt = '(x%d)' % self.count
2246 l = '%0.3fms' % (self.length * 1000)
2247 if self.ubiquitous:
2248 title = '%s(%s)%s <- %s, %s(%s)' % \
2249 (self.name, self.args, cnt, self.caller, self.ret, l)
2251 title = '%s(%s) %s%s(%s)' % (self.name, self.args, self.ret, cnt, l)
2253 def text(self): argument
2254 if self.count > 1:
2255 text = '%s(x%d)' % (self.name, self.count)
2257 text = self.name
2259 def repeat(self, tgt): argument
2261 dt = self.time - tgt.end
2262 # only combine calls if -all- attributes are identical
2263 if tgt.caller == self.caller and \
2264 tgt.name == self.name and tgt.args == self.args and \
2265 tgt.proc == self.proc and tgt.pid == self.pid and \
2266 tgt.ret == self.ret and dt >= 0 and \
2268 self.length < sysvals.callloopmaxlen:
2284 def __init__(self, t, m='', d=''): argument
2285 self.length = 0.0
2286 self.fcall = False
2287 self.freturn = False
2288 self.fevent = False
2289 self.fkprobe = False
2290 self.depth = 0
2291 self.name = ''
2292 self.type = ''
2293 self.time = float(t)
2308 self.name = emm.group('msg')
2309 self.type = emm.group('call')
2311 self.name = msg
2312 km = re.match('^(?P<n>.*)_cal$', self.type)
2314 self.fcall = True
2315 self.fkprobe = True
2316 self.type = km.group('n')
2318 km = re.match('^(?P<n>.*)_ret$', self.type)
2320 self.freturn = True
2321 self.fkprobe = True
2322 self.type = km.group('n')
2324 self.fevent = True
2328 self.length = float(d)/1000000
2333 self.depth = self.getDepth(match.group('d'))
2337 self.freturn = True
2342 self.name = match.group('n').strip()
2345 self.fcall = True
2347 if(m[-1] == '{'):
2350 self.name = match.group('n').strip()
2352 elif(m[-1] == ';'):
2353 self.freturn = True
2356 self.name = match.group('n').strip()
2359 self.name = m
2360 def isCall(self): argument
2361 return self.fcall and not self.freturn
2362 def isReturn(self): argument
2363 return self.freturn and not self.fcall
2364 def isLeaf(self): argument
2365 return self.fcall and self.freturn
2366 def getDepth(self, str): argument
2368 def debugPrint(self, info=''): argument
2369 if self.isLeaf():
2370 pprint(' -- %12.6f (depth=%02d): %s(); (%.3f us) %s' % (self.time, \
2371 self.depth, self.name, self.length*1000000, info))
2372 elif self.freturn:
2373 pprint(' -- %12.6f (depth=%02d): %s} (%.3f us) %s' % (self.time, \
2374 self.depth, self.name, self.length*1000000, info))
2376 pprint(' -- %12.6f (depth=%02d): %s() { (%.3f us) %s' % (self.time, \
2377 self.depth, self.name, self.length*1000000, info))
2378 def startMarker(self): argument
2380 if not self.fevent:
2383 if(self.name.startswith('SUSPEND START')):
2387 if(self.type == 'suspend_resume' and
2388 re.match('suspend_enter\[.*\] begin', self.name)):
2391 def endMarker(self): argument
2393 if not self.fevent:
2396 if(self.name.startswith('RESUME COMPLETE')):
2400 if(self.type == 'suspend_resume' and
2401 re.match('thaw_processes\[.*\] end', self.name)):
2413 def __init__(self, pid, sv): argument
2414 self.id = ''
2415 self.invalid = False
2416 self.name = ''
2417 self.partial = False
2418 self.ignore = False
2419 self.start = -1.0
2420 self.end = -1.0
2421 self.list = []
2422 self.depth = 0
2423 self.pid = pid
2424 self.sv = sv
2425 def addLine(self, line): argument
2427 if(self.invalid):
2432 if(self.depth < 0):
2433 self.invalidate(line)
2436 if self.ignore:
2437 if line.depth > self.depth:
2440 self.list[-1].freturn = True
2441 self.list[-1].length = line.time - self.list[-1].time
2442 self.ignore = False
2443 # if this is a return at self.depth, no more work is needed
2444 if line.depth == self.depth and line.isReturn():
2446 self.end = line.time
2449 # compare current depth with this lines pre-call depth
2455 if len(self.list) > 0:
2456 last = self.list[-1]
2461 mismatch = prelinedep - self.depth
2462 warning = self.sv.verbose and abs(mismatch) > 1
2467 while prelinedep < self.depth:
2468 self.depth -= 1
2471 last.depth = self.depth
2473 last.length = line.time - last.time
2478 vline.depth = self.depth
2479 vline.name = self.vfname
2481 self.list.append(vline)
2495 while prelinedep > self.depth:
2499 prelinedep -= 1
2504 vline.depth = self.depth
2505 vline.name = self.vfname
2507 self.list.append(vline)
2508 self.depth += 1
2510 self.start = vline.time
2524 md = self.sv.max_graph_depth
2527 if (md and self.depth >= md - 1) or (line.name in self.sv.cgblacklist):
2528 self.ignore = True
2530 self.depth += 1
2532 self.depth -= 1
2536 (line.name in self.sv.cgblacklist):
2537 while len(self.list) > 0 and self.list[-1].depth > line.depth:
2538 self.list.pop(-1)
2539 if len(self.list) == 0:
2540 self.invalid = True
2542 self.list[-1].freturn = True
2543 self.list[-1].length = line.time - self.list[-1].time
2544 self.list[-1].name = line.name
2546 if len(self.list) < 1:
2547 self.start = line.time
2550 if mismatch < 0 and self.list[-1].depth == 0 and self.list[-1].freturn:
2551 line = self.list[-1]
2553 res = -1
2555 self.list.append(line)
2557 if(self.start < 0):
2558 self.start = line.time
2559 self.end = line.time
2561 self.end += line.length
2562 if self.list[0].name == self.vfname:
2563 self.invalid = True
2564 if res == -1:
2565 self.partial = True
2568 def invalidate(self, line): argument
2569 if(len(self.list) > 0):
2570 first = self.list[0]
2571 self.list = []
2572 self.list.append(first)
2573 self.invalid = True
2574 id = 'task %s' % (self.pid)
2575 window = '(%f - %f)' % (self.start, line.time)
2576 if(self.depth < 0):
2582 def slice(self, dev): argument
2583 minicg = FTraceCallGraph(dev['pid'], self.sv)
2584 minicg.name = self.name
2585 mydepth = -1
2587 for l in self.list:
2597 l.depth -= mydepth
2602 def repair(self, enddepth): argument
2605 last = self.list[-1]
2610 fixed = self.addLine(t)
2612 self.end = last.time
2615 def postProcess(self): argument
2616 if len(self.list) > 0:
2617 self.name = self.list[0].name
2621 for l in self.list:
2625 if last.length > l.time - last.time:
2626 last.length = l.time - last.time
2632 if self.sv.verbose:
2638 cl.length = l.time - cl.time
2639 if cl.name == self.vfname:
2643 cnt -= 1
2649 if self.sv.verbose:
2653 return self.repair(cnt)
2654 def deviceMatch(self, pid, data): argument
2661 if(self.name in borderphase):
2662 p = borderphase[self.name]
2667 self.start <= dev['start'] and
2668 self.end >= dev['end']):
2669 cg = self.slice(dev)
2675 if(data.dmesg[p]['start'] <= self.start and
2676 self.start <= data.dmesg[p]['end']):
2681 self.start <= dev['start'] and
2682 self.end >= dev['end']):
2683 dev['ftrace'] = self
2688 def newActionFromFunction(self, data): argument
2689 name = self.name
2692 fs = self.start
2693 fe = self.end
2698 if(data.dmesg[p]['start'] <= self.start and
2699 self.start < data.dmesg[p]['end']):
2704 out = data.newActionGlobal(name, fs, fe, -2)
2707 data.dmesg[phase]['list'][myname]['ftrace'] = self
2708 def debugPrint(self, info=''): argument
2709 pprint('%s pid=%d [%f - %f] %.3f us' % \
2710 (self.name, self.pid, self.start, self.end,
2711 (self.end - self.start)*1000000))
2712 for l in self.list:
2725 def __init__(self, test, phase, dev): argument
2726 self.test = test
2727 self.phase = phase
2728 self.dev = dev
2729 def isa(self, cls): argument
2730 if 'htmlclass' in self.dev and cls in self.dev['htmlclass']:
2744 def __init__(self, rowheight, scaleheight): argument
2745 self.html = ''
2746 self.height = 0 # total timeline height
2747 self.scaleH = scaleheight # timescale (top) row height
2748 self.rowH = rowheight # device row height
2749 self.bodyH = 0 # body height
2750 self.rows = 0 # total timeline rows
2751 self.rowlines = dict()
2752 self.rowheight = dict()
2753 def createHeader(self, sv, stamp): argument
2756 self.html += '<div class="version"><a href="https://01.org/pm-graph">%s v%s</a></div>' \
2759 self.html += '<button id="showtest" class="logbtn btnfmt">log</button>'
2761 self.html += '<button id="showdmesg" class="logbtn btnfmt">dmesg</button>'
2763 self.html += '<button id="showftrace" class="logbtn btnfmt">ftrace</button>'
2765 self.html += headline_stamp.format(stamp['host'], stamp['kernel'],
2770 self.html += headline_sysinfo.format(stamp['man'], stamp['plat'], stamp['cpu'])
2779 def getDeviceRows(self, rawlist): argument
2783 item.row = -1
2809 remaining -= 1
2820 def getPhaseRows(self, devlist, row=0, sortby='length'): argument
2826 # initialize all device rows to -1 and calculate devrows
2832 dev['row'] = -1
2835 sortdict[item] = (-1*float(dev['start']), float(dev['end']) - float(dev['start']))
2838 sortdict[item] = (float(dev['end']) - float(dev['start']), item.dev['name'])
2840 dev['devrows'] = self.getDeviceRows(dev['src'])
2845 if item.dev['pid'] == -2:
2871 remaining -= 1
2875 if t not in self.rowlines or t not in self.rowheight:
2876 self.rowlines[t] = dict()
2877 self.rowheight[t] = dict()
2878 if p not in self.rowlines[t] or p not in self.rowheight[t]:
2879 self.rowlines[t][p] = dict()
2880 self.rowheight[t][p] = dict()
2881 rh = self.rowH
2887 self.rowlines[t][p][row] = rowheight
2888 self.rowheight[t][p][row] = rowheight * rh
2890 if(row > self.rows):
2891 self.rows = int(row)
2893 def phaseRowHeight(self, test, phase, row): argument
2894 return self.rowheight[test][phase][row]
2895 def phaseRowTop(self, test, phase, row): argument
2897 for i in sorted(self.rowheight[test][phase]):
2900 top += self.rowheight[test][phase][i]
2902 def calcTotalRows(self): argument
2906 for t in self.rowlines:
2907 for p in self.rowlines[t]:
2909 for i in sorted(self.rowlines[t][p]):
2910 total += self.rowlines[t][p][i]
2913 if total == len(self.rowlines[t][p]):
2915 self.height = self.scaleH + (maxrows*self.rowH)
2916 self.bodyH = self.height - self.scaleH
2919 for i in sorted(self.rowheight[t][p]):
2920 self.rowheight[t][p][i] = float(self.bodyH)/len(self.rowlines[t][p])
2921 def createZoomBox(self, mode='command', testcount=1): argument
2923 …html_zoombox = '<center><button id="zoomin">ZOOM IN +</button><button id="zoomout">ZOOM OUT -</but…
2929 self.html += html_devlist2
2930 self.html += html_devlist1.format('1')
2932 self.html += html_devlist1.format('')
2933 self.html += html_zoombox
2934 self.html += html_timeline.format('dmesg', self.height)
2945 def createTimeScale(self, m0, mMax, tTotal, mode): argument
2947 rline = '<div class="t" style="left:0;border-left:1px solid black;border-right:0;">{0}</div>\n'
2950 mTotal = mMax - m0
2957 divEdge = (mTotal - tS*(divTotal-1))*100/mTotal
2961 pos = '%0.3f' % (100 - ((float(i)*tS*100)/mTotal) - divEdge)
2962 val = '%0.fms' % (float(i-divTotal+1)*tS*1000)
2963 if(i == divTotal - 1):
2967 pos = '%0.3f' % (100 - ((float(i)*tS*100)/mTotal))
2973 self.html += output+'</div>\n'
2979 stampfmt = '# [a-z]*-(?P<m>[0-9]{2})(?P<d>[0-9]{2})(?P<y>[0-9]{2})-'+\
2980 '(?P<H>[0-9]{2})(?P<M>[0-9]{2})(?P<S>[0-9]{2})'+\
2982 wififmt = '^# wifi *(?P<d>\S*) *(?P<s>\S*) *(?P<t>[0-9\.]+).*'
2989 pinfofmt = '# platform-(?P<val>[a-z,A-Z,0-9,_]*): (?P<info>.*)'
2991 firmwarefmt = '# fwsuspend (?P<s>[0-9]*) fwresume (?P<r>[0-9]*)$'
2992 procexecfmt = 'ps - (?P<ps>.*)$'
2993 procmultifmt = '@(?P<n>[0-9]*)\|(?P<ps>.*)$'
2995 '^ *(?P<time>[0-9\.]*) *\| *(?P<cpu>[0-9]*)\)'+\
2996 ' *(?P<proc>.*)-(?P<pid>[0-9]*) *\|'+\
2997 '[ +!#\*@$]*(?P<dur>[0-9\.]*) .*\| (?P<msg>.*)'
2999 ' *(?P<proc>.*)-(?P<pid>[0-9]*) *\[(?P<cpu>[0-9]*)\] *'+\
3000 '(?P<flags>\S*) *(?P<time>[0-9\.]*): *'+\
3006 def __init__(self): argument
3007 self.stamp = ''
3008 self.sysinfo = ''
3009 self.cmdline = ''
3010 self.testerror = []
3011 self.turbostat = []
3012 self.wifi = []
3013 self.fwdata = []
3014 self.ftrace_line_fmt = self.ftrace_line_fmt_nop
3015 self.cgformat = False
3016 self.data = 0
3017 self.ktemp = dict()
3018 def setTracerType(self, tracer): argument
3020 self.cgformat = True
3021 self.ftrace_line_fmt = self.ftrace_line_fmt_fg
3023 self.ftrace_line_fmt = self.ftrace_line_fmt_nop
3026 def stampInfo(self, line, sv): argument
3027 if re.match(self.stampfmt, line):
3028 self.stamp = line
3030 elif re.match(self.sysinfofmt, line):
3031 self.sysinfo = line
3033 elif re.match(self.tstatfmt, line):
3034 self.turbostat.append(line)
3036 elif re.match(self.wififmt, line):
3037 self.wifi.append(line)
3039 elif re.match(self.testerrfmt, line):
3040 self.testerror.append(line)
3042 elif re.match(self.firmwarefmt, line):
3043 self.fwdata.append(line)
3045 elif(re.match(self.devpropfmt, line)):
3046 self.parseDevprops(line, sv)
3048 elif(re.match(self.pinfofmt, line)):
3049 self.parsePlatformInfo(line, sv)
3051 m = re.match(self.cmdlinefmt, line)
3053 self.cmdline = m.group('cmd')
3055 m = re.match(self.tracertypefmt, line)
3057 self.setTracerType(m.group('t'))
3060 def parseStamp(self, data, sv): argument
3062 m = re.match(self.stampfmt, self.stamp)
3063 if not self.stamp or not m:
3073 if re.match(self.sysinfofmt, self.sysinfo):
3074 for f in self.sysinfo.split('|'):
3084 self.machinesuspend = 'timekeeping_freeze\[.*'
3086 self.machinesuspend = 'machine_suspend\[.*'
3097 sv.cmdline = self.cmdline
3101 if sv.suspendmode == 'mem' and len(self.fwdata) > data.testnumber:
3102 m = re.match(self.firmwarefmt, self.fwdata[data.testnumber])
3108 if len(self.turbostat) > data.testnumber:
3109 m = re.match(self.tstatfmt, self.turbostat[data.testnumber])
3113 if len(self.wifi) > data.testnumber:
3114 m = re.match(self.wififmt, self.wifi[data.testnumber])
3120 if len(self.testerror) > data.testnumber:
3121 m = re.match(self.testerrfmt, self.testerror[data.testnumber])
3124 def devprops(self, data): argument
3139 def parseDevprops(self, line, sv): argument
3143 props = self.devprops(line[idx:])
3147 def parsePlatformInfo(self, line, sv): argument
3148 m = re.match(self.pinfofmt, line)
3153 sv.devprops = self.devprops(sv.b64unzip(info))
3170 def __init__(self, dataobj): argument
3171 self.data = dataobj
3172 self.ftemp = dict()
3173 self.ttemp = dict()
3177 def __init__(self): argument
3178 self.proclist = dict()
3179 self.running = False
3180 def procstat(self): argument
3181 c = ['cat /proc/[1-9]*/stat 2>/dev/null']
3191 if pid not in self.proclist:
3192 self.proclist[pid] = {'name' : name, 'user' : user, 'kern' : kern}
3194 val = self.proclist[pid]
3195 ujiff = user - val['user']
3196 kjiff = kern - val['kern']
3205 val = self.proclist[pid]
3206 if len(out[-1]) > self.maxchars:
3208 elif len(out[-1]) > 0:
3209 out[-1] += ','
3210 out[-1] += '%s-%s %d' % (val['name'], pid, jiffies)
3213 sysvals.fsetVal('ps - @%d|%s' % (len(out), line), 'trace_marker')
3215 sysvals.fsetVal('ps - %s' % out[0], 'trace_marker')
3216 def processMonitor(self, tid): argument
3217 while self.running:
3218 self.procstat()
3219 def start(self): argument
3220 self.thread = Thread(target=self.processMonitor, args=(0,))
3221 self.running = True
3222 self.thread.start()
3223 def stop(self): argument
3224 self.running = False
3226 # ----------------- FUNCTIONS --------------------
3330 cg = testrun[testidx].ftemp[pid][-1]
3334 if(res == -1):
3335 testrun[testidx].ftemp[pid][-1].addLine(t)
3342 if len(cg.list) < 1 or cg.invalid or (cg.end - cg.start == 0):
3492 name = val[0].replace('--', '-')
3510 testrun.ttemp['thaw_processes'][-1]['end'] = t.time
3531 # -- phase changes --
3571 t.time - data.dmesg[lp]['start']
3619 testrun.ttemp[name][-1]['end'] = t.time
3620 testrun.ttemp[name][-1]['loop'] += 1
3633 testrun.ttemp[name][-1]['end'] = t.time
3646 data.newAction(phase, n, pid, p, t.time, -1, drv)
3659 dev['length'] = t.time - dev['start']
3677 'end': -1,
3692 if (t.time - e['begin']) * 1000 < sysvals.mindevlen:
3711 cg = testrun.ftemp[key][-1]
3715 if(res == -1):
3716 testrun.ftemp[key][-1].addLine(t)
3753 if i < len(testruns) - 1:
3763 if event['end'] - event['begin'] <= 0:
3778 if ke - kb < 0.000001 or tlb > kb or tle <= kb:
3790 if ke - kb < 0.000001 or tlb > kb or tle <= kb:
3800 if len(cg.list) < 1 or cg.invalid or (cg.end - cg.start == 0):
3822 …sysvals.vprint('Callgraph found for task %d: %.3fms, %s' % (cg.pid, (cg.end - cg.start)*1000, name…
3842 terr = 'test%s did not enter %s power mode' % (tn, sm)
3876 for i in range(tc - 1):
3896 tp.stamp = datetime.now().strftime('# suspend-%m%d%y-%H%M%S localhost mem unknown')
3907 m = re.match('[ \t]*(\[ *)(?P<ktime>[0-9\.]*)(\]) (?P<msg>.*)', line)
3919 m = re.match('.* *(?P<k>[0-9]\.[0-9]{2}\.[0-9]-.*) .*', msg)
3975 'suspend': ['PM: Entering [a-z]* sleep.*', 'Suspending console.*',
3981 'suspend_machine': ['PM: suspend-to-idle',
3985 'ACPI: Low-level resume complete.*',
3987 'Suspended for [0-9\.]* seconds'],
3988 'resume_noirq': ['PM: resume from suspend-to-idle',
4003 'emsg': 'PM: Preparing system for[a-z]* sleep.*' },
4015 'emsg': 'Disabling non-boot CPUs .*' },
4018 t0 = -1.0
4019 cpu_start = -1.0
4020 prevktime = -1.0
4024 m = re.match('[ \t]*(\[ *)(?P<ktime>[0-9\.]*)(\]) (?P<msg>.*)', line)
4121 # -- device callbacks --
4126 data.newAction(phase, f, int(n), p, ktime, -1, '')
4145 if(a in actions and actions[a][-1]['begin'] == actions[a][-1]['end']):
4146 actions[a][-1]['end'] = ktime
4148 if(re.match('Disabling non-boot CPUs .*', msg)):
4151 elif(re.match('Enabling non-boot CPUs .*', msg)):
4154 elif(re.match('smpboot: CPU (?P<cpu>[0-9]*) is now offline', msg) \
4155 or re.match('psci: CPU(?P<cpu>[0-9]*) killed.*', msg)):
4157 m = re.match('smpboot: CPU (?P<cpu>[0-9]*) is now offline', msg)
4159 m = re.match('psci: CPU(?P<cpu>[0-9]*) killed.*', msg)
4165 elif(re.match('CPU(?P<cpu>[0-9]*) is up', msg)):
4167 m = re.match('CPU(?P<cpu>[0-9]*) is up', msg)
4221 cglen = (cg.end - cg.start) * 1000
4284 tdcenter = 'text-align:center;' if center else ''
4286 <meta http-equiv="content-type" content="text/html; charset=UTF-8">\n\
4289 ….stamp {width: 100%;text-align:center;background:#888;line-height:30px;color:white;font: 25px Aria…
4290 table {width:100%;border-collapse: collapse;border:1px solid;}\n\
4294 tr.alt {background-color:#ddd;}\n\
4296 .minval {background-color:#BBFFBB;}\n\
4297 .medval {background-color:#BBBBFF;}\n\
4298 .maxval {background-color:#FFBBBB;}\n\
4299 .head a {color:#000;text-decoration: none;}\n\
4310 html = summaryCSS('Summary - SleepGraph')
4347 idx = len(list[mode]['data']) - 1
4432 iMin = iMed = iMax = [-1, -1, -1]
4435 # row classes - alternate row color
4479 html = summaryCSS('Device Summary - SleepGraph', False)
4525 # row classes - alternate row color
4546 html = summaryCSS('Issues Summary - SleepGraph', False)
4569 # row classes - alternate row color
4616 data.trimFreezeTime(testruns[-1].tSuspended)
4622 …lass="traceevent{6}" style="left:{1}%;top:{2}px;height:{3}px;width:{4}%;line-height:{3}px;{7}">{5}…
4630 …'<td class="gray" title="time spent in low-power mode with clock running">'+sysvals.suspendmode+' …
4655 tTotal = data.end - data.start
4679 rtot += data.end - data.tKernRes + (data.wifi['time'] * 1000.0)
4711 wtime = '%.0f ms'%(data.end - data.tKernRes + (data.wifi['time'] * 1000.0))
4722 tMax = testruns[-1].end
4723 tTotal = tMax - t0
4756 d = testruns[0].addHorizontalDivider(msg, testruns[-1].end)
4760 d = testruns[0].addHorizontalDivider('asynchronous kernel threads', testruns[-1].end)
4782 left = '%f' % (((m0-t0)*100.0)/tTotal)
4789 left = '%f' % ((((m0-t0)*100.0)+sysvals.srgap/2)/tTotal)
4790 mTotal = mMax - m0
4794 width = '%f' % (((mTotal*100.0)-sysvals.srgap/2)/tTotal)
4799 length = phase['end']-phase['start']
4800 left = '%f' % (((phase['start']-m0)*100.0)/mTotal)
4809 right = '%f' % (((mMax-t)*100.0)/mTotal)
4833 left = '%f' % (((dev['start']-m0)*100)/mTotal)
4834 width = '%f' % (((dev['end']-dev['start'])*100)/mTotal)
4835 length = ' (%0.3f ms) ' % ((dev['end']-dev['start'])*1000)
4854 left = '%f' % (((start-m0)*100)/mTotal)
4855 width = '%f' % ((end-start)*100/mTotal)
4867 left = '%f' % (((e.time-m0)*100)/mTotal)
4884 phasedef = testruns[-1].phasedef
4907 pscolor = 'linear-gradient(to top left, #ccc, #eee)'
4912 length = phase['end']-phase['start']
4913 left = '%.3f' % (((phase['start']-t0)*100.0)/tTotal)
4928 data = testruns[-1]
4974 hoverZ = 'z-index:8;'
4988 <meta http-equiv="content-type" content="text/html; charset=UTF-8">\n\
4991 body {overflow-y:scroll;}\n\
4992 ….stamp {width:100%;text-align:center;background:gray;line-height:30px;color:white;font:25px Arial;…
4994 .callgraph {margin-top:30px;box-shadow:5px 5px 20px black;}\n\
4995 .callgraph article * {padding-left:28px;}\n\
5000 t3 {color:black;font:20px Times;white-space:nowrap;}\n\
5001 t4 {color:black;font:bold 30px Times;line-height:60px;white-space:nowrap;}\n\
5010 .time2 {font:15px Arial;border-bottom:1px solid;border-left:1px solid;border-right:1px solid;}\n\
5012 td {text-align:center;}\n\
5018-width="1" fill="white"/><rect x="4" y="8" width="10" height="2" style="fill:black;stroke-width:0"…
5019 …troke="black" stroke-width="1" fill="white"/><rect x="4" y="8" width="10" height="2" style="fill:b…
5020 .pf:'+cgchk+' ~ *:not(:nth-child(2)) {display:none;}\n\
5021 …oombox {position:relative;width:100%;overflow-x:scroll;-webkit-user-select:none;-moz-user-select:n…
5022 ….timeline {position:relative;font-size:14px;cursor:pointer;width:100%; overflow:hidden;background:…
5023 …bsolute;height:0%;overflow:hidden;z-index:7;line-height:30px;font-size:14px;border:1px solid;text-
5024 .thread.ps {border-radius:3px;background:linear-gradient(to top, #ccc, #eee);}\n\
5026 ….thread.sec,.thread.sec:hover {background:black;border:0;color:white;line-height:15px;font-size:10…
5030 .jiffie {position:absolute;pointer-events: none;z-index:8;}\n\
5031 …font-size:10px;z-index:7;overflow:hidden;color:black;text-align:center;white-space:nowrap;border-r…
5032 .traceevent:hover {color:white;font-weight:bold;border:1px solid white;}\n\
5033 .phase {position:absolute;overflow:hidden;border:0px;text-align:center;}\n\
5034 ….phaselet {float:left;overflow:hidden;border:0px;text-align:center;min-height:100px;font-size:24px…
5035 ….t {position:absolute;line-height:'+('%d'%scaleTH)+'px;pointer-events:none;top:0;height:100%;borde…
5036 …err {position:absolute;top:0%;height:100%;border-right:3px solid red;color:red;font:bold 14px Time…
5037 .legend {position:relative; width:100%; height:40px; text-align:center;margin-bottom:20px}\n\
5038 …ion:absolute;cursor:pointer;top:10px; width:0px;height:20px;border:1px solid;padding-left:20px;}\n\
5039 button {height:40px;width:200px;margin-bottom:20px;margin-top:20px;font-size:24px;}\n\
5040 …ion:relative;float:right;height:25px;width:auto;margin-top:3px;margin-bottom:0;font-size:10px;text
5042 a:link {color:white;text-decoration:none;}\n\
5046 ….version {position:relative;float:left;color:white;font-size:10px;line-height:30px;margin-left:10p…
5047 #devicedetail {min-height:100px;box-shadow:5px 5px 20px black;}\n\
5049 .tback {position:absolute;width:100%;background:linear-gradient(#ccc, #ddd);}\n\
5050 .bg {z-index:1;}\n\
5063 tMax = testruns[-1].end * 1000
5073 ' var resolution = -1;\n'\
5076 ' var rline = \'<div class="t" style="left:0;border-left:1px solid black;border-right:0;">\';\n'\
5077 ' var tTotal = tMax - t0;\n'\
5087 ' var divEdge = (mTotal - tS*(divTotal-1))*100/mTotal;\n'\
5093 ' pos = 100 - (((j)*tS*100)/mTotal) - divEdge;\n'\
5094 ' val = (j-divTotal+1)*tS;\n'\
5095 ' if(j == divTotal - 1)\n'\
5100 ' pos = 100 - (((j)*tS*100)/mTotal);\n'\
5125 ' zoombox.scrollLeft = ((left + sh) * newval / val) - sh;\n'\
5130 ' zoombox.scrollLeft = ((left + sh) * newval / val) - sh;\n'\
5138 ' var tTotal = tMax - t0;\n'\
5142 ' if(i >= tS.length) i = tS.length - 1;\n'\
5155 ' var cpu = -1;\n'\
5156 ' if(name.match("CPU_ON\[[0-9]*\]"))\n'\
5158 ' else if(name.match("CPU_OFF\[[0-9]*\]"))\n'\
5210 ' var cpu = -1;\n'\
5211 ' if(name.match("CPU_ON\[[0-9]*\]"))\n'\
5213 ' else if(name.match("CPU_OFF\[[0-9]*\]"))\n'\
5239 ' var pname = info[info.length-1];\n'\
5240 ' pd[pname] = parseFloat(info[info.length-3].slice(1));\n'\
5264 ' var time = "<t4 style=\\"font-size:"+fs+"px\\">"+pd[phases[i].id]+" ms<br></t4>";\n'\
5265 …' var pname = "<t3 style=\\"font-size:"+fs2+"px\\">"+phases[i].id.replace(new RegExp("_", "g")…
5293 ' var name = tmp[0], phase = tmp[tmp.length-1];\n'\
5313 ' var html = \'<div style="padding-top:\'+pad+\'px"><t3> <b>\'+name+\':</b>\';\n'\
5322 …' html += \'<table class=fstat style="padding-top:\'+(maxlen*5)+\'px;"><tr><th>Function</th>\';\…
5357 ' " ul {list-style-type:circle;padding-left:10px;margin-left:10px;}"+\n'\
5401 ' zoombox.scrollLeft = dragval[1] + dragval[0] - e.clientX;\n'\
5589 return os.readlink(file).split('/')[-1]
5623 '---------------------------------------------------------------------------------------------\n'\
5628 '---------------------------------------------------------------------------------------------\n'\
5630 '---------------------------------------------------------------------------------------------')
5636 if(not re.match('.*/power', dirname) or
5641 dirname = dirname[:-6]
5642 device = dirname.split('/')[-1]
5643 power = dict()
5644 power[tgtval] = readFile('%s/power/%s' % (dirname, tgtval))
5646 if power[tgtval] not in ['active', 'suspended', 'suspending']:
5657 power[i] = readFile('%s/power/%s' % (dirname, i))
5659 if power['control'] == output:
5660 res.append('%s/power/control' % dirname)
5662 lines[dirname] = '%-26s %-26s %1s %1s %1s %1s %1s %10s %10s' % \
5664 yesno(power['async']), \
5665 yesno(power['control']), \
5666 yesno(power['runtime_status']), \
5667 power['runtime_usage'], \
5668 power['runtime_active_kids'], \
5669 ms2nice(power['runtime_active_time']), \
5670 ms2nice(power['runtime_suspended_time']))
5677 # Determine the supported power modes on this system
5694 modes.append('mem-%s' % memmode)
5701 modes.append('disk-%s' % m.strip('[]'))
5718 'bios-vendor': (0, 4),
5719 'bios-version': (0, 5),
5720 'bios-release-date': (0, 8),
5721 'system-manufacturer': (1, 4),
5722 'system-product-name': (1, 5),
5723 'system-version': (1, 6),
5724 'system-serial-number': (1, 7),
5725 'baseboard-manufacturer': (2, 4),
5726 'baseboard-product-name': (2, 5),
5727 'baseboard-version': (2, 6),
5728 'baseboard-serial-number': (2, 7),
5729 'chassis-manufacturer': (3, 4),
5730 'chassis-type': (3, 5),
5731 'chassis-version': (3, 6),
5732 'chassis-serial-number': (3, 7),
5733 'processor-manufacturer': (4, 7),
5734 'processor-version': (4, 16),
5778 if buf[i:i+4] == b'_SM_' and i < memsize - 16:
5808 while(count < num and i <= len(buf) - 4):
5811 while n < len(buf) - 1:
5820 if idx > 0 and idx < len(data) - 1:
5821 s = data[idx-1].decode('utf-8')
5917 recdata = fp.read(rechead[1]-8)
5949 fwData[0] = record[1] - record[0]
6001 pprint(' is "%s" a valid power mode: %s' % (sysvals.suspendmode, res))
6003 pprint(' valid power modes are: %s' % modes)
6004 pprint(' please choose one with -m')
6014 status = efmt.format('-f')
6016 status = efmt.format('-dev')
6018 status = efmt.format('-proc')
6102 doError(name+': non-integer value given', True)
6121 doError(name+': non-numerical value given', True)
6151 sysvals.vprint(' %-8s : %s' % (key.upper(), sysvals.stamp[key]))
6167 sysvals.vprint('[%s - %s]' % (info[0], info[1]))
6265 num = re.search(r'[-+]?\d*\.\d+|\d+', str)
6293 m = re.match('[a-z0-9]* failed in (?P<p>\S*).*', error)
6337 m = re.match('.*waking *(?P<n>[0-9]*) *times.*', low)
6355 m = re.match(' *<div id=\"[a,0-9]*\" *title=\"(?P<title>.*)\" class=\"thread.*', line)
6358 m = re.match('(?P<n>.*) \((?P<t>[0-9,\.]*) ms\) (?P<p>.*)', m.group('title'))
6365 name = ' '.join(name.split(' ')[:-1])
6407 for arg in ['-multi ', '-info ']:
6433 # create a summary of tests in a sub-directory
6463 pprint(' summary.html - tabular list of test data found')
6464 createHTMLDeviceSummary(testruns, os.path.join(outpath, 'summary-devices.html'), title)
6465 pprint(' summary-devices.html - kernel device list sorted by total execution time')
6466 createHTMLIssuesSummary(testruns, issues, os.path.join(outpath, 'summary-issues.html'), title)
6467 pprint(' summary-issues.html - kernel issues found sorted by frequency')
6477 doError('invalid boolean --> (%s: %s), use "true/false" or "1/0"' % (name, value), True)
6507 elif(option == 'override-timeline-functions'):
6509 elif(option == 'override-dev-timeline-functions'):
6518 sysvals.rs = -1
6522 doError('invalid value --> (%s: %s), use "enable/disable"' % (option, value), True)
6526 doError('invalid value --> (%s: %s), use %s' % (option, value, disopt), True)
6544 doError('invalid phase --> (%s: %s), valid phases are %s'\
6588 elif(option == 'callloop-maxgap'):
6589 sysvals.callloopmaxgap = getArgFloat('callloop-maxgap', value, 0.0, 1.0, False)
6590 elif(option == 'callloop-maxlen'):
6591 sysvals.callloopmaxgap = getArgFloat('callloop-maxlen', value, 0.0, 1.0, False)
6596 elif(option == 'output-dir'):
6604 doError('-dev is not compatible with -f')
6606 doError('-proc is not compatible with -f')
6637 if val[0] == '[' and val[-1] == ']':
6638 for prop in val[1:-1].split(','):
6657 for arg in re.findall('{(?P<n>[a-z,A-Z,0-9]*)}', format):
6695 ' Generates output files in subdirectory: suspend-yymmdd-HHMMSS\n'\
6701 ' -h Print this help text\n'\
6702 ' -v Print the current tool version\n'\
6703 ' -config fn Pull arguments and config options from file fn\n'\
6704 ' -verbose Print extra information during execution and analysis\n'\
6705 ' -m mode Mode to initiate for suspend (default: %s)\n'\
6706 ' -o name Overrides the output subdirectory name when running a new test\n'\
6707 ' default: suspend-{date}-{time}\n'\
6708 ' -rtcwake t Wakeup t seconds after suspend, set t to "off" to disable (default: 15)\n'\
6709 ' -addlogs Add the dmesg and ftrace logs to the html output\n'\
6710 ' -noturbostat Dont use turbostat in freeze mode (default: disabled)\n'\
6711 ' -srgap Add a visible gap in the timeline between sus/res (default: disabled)\n'\
6712 …' -skiphtml Run the test and capture the trace logs, but skip the timeline (default: disabled…
6713 ' -result fn Export a results table to a text file for parsing.\n'\
6714 ' -wifi If a wifi connection is available, check that it reconnects after resume.\n'\
6715 ' -wifitrace Trace kernel execution through wifi reconnect.\n'\
6716 ' -netfix Use netfix to reset the network in the event it fails to resume.\n'\
6718 ' -sync Sync the filesystems before starting the test\n'\
6719 ' -rs on/off Enable/disable runtime suspend for all devices, restore all after test\n'\
6720 ' -display m Change the display mode to m for the test (on/off/standby/suspend)\n'\
6722 ' -gzip Gzip the trace and dmesg logs to save space\n'\
6723 ' -cmd {s} Run the timeline over a custom command, e.g. "sync -d"\n'\
6724 ' -proc Add usermode process info into the timeline (default: disabled)\n'\
6725 ' -dev Add kernel function calls and threads to the timeline (default: disabled)\n'\
6726 ' -x2 Run two suspend/resumes back to back (default: disabled)\n'\
6727 ' -x2delay t Include t ms delay between multiple test runs (default: 0 ms)\n'\
6728 ' -predelay t Include t ms delay before 1st suspend (default: 0 ms)\n'\
6729 ' -postdelay t Include t ms delay after last resume (default: 0 ms)\n'\
6730 ' -mindev ms Discard all device blocks shorter than ms milliseconds (e.g. 0.001 for us)\n'\
6731 ' -multi n d Execute <n> consecutive tests at <d> seconds intervals. If <n> is followed\n'\
6734 ' -maxfail n Abort a -multi run after n consecutive fails (default is 0 = never abort)\n'\
6736 ' -f Use ftrace to create device callgraphs (default: disabled)\n'\
6737 ' -ftop Use ftrace on the top level call: "%s" (default: disabled)\n'\
6738 ' -maxdepth N limit the callgraph data to N call levels (default: 0=all)\n'\
6739 ' -expandcg pre-expand the callgraph data in the html output (default: disabled)\n'\
6740 ' -fadd file Add functions to be graphed in the timeline from a list in a text file\n'\
6741 ' -filter "d1,d2,..." Filter out all but this comma-delimited list of device names\n'\
6742 ' -mincg ms Discard all callgraphs shorter than ms milliseconds (e.g. 0.001 for us)\n'\
6743 ' -cgphase P Only show callgraph data for phase P (e.g. suspend_late)\n'\
6744 ' -cgtest N Only show callgraph data for test N (e.g. 0 or 1 in an x2 run)\n'\
6745 ' -timeprec N Number of significant digits in timestamps (0:S, [3:ms], 6:us)\n'\
6746 ' -cgfilter S Filter the callgraph output in the timeline\n'\
6747 ' -cgskip file Callgraph functions to skip, off to disable (default: cgskip.txt)\n'\
6748 ' -bufsize N Set trace buffer size to N kilo-bytes (default: all of free memory)\n'\
6749 ' -devdump Print out all the raw device data for each phase\n'\
6750 ' -cgdump Print out all the raw callgraph data\n'\
6753 ' -modes List available suspend modes\n'\
6754 ' -status Test to see if the system is enabled to run this tool\n'\
6755 ' -fpdt Print out the contents of the ACPI Firmware Performance Data Table\n'\
6756 ' -wificheck Print out wifi connection info\n'\
6757 ' -x<mode> Test xset by toggling the given mode (on/off/standby/suspend)\n'\
6758 ' -sysinfo Print out system info extracted from BIOS\n'\
6759 ' -devinfo Print out the pm settings of all devices which support runtime suspend\n'\
6760 ' -cmdinfo Print out all the platform info collected before and after suspend/resume\n'\
6761 ' -flist Print the list of functions currently being captured in ftrace\n'\
6762 ' -flistall Print all functions capable of being captured in ftrace\n'\
6763 ' -summary dir Create a summary of tests in this dir [-genhtml builds missing html]\n'\
6765 ' -ftrace ftracefile Create HTML output using ftrace input (used with -dmesg)\n'\
6766 ' -dmesg dmesgfile Create HTML output using dmesg (used with -ftrace)\n'\
6770 # ----------------- MAIN --------------------
6775 simplecmds = ['-sysinfo', '-modes', '-fpdt', '-flist', '-flistall',
6776 '-devinfo', '-status', '-xon', '-xoff', '-xstandby', '-xsuspend',
6777 '-xinit', '-xreset', '-xstat', '-wificheck', '-cmdinfo']
6778 if '-f' in sys.argv:
6783 if(arg == '-m'):
6793 elif(arg == '-h'):
6796 elif(arg == '-v'):
6799 elif(arg == '-debugtiming'):
6801 elif(arg == '-x2'):
6803 elif(arg == '-x2delay'):
6804 sysvals.x2delay = getArgInt('-x2delay', args, 0, 60000)
6805 elif(arg == '-predelay'):
6806 sysvals.predelay = getArgInt('-predelay', args, 0, 60000)
6807 elif(arg == '-postdelay'):
6808 sysvals.postdelay = getArgInt('-postdelay', args, 0, 60000)
6809 elif(arg == '-f'):
6811 elif(arg == '-ftop'):
6815 elif(arg == '-skiphtml'):
6817 elif(arg == '-cgdump'):
6819 elif(arg == '-devdump'):
6821 elif(arg == '-genhtml'):
6823 elif(arg == '-addlogs'):
6825 elif(arg == '-nologs'):
6827 elif(arg == '-addlogdmesg'):
6829 elif(arg == '-addlogftrace'):
6831 elif(arg == '-noturbostat'):
6833 elif(arg == '-verbose'):
6835 elif(arg == '-proc'):
6837 elif(arg == '-dev'):
6839 elif(arg == '-sync'):
6841 elif(arg == '-wifi'):
6843 elif(arg == '-wifitrace'):
6845 elif(arg == '-netfix'):
6847 elif(arg == '-gzip'):
6849 elif(arg == '-info'):
6853 doError('-info requires one string argument', True)
6854 elif(arg == '-desc'):
6858 doError('-desc requires one string argument', True)
6859 elif(arg == '-rs'):
6863 doError('-rs requires "enable" or "disable"', True)
6866 sysvals.rs = -1
6871 elif(arg == '-display'):
6875 doError('-display requires an mode value', True)
6880 elif(arg == '-maxdepth'):
6881 sysvals.max_graph_depth = getArgInt('-maxdepth', args, 0, 1000)
6882 elif(arg == '-rtcwake'):
6891 sysvals.rtcwaketime = getArgInt('-rtcwake', val, 0, 3600, False)
6892 elif(arg == '-timeprec'):
6893 sysvals.setPrecision(getArgInt('-timeprec', args, 0, 6))
6894 elif(arg == '-mindev'):
6895 sysvals.mindevlen = getArgFloat('-mindev', args, 0.0, 10000.0)
6896 elif(arg == '-mincg'):
6897 sysvals.mincglen = getArgFloat('-mincg', args, 0.0, 10000.0)
6898 elif(arg == '-bufsize'):
6899 sysvals.bufsize = getArgInt('-bufsize', args, 1, 1024*1024*8)
6900 elif(arg == '-cgtest'):
6901 sysvals.cgtest = getArgInt('-cgtest', args, 0, 1)
6902 elif(arg == '-cgphase'):
6909 doError('invalid phase --> (%s: %s), valid phases are %s'\
6912 elif(arg == '-cgfilter'):
6918 elif(arg == '-skipkprobe'):
6924 elif(arg == '-cgskip'):
6935 elif(arg == '-callloop-maxgap'):
6936 sysvals.callloopmaxgap = getArgFloat('-callloop-maxgap', args, 0.0, 1.0)
6937 elif(arg == '-callloop-maxlen'):
6938 sysvals.callloopmaxlen = getArgFloat('-callloop-maxlen', args, 0.0, 1.0)
6939 elif(arg == '-cmd'):
6946 elif(arg == '-expandcg'):
6948 elif(arg == '-srgap'):
6950 elif(arg == '-maxfail'):
6951 sysvals.maxfail = getArgInt('-maxfail', args, 0, 1000000)
6952 elif(arg == '-multi'):
6956 doError('-multi requires two values', True)
6958 elif(arg == '-o'):
6964 elif(arg == '-config'):
6973 elif(arg == '-fadd'):
6982 elif(arg == '-dmesg'):
6991 elif(arg == '-ftrace'):
7000 elif(arg == '-summary'):
7010 elif(arg == '-filter'):
7016 elif(arg == '-result'):
7028 doError('-dev is not compatible with -f')
7030 doError('-proc is not compatible with -f')
7079 print('[%s - %s]\n%s\n' % out)
7082 # if instructed, re-analyze existing data files
7096 memmode = mode.split('-', 1)[-1] if '-' in mode else 'deep'
7105 if mode.startswith('disk-'):
7106 sysvals.diskmode = mode.split('-', 1)[-1]
7115 s = '-%dm' % sysvals.multitest['time']
7117 s = '-x%d' % sysvals.multitest['count']
7118 sysvals.outdir = datetime.now().strftime('suspend-%y%m%d-%H%M%S'+s)
7130 fmt = 'suspend-%y%m%d-%H%M%S'