Lines Matching +full:hf +full:- +full:buffer +full:- +full:low +full:- +full:power
2 # SPDX-License-Identifier: GPL-2.0-only
21 # https://www.intel.com/content/www/us/en/developer/topic-technology/open/pm-graph/overview.html
23 # git@github.com:intel/pm-graph
51 # ----------------- LIBRARIES --------------------
74 print('[%09.3f] %s' % (time.time()-mystarttime, msg))
82 # ----------------- CLASSES --------------------
86 # A global, single-instance container used to
108 cgtest = -1
126 epath = '/sys/kernel/tracing/events/power/'
127 pmdpath = '/sys/power/pm_debug_messages'
141 powerfile = '/sys/power/state'
142 mempowerfile = '/sys/power/mem_sleep'
143 diskpowerfile = '/sys/power/disk'
183 tmstart = 'SUSPEND START %Y%m%d-%H:%M:%S.%f'
184 tmend = 'RESUME COMPLETE %Y%m%d-%H:%M:%S.%f'
299 [0, 'sysinfo', 'uname', '-a'],
300 [0, 'cpuinfo', 'head', '-7', '/proc/cpuinfo'],
303 [0, 'pcidevices', 'lspci', '-tv'],
304 [0, 'usbdevices', 'lsusb', '-tv'],
305 [0, 'acpidevices', 'sh', '-c', 'ls -l /sys/bus/acpi/devices/*/physical_node'],
312 [2, 'gpecounts', 'sh', '-c', 'grep -v invalid /sys/firmware/acpi/interrupts/*'],
313 [2, 'suspendstats', 'sh', '-c', 'grep -v invalid /sys/power/suspend_stats/*'],
314 …[2, 'cpuidle', 'sh', '-c', 'grep -v invalid /sys/devices/system/cpu/cpu*/cpuidle/state*/s2idle/*'],
315 [2, 'battery', 'sh', '-c', 'grep -v invalid /sys/class/power_supply/*/*'],
316 [2, 'thermal', 'sh', '-c', 'grep . /sys/class/thermal/thermal_zone*/temp'],
338 self.testdir = datetime.now().strftime('suspend-%y%m%d-%H%M%S')
443 if 'baseboard-manufacturer' in info:
444 m = info['baseboard-manufacturer']
445 elif 'system-manufacturer' in info:
446 m = info['system-manufacturer']
447 if 'system-product-name' in info:
448 p = info['system-product-name']
449 elif 'baseboard-product-name' in info:
450 p = info['baseboard-product-name']
451 if m[:5].lower() == 'intel' and 'baseboard-product-name' in info:
452 p = info['baseboard-product-name']
453 c = info['processor-version'] if 'processor-version' in info else ''
454 b = info['bios-version'] if 'bios-version' in info else ''
455 r = info['bios-release-date'] if 'bios-release-date' in info else ''
465 fmt = '%-24s: %s'
467 print(fmt % ('os-version', self.osversion))
478 if re.match(r'^processor[ \t]*:[ \t]*[0-9]*', line):
483 m = re.match(r'^MemTotal:[ \t]*(?P<sz>[0-9]*) *kB', line)
486 m = re.match(r'^MemFree:[ \t]*(?P<sz>[0-9]*) *kB', line)
489 if os.path.exists('/etc/os-release'):
490 with open('/etc/os-release', 'r') as fp:
498 fmt = name+'-%m%d%y-%H%M%S'
553 m = re.match(r'[ \t]*(\[ *)(?P<ktime>[0-9\.]*)(\]) (?P<msg>.*)', line)
567 m = re.match(r'[ \t]*(\[ *)(?P<ktime>[0-9\.]*)(\]) (?P<msg>.*)', line)
673 if re.findall('{(?P<n>[a-z,A-Z,0-9]*)}', func):
675 for arg in re.findall('{(?P<n>[a-z,A-Z,0-9]*)}', fmt):
690 # sort kprobes: trace, ub-dev, custom, dev
722 linesack = (len(check.split('\n')) - 1) // 2
803 # set trace buffer to an appropriate value
815 tgtsize -= 65536
830 self.fsetVal('print-parent', 'trace_options')
831 self.fsetVal('funcgraph-abstime', 'trace_options')
832 self.fsetVal('funcgraph-cpu', 'trace_options')
833 self.fsetVal('funcgraph-duration', 'trace_options')
834 self.fsetVal('funcgraph-proc', 'trace_options')
835 self.fsetVal('funcgraph-tail', 'trace_options')
836 self.fsetVal('nofuncgraph-overhead', 'trace_options')
837 self.fsetVal('context-info', 'trace_options')
838 self.fsetVal('graph-time', 'trace_options')
866 self.fsetVal('1', 'events/power/'+e+'/enable')
867 # clear the trace buffer
877 self.epath = '/sys/kernel/debug/tracing/events/power/'
921 cmd = 'chown -R {0}:{0} {1} > /dev/null 2>&1'
1002 footer += '# platform-testcmd: %s\n' % (self.testcommand)
1025 if(re.match(r'.*/power', dirname) and 'async' in filenames):
1026 dev = dirname.split('/')[-2]
1028 props[dev].syspath = dirname[:-6]
1036 if os.path.exists(dirname+'/power/async'):
1037 fp = open(dirname+'/power/async')
1069 footer += '# platform-devinfo: %s\n' % self.b64zip(out)
1073 footer += '# platform-%s: %s | %s\n' % (name, cmdline, self.b64zip(info))
1082 prefix = prefix[:len(prefix)-1]
1085 if '/' in prefix and prefix[-1] != '/':
1108 cmd = [self.getExec('ip'), '-4', '-o', '-br', 'addr']
1126 if args[i][0] == '{' and args[i][-1] == '}':
1127 args[i] = self.cmdinfovar(args[i][1:-1])
1148 dinfo += '\t%s : %s -> %s\n' % \
1173 line = fp.read().strip().split('\n')[-1]
1174 m = re.match(r'.* (?P<v>[0-9A-Fx]*) .*', line)
1196 fp = Popen([cmd, '-v'], stdout=PIPE, stderr=PIPE).stderr
1206 fullcmd = '%s -q -S echo freeze > %s' % (cmd, self.powerfile)
1207 fp = Popen(['sh', '-c', fullcmd], stdout=PIPE, stderr=PIPE)
1238 fp = Popen([cmd, '-s', net, 'on'], stdout=PIPE, stderr=PIPE).stdout
1250 vals.append(prop.split('=')[-1])
1258 m = re.match(r' *(?P<dev>.*): (?P<stat>[0-9a-f]*) .*', line)
1265 while (time.time() - start) < timeout:
1269 (self.wifiDetails(dev), max(0, time.time() - start))
1287 if re.match(r'^[0-9,\-\.]*$', arr[j]):
1288 arr[j] = r'[0-9,\-\.]*'
1314 dt = t - self.multitest['last']
1318 pprint('TEST (%s) COMPLETE -- Duration %.1fs' % (id, dt))
1324 left = finish - datetime.now()
1325 left -= timedelta(microseconds=left.microseconds)
1327 left = timedelta(seconds=((self.multitest['count'] - idx) * int(avg)))
1328 pprint('TEST (%s) START - Avg Duration %.1fs, Time left %s' % \
1333 sz, unit, c = 'time', c[-1], c[:-1]
1342 xset, ret = 'timeout 10 xset -d :0.0 {0}', 0
1344 xset = 'sudo -u %s %s' % (self.sudouser, xset)
1356 self.vprint('Display Switched: %s -> %s' % (b4, curr))
1388 # runtime suspend re-enable or re-disable
1465 # 10 sequential, non-overlapping phases of S/R
1507 'ACPI' : r'.*\bACPI *(?P<b>[A-Za-z]*) *Error[: ].*',
1509 'USBERR' : r'.*usb .*device .*, error [0-9-]*',
1510 'ATAERR' : r' *ata[0-9\.]*: .*failed.*',
1512 'TPMERR' : r'(?i) *tpm *tpm[0-9]*: .*error.*',
1520 self.tSuspended = 0.0 # low-level suspend start
1521 self.tResumed = 0.0 # low-level resume start
1541 self.tLow = [] # time spent in low-level suspends (standby/freeze)
1566 return plist[-1*depth]
1576 out['syslpi'] = i.split('=')[-1]+'%'
1578 out['pkgpc10'] = i.split('=')[-1]+'%'
1592 m = re.match(r'[ \t]*(\[ *)(?P<ktime>[0-9\.]*)(\]) (?P<msg>.*)', line)
1685 threadname = 'kthread-%d' % (pid)
1687 threadname = '%s-%d' % (proc, pid)
1695 sysvals.vprint('[%f - %f] %s-%d %s %s %s' % \
1742 o = min(dev['end'], tdev['end']) - max(dev['start'], tdev['start'])
1756 if tdev['start'] - dev['end'] < 0.1:
1789 p.length = p.end - p.time
1795 if(t - dT < t0):
1797 return t - dT
1823 d['length'] = d['end'] - d['start']
1834 e.length = e.end - e.time
1856 tL = tR - tS
1875 stime = (self.tSuspended - self.start) * 1000000
1876 rtime = (self.end - self.tResumed) * 1000000
1878 hwr = self.hwend - timedelta(microseconds=rtime)
1879 self.tLow.append('%.0f'%((hwr - hws).total_seconds() * 1000))
1881 s = (self.tSuspended - self.tKernSus) * 1000
1882 r = (self.tKernRes - self.tResumed) * 1000
1884 def setPhase(self, phase, ktime, isbegin, order=-1):
1897 self.dmesg[phase] = {'list': dict(), 'start': -1.0, 'end': -1.0,
1960 def newActionGlobal(self, name, start, end, pid=-1, color=''):
1971 o = max(0, min(end, pend) - max(start, pstart))
1986 targetphase = phases[-1]
1987 if pid == -2:
1989 elif pid == -3:
2003 length = -1.0
2005 length = end - start
2006 if pid >= -2:
2023 if name == devname or re.match(r'^%s\[(?P<num>[0-9]*)\]$' % name, devname):
2055 sysvals.vprint('%20s: %f - %f (%d devices)' % (phase, ps, pe, dc))
2057 sysvals.vprint(''.join('-' for i in range(80)))
2059 fmt = '%3d) %'+maxname+'s - %f - %f'
2066 sysvals.vprint(''.join('-' for i in range(80)))
2099 info += ('<li>%s: %.3fms</li>' % (phase, (e-s)*1000))
2118 # list of top-most root devices
2125 if(pid < 0 or re.match(r'[0-9]*-[0-9]*\.[0-9]*[\.0-9]*\:[\.0-9]*$', pdev)):
2141 length = (list[dev]['end'] - list[dev]['start']) * 1000
2142 width = widfmt % (((list[dev]['end']-list[dev]['start'])*100)/tTotal)
2148 self.newAction(phase, devname, -2, '', \
2158 tlast = start = end = -1
2167 maxj = (t - tlast) * 1024.0
2173 out = self.newActionGlobal(name, start, end, -3)
2216 m = re.match(r'.*(\[ *)(?P<t>[0-9\.]*)(\]) .* (?P<f>.*)\: '+\
2219 m = re.match(r'.*(\[ *)(?P<t>[0-9\.]*)(\]) .* (?P<f>.*)\: '+\
2222 m = re.match(r'.*(\[ *)(?P<t>[0-9\.]*)(\]) calling '+\
2228 m = re.match(r'.*(\[ *)(?P<t>[0-9\.]*)(\]) .* (?P<f>.*)\: PM: '+\
2229 r'.* returned (?P<r>[0-9]*) after (?P<dt>[0-9]*) usecs', line)
2231 m = re.match(r'.*(\[ *)(?P<t>[0-9\.]*)(\]) .* (?P<f>.*)\: '+\
2232 r'.* returned (?P<r>[0-9]*) after (?P<dt>[0-9]*) usecs', line)
2234 m = re.match(r'.*(\[ *)(?P<t>[0-9\.]*)(\]) call '+\
2259 self.length = end - start
2271 title = '%s(%s)%s <- %s, %s(%s)' % \
2284 dt = self.time - tgt.end
2285 # only combine calls if -all- attributes are identical
2370 if(m[-1] == '{'):
2375 elif(m[-1] == ';'):
2393 pprint(' -- %12.6f (depth=%02d): %s(); (%.3f us) %s' % (self.time, \
2396 pprint(' -- %12.6f (depth=%02d): %s} (%.3f us) %s' % (self.time, \
2399 pprint(' -- %12.6f (depth=%02d): %s() { (%.3f us) %s' % (self.time, \
2442 self.start = -1.0
2443 self.end = -1.0
2463 self.list[-1].freturn = True
2464 self.list[-1].length = line.time - self.list[-1].time
2472 # compare current depth with this lines pre-call depth
2479 last = self.list[-1]
2483 # handle low misalignments by inserting returns
2484 mismatch = prelinedep - self.depth
2491 self.depth -= 1
2496 last.length = line.time - last.time
2522 prelinedep -= 1
2550 if (md and self.depth >= md - 1) or (line.name in self.sv.cgblacklist):
2555 self.depth -= 1
2560 while len(self.list) > 0 and self.list[-1].depth > line.depth:
2561 self.list.pop(-1)
2565 self.list[-1].freturn = True
2566 self.list[-1].length = line.time - self.list[-1].time
2567 self.list[-1].name = line.name
2573 if mismatch < 0 and self.list[-1].depth == 0 and self.list[-1].freturn:
2574 line = self.list[-1]
2576 res = -1
2587 if res == -1:
2598 window = '(%f - %f)' % (self.start, line.time)
2601 ' (buffer overflow), ignoring this callback')
2608 mydepth = -1
2620 l.depth -= mydepth
2628 last = self.list[-1]
2648 if last.length > l.time - last.time:
2649 last.length = l.time - last.time
2661 cl.length = l.time - cl.time
2666 cnt -= 1
2727 out = data.newActionGlobal(name, fs, fe, -2)
2732 pprint('%s pid=%d [%f - %f] %.3f us' % \
2734 (self.end - self.start)*1000000))
2780 'us/en/developer/topic-technology/open/pm-graph/overview.html">%s v%s</a></div>' \
2807 item.row = -1
2833 remaining -= 1
2850 # initialize all device rows to -1 and calculate devrows
2856 dev['row'] = -1
2859 sortdict[item] = (-1*float(dev['start']), float(dev['end']) - float(dev['start']))
2862 sortdict[item] = (float(dev['end']) - float(dev['start']), item.dev['name'])
2869 if item.dev['pid'] == -2:
2895 remaining -= 1
2940 self.bodyH = self.height - self.scaleH
2947 …html_zoombox = '<center><button id="zoomin">ZOOM IN +</button><button id="zoomout">ZOOM OUT -</but…
2971 rline = '<div class="t" style="left:0;border-left:1px solid black;border-right:0;">{0}</div>\n'
2974 mTotal = mMax - m0
2981 divEdge = (mTotal - tS*(divTotal-1))*100/mTotal
2985 pos = '%0.3f' % (100 - ((float(i)*tS*100)/mTotal) - divEdge)
2986 val = '%0.fms' % (float(i-divTotal+1)*tS*1000)
2987 if(i == divTotal - 1):
2991 pos = '%0.3f' % (100 - ((float(i)*tS*100)/mTotal))
3003 stampfmt = r'# [a-z]*-(?P<m>[0-9]{2})(?P<d>[0-9]{2})(?P<y>[0-9]{2})-'+\
3004 r'(?P<H>[0-9]{2})(?P<M>[0-9]{2})(?P<S>[0-9]{2})'+\
3006 wififmt = r'^# wifi *(?P<d>\S*) *(?P<s>\S*) *(?P<t>[0-9\.]+).*'
3013 pinfofmt = r'# platform-(?P<val>[a-z,A-Z,0-9,_]*): (?P<info>.*)'
3015 firmwarefmt = r'# fwsuspend (?P<s>[0-9]*) fwresume (?P<r>[0-9]*)$'
3016 procexecfmt = r'ps - (?P<ps>.*)$'
3017 procmultifmt = r'@(?P<n>[0-9]*)\|(?P<ps>.*)$'
3019 r'^ *(?P<time>[0-9\.]*) *\| *(?P<cpu>[0-9]*)\)'+\
3020 r' *(?P<proc>.*)-(?P<pid>[0-9]*) *\|'+\
3021 r'[ +!#\*@$]*(?P<dur>[0-9\.]*) .*\| (?P<msg>.*)'
3023 r' *(?P<proc>.*)-(?P<pid>[0-9]*) *\[(?P<cpu>[0-9]*)\] *'+\
3024 r'(?P<flags>\S*) *(?P<time>[0-9\.]*): *'+\
3205 c = ['cat /proc/[1-9]*/stat 2>/dev/null']
3219 ujiff = user - val['user']
3220 kjiff = kern - val['kern']
3230 if len(out[-1]) > self.maxchars:
3232 elif len(out[-1]) > 0:
3233 out[-1] += ','
3234 out[-1] += '%s-%s %d' % (val['name'], pid, jiffies)
3237 sysvals.fsetVal('ps - @%d|%s' % (len(out), line), 'trace_marker')
3239 sysvals.fsetVal('ps - %s' % out[0], 'trace_marker')
3250 # ----------------- FUNCTIONS --------------------
3354 cg = testrun[testidx].ftemp[pid][-1]
3358 if(res == -1):
3359 testrun[testidx].ftemp[pid][-1].addLine(t)
3366 if len(cg.list) < 1 or cg.invalid or (cg.end - cg.start == 0):
3516 name = val[0].replace('--', '-')
3534 testrun.ttemp['thaw_processes'][-1]['end'] = t.time
3555 # -- phase changes --
3595 t.time - data.dmesg[lp]['start']
3643 testrun.ttemp[name][-1]['end'] = t.time
3644 testrun.ttemp[name][-1]['loop'] += 1
3657 testrun.ttemp[name][-1]['end'] = t.time
3670 data.newAction(phase, n, pid, p, t.time, -1, drv)
3683 dev['length'] = t.time - dev['start']
3701 'end': -1,
3716 if (t.time - e['begin']) * 1000 < sysvals.mindevlen:
3735 cg = testrun.ftemp[key][-1]
3739 if(res == -1):
3740 testrun.ftemp[key][-1].addLine(t)
3777 if i < len(testruns) - 1:
3787 if event['end'] - event['begin'] <= 0:
3802 if ke - kb < 0.000001 or tlb > kb or tle <= kb:
3814 if ke - kb < 0.000001 or tlb > kb or tle <= kb:
3824 if len(cg.list) < 1 or cg.invalid or (cg.end - cg.start == 0):
3846 …sysvals.vprint('Callgraph found for task %d: %.3fms, %s' % (cg.pid, (cg.end - cg.start)*1000, name…
3866 terr = 'test%s did not enter %s power mode' % (tn, sm)
3900 for i in range(tc - 1):
3920 tp.stamp = datetime.now().strftime('# suspend-%m%d%y-%H%M%S localhost mem unknown')
3931 m = re.match(r'[ \t]*(\[ *)(?P<ktime>[0-9\.]*)(\]) (?P<msg>.*)', line)
3943 m = re.match(r'.* *(?P<k>[0-9]\.[0-9]{2}\.[0-9]-.*) .*', msg)
3999 'suspend': ['PM: Entering [a-z]* sleep.*', 'Suspending console.*',
4005 'suspend_machine': ['PM: suspend-to-idle',
4009 'ACPI: Low-level resume complete.*',
4011 r'Suspended for [0-9\.]* seconds'],
4012 'resume_noirq': ['PM: resume from suspend-to-idle',
4028 'emsg': 'PM: Preparing system for[a-z]* sleep.*' },
4040 'emsg': 'Disabling non-boot CPUs .*' },
4043 t0 = -1.0
4044 cpu_start = -1.0
4045 prevktime = -1.0
4049 m = re.match(r'[ \t]*(\[ *)(?P<ktime>[0-9\.]*)(\]) (?P<msg>.*)', line)
4146 # -- device callbacks --
4151 data.newAction(phase, f, int(n), p, ktime, -1, '')
4170 if(a in actions and actions[a][-1]['begin'] == actions[a][-1]['end']):
4171 actions[a][-1]['end'] = ktime
4173 if(re.match(r'Disabling non-boot CPUs .*', msg)):
4176 elif(re.match(r'Enabling non-boot CPUs .*', msg)):
4179 elif(re.match(r'smpboot: CPU (?P<cpu>[0-9]*) is now offline', msg) \
4180 or re.match(r'psci: CPU(?P<cpu>[0-9]*) killed.*', msg)):
4182 m = re.match(r'smpboot: CPU (?P<cpu>[0-9]*) is now offline', msg)
4184 m = re.match(r'psci: CPU(?P<cpu>[0-9]*) killed.*', msg)
4190 elif(re.match(r'CPU(?P<cpu>[0-9]*) is up', msg)):
4192 m = re.match(r'CPU(?P<cpu>[0-9]*) is up', msg)
4237 def callgraphHTML(sv, hf, num, cg, title, color, devid): argument
4246 cglen = (cg.end - cg.start) * 1000
4252 hf.write(html_func_top.format(cgid, color, num, title, flen))
4263 hf.write(html_func_leaf.format(line.name, flen))
4265 hf.write(html_func_end)
4267 hf.write(html_func_start.format(num, line.name, flen))
4269 hf.write(html_func_end)
4272 def addCallgraphs(sv, hf, data): argument
4273 hf.write('<section id="callgraphs" class="callgraph">\n')
4300 num = callgraphHTML(sv, hf, num, cg,
4304 num = callgraphHTML(sv, hf, num, cg,
4306 hf.write('\n\n </section>\n')
4309 tdcenter = 'text-align:center;' if center else ''
4311 <meta http-equiv="content-type" content="text/html; charset=UTF-8">\n\
4314 ….stamp {width: 100%;text-align:center;background:#888;line-height:30px;color:white;font: 25px Aria…
4315 table {width:100%;border-collapse: collapse;border:1px solid;}\n\
4319 tr.alt {background-color:#ddd;}\n\
4321 .minval {background-color:#BBFFBB;}\n\
4322 .medval {background-color:#BBBBFF;}\n\
4323 .maxval {background-color:#FFBBBB;}\n\
4324 .head a {color:#000;text-decoration: none;}\n\
4335 html = summaryCSS('Summary - SleepGraph')
4373 idx = len(list[mode]['data']) - 1
4458 iMin = iMed = iMax = [-1, -1, -1]
4461 # row classes - alternate row color
4500 hf = open(htmlfile, 'w')
4501 hf.write(html+'</table>\n</body>\n</html>\n')
4502 hf.close()
4505 html = summaryCSS('Device Summary - SleepGraph', False)
4551 # row classes - alternate row color
4565 hf = open(htmlfile, 'w')
4566 hf.write(html+'</body>\n</html>\n')
4567 hf.close()
4572 html = summaryCSS('Issues Summary - SleepGraph', False)
4595 # row classes - alternate row color
4609 hf = open(htmlfile, 'w')
4610 hf.write(html+'</table>\n'+extra+'</body>\n</html>\n')
4611 hf.close()
4642 data.trimFreezeTime(testruns[-1].tSuspended)
4648 …lass="traceevent{6}" style="left:{1}%;top:{2}px;height:{3}px;width:{4}%;line-height:{3}px;{7}">{5}…
4656 …'<td class="gray" title="time spent in low-power mode with clock running">'+sysvals.suspendmode+' …
4681 tTotal = data.end - data.start
4705 rtot += data.end - data.tKernRes + (data.wifi['time'] * 1000.0)
4737 wtime = '%.0f ms'%(data.end - data.tKernRes + (data.wifi['time'] * 1000.0))
4748 tMax = testruns[-1].end
4749 tTotal = tMax - t0
4782 d = testruns[0].addHorizontalDivider(msg, testruns[-1].end)
4786 d = testruns[0].addHorizontalDivider('asynchronous kernel threads', testruns[-1].end)
4808 left = '%f' % (((m0-t0)*100.0)/tTotal)
4815 left = '%f' % ((((m0-t0)*100.0)+sysvals.srgap/2)/tTotal)
4816 mTotal = mMax - m0
4820 width = '%f' % (((mTotal*100.0)-sysvals.srgap/2)/tTotal)
4825 length = phase['end']-phase['start']
4826 left = '%f' % (((phase['start']-m0)*100.0)/mTotal)
4835 right = '%f' % (((mMax-t)*100.0)/mTotal)
4859 left = '%f' % (((dev['start']-m0)*100)/mTotal)
4860 width = '%f' % (((dev['end']-dev['start'])*100)/mTotal)
4861 length = ' (%0.3f ms) ' % ((dev['end']-dev['start'])*1000)
4880 left = '%f' % (((start-m0)*100)/mTotal)
4881 width = '%f' % ((end-start)*100/mTotal)
4893 left = '%f' % (((e.time-m0)*100)/mTotal)
4910 phasedef = testruns[-1].phasedef
4923 hf = open(sysvals.htmlfile, 'w')
4924 addCSS(hf, sysvals, len(testruns), kerror)
4927 hf.write(devtl.html)
4928 hf.write('<div id="devicedetailtitle"></div>\n')
4929 hf.write('<div id="devicedetail" style="display:none;">\n')
4932 hf.write('<div id="devicedetail%d">\n' % data.testnumber)
4933 pscolor = 'linear-gradient(to top left, #ccc, #eee)'
4934 hf.write(devtl.html_phaselet.format('pre_suspend_process', \
4938 length = phase['end']-phase['start']
4939 left = '%.3f' % (((phase['start']-t0)*100.0)/tTotal)
4941 hf.write(devtl.html_phaselet.format(b, left, width, \
4943 hf.write(devtl.html_phaselet.format('post_resume_process', \
4946 hf.write(devtl.html_phaselet.format('cmdexec', '0', '0', pscolor))
4947 hf.write('</div>\n')
4948 hf.write('</div>\n')
4954 data = testruns[-1]
4956 addCallgraphs(sysvals, hf, data)
4960 hf.write('<div id="testlog" style="display:none;">\n'+sysvals.logmsg+'</div>\n')
4963 hf.write('<div id="dmesglog" style="display:none;">\n')
4967 hf.write(line)
4969 hf.write('</div>\n')
4972 hf.write('<div id="ftracelog" style="display:none;">\n')
4975 hf.write(line)
4977 hf.write('</div>\n')
4980 addScriptCode(hf, testruns)
4981 hf.write('</body>\n</html>\n')
4982 hf.close()
4985 def addCSS(hf, sv, testcount=1, kerror=False, extra=''): argument
5000 hoverZ = 'z-index:8;'
5014 <meta http-equiv="content-type" content="text/html; charset=UTF-8">\n\
5017 body {overflow-y:scroll;}\n\
5018 ….stamp {width:100%;text-align:center;background:gray;line-height:30px;color:white;font:25px Arial;…
5020 .callgraph {margin-top:30px;box-shadow:5px 5px 20px black;}\n\
5021 .callgraph article * {padding-left:28px;}\n\
5026 t3 {color:black;font:20px Times;white-space:nowrap;}\n\
5027 t4 {color:black;font:bold 30px Times;line-height:60px;white-space:nowrap;}\n\
5036 .time2 {font:15px Arial;border-bottom:1px solid;border-left:1px solid;border-right:1px solid;}\n\
5038 td {text-align:center;}\n\
5044 …-width="1" fill="white"/><rect x="4" y="8" width="10" height="2" style="fill:black;stroke-width:0"…
5045 …troke="black" stroke-width="1" fill="white"/><rect x="4" y="8" width="10" height="2" style="fill:b…
5046 .pf:'+cgchk+' ~ *:not(:nth-child(2)) {display:none;}\n\
5047 …oombox {position:relative;width:100%;overflow-x:scroll;-webkit-user-select:none;-moz-user-select:n…
5048 ….timeline {position:relative;font-size:14px;cursor:pointer;width:100%; overflow:hidden;background:…
5049 …bsolute;height:0%;overflow:hidden;z-index:7;line-height:30px;font-size:14px;border:1px solid;text-…
5050 .thread.ps {border-radius:3px;background:linear-gradient(to top, #ccc, #eee);}\n\
5052 ….thread.sec,.thread.sec:hover {background:black;border:0;color:white;line-height:15px;font-size:10…
5056 .jiffie {position:absolute;pointer-events: none;z-index:8;}\n\
5057 …font-size:10px;z-index:7;overflow:hidden;color:black;text-align:center;white-space:nowrap;border-r…
5058 .traceevent:hover {color:white;font-weight:bold;border:1px solid white;}\n\
5059 .phase {position:absolute;overflow:hidden;border:0px;text-align:center;}\n\
5060 ….phaselet {float:left;overflow:hidden;border:0px;text-align:center;min-height:100px;font-size:24px…
5061 ….t {position:absolute;line-height:'+('%d'%scaleTH)+'px;pointer-events:none;top:0;height:100%;borde…
5062 …err {position:absolute;top:0%;height:100%;border-right:3px solid red;color:red;font:bold 14px Time…
5063 .legend {position:relative; width:100%; height:40px; text-align:center;margin-bottom:20px}\n\
5064 …ion:absolute;cursor:pointer;top:10px; width:0px;height:20px;border:1px solid;padding-left:20px;}\n\
5065 button {height:40px;width:200px;margin-bottom:20px;margin-top:20px;font-size:24px;}\n\
5066 …ion:relative;float:right;height:25px;width:auto;margin-top:3px;margin-bottom:0;font-size:10px;text…
5068 a:link {color:white;text-decoration:none;}\n\
5072 ….version {position:relative;float:left;color:white;font-size:10px;line-height:30px;margin-left:10p…
5073 #devicedetail {min-height:100px;box-shadow:5px 5px 20px black;}\n\
5075 .tback {position:absolute;width:100%;background:linear-gradient(#ccc, #ddd);}\n\
5076 .bg {z-index:1;}\n\
5079 hf.write(html_header)
5085 # hf: the open html file pointer
5087 def addScriptCode(hf, testruns): argument
5089 tMax = testruns[-1].end * 1000
5090 hf.write('<script type="text/javascript">\n');
5098 hf.write(detail);
5099 script_code = r""" var resolution = -1;
5102 var rline = '<div class="t" style="left:0;border-left:1px solid black;border-right:0;">';
5103 var tTotal = tMax - t0;
5113 var divEdge = (mTotal - tS*(divTotal-1))*100/mTotal;
5119 pos = 100 - (((j)*tS*100)/mTotal) - divEdge;
5120 val = (j-divTotal+1)*tS;
5121 if(j == divTotal - 1)
5126 pos = 100 - (((j)*tS*100)/mTotal);
5151 zoombox.scrollLeft = ((left + sh) * newval / val) - sh;
5156 zoombox.scrollLeft = ((left + sh) * newval / val) - sh;
5164 var tTotal = tMax - t0;
5168 if(i >= tS.length) i = tS.length - 1;
5181 var cpu = -1;
5182 if(name.match("CPU_ON\[[0-9]*\]"))
5184 else if(name.match("CPU_OFF\[[0-9]*\]"))
5236 var cpu = -1;
5237 if(name.match("CPU_ON\[[0-9]*\]"))
5239 else if(name.match("CPU_OFF\[[0-9]*\]"))
5265 var pname = info[info.length-1];
5266 var length = parseFloat(info[info.length-3].slice(1));
5294 var time = "<t4 style=\"font-size:"+fs+"px\">"+pd[phases[i].id].toFixed(3)+" ms<br></t4>";
5295 …var pname = "<t3 style=\"font-size:"+fs2+"px\">"+phases[i].id.replace(new RegExp("_", "g"), " ")+"…
5323 var name = tmp[0], phase = tmp[tmp.length-1];
5343 var html = '<div style="padding-top:'+pad+'px"><t3> <b>'+name+':</b>';
5352 html += '<table class=fstat style="padding-top:'+(maxlen*5)+'px;"><tr><th>Function</th>';
5387 " ul {list-style-type:circle;padding-left:10px;margin-left:10px;}"+
5431 zoombox.scrollLeft = dragval[1] + dragval[0] - e.clientX;
5479 hf.write(script_code);
5622 return os.readlink(file).split('/')[-1]
5656 '---------------------------------------------------------------------------------------------\n'\
5661 '---------------------------------------------------------------------------------------------\n'\
5663 '---------------------------------------------------------------------------------------------')
5669 if(not re.match(r'.*/power', dirname) or
5674 dirname = dirname[:-6]
5675 device = dirname.split('/')[-1]
5676 power = dict()
5677 power[tgtval] = readFile('%s/power/%s' % (dirname, tgtval))
5679 if power[tgtval] not in ['active', 'suspended', 'suspending']:
5690 power[i] = readFile('%s/power/%s' % (dirname, i))
5692 if power['control'] == output:
5693 res.append('%s/power/control' % dirname)
5695 lines[dirname] = '%-26s %-26s %1s %1s %1s %1s %1s %10s %10s' % \
5697 yesno(power['async']), \
5698 yesno(power['control']), \
5699 yesno(power['runtime_status']), \
5700 power['runtime_usage'], \
5701 power['runtime_active_kids'], \
5702 ms2nice(power['runtime_active_time']), \
5703 ms2nice(power['runtime_suspended_time']))
5710 # Determine the supported power modes on this system
5727 modes.append('mem-%s' % memmode)
5734 modes.append('disk-%s' % m.strip('[]'))
5740 'bios-vendor': 'bios_vendor',
5741 'bios-version': 'bios_version',
5742 'bios-release-date': 'bios_date',
5743 'system-manufacturer': 'sys_vendor',
5744 'system-product-name': 'product_name',
5745 'system-version': 'product_version',
5746 'system-serial-number': 'product_serial',
5747 'baseboard-manufacturer': 'board_vendor',
5748 'baseboard-product-name': 'board_name',
5749 'baseboard-version': 'board_version',
5750 'baseboard-serial-number': 'board_serial',
5751 'chassis-manufacturer': 'chassis_vendor',
5752 'chassis-version': 'chassis_version',
5753 'chassis-serial-number': 'chassis_serial',
5760 if 'processor-version' not in out and os.path.exists(cpath):
5765 out['processor-version'] = m.group('c').strip()
5787 'bios-vendor': (0, 4),
5788 'bios-version': (0, 5),
5789 'bios-release-date': (0, 8),
5790 'system-manufacturer': (1, 4),
5791 'system-product-name': (1, 5),
5792 'system-version': (1, 6),
5793 'system-serial-number': (1, 7),
5794 'baseboard-manufacturer': (2, 4),
5795 'baseboard-product-name': (2, 5),
5796 'baseboard-version': (2, 6),
5797 'baseboard-serial-number': (2, 7),
5798 'chassis-manufacturer': (3, 4),
5799 'chassis-version': (3, 6),
5800 'chassis-serial-number': (3, 7),
5801 'processor-manufacturer': (4, 7),
5802 'processor-version': (4, 16),
5833 if buf[i:i+4] == b'_SM_' and i < memsize - 16:
5856 while(count < num and i <= len(buf) - 4):
5859 while n < len(buf) - 1:
5868 if idx > 0 and idx < len(data) - 1:
5869 s = data[idx-1].decode('utf-8')
5965 recdata = fp.read(rechead[1]-8)
5997 fwData[0] = record[1] - record[0]
6049 pprint(' is "%s" a valid power mode: %s' % (sysvals.suspendmode, res))
6051 pprint(' valid power modes are: %s' % modes)
6052 pprint(' please choose one with -m')
6062 status = efmt.format('-f')
6064 status = efmt.format('-dev')
6066 status = efmt.format('-proc')
6150 doError(name+': non-integer value given', True)
6169 doError(name+': non-numerical value given', True)
6199 sysvals.vprint(' %-8s : %s' % (key.upper(), sysvals.stamp[key]))
6215 sysvals.vprint('[%s - %s]' % (info[0], info[1]))
6313 num = re.search(r'[-+]?\d*\.\d+|\d+', str)
6344 m = re.match(r'[a-z0-9]* failed in (?P<p>\S*).*', error)
6382 m = re.match(r'.* -m (?P<m>\S*).*', line)
6385 low = find_in_html(html, 'freeze time: <b>', ' ms</b>')
6387 if not low:
6389 if lowstr not in low:
6392 issue = 'S2LOOPx%d' % len(low.split('+'))
6394 m = re.match(r'.*waking *(?P<n>[0-9]*) *times.*', low)
6412 m = re.match(r' *<div id=\"[a,0-9]*\" *title=\"(?P<title>.*)\" class=\"thread.*', line)
6415 m = re.match(r'(?P<n>.*) \((?P<t>[0-9,\.]*) ms\) (?P<p>.*)', m.group('title'))
6422 name = ' '.join(name.split(' ')[:-1])
6464 for arg in ['-multi ', '-info ']:
6490 # create a summary of tests in a sub-directory
6520 pprint(' summary.html - tabular list of test data found')
6521 createHTMLDeviceSummary(testruns, os.path.join(outpath, 'summary-devices.html'), title)
6522 pprint(' summary-devices.html - kernel device list sorted by total execution time')
6523 createHTMLIssuesSummary(testruns, issues, os.path.join(outpath, 'summary-issues.html'), title)
6524 pprint(' summary-issues.html - kernel issues found sorted by frequency')
6534 doError('invalid boolean --> (%s: %s), use "true/false" or "1/0"' % (name, value), True)
6564 elif(option == 'override-timeline-functions'):
6566 elif(option == 'override-dev-timeline-functions'):
6575 sysvals.rs = -1
6579 doError('invalid value --> (%s: %s), use "enable/disable"' % (option, value), True)
6583 doError('invalid value --> (%s: %s), use %s' % (option, value, disopt), True)
6601 doError('invalid phase --> (%s: %s), valid phases are %s'\
6645 elif(option == 'callloop-maxgap'):
6646 sysvals.callloopmaxgap = getArgFloat('callloop-maxgap', value, 0.0, 1.0, False)
6647 elif(option == 'callloop-maxlen'):
6648 sysvals.callloopmaxgap = getArgFloat('callloop-maxlen', value, 0.0, 1.0, False)
6653 elif(option == 'output-dir'):
6661 doError('-dev is not compatible with -f')
6663 doError('-proc is not compatible with -f')
6694 if val[0] == '[' and val[-1] == ']':
6695 for prop in val[1:-1].split(','):
6714 for arg in re.findall('{(?P<n>[a-z,A-Z,0-9]*)}', format):
6752 ' Generates output files in subdirectory: suspend-yymmdd-HHMMSS\n'\
6758 ' -h Print this help text\n'\
6759 ' -v Print the current tool version\n'\
6760 ' -config fn Pull arguments and config options from file fn\n'\
6761 ' -verbose Print extra information during execution and analysis\n'\
6762 ' -m mode Mode to initiate for suspend (default: %s)\n'\
6763 ' -o name Overrides the output subdirectory name when running a new test\n'\
6764 ' default: suspend-{date}-{time}\n'\
6765 ' -rtcwake t Wakeup t seconds after suspend, set t to "off" to disable (default: 15)\n'\
6766 ' -addlogs Add the dmesg and ftrace logs to the html output\n'\
6767 ' -noturbostat Dont use turbostat in freeze mode (default: disabled)\n'\
6768 ' -srgap Add a visible gap in the timeline between sus/res (default: disabled)\n'\
6769 …' -skiphtml Run the test and capture the trace logs, but skip the timeline (default: disabled…
6770 ' -result fn Export a results table to a text file for parsing.\n'\
6771 ' -wifi If a wifi connection is available, check that it reconnects after resume.\n'\
6772 ' -wifitrace Trace kernel execution through wifi reconnect.\n'\
6773 ' -netfix Use netfix to reset the network in the event it fails to resume.\n'\
6774 ' -debugtiming Add timestamp to each printed line\n'\
6776 ' -sync Sync the filesystems before starting the test\n'\
6777 ' -rs on/off Enable/disable runtime suspend for all devices, restore all after test\n'\
6778 ' -display m Change the display mode to m for the test (on/off/standby/suspend)\n'\
6780 ' -gzip Gzip the trace and dmesg logs to save space\n'\
6781 ' -cmd {s} Run the timeline over a custom command, e.g. "sync -d"\n'\
6782 ' -proc Add usermode process info into the timeline (default: disabled)\n'\
6783 ' -dev Add kernel function calls and threads to the timeline (default: disabled)\n'\
6784 ' -x2 Run two suspend/resumes back to back (default: disabled)\n'\
6785 ' -x2delay t Include t ms delay between multiple test runs (default: 0 ms)\n'\
6786 ' -predelay t Include t ms delay before 1st suspend (default: 0 ms)\n'\
6787 ' -postdelay t Include t ms delay after last resume (default: 0 ms)\n'\
6788 ' -mindev ms Discard all device blocks shorter than ms milliseconds (e.g. 0.001 for us)\n'\
6789 ' -multi n d Execute <n> consecutive tests at <d> seconds intervals. If <n> is followed\n'\
6792 ' -maxfail n Abort a -multi run after n consecutive fails (default is 0 = never abort)\n'\
6794 ' -f Use ftrace to create device callgraphs (default: disabled)\n'\
6795 ' -ftop Use ftrace on the top level call: "%s" (default: disabled)\n'\
6796 ' -maxdepth N limit the callgraph data to N call levels (default: 0=all)\n'\
6797 ' -expandcg pre-expand the callgraph data in the html output (default: disabled)\n'\
6798 ' -fadd file Add functions to be graphed in the timeline from a list in a text file\n'\
6799 ' -filter "d1,d2,..." Filter out all but this comma-delimited list of device names\n'\
6800 ' -mincg ms Discard all callgraphs shorter than ms milliseconds (e.g. 0.001 for us)\n'\
6801 ' -cgphase P Only show callgraph data for phase P (e.g. suspend_late)\n'\
6802 ' -cgtest N Only show callgraph data for test N (e.g. 0 or 1 in an x2 run)\n'\
6803 ' -timeprec N Number of significant digits in timestamps (0:S, [3:ms], 6:us)\n'\
6804 ' -cgfilter S Filter the callgraph output in the timeline\n'\
6805 ' -cgskip file Callgraph functions to skip, off to disable (default: cgskip.txt)\n'\
6806 ' -bufsize N Set trace buffer size to N kilo-bytes (default: all of free memory)\n'\
6807 ' -devdump Print out all the raw device data for each phase\n'\
6808 ' -cgdump Print out all the raw callgraph data\n'\
6811 ' -modes List available suspend modes\n'\
6812 ' -status Test to see if the system is enabled to run this tool\n'\
6813 ' -fpdt Print out the contents of the ACPI Firmware Performance Data Table\n'\
6814 ' -wificheck Print out wifi connection info\n'\
6815 ' -x<mode> Test xset by toggling the given mode (on/off/standby/suspend)\n'\
6816 ' -sysinfo Print out system info extracted from BIOS\n'\
6817 ' -devinfo Print out the pm settings of all devices which support runtime suspend\n'\
6818 ' -cmdinfo Print out all the platform info collected before and after suspend/resume\n'\
6819 ' -flist Print the list of functions currently being captured in ftrace\n'\
6820 ' -flistall Print all functions capable of being captured in ftrace\n'\
6821 ' -summary dir Create a summary of tests in this dir [-genhtml builds missing html]\n'\
6823 ' -ftrace ftracefile Create HTML output using ftrace input (used with -dmesg)\n'\
6824 ' -dmesg dmesgfile Create HTML output using dmesg (used with -ftrace)\n'\
6828 # ----------------- MAIN --------------------
6833 simplecmds = ['-sysinfo', '-modes', '-fpdt', '-flist', '-flistall',
6834 '-devinfo', '-status', '-xon', '-xoff', '-xstandby', '-xsuspend',
6835 '-xinit', '-xreset', '-xstat', '-wificheck', '-cmdinfo']
6836 if '-f' in sys.argv:
6841 if(arg == '-m'):
6851 elif(arg == '-h'):
6854 elif(arg == '-v'):
6857 elif(arg == '-debugtiming'):
6859 elif(arg == '-x2'):
6861 elif(arg == '-x2delay'):
6862 sysvals.x2delay = getArgInt('-x2delay', args, 0, 60000)
6863 elif(arg == '-predelay'):
6864 sysvals.predelay = getArgInt('-predelay', args, 0, 60000)
6865 elif(arg == '-postdelay'):
6866 sysvals.postdelay = getArgInt('-postdelay', args, 0, 60000)
6867 elif(arg == '-f'):
6869 elif(arg == '-ftop'):
6873 elif(arg == '-skiphtml'):
6875 elif(arg == '-cgdump'):
6877 elif(arg == '-devdump'):
6879 elif(arg == '-genhtml'):
6881 elif(arg == '-addlogs'):
6883 elif(arg == '-nologs'):
6885 elif(arg == '-addlogdmesg'):
6887 elif(arg == '-addlogftrace'):
6889 elif(arg == '-noturbostat'):
6891 elif(arg == '-verbose'):
6893 elif(arg == '-proc'):
6895 elif(arg == '-dev'):
6897 elif(arg == '-sync'):
6899 elif(arg == '-wifi'):
6901 elif(arg == '-wifitrace'):
6903 elif(arg == '-netfix'):
6905 elif(arg == '-gzip'):
6907 elif(arg == '-info'):
6911 doError('-info requires one string argument', True)
6912 elif(arg == '-desc'):
6916 doError('-desc requires one string argument', True)
6917 elif(arg == '-rs'):
6921 doError('-rs requires "enable" or "disable"', True)
6924 sysvals.rs = -1
6929 elif(arg == '-display'):
6933 doError('-display requires an mode value', True)
6938 elif(arg == '-maxdepth'):
6939 sysvals.max_graph_depth = getArgInt('-maxdepth', args, 0, 1000)
6940 elif(arg == '-rtcwake'):
6949 sysvals.rtcwaketime = getArgInt('-rtcwake', val, 0, 3600, False)
6950 elif(arg == '-timeprec'):
6951 sysvals.setPrecision(getArgInt('-timeprec', args, 0, 6))
6952 elif(arg == '-mindev'):
6953 sysvals.mindevlen = getArgFloat('-mindev', args, 0.0, 10000.0)
6954 elif(arg == '-mincg'):
6955 sysvals.mincglen = getArgFloat('-mincg', args, 0.0, 10000.0)
6956 elif(arg == '-bufsize'):
6957 sysvals.bufsize = getArgInt('-bufsize', args, 1, 1024*1024*8)
6958 elif(arg == '-cgtest'):
6959 sysvals.cgtest = getArgInt('-cgtest', args, 0, 1)
6960 elif(arg == '-cgphase'):
6967 doError('invalid phase --> (%s: %s), valid phases are %s'\
6970 elif(arg == '-cgfilter'):
6976 elif(arg == '-skipkprobe'):
6982 elif(arg == '-cgskip'):
6993 elif(arg == '-callloop-maxgap'):
6994 sysvals.callloopmaxgap = getArgFloat('-callloop-maxgap', args, 0.0, 1.0)
6995 elif(arg == '-callloop-maxlen'):
6996 sysvals.callloopmaxlen = getArgFloat('-callloop-maxlen', args, 0.0, 1.0)
6997 elif(arg == '-cmd'):
7004 elif(arg == '-expandcg'):
7006 elif(arg == '-srgap'):
7008 elif(arg == '-maxfail'):
7009 sysvals.maxfail = getArgInt('-maxfail', args, 0, 1000000)
7010 elif(arg == '-multi'):
7014 doError('-multi requires two values', True)
7016 elif(arg == '-o'):
7022 elif(arg == '-config'):
7031 elif(arg == '-fadd'):
7040 elif(arg == '-dmesg'):
7049 elif(arg == '-ftrace'):
7058 elif(arg == '-summary'):
7068 elif(arg == '-filter'):
7074 elif(arg == '-result'):
7085 doError('-dev is not compatible with -f')
7087 doError('-proc is not compatible with -f')
7137 print('[%s - %s]\n%s\n' % out)
7140 # if instructed, re-analyze existing data files
7154 memmode = mode.split('-', 1)[-1] if '-' in mode else 'deep'
7163 if mode.startswith('disk-'):
7164 sysvals.diskmode = mode.split('-', 1)[-1]
7173 s = '-%dm' % sysvals.multitest['time']
7175 s = '-x%d' % sysvals.multitest['count']
7176 sysvals.outdir = datetime.now().strftime('suspend-%y%m%d-%H%M%S'+s)
7188 fmt = 'suspend-%y%m%d-%H%M%S'