Lines Matching +full:cpu +full:- +full:viewed

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
33 # viewed in firefox or chrome.
51 # ----------------- LIBRARIES --------------------
74 print('[%09.3f] %s' % (time.time()-mystarttime, msg))
82 # ----------------- CLASSES --------------------
86 # A global, single-instance container used to
108 cgtest = -1
129 s0ixres = '/sys/devices/system/cpu/cpuidle/low_power_idle_system_residency_us'
183 tmstart = 'SUSPEND START %Y%m%d-%H:%M:%S.%f'
184 tmend = 'RESUME COMPLETE %Y%m%d-%H:%M:%S.%f'
226 'args_x86_64': {'cpu':'%di:s32'},
227 'format': 'CPU_OFF[{cpu}]'
231 'args_x86_64': {'cpu':'%di:s32'},
232 'format': 'CPU_ON[{cpu}]'
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 ''
456 self.sysstamp = '# sysinfo | man:%s | plat:%s | cpu:%s | bios:%s | biosdate:%s | numcpu:%d | memsz:%d | memfr:%d' % \
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
815 tgtsize -= 65536
819 self.vprint('Setting trace buffers to %d kB (%d kB per cpu)' % (tgtsize, tgtsize/cpus))
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')
921 cmd = 'chown -R {0}:{0} {1} > /dev/null 2>&1'
1002 footer += '# platform-testcmd: %s\n' % (self.testcommand)
1026 dev = dirname.split('/')[-2]
1028 props[dev].syspath = dirname[:-6]
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
1471 # contents: start/stop times, pid/cpu/driver info
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]
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)
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>' \
2791 if 'man' in stamp and 'plat' in stamp and 'cpu' in stamp and \
2792 stamp['man'] and stamp['plat'] and stamp['cpu']:
2794 self.html += headline_sysinfo.format(stamp['man'], stamp['plat'], stamp['cpu'])
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 -</button><button id="zoomdef">ZOOM 1:1</button></center>\n'
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):
3369 id = 'task %s cpu %s' % (pid, m.group('cpu'))
3494 # process cpu exec line
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))
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',
4027 'emsg': 'PM: Preparing system for[a-z]* sleep.*' },
4039 'emsg': 'Disabling non-boot CPUs .*' },
4042 t0 = -1.0
4043 cpu_start = -1.0
4044 prevktime = -1.0
4048 m = re.match(r'[ \t]*(\[ *)(?P<ktime>[0-9\.]*)(\]) (?P<msg>.*)', line)
4145 # -- device callbacks --
4150 data.newAction(phase, f, int(n), p, ktime, -1, '')
4169 if(a in actions and actions[a][-1]['begin'] == actions[a][-1]['end']):
4170 actions[a][-1]['end'] = ktime
4171 # now look for CPU on/off events
4172 if(re.match(r'Disabling non-boot CPUs .*', msg)):
4173 # start of first cpu suspend
4175 elif(re.match(r'Enabling non-boot CPUs .*', msg)):
4176 # start of first cpu resume
4178 elif(re.match(r'smpboot: CPU (?P<cpu>[0-9]*) is now offline', msg) \
4179 or re.match(r'psci: CPU(?P<cpu>[0-9]*) killed.*', msg)):
4180 # end of a cpu suspend, start of the next
4181 m = re.match(r'smpboot: CPU (?P<cpu>[0-9]*) is now offline', msg)
4183 m = re.match(r'psci: CPU(?P<cpu>[0-9]*) killed.*', msg)
4184 cpu = 'CPU'+m.group('cpu')
4185 if(cpu not in actions):
4186 actions[cpu] = []
4187 actions[cpu].append({'begin': cpu_start, 'end': ktime})
4189 elif(re.match(r'CPU(?P<cpu>[0-9]*) is up', msg)):
4190 # end of a cpu resume, start of the next
4191 m = re.match(r'CPU(?P<cpu>[0-9]*) is up', msg)
4192 cpu = 'CPU'+m.group('cpu')
4193 if(cpu not in actions):
4194 actions[cpu] = []
4195 actions[cpu].append({'begin': cpu_start, 'end': ktime})
4245 cglen = (cg.end - cg.start) * 1000
4308 tdcenter = 'text-align:center;' if center else ''
4310 <meta http-equiv="content-type" content="text/html; charset=UTF-8">\n\
4313 .stamp {width: 100%;text-align:center;background:#888;line-height:30px;color:white;font: 25px Arial;}\n\
4314 table {width:100%;border-collapse: collapse;border:1px solid;}\n\
4318 tr.alt {background-color:#ddd;}\n\
4320 .minval {background-color:#BBFFBB;}\n\
4321 .medval {background-color:#BBBBFF;}\n\
4322 .maxval {background-color:#FFBBBB;}\n\
4323 .head a {color:#000;text-decoration: none;}\n\
4334 html = summaryCSS('Summary - SleepGraph')
4372 idx = len(list[mode]['data']) - 1
4457 iMin = iMed = iMax = [-1, -1, -1]
4460 # row classes - alternate row color
4504 html = summaryCSS('Device Summary - SleepGraph', False)
4550 # row classes - alternate row color
4571 html = summaryCSS('Issues Summary - SleepGraph', False)
4594 # row classes - alternate row color
4641 data.trimFreezeTime(testruns[-1].tSuspended)
4647 html_traceevent = '<div title="{0}" class="traceevent{6}" style="left:{1}%;top:{2}px;height:{3}px;width:{4}%;line-height:{3}px;{7}">{5}</div>\n'
4655 '<td class="gray" title="time spent in low-power mode with clock running">'+sysvals.suspendmode+' time: <b>{1} ms</b></td>'\
4680 tTotal = data.end - data.start
4704 rtot += data.end - data.tKernRes + (data.wifi['time'] * 1000.0)
4736 wtime = '%.0f ms'%(data.end - data.tKernRes + (data.wifi['time'] * 1000.0))
4747 tMax = testruns[-1].end
4748 tTotal = tMax - t0
4781 d = testruns[0].addHorizontalDivider(msg, testruns[-1].end)
4785 d = testruns[0].addHorizontalDivider('asynchronous kernel threads', testruns[-1].end)
4807 left = '%f' % (((m0-t0)*100.0)/tTotal)
4814 left = '%f' % ((((m0-t0)*100.0)+sysvals.srgap/2)/tTotal)
4815 mTotal = mMax - m0
4819 width = '%f' % (((mTotal*100.0)-sysvals.srgap/2)/tTotal)
4824 length = phase['end']-phase['start']
4825 left = '%f' % (((phase['start']-m0)*100.0)/mTotal)
4834 right = '%f' % (((mMax-t)*100.0)/mTotal)
4840 dname = d if ('[' not in d or 'CPU' in d) else d.split('[')[0]
4858 left = '%f' % (((dev['start']-m0)*100)/mTotal)
4859 width = '%f' % (((dev['end']-dev['start'])*100)/mTotal)
4860 length = ' (%0.3f ms) ' % ((dev['end']-dev['start'])*1000)
4879 left = '%f' % (((start-m0)*100)/mTotal)
4880 width = '%f' % ((end-start)*100/mTotal)
4892 left = '%f' % (((e.time-m0)*100)/mTotal)
4909 phasedef = testruns[-1].phasedef
4932 pscolor = 'linear-gradient(to top left, #ccc, #eee)'
4937 length = phase['end']-phase['start']
4938 left = '%.3f' % (((phase['start']-t0)*100.0)/tTotal)
4953 data = testruns[-1]
4999 hoverZ = 'z-index:8;'
5013 <meta http-equiv="content-type" content="text/html; charset=UTF-8">\n\
5016 body {overflow-y:scroll;}\n\
5017 .stamp {width:100%;text-align:center;background:gray;line-height:30px;color:white;font:25px Arial;}\n\
5019 .callgraph {margin-top:30px;box-shadow:5px 5px 20px black;}\n\
5020 .callgraph article * {padding-left:28px;}\n\
5025 t3 {color:black;font:20px Times;white-space:nowrap;}\n\
5026 t4 {color:black;font:bold 30px Times;line-height:60px;white-space:nowrap;}\n\
5035 .time2 {font:15px Arial;border-bottom:1px solid;border-left:1px solid;border-right:1px solid;}\n\
5037 td {text-align:center;}\n\
5043 .pf:'+cgchk+' + label {background:url(\'data:image/svg+xml;utf,<?xml version="1.0" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" height="18" width="18" version="1.1"><circle cx="9" cy="9" r="8" stroke="black" stroke-width="1" fill="white"/><rect x="4" y="8" width="10" height="2" style="fill:black;stroke-width:0"/><rect x="8" y="4" width="2" height="10" style="fill:black;stroke-width:0"/></svg>\') no-repeat left center;}\n\
5044 .pf:'+cgnchk+' ~ label {background:url(\'data:image/svg+xml;utf,<?xml version="1.0" standalone="no"?><svg xmlns="http://www.w3.org/2000/svg" height="18" width="18" version="1.1"><circle cx="9" cy="9" r="8" stroke="black" stroke-width="1" fill="white"/><rect x="4" y="8" width="10" height="2" style="fill:black;stroke-width:0"/></svg>\') no-repeat left center;}\n\
5045 .pf:'+cgchk+' ~ *:not(:nth-child(2)) {display:none;}\n\
5046 .zoombox {position:relative;width:100%;overflow-x:scroll;-webkit-user-select:none;-moz-user-select:none;user-select:none;}\n\
5047 .timeline {position:relative;font-size:14px;cursor:pointer;width:100%; overflow:hidden;background:linear-gradient(#cccccc, white);}\n\
5048 .thread {position:absolute;height:0%;overflow:hidden;z-index:7;line-height:30px;font-size:14px;border:1px solid;text-align:center;white-space:nowrap;}\n\
5049 .thread.ps {border-radius:3px;background:linear-gradient(to top, #ccc, #eee);}\n\
5051 .thread.sec,.thread.sec:hover {background:black;border:0;color:white;line-height:15px;font-size:10px;}\n\
5055 .jiffie {position:absolute;pointer-events: none;z-index:8;}\n\
5056 .traceevent {position:absolute;font-size:10px;z-index:7;overflow:hidden;color:black;text-align:center;white-space:nowrap;border-radius:5px;border:1px solid black;background:linear-gradient(to bottom right,#CCC,#969696);}\n\
5057 .traceevent:hover {color:white;font-weight:bold;border:1px solid white;}\n\
5058 .phase {position:absolute;overflow:hidden;border:0px;text-align:center;}\n\
5059 .phaselet {float:left;overflow:hidden;border:0px;text-align:center;min-height:100px;font-size:24px;}\n\
5060 .t {position:absolute;line-height:'+('%d'%scaleTH)+'px;pointer-events:none;top:0;height:100%;border-right:1px solid black;z-index:6;}\n\
5061 .err {position:absolute;top:0%;height:100%;border-right:3px solid red;color:red;font:bold 14px Times;line-height:18px;}\n\
5062 .legend {position:relative; width:100%; height:40px; text-align:center;margin-bottom:20px}\n\
5063 .legend .square {position:absolute;cursor:pointer;top:10px; width:0px;height:20px;border:1px solid;padding-left:20px;}\n\
5064 button {height:40px;width:200px;margin-bottom:20px;margin-top:20px;font-size:24px;}\n\
5065 .btnfmt {position:relative;float:right;height:25px;width:auto;margin-top:3px;margin-bottom:0;font-size:10px;text-align:center;}\n\
5067 a:link {color:white;text-decoration:none;}\n\
5071 .version {position:relative;float:left;color:white;font-size:10px;line-height:30px;margin-left:10px;}\n\
5072 #devicedetail {min-height:100px;box-shadow:5px 5px 20px black;}\n\
5074 .tback {position:absolute;width:100%;background:linear-gradient(#ccc, #ddd);}\n\
5075 .bg {z-index:1;}\n\
5088 tMax = testruns[-1].end * 1000
5098 script_code = r""" var resolution = -1;
5101 var rline = '<div class="t" style="left:0;border-left:1px solid black;border-right:0;">';
5102 var tTotal = tMax - t0;
5112 var divEdge = (mTotal - tS*(divTotal-1))*100/mTotal;
5118 pos = 100 - (((j)*tS*100)/mTotal) - divEdge;
5119 val = (j-divTotal+1)*tS;
5120 if(j == divTotal - 1)
5125 pos = 100 - (((j)*tS*100)/mTotal);
5150 zoombox.scrollLeft = ((left + sh) * newval / val) - sh;
5155 zoombox.scrollLeft = ((left + sh) * newval / val) - sh;
5163 var tTotal = tMax - t0;
5167 if(i >= tS.length) i = tS.length - 1;
5180 var cpu = -1;
5181 if(name.match("CPU_ON\[[0-9]*\]"))
5182 cpu = parseInt(name.slice(7));
5183 else if(name.match("CPU_OFF\[[0-9]*\]"))
5184 cpu = parseInt(name.slice(8));
5188 if((cpu >= 0 && dname.match("CPU_O[NF]*\\[*"+cpu+"\\]")) ||
5204 function deviceTitle(title, total, cpu) {
5213 if(cpu >= 0) name = "CPU"+cpu;
5235 var cpu = -1;
5236 if(name.match("CPU_ON\[[0-9]*\]"))
5237 cpu = parseInt(name.slice(7));
5238 else if(name.match("CPU_OFF\[[0-9]*\]"))
5239 cpu = parseInt(name.slice(8));
5250 if((cpu >= 0 && dname.match("CPU_O[NF]*\\[*"+cpu+"\\]")) ||
5264 var pname = info[info.length-1];
5265 var length = parseFloat(info[info.length-3].slice(1));
5277 var devname = deviceTitle(this.title, total, cpu);
5293 var time = "<t4 style=\"font-size:"+fs+"px\">"+pd[phases[i].id].toFixed(3)+" ms<br></t4>";
5294 var pname = "<t3 style=\"font-size:"+fs2+"px\">"+phases[i].id.replace(new RegExp("_", "g"), " ")+"</t3>";
5322 var name = tmp[0], phase = tmp[tmp.length-1];
5342 var html = '<div style="padding-top:'+pad+'px"><t3> <b>'+name+':</b>';
5351 html += '<table class=fstat style="padding-top:'+(maxlen*5)+'px;"><tr><th>Function</th>';
5386 " ul {list-style-type:circle;padding-left:10px;margin-left:10px;}"+
5430 zoombox.scrollLeft = dragval[1] + dragval[0] - e.clientX;
5621 return os.readlink(file).split('/')[-1]
5655 '---------------------------------------------------------------------------------------------\n'\
5660 '---------------------------------------------------------------------------------------------\n'\
5662 '---------------------------------------------------------------------------------------------')
5673 dirname = dirname[:-6]
5674 device = dirname.split('/')[-1]
5694 lines[dirname] = '%-26s %-26s %1s %1s %1s %1s %1s %10s %10s' % \
5726 modes.append('mem-%s' % memmode)
5733 modes.append('disk-%s' % m.strip('[]'))
5739 'bios-vendor': 'bios_vendor',
5740 'bios-version': 'bios_version',
5741 'bios-release-date': 'bios_date',
5742 'system-manufacturer': 'sys_vendor',
5743 'system-product-name': 'product_name',
5744 'system-version': 'product_version',
5745 'system-serial-number': 'product_serial',
5746 'baseboard-manufacturer': 'board_vendor',
5747 'baseboard-product-name': 'board_name',
5748 'baseboard-version': 'board_version',
5749 'baseboard-serial-number': 'board_serial',
5750 'chassis-manufacturer': 'chassis_vendor',
5751 'chassis-version': 'chassis_version',
5752 'chassis-serial-number': 'chassis_serial',
5759 if 'processor-version' not in out and os.path.exists(cpath):
5764 out['processor-version'] = m.group('c').strip()
5786 'bios-vendor': (0, 4),
5787 'bios-version': (0, 5),
5788 'bios-release-date': (0, 8),
5789 'system-manufacturer': (1, 4),
5790 'system-product-name': (1, 5),
5791 'system-version': (1, 6),
5792 'system-serial-number': (1, 7),
5793 'baseboard-manufacturer': (2, 4),
5794 'baseboard-product-name': (2, 5),
5795 'baseboard-version': (2, 6),
5796 'baseboard-serial-number': (2, 7),
5797 'chassis-manufacturer': (3, 4),
5798 'chassis-version': (3, 6),
5799 'chassis-serial-number': (3, 7),
5800 'processor-manufacturer': (4, 7),
5801 'processor-version': (4, 16),
5832 if buf[i:i+4] == b'_SM_' and i < memsize - 16:
5855 while(count < num and i <= len(buf) - 4):
5858 while n < len(buf) - 1:
5867 if idx > 0 and idx < len(data) - 1:
5868 s = data[idx-1].decode('utf-8')
5964 recdata = fp.read(rechead[1]-8)
5996 fwData[0] = record[1] - record[0]
6051 pprint(' please choose one with -m')
6061 status = efmt.format('-f')
6063 status = efmt.format('-dev')
6065 status = efmt.format('-proc')
6149 doError(name+': non-integer value given', True)
6168 doError(name+': non-numerical value given', True)
6193 shown = ['os', 'bios', 'biosdate', 'cpu', 'host', 'kernel', 'man', 'memfr',
6198 sysvals.vprint(' %-8s : %s' % (key.upper(), sysvals.stamp[key]))
6214 sysvals.vprint('[%s - %s]' % (info[0], info[1]))
6312 num = re.search(r'[-+]?\d*\.\d+|\d+', str)
6343 m = re.match(r'[a-z0-9]* failed in (?P<p>\S*).*', error)
6381 m = re.match(r'.* -m (?P<m>\S*).*', line)
6393 m = re.match(r'.*waking *(?P<n>[0-9]*) *times.*', low)
6411 m = re.match(r' *<div id=\"[a,0-9]*\" *title=\"(?P<title>.*)\" class=\"thread.*', line)
6414 m = re.match(r'(?P<n>.*) \((?P<t>[0-9,\.]*) ms\) (?P<p>.*)', m.group('title'))
6421 name = ' '.join(name.split(' ')[:-1])
6463 for arg in ['-multi ', '-info ']:
6489 # create a summary of tests in a sub-directory
6519 pprint(' summary.html - tabular list of test data found')
6520 createHTMLDeviceSummary(testruns, os.path.join(outpath, 'summary-devices.html'), title)
6521 pprint(' summary-devices.html - kernel device list sorted by total execution time')
6522 createHTMLIssuesSummary(testruns, issues, os.path.join(outpath, 'summary-issues.html'), title)
6523 pprint(' summary-issues.html - kernel issues found sorted by frequency')
6533 doError('invalid boolean --> (%s: %s), use "true/false" or "1/0"' % (name, value), True)
6563 elif(option == 'override-timeline-functions'):
6565 elif(option == 'override-dev-timeline-functions'):
6574 sysvals.rs = -1
6578 doError('invalid value --> (%s: %s), use "enable/disable"' % (option, value), True)
6582 doError('invalid value --> (%s: %s), use %s' % (option, value, disopt), True)
6600 doError('invalid phase --> (%s: %s), valid phases are %s'\
6644 elif(option == 'callloop-maxgap'):
6645 sysvals.callloopmaxgap = getArgFloat('callloop-maxgap', value, 0.0, 1.0, False)
6646 elif(option == 'callloop-maxlen'):
6647 sysvals.callloopmaxgap = getArgFloat('callloop-maxlen', value, 0.0, 1.0, False)
6652 elif(option == 'output-dir'):
6660 doError('-dev is not compatible with -f')
6662 doError('-proc is not compatible with -f')
6693 if val[0] == '[' and val[-1] == ']':
6694 for prop in val[1:-1].split(','):
6713 for arg in re.findall('{(?P<n>[a-z,A-Z,0-9]*)}', format):
6751 ' Generates output files in subdirectory: suspend-yymmdd-HHMMSS\n'\
6757 ' -h Print this help text\n'\
6758 ' -v Print the current tool version\n'\
6759 ' -config fn Pull arguments and config options from file fn\n'\
6760 ' -verbose Print extra information during execution and analysis\n'\
6761 ' -m mode Mode to initiate for suspend (default: %s)\n'\
6762 ' -o name Overrides the output subdirectory name when running a new test\n'\
6763 ' default: suspend-{date}-{time}\n'\
6764 ' -rtcwake t Wakeup t seconds after suspend, set t to "off" to disable (default: 15)\n'\
6765 ' -addlogs Add the dmesg and ftrace logs to the html output\n'\
6766 ' -noturbostat Dont use turbostat in freeze mode (default: disabled)\n'\
6767 ' -srgap Add a visible gap in the timeline between sus/res (default: disabled)\n'\
6768 ' -skiphtml Run the test and capture the trace logs, but skip the timeline (default: disabled)\n'\
6769 ' -result fn Export a results table to a text file for parsing.\n'\
6770 ' -wifi If a wifi connection is available, check that it reconnects after resume.\n'\
6771 ' -wifitrace Trace kernel execution through wifi reconnect.\n'\
6772 ' -netfix Use netfix to reset the network in the event it fails to resume.\n'\
6773 ' -debugtiming Add timestamp to each printed line\n'\
6775 ' -sync Sync the filesystems before starting the test\n'\
6776 ' -rs on/off Enable/disable runtime suspend for all devices, restore all after test\n'\
6777 ' -display m Change the display mode to m for the test (on/off/standby/suspend)\n'\
6779 ' -gzip Gzip the trace and dmesg logs to save space\n'\
6780 ' -cmd {s} Run the timeline over a custom command, e.g. "sync -d"\n'\
6781 ' -proc Add usermode process info into the timeline (default: disabled)\n'\
6782 ' -dev Add kernel function calls and threads to the timeline (default: disabled)\n'\
6783 ' -x2 Run two suspend/resumes back to back (default: disabled)\n'\
6784 ' -x2delay t Include t ms delay between multiple test runs (default: 0 ms)\n'\
6785 ' -predelay t Include t ms delay before 1st suspend (default: 0 ms)\n'\
6786 ' -postdelay t Include t ms delay after last resume (default: 0 ms)\n'\
6787 ' -mindev ms Discard all device blocks shorter than ms milliseconds (e.g. 0.001 for us)\n'\
6788 ' -multi n d Execute <n> consecutive tests at <d> seconds intervals. If <n> is followed\n'\
6791 ' -maxfail n Abort a -multi run after n consecutive fails (default is 0 = never abort)\n'\
6793 ' -f Use ftrace to create device callgraphs (default: disabled)\n'\
6794 ' -ftop Use ftrace on the top level call: "%s" (default: disabled)\n'\
6795 ' -maxdepth N limit the callgraph data to N call levels (default: 0=all)\n'\
6796 ' -expandcg pre-expand the callgraph data in the html output (default: disabled)\n'\
6797 ' -fadd file Add functions to be graphed in the timeline from a list in a text file\n'\
6798 ' -filter "d1,d2,..." Filter out all but this comma-delimited list of device names\n'\
6799 ' -mincg ms Discard all callgraphs shorter than ms milliseconds (e.g. 0.001 for us)\n'\
6800 ' -cgphase P Only show callgraph data for phase P (e.g. suspend_late)\n'\
6801 ' -cgtest N Only show callgraph data for test N (e.g. 0 or 1 in an x2 run)\n'\
6802 ' -timeprec N Number of significant digits in timestamps (0:S, [3:ms], 6:us)\n'\
6803 ' -cgfilter S Filter the callgraph output in the timeline\n'\
6804 ' -cgskip file Callgraph functions to skip, off to disable (default: cgskip.txt)\n'\
6805 ' -bufsize N Set trace buffer size to N kilo-bytes (default: all of free memory)\n'\
6806 ' -devdump Print out all the raw device data for each phase\n'\
6807 ' -cgdump Print out all the raw callgraph data\n'\
6810 ' -modes List available suspend modes\n'\
6811 ' -status Test to see if the system is enabled to run this tool\n'\
6812 ' -fpdt Print out the contents of the ACPI Firmware Performance Data Table\n'\
6813 ' -wificheck Print out wifi connection info\n'\
6814 ' -x<mode> Test xset by toggling the given mode (on/off/standby/suspend)\n'\
6815 ' -sysinfo Print out system info extracted from BIOS\n'\
6816 ' -devinfo Print out the pm settings of all devices which support runtime suspend\n'\
6817 ' -cmdinfo Print out all the platform info collected before and after suspend/resume\n'\
6818 ' -flist Print the list of functions currently being captured in ftrace\n'\
6819 ' -flistall Print all functions capable of being captured in ftrace\n'\
6820 ' -summary dir Create a summary of tests in this dir [-genhtml builds missing html]\n'\
6822 ' -ftrace ftracefile Create HTML output using ftrace input (used with -dmesg)\n'\
6823 ' -dmesg dmesgfile Create HTML output using dmesg (used with -ftrace)\n'\
6827 # ----------------- MAIN --------------------
6832 simplecmds = ['-sysinfo', '-modes', '-fpdt', '-flist', '-flistall',
6833 '-devinfo', '-status', '-xon', '-xoff', '-xstandby', '-xsuspend',
6834 '-xinit', '-xreset', '-xstat', '-wificheck', '-cmdinfo']
6835 if '-f' in sys.argv:
6840 if(arg == '-m'):
6850 elif(arg == '-h'):
6853 elif(arg == '-v'):
6856 elif(arg == '-debugtiming'):
6858 elif(arg == '-x2'):
6860 elif(arg == '-x2delay'):
6861 sysvals.x2delay = getArgInt('-x2delay', args, 0, 60000)
6862 elif(arg == '-predelay'):
6863 sysvals.predelay = getArgInt('-predelay', args, 0, 60000)
6864 elif(arg == '-postdelay'):
6865 sysvals.postdelay = getArgInt('-postdelay', args, 0, 60000)
6866 elif(arg == '-f'):
6868 elif(arg == '-ftop'):
6872 elif(arg == '-skiphtml'):
6874 elif(arg == '-cgdump'):
6876 elif(arg == '-devdump'):
6878 elif(arg == '-genhtml'):
6880 elif(arg == '-addlogs'):
6882 elif(arg == '-nologs'):
6884 elif(arg == '-addlogdmesg'):
6886 elif(arg == '-addlogftrace'):
6888 elif(arg == '-noturbostat'):
6890 elif(arg == '-verbose'):
6892 elif(arg == '-proc'):
6894 elif(arg == '-dev'):
6896 elif(arg == '-sync'):
6898 elif(arg == '-wifi'):
6900 elif(arg == '-wifitrace'):
6902 elif(arg == '-netfix'):
6904 elif(arg == '-gzip'):
6906 elif(arg == '-info'):
6910 doError('-info requires one string argument', True)
6911 elif(arg == '-desc'):
6915 doError('-desc requires one string argument', True)
6916 elif(arg == '-rs'):
6920 doError('-rs requires "enable" or "disable"', True)
6923 sysvals.rs = -1
6928 elif(arg == '-display'):
6932 doError('-display requires an mode value', True)
6937 elif(arg == '-maxdepth'):
6938 sysvals.max_graph_depth = getArgInt('-maxdepth', args, 0, 1000)
6939 elif(arg == '-rtcwake'):
6948 sysvals.rtcwaketime = getArgInt('-rtcwake', val, 0, 3600, False)
6949 elif(arg == '-timeprec'):
6950 sysvals.setPrecision(getArgInt('-timeprec', args, 0, 6))
6951 elif(arg == '-mindev'):
6952 sysvals.mindevlen = getArgFloat('-mindev', args, 0.0, 10000.0)
6953 elif(arg == '-mincg'):
6954 sysvals.mincglen = getArgFloat('-mincg', args, 0.0, 10000.0)
6955 elif(arg == '-bufsize'):
6956 sysvals.bufsize = getArgInt('-bufsize', args, 1, 1024*1024*8)
6957 elif(arg == '-cgtest'):
6958 sysvals.cgtest = getArgInt('-cgtest', args, 0, 1)
6959 elif(arg == '-cgphase'):
6966 doError('invalid phase --> (%s: %s), valid phases are %s'\
6969 elif(arg == '-cgfilter'):
6975 elif(arg == '-skipkprobe'):
6981 elif(arg == '-cgskip'):
6992 elif(arg == '-callloop-maxgap'):
6993 sysvals.callloopmaxgap = getArgFloat('-callloop-maxgap', args, 0.0, 1.0)
6994 elif(arg == '-callloop-maxlen'):
6995 sysvals.callloopmaxlen = getArgFloat('-callloop-maxlen', args, 0.0, 1.0)
6996 elif(arg == '-cmd'):
7003 elif(arg == '-expandcg'):
7005 elif(arg == '-srgap'):
7007 elif(arg == '-maxfail'):
7008 sysvals.maxfail = getArgInt('-maxfail', args, 0, 1000000)
7009 elif(arg == '-multi'):
7013 doError('-multi requires two values', True)
7015 elif(arg == '-o'):
7021 elif(arg == '-config'):
7030 elif(arg == '-fadd'):
7039 elif(arg == '-dmesg'):
7048 elif(arg == '-ftrace'):
7057 elif(arg == '-summary'):
7067 elif(arg == '-filter'):
7073 elif(arg == '-result'):
7084 doError('-dev is not compatible with -f')
7086 doError('-proc is not compatible with -f')
7136 print('[%s - %s]\n%s\n' % out)
7139 # if instructed, re-analyze existing data files
7153 memmode = mode.split('-', 1)[-1] if '-' in mode else 'deep'
7162 if mode.startswith('disk-'):
7163 sysvals.diskmode = mode.split('-', 1)[-1]
7172 s = '-%dm' % sysvals.multitest['time']
7174 s = '-x%d' % sysvals.multitest['count']
7175 sysvals.outdir = datetime.now().strftime('suspend-%y%m%d-%H%M%S'+s)
7187 fmt = 'suspend-%y%m%d-%H%M%S'