History

Merge back earlier pm-tools material for v5.3.

Rafael J. Wysocki committed 7 years ago

Commit d3820842 parents 30f234b d5a5e4e5 files · +1253 −206Browse files

Unified · Split

5 files
  1. tools/power/pm-graph/README +552 −0
  2. tools/power/pm-graph/bootgraph.py +4 −4
  3. tools/power/pm-graph/config/example.cfg +26 −0
  4. tools/power/pm-graph/sleepgraph.8 +14 −2
  5. tools/power/pm-graph/sleepgraph.py +657 −200
tools/power/pm-graph/README+552−0
@@ -0,0 +1,552 @@
1+ p m - g r a p h
2+
3+ pm-graph: suspend/resume/boot timing analysis tools
4+ Version: 5.4
5+ Author: Todd Brandt <todd.e.brandt@intel.com>
6+ Home Page: https://01.org/pm-graph
7+
8+ Report bugs/issues at bugzilla.kernel.org Tools/pm-graph
9+ - https://bugzilla.kernel.org/buglist.cgi?component=pm-graph&product=Tools
10+
11+ Full documentation available online & in man pages
12+ - Getting Started:
13+ https://01.org/pm-graph/documentation/getting-started
14+
15+ - Config File Format:
16+ https://01.org/pm-graph/documentation/3-config-file-format
17+
18+ - upstream version in git:
19+ https://github.com/intel/pm-graph/
20+
21+ Table of Contents
22+ - Overview
23+ - Setup
24+ - Usage
25+ - Basic Usage
26+ - Dev Mode Usage
27+ - Proc Mode Usage
28+ - Configuration Files
29+ - Usage Examples
30+ - Config File Options
31+ - Custom Timeline Entries
32+ - Adding/Editing Timeline Functions
33+ - Adding/Editing Dev Timeline Source Functions
34+ - Verifying your Custom Functions
35+ - Testing on consumer linux Operating Systems
36+ - Android
37+
38+------------------------------------------------------------------
39+| OVERVIEW |
40+------------------------------------------------------------------
41+
42+ This tool suite is designed to assist kernel and OS developers in optimizing
43+ their linux stack's suspend/resume & boot time. Using a kernel image built
44+ with a few extra options enabled, the tools will execute a suspend or boot,
45+ and will capture dmesg and ftrace data. This data is transformed into a set of
46+ timelines and a callgraph to give a quick and detailed view of which devices
47+ and kernel processes are taking the most time in suspend/resume & boot.
48+
49+------------------------------------------------------------------
50+| SETUP |
51+------------------------------------------------------------------
52+
53+ These packages are required to execute the scripts
54+ - python
55+ - python-requests
56+
57+ Ubuntu:
58+ sudo apt-get install python python-requests
59+
60+ Fedora:
61+ sudo dnf install python python-requests
62+
63+ The tools can most easily be installed via git clone and make install
64+
65+ $> git clone http://github.com/intel/pm-graph.git
66+ $> cd pm-graph
67+ $> sudo make install
68+ $> man sleepgraph ; man bootgraph
69+
70+ Setup involves some minor kernel configuration
71+
72+ The following kernel build options are required for all kernels:
73+ CONFIG_DEVMEM=y
74+ CONFIG_PM_DEBUG=y
75+ CONFIG_PM_SLEEP_DEBUG=y
76+ CONFIG_FTRACE=y
77+ CONFIG_FUNCTION_TRACER=y
78+ CONFIG_FUNCTION_GRAPH_TRACER=y
79+ CONFIG_KPROBES=y
80+ CONFIG_KPROBES_ON_FTRACE=y
81+
82+ In kernel 3.15.0, two patches were upstreamed which enable the
83+ v3.0 behavior. These patches allow the tool to read all the
84+ data from trace events instead of from dmesg. You can enable
85+ this behavior on earlier kernels with these patches:
86+
87+ (kernel/pre-3.15/enable_trace_events_suspend_resume.patch)
88+ (kernel/pre-3.15/enable_trace_events_device_pm_callback.patch)
89+
90+ If you're using a kernel older than 3.15.0, the following
91+ additional kernel parameters are required:
92+ (e.g. in file /etc/default/grub)
93+ GRUB_CMDLINE_LINUX_DEFAULT="... initcall_debug log_buf_len=32M ..."
94+
95+ If you're using a kernel older than 3.11-rc2, the following simple
96+ patch must be applied to enable ftrace data:
97+ in file: kernel/power/suspend.c
98+ in function: int suspend_devices_and_enter(suspend_state_t state)
99+ remove call to "ftrace_stop();"
100+ remove call to "ftrace_start();"
101+
102+ There is a patch which does this for kernel v3.8.0:
103+ (kernel/pre-3.11-rc2/enable_ftrace_in_suspendresume.patch)
104+
105+
106+
107+------------------------------------------------------------------
108+| USAGE |
109+------------------------------------------------------------------
110+
111+Basic Usage
112+___________
113+
114+ 1) First configure a kernel using the instructions from the previous sections.
115+ Then build, install, and boot with it.
116+ 2) Open up a terminal window and execute the mode list command:
117+
118+ %> sudo ./sleepgraph.py -modes
119+ ['freeze', 'mem', 'disk']
120+
121+ Execute a test using one of the available power modes, e.g. mem (S3):
122+
123+ %> sudo ./sleepgraph.py -m mem -rtcwake 15
124+
125+ or with a config file
126+
127+ %> sudo ./sleepgraph.py -config config/suspend.cfg
128+
129+ When the system comes back you'll see the script finishing up and
130+ creating the output files in the test subdir. It generates output
131+ files in subdirectory: suspend-mmddyy-HHMMSS. The ftrace file can
132+ be used to regenerate the html timeline with different options
133+
134+ HTML output: <hostname>_<mode>.html
135+ raw dmesg output: <hostname>_<mode>_dmesg.txt
136+ raw ftrace output: <hostname>_<mode>_ftrace.txt
137+
138+ View the html in firefox or chrome.
139+
140+
141+Dev Mode Usage
142+______________
143+
144+ Developer mode adds information on low level source calls to the timeline.
145+ The tool sets kprobes on all delay and mutex calls to see which devices
146+ are waiting for something and when. It also sets a suite of kprobes on
147+ subsystem dependent calls to better fill out the timeline.
148+
149+ The tool will also expose kernel threads that don't normally show up in the
150+ timeline. This is useful in discovering dependent threads to get a better
151+ idea of what each device is waiting for. For instance, the scsi_eh thread,
152+ a.k.a. scsi resume error handler, is what each SATA disk device waits for
153+ before it can continue resume.
154+
155+ The timeline will be much larger if run with dev mode, so it can be useful
156+ to set the -mindev option to clip out any device blocks that are too small
157+ to see easily. The following command will give a nice dev mode run:
158+
159+ %> sudo ./sleepgraph.py -m mem -rtcwake 15 -mindev 1 -dev
160+
161+ or with a config file
162+
163+ %> sudo ./sleepgraph.py -config config/suspend-dev.cfg
164+
165+
166+Proc Mode Usage
167+_______________
168+
169+ Proc mode adds user process info to the timeline. This is done in a manner
170+ similar to the bootchart utility, which graphs init processes and their
171+ execution as the system boots. This tool option does the same thing but for
172+ the period before and after suspend/resume.
173+
174+ In order to see any process info, there needs to be some delay before or
175+ after resume since processes are frozen in suspend_prepare and thawed in
176+ resume_complete. The predelay and postdelay args allow you to do this. It
177+ can also be useful to run in x2 mode with an x2 delay, this way you can
178+ see process activity before and after resume, and in between two
179+ successive suspend/resumes.
180+
181+ The command can be run like this:
182+
183+ %> sudo ./sleepgraph.py -m mem -rtcwake 15 -x2 -x2delay 1000 -predelay 1000 -postdelay 1000 -proc
184+
185+ or with a config file
186+
187+ %> sudo ./sleepgraph.py -config config/suspend-proc.cfg
188+
189+
190+------------------------------------------------------------------
191+| CONFIGURATION FILES |
192+------------------------------------------------------------------
193+
194+ Since 4.0 we've moved to using config files in lieu of command line options.
195+ The config folder contains a collection of typical use cases.
196+ There are corresponding configs for other power modes:
197+
198+ Simple suspend/resume with basic timeline (mem/freeze/standby)
199+ config/suspend.cfg
200+ config/freeze.cfg
201+ config/standby.cfg
202+
203+ Dev mode suspend/resume with dev timeline (mem/freeze/standby)
204+ config/suspend-dev.cfg
205+ config/freeze-dev.cfg
206+ config/standby-dev.cfg
207+
208+ Simple suspend/resume with timeline and callgraph (mem/freeze/standby)
209+ config/suspend-callgraph.cfg
210+ config/freeze-callgraph.cfg
211+ config/standby-callgraph.cfg
212+
213+ Sample proc mode x2 run using mem suspend
214+ config/suspend-x2-proc.cfg
215+
216+ Sample for editing timeline funcs (moves internal functions into config)
217+ config/custom-timeline-functions.cfg
218+
219+ Sample debug config for serio subsystem
220+ config/debug-serio-suspend.cfg
221+
222+
223+Usage Examples
224+______________
225+
226+ Run a simple mem suspend:
227+ %> sudo ./sleepgraph.py -config config/suspend.cfg
228+
229+ Run a mem suspend with callgraph data:
230+ %> sudo ./sleepgraph.py -config config/suspend-callgraph.cfg
231+
232+ Run a mem suspend with dev mode detail:
233+ %> sudo ./sleepgraph.py -config config/suspend-dev.cfg
234+
235+
236+Config File Options
237+___________________
238+
239+ [Settings]
240+
241+ # Verbosity: print verbose messages (def: false)
242+ verbose: false
243+
244+ # Suspend Mode: e.g. standby, mem, freeze, disk (def: mem)
245+ mode: mem
246+
247+ # Output Directory Format: {hostname}, {date}, {time} give current values
248+ output-dir: suspend-{hostname}-{date}-{time}
249+
250+ # Automatic Wakeup: use rtcwake to wakeup after X seconds (def: infinity)
251+ rtcwake: 15
252+
253+ # Add Logs: add the dmesg and ftrace log to the html output (def: false)
254+ addlogs: false
255+
256+ # Sus/Res Gap: insert a gap between sus & res in the timeline (def: false)
257+ srgap: false
258+
259+ # Custom Command: Command to execute in lieu of suspend (def: "")
260+ command: echo mem > /sys/power/state
261+
262+ # Proc mode: graph user processes and cpu usage in the timeline (def: false)
263+ proc: false
264+
265+ # Dev mode: graph source functions in the timeline (def: false)
266+ dev: false
267+
268+ # Suspend/Resume x2: run 2 suspend/resumes back to back (def: false)
269+ x2: false
270+
271+ # x2 Suspend Delay: time delay between the two test runs in ms (def: 0 ms)
272+ x2delay: 0
273+
274+ # Pre Suspend Delay: nclude an N ms delay before (1st) suspend (def: 0 ms)
275+ predelay: 0
276+
277+ # Post Resume Delay: include an N ms delay after (last) resume (def: 0 ms)
278+ postdelay: 0
279+
280+ # Min Device Length: graph only dev callbacks longer than min (def: 0.001 ms)
281+ mindev: 0.001
282+
283+ # Callgraph: gather ftrace callgraph data on all timeline events (def: false)
284+ callgraph: false
285+
286+ # Expand Callgraph: pre-expand the callgraph treeviews in html (def: false)
287+ expandcg: false
288+
289+ # Min Callgraph Length: show callgraphs only if longer than min (def: 1 ms)
290+ mincg: 1
291+
292+ # Timestamp Precision: number of sig digits in timestamps (0:S, [3:ms], 6:us)
293+ timeprec: 3
294+
295+ # Device Filter: show only devs whose name/driver includes one of these strings
296+ devicefilter: _cpu_up,_cpu_down,i915,usb
297+
298+ # Override default timeline entries:
299+ # Do not use the internal default functions for timeline entries (def: false)
300+ # Set this to true if you intend to only use the ones defined in the config
301+ override-timeline-functions: true
302+
303+ # Override default dev timeline entries:
304+ # Do not use the internal default functions for dev timeline entries (def: false)
305+ # Set this to true if you intend to only use the ones defined in the config
306+ override-dev-timeline-functions: true
307+
308+ # Call Loop Max Gap (dev mode only)
309+ # merge loops of the same call if each is less than maxgap apart (def: 100us)
310+ callloop-maxgap: 0.0001
311+
312+ # Call Loop Max Length (dev mode only)
313+ # merge loops of the same call if each is less than maxlen in length (def: 5ms)
314+ callloop-maxlen: 0.005
315+
316+------------------------------------------------------------------
317+| CUSTOM TIMELINE ENTRIES |
318+------------------------------------------------------------------
319+
320+Adding or Editing Timeline Functions
321+____________________________________
322+
323+ The tool uses an array of function names to fill out empty spaces in the
324+ timeline where device callbacks don't appear. For instance, in suspend_prepare
325+ the tool adds the sys_sync and freeze_processes calls as virtual device blocks
326+ in the timeline to show you where the time is going. These calls should fill
327+ the timeline with contiguous data so that most kernel execution is covered.
328+
329+ It is possible to add new function calls to the timeline by adding them to
330+ the config. It's also possible to copy the internal timeline functions into
331+ the config so that you can override and edit them. Place them in the
332+ timeline_functions_ARCH section with the name of your architecture appended.
333+ i.e. for x86_64: [timeline_functions_x86_64]
334+
335+ Use the override-timeline-functions option if you only want to use your
336+ custom calls, or leave it false to append them to the internal ones.
337+
338+ This section includes a list of functions (set using kprobes) which use both
339+ symbol data and function arg data. The args are pulled directly from the
340+ stack using this architecture's registers and stack formatting. Each entry
341+ can include up to four pieces of info: The function name, a format string,
342+ an argument list, and a color. But only a function name is required.
343+
344+ For a full example config, see config/custom-timeline-functions.cfg. It pulls
345+ all the internal timeline functions into the config and allows you to edit
346+ them.
347+
348+ Entry format:
349+
350+ function: format{fn_arg1}_{fn_arg2} fn_arg1 fn_arg2 ... [color=purple]
351+
352+ Required Arguments:
353+
354+ function: The symbol name for the function you want probed, this is the
355+ minimum required for an entry, it will show up as the function
356+ name with no arguments.
357+
358+ example: _cpu_up:
359+
360+ Optional Arguments:
361+
362+ format: The format to display the data on the timeline in. Use braces to
363+ enclose the arg names.
364+
365+ example: CPU_ON[{cpu}]
366+
367+ color: The color of the entry block in the timeline. The default color is
368+ transparent, so the entry shares the phase color. The color is an
369+ html color string, either a word, or an RGB.
370+
371+ example: [color=#CC00CC]
372+
373+ arglist: A list of arguments from registers/stack addresses. See URL:
374+ https://www.kernel.org/doc/Documentation/trace/kprobetrace.txt
375+
376+ example: cpu=%di:s32
377+
378+ Here is a full example entry. It displays cpu resume calls in the timeline
379+ in orange. They will appear as CPU_ON[0], CPU_ON[1], etc.
380+
381+ [timeline_functions_x86_64]
382+ _cpu_up: CPU_ON[{cpu}] cpu=%di:s32 [color=orange]
383+
384+
385+Adding or Editing Dev Mode Timeline Source Functions
386+____________________________________________________
387+
388+ In dev mode, the tool uses an array of function names to monitor source
389+ execution within the timeline entries.
390+
391+ The function calls are displayed inside the main device/call blocks in the
392+ timeline. However, if a function call is not within a main timeline event,
393+ it will spawn an entirely new event named after the caller's kernel thread.
394+ These asynchronous kernel threads will populate in a separate section
395+ beneath the main device/call section.
396+
397+ The tool has a set of hard coded calls which focus on the most common use
398+ cases: msleep, udelay, schedule_timeout, mutex_lock_slowpath, etc. These are
399+ the functions that add a hardcoded time delay to the suspend/resume path.
400+ The tool also includes some common functions native to important
401+ subsystems: ata, i915, and ACPI, etc.
402+
403+ It is possible to add new function calls to the dev timeline by adding them
404+ to the config. It's also possible to copy the internal dev timeline
405+ functions into the config so that you can override and edit them. Place them
406+ in the dev_timeline_functions_ARCH section with the name of your architecture
407+ appended. i.e. for x86_64: [dev_timeline_functions_x86_64]
408+
409+ Use the override-dev-timeline-functions option if you only want to use your
410+ custom calls, or leave it false to append them to the internal ones.
411+
412+ The format is the same as the timeline_functions_x86_64 section. It's a
413+ list of functions (set using kprobes) which use both symbol data and function
414+ arg data. The args are pulled directly from the stack using this
415+ architecture's registers and stack formatting. Each entry can include up
416+ to four pieces of info: The function name, a format string, an argument list,
417+ and a color. But only the function name is required.
418+
419+ For a full example config, see config/custom-timeline-functions.cfg. It pulls
420+ all the internal dev timeline functions into the config and allows you to edit
421+ them.
422+
423+ Here is a full example entry. It displays the ATA port reset calls as
424+ ataN_port_reset in the timeline. This is where most of the SATA disk resume
425+ time goes, so it can be helpful to see the low level call.
426+
427+ [dev_timeline_functions_x86_64]
428+ ata_eh_recover: ata{port}_port_reset port=+36(%di):s32 [color=#CC00CC]
429+
430+
431+Verifying your custom functions
432+_______________________________
433+
434+ Once you have a set of functions (kprobes) defined, it can be useful to
435+ perform a quick check to see if you formatted them correctly and if the system
436+ actually supports them. To do this, run the tool with your config file
437+ and the -status option. The tool will go through all the kprobes (both
438+ custom and internal if you haven't overridden them) and actually attempts
439+ to set them in ftrace. It will then print out success or fail for you.
440+
441+ Note that kprobes which don't actually exist in the kernel won't stop the
442+ tool, they just wont show up.
443+
444+ For example:
445+
446+ sudo ./sleepgraph.py -config config/custom-timeline-functions.cfg -status
447+ Checking this system (myhostname)...
448+ have root access: YES
449+ is sysfs mounted: YES
450+ is "mem" a valid power mode: YES
451+ is ftrace supported: YES
452+ are kprobes supported: YES
453+ timeline data source: FTRACE (all trace events found)
454+ is rtcwake supported: YES
455+ verifying timeline kprobes work:
456+ _cpu_down: YES
457+ _cpu_up: YES
458+ acpi_pm_finish: YES
459+ acpi_pm_prepare: YES
460+ freeze_kernel_threads: YES
461+ freeze_processes: YES
462+ sys_sync: YES
463+ thaw_processes: YES
464+ verifying dev kprobes work:
465+ __const_udelay: YES
466+ __mutex_lock_slowpath: YES
467+ acpi_os_stall: YES
468+ acpi_ps_parse_aml: YES
469+ intel_opregion_init: NO
470+ intel_opregion_register: NO
471+ intel_opregion_setup: NO
472+ msleep: YES
473+ schedule_timeout: YES
474+ schedule_timeout_uninterruptible: YES
475+ usleep_range: YES
476+
477+
478+------------------------------------------------------------------
479+| TESTING ON CONSUMER LINUX OPERATING SYSTEMS |
480+------------------------------------------------------------------
481+
482+Android
483+_______
484+
485+ The easiest way to execute on an android device is to run the android.sh
486+ script on the device, then pull the ftrace log back to the host and run
487+ sleepgraph.py on it.
488+
489+ Here are the steps:
490+
491+ [download and install the tool on the device]
492+
493+ host%> wget https://raw.githubusercontent.com/intel/pm-graph/master/tools/android.sh
494+ host%> adb connect 192.168.1.6
495+ host%> adb root
496+ # push the script to a writeable location
497+ host%> adb push android.sh /sdcard/
498+
499+ [check whether the tool will run on your device]
500+
501+ host%> adb shell
502+ dev%> cd /sdcard
503+ dev%> sh android.sh status
504+ host : asus_t100
505+ kernel : 3.14.0-i386-dirty
506+ modes : freeze mem
507+ rtcwake : supported
508+ ftrace : supported
509+ trace events {
510+ suspend_resume: found
511+ device_pm_callback_end: found
512+ device_pm_callback_start: found
513+ }
514+ # the above is what you see on a system that's properly patched
515+
516+ [execute the suspend]
517+
518+ # NOTE: The suspend will only work if the screen isn't timed out,
519+ # so you have to press some keys first to wake it up b4 suspend)
520+ dev%> sh android.sh suspend mem
521+ ------------------------------------
522+ Suspend/Resume timing test initiated
523+ ------------------------------------
524+ hostname : asus_t100
525+ kernel : 3.14.0-i386-dirty
526+ mode : mem
527+ ftrace out : /mnt/shell/emulated/0/ftrace.txt
528+ dmesg out : /mnt/shell/emulated/0/dmesg.txt
529+ log file : /mnt/shell/emulated/0/log.txt
530+ ------------------------------------
531+ INITIALIZING FTRACE........DONE
532+ STARTING FTRACE
533+ SUSPEND START @ 21:24:02 (rtcwake in 10 seconds)
534+ <adb connection will now terminate>
535+
536+ [retrieve the data from the device]
537+
538+ # I find that you have to actually kill the adb process and
539+ # reconnect sometimes in order for the connection to work post-suspend
540+ host%> adb connect 192.168.1.6
541+ # (required) get the ftrace data, this is the most important piece
542+ host%> adb pull /sdcard/ftrace.txt
543+ # (optional) get the dmesg data, this is for debugging
544+ host%> adb pull /sdcard/dmesg.txt
545+ # (optional) get the log, which just lists some test times for comparison
546+ host%> adb pull /sdcard/log.txt
547+
548+ [create an output html file using sleepgraph.py]
549+
550+ host%> sleepgraph.py -ftrace ftrace.txt
551+
552+ You should now have an output.html with the android data, enjoy!
tools/power/pm-graph/bootgraph.py+4−4
@@ -325,9 +325,9 @@ def parseKernelLog(): · 324 unmodified lines
325325 if(not sysvals.stamp['kernel']):
326326 sysvals.stamp['kernel'] = sysvals.kernelVersion(msg)
327327 continue
328− m = re.match('.* setting system clock to (?P<t>.*) UTC.*', msg)
328+ m = re.match('.* setting system clock to (?P<d>[0-9\-]*)[ A-Z](?P<t>[0-9:]*) UTC.*', msg)
329329 if(m):
330− bt = datetime.strptime(m.group('t'), '%Y-%m-%d %H:%M:%S')
330+ bt = datetime.strptime(m.group('d')+' '+m.group('t'), '%Y-%m-%d %H:%M:%S')
331331 bt = bt - timedelta(seconds=int(ktime))
332332 data.boottime = bt.strftime('%Y-%m-%d_%H:%M:%S')
333333 sysvals.stamp['time'] = bt.strftime('%B %d %Y, %I:%M:%S %p')
@@ -348,7 +348,7 @@ def parseKernelLog(): · 14 unmodified lines
348348 data.newAction(phase, f, pid, start, ktime, int(r), int(t))
349349 del devtemp[f]
350350 continue
351− if(re.match('^Freeing unused kernel memory.*', msg)):
351+ if(re.match('^Freeing unused kernel .*', msg)):
352352 data.tUserMode = ktime
353353 data.dmesg['kernel']['end'] = ktime
354354 data.dmesg['user']['start'] = ktime
@@ -1008,7 +1008,7 @@ if __name__ == '__main__': · 653 unmodified lines
10081008 updateKernelParams()
10091009 elif cmd == 'flistall':
10101010 for f in sysvals.getBootFtraceFilterFunctions():
1011− print f
1011+ print(f)
10121012 elif cmd == 'checkbl':
10131013 sysvals.getBootLoader()
10141014 pprint('Boot Loader: %s\n%s' % (sysvals.bootloader, sysvals.blexec))
tools/power/pm-graph/config/example.cfg+26−0
@@ -98,12 +98,34 @@ postdelay: 0 · 97 unmodified lines
9898 # graph only devices longer than min in the timeline (default: 0.001 ms)
9999 mindev: 0.001
100100
101+# Call Loop Max Gap (dev mode only)
102+# merge loops of the same call if each is less than maxgap apart (def: 100us)
103+callloop-maxgap: 0.0001
104+
105+# Call Loop Max Length (dev mode only)
106+# merge loops of the same call if each is less than maxlen in length (def: 5ms)
107+callloop-maxlen: 0.005
108+
109+# Override default timeline entries:
110+# Do not use the internal default functions for timeline entries (def: false)
111+# Set this to true if you intend to only use the ones defined in the config
112+override-timeline-functions: true
113+
114+# Override default dev timeline entries:
115+# Do not use the internal default functions for dev timeline entries (def: false)
116+# Set this to true if you intend to only use the ones defined in the config
117+override-dev-timeline-functions: true
118+
101119 # ---- Debug Options ----
102120
103121 # Callgraph
104122 # gather detailed ftrace callgraph data on all timeline events (default: false)
105123 callgraph: false
106124
125+# Max graph depth
126+# limit the callgraph trace to this depth (default: 0 = all)
127+maxdepth: 2
128+
107129 # Callgraph phase filter
108130 # Only enable callgraphs for one phase, i.e. resume_noirq (default: all)
109131 cgphase: suspend
@@ -131,3 +153,7 @@ timeprec: 6 · 21 unmodified lines
131153 # Add kprobe functions to the timeline
132154 # Add functions to the timeline from a text file (default: no-action)
133155 # fadd: file.txt
156+
157+# Ftrace buffer size
158+# Set trace buffer size to N kilo-bytes (default: all of free memory up to 3GB)
159+# bufsize: 1000
tools/power/pm-graph/sleepgraph.8+14−2
@@ -53,6 +53,11 @@ disable rtcwake and require a user keypress to resume. · 52 unmodified lines
5353 Add the dmesg and ftrace logs to the html output. They will be viewable by
5454 clicking buttons in the timeline.
5555 .TP
56+\fB-turbostat\fR
57+Use turbostat to execute the command in freeze mode (default: disabled). This
58+will provide turbostat output in the log which will tell you which actual
59+power modes were entered.
60+.TP
5661 \fB-result \fIfile\fR
5762 Export a results table to a text file for parsing.
5863 .TP
@@ -121,6 +126,10 @@ be created in a new subdirectory with a summary page: suspend-xN-{date}-{time}. · 62 unmodified lines
121126 Use ftrace to create device callgraphs (default: disabled). This can produce
122127 very large outputs, i.e. 10MB - 100MB.
123128 .TP
129+\fB-ftop\fR
130+Use ftrace on the top level call: "suspend_devices_and_enter" only (default: disabled).
131+This option implies -f and creates a single callgraph covering all of suspend/resume.
132+.TP
124133 \fB-maxdepth \fIlevel\fR
125134 limit the callgraph trace depth to \fIlevel\fR (default: 0=all). This is
126135 the best way to limit the output size when using callgraphs via -f.
@@ -138,8 +147,8 @@ which are barely visible in the timeline. · 11 unmodified lines
138147 The value is a float: e.g. 0.001 represents 1 us.
139148 .TP
140149 \fB-cgfilter \fI"func1,func2,..."\fR
141−Reduce callgraph output in the timeline by limiting it to a list of calls. The
142−argument can be a single function name or a comma delimited list.
150+Reduce callgraph output in the timeline by limiting it certain devices. The
151+argument can be a single device name or a comma delimited list.
143152 (default: none)
144153 .TP
145154 \fB-cgskip \fIfile\fR
@@ -183,6 +192,9 @@ Print out the contents of the ACPI Firmware Performance Data Table. · 37 unmodified lines
183192 \fB-battery\fR
184193 Print out battery status and current charge.
185194 .TP
195+\fB-wifi\fR
196+Print out wifi status and connection details.
197+.TP
186198 \fB-xon/-xoff/-xstandby/-xsuspend\fR
187199 Test xset by attempting to switch the display to the given mode. This
188200 is the same command which will be issued by \fB-display \fImode\fR.
tools/power/pm-graph/sleepgraph.py+657−200
@@ -9,9 +9,9 @@ · 8 unmodified lines
99 #
1010 # Links:
1111 # Home Page
12−# https://01.org/suspendresume
12+# https://01.org/pm-graph
1313 # Source repo
14−# git@github.com:01org/pm-graph
14+# git@github.com:intel/pm-graph
1515 #
1616 # Description:
1717 # This tool is designed to assist kernel and OS developers in optimizing
@@ -24,6 +24,7 @@ · 6 unmodified lines
2424 # viewed in firefox or chrome.
2525 #
2626 # The following kernel build options are required:
27+# CONFIG_DEVMEM=y
2728 # CONFIG_PM_DEBUG=y
2829 # CONFIG_PM_SLEEP_DEBUG=y
2930 # CONFIG_FTRACE=y
@@ -53,6 +54,7 @@ import ConfigParser · 23 unmodified lines
5354 import gzip
5455 from threading import Thread
5556 from subprocess import call, Popen, PIPE
57+import base64
5658
5759 def pprint(msg):
5860 print(msg)
@@ -66,7 +68,7 @@ def pprint(msg): · 7 unmodified lines
6668 # store system values and test parameters
6769 class SystemValues:
6870 title = 'SleepGraph'
69− version = '5.2'
71+ version = '5.4'
7072 ansi = False
7173 rs = 0
7274 display = ''
@@ -74,8 +76,9 @@ class SystemValues: · 1 unmodified line
7476 sync = False
7577 verbose = False
7678 testlog = True
77− dmesglog = False
79+ dmesglog = True
7880 ftracelog = False
81+ tstat = False
7982 mindevlen = 0.0
8083 mincglen = 0.0
8184 cgphase = ''
@@ -99,6 +102,8 @@ class SystemValues: · 17 unmodified lines
99102 pmdpath = '/sys/power/pm_debug_messages'
100103 traceevents = [
101104 'suspend_resume',
105+ 'wakeup_source_activate',
106+ 'wakeup_source_deactivate',
102107 'device_pm_callback_end',
103108 'device_pm_callback_start'
104109 ]
@@ -130,6 +135,8 @@ class SystemValues: · 25 unmodified lines
130135 x2delay = 0
131136 skiphtml = False
132137 usecallgraph = False
138+ ftopfunc = 'suspend_devices_and_enter'
139+ ftop = False
133140 usetraceevents = False
134141 usetracemarkers = True
135142 usekprobes = True
@@ -158,6 +165,13 @@ class SystemValues: · 22 unmodified lines
158165 'acpi_hibernation_leave': {},
159166 'acpi_pm_freeze': {},
160167 'acpi_pm_thaw': {},
168+ 'acpi_s2idle_end': {},
169+ 'acpi_s2idle_sync': {},
170+ 'acpi_s2idle_begin': {},
171+ 'acpi_s2idle_prepare': {},
172+ 'acpi_s2idle_wake': {},
173+ 'acpi_s2idle_wakeup': {},
174+ 'acpi_s2idle_restore': {},
161175 'hibernate_preallocate_memory': {},
162176 'create_basic_memory_bitmaps': {},
163177 'swsusp_write': {},
@@ -191,9 +205,14 @@ class SystemValues: · 27 unmodified lines
191205 'usleep_range': { 'args_x86_64': {'min':'%di:s32', 'max':'%si:s32'}, 'ub': 1 },
192206 'mutex_lock_slowpath': { 'func':'__mutex_lock_slowpath', 'ub': 1 },
193207 'acpi_os_stall': {'ub': 1},
208+ 'rt_mutex_slowlock': {'ub': 1},
194209 # ACPI
195210 'acpi_resume_power_resources': {},
196− 'acpi_ps_parse_aml': {},
211+ 'acpi_ps_execute_method': { 'args_x86_64': {
212+ 'fullpath':'+0(+40(%di)):string',
213+ }},
214+ # mei_me
215+ 'mei_reset': {},
197216 # filesystem
198217 'ext4_sync_fs': {},
199218 # 80211
@@ -242,6 +261,7 @@ class SystemValues: · 42 unmodified lines
242261 timeformat = '%.3f'
243262 cmdline = '%s %s' % \
244263 (os.path.basename(sys.argv[0]), ' '.join(sys.argv[1:]))
264+ kparams = ''
245265 sudouser = ''
246266 def __init__(self):
247267 self.archargs = 'args_'+platform.machine()
@@ -320,6 +340,7 @@ class SystemValues: · 72 unmodified lines
320340 args['date'] = n.strftime('%y%m%d')
321341 args['time'] = n.strftime('%H%M%S')
322342 args['hostname'] = args['host'] = self.hostname
343+ args['mode'] = self.suspendmode
323344 return value.format(**args)
324345 def setOutputFile(self):
325346 if self.dmesgfile != '':
@@ -331,21 +352,28 @@ class SystemValues: · 5 unmodified lines
331352 if(m):
332353 self.htmlfile = m.group('name')+'.html'
333354 def systemInfo(self, info):
334− p = c = m = b = ''
355+ p = m = ''
335356 if 'baseboard-manufacturer' in info:
336357 m = info['baseboard-manufacturer']
337358 elif 'system-manufacturer' in info:
338359 m = info['system-manufacturer']
339− if 'baseboard-product-name' in info:
340− p = info['baseboard-product-name']
341− elif 'system-product-name' in info:
360+ if 'system-product-name' in info:
342361 p = info['system-product-name']
343− if 'processor-version' in info:
344− c = info['processor-version']
345− if 'bios-version' in info:
346− b = info['bios-version']
347− self.sysstamp = '# sysinfo | man:%s | plat:%s | cpu:%s | bios:%s | numcpu:%d | memsz:%d | memfr:%d' % \
348− (m, p, c, b, self.cpucount, self.memtotal, self.memfree)
362+ elif 'baseboard-product-name' in info:
363+ p = info['baseboard-product-name']
364+ if m[:5].lower() == 'intel' and 'baseboard-product-name' in info:
365+ p = info['baseboard-product-name']
366+ c = info['processor-version'] if 'processor-version' in info else ''
367+ b = info['bios-version'] if 'bios-version' in info else ''
368+ r = info['bios-release-date'] if 'bios-release-date' in info else ''
369+ self.sysstamp = '# sysinfo | man:%s | plat:%s | cpu:%s | bios:%s | biosdate:%s | numcpu:%d | memsz:%d | memfr:%d' % \
370+ (m, p, c, b, r, self.cpucount, self.memtotal, self.memfree)
371+ try:
372+ kcmd = open('/proc/cmdline', 'r').read().strip()
373+ except:
374+ kcmd = ''
375+ if kcmd:
376+ self.sysstamp += '\n# kparams | %s' % kcmd
349377 def printSystemInfo(self, fatal=False):
350378 self.rootCheck(True)
351379 out = dmidecode(self.mempath, fatal)
@@ -353,10 +381,10 @@ class SystemValues: · 1 unmodified line
353381 return
354382 fmt = '%-24s: %s'
355383 for name in sorted(out):
356− print fmt % (name, out[name])
357− print fmt % ('cpucount', ('%d' % self.cpucount))
358− print fmt % ('memtotal', ('%d kB' % self.memtotal))
359− print fmt % ('memfree', ('%d kB' % self.memfree))
384+ print(fmt % (name, out[name]))
385+ print(fmt % ('cpucount', ('%d' % self.cpucount)))
386+ print(fmt % ('memtotal', ('%d kB' % self.memtotal)))
387+ print(fmt % ('memfree', ('%d kB' % self.memfree)))
360388 def cpuInfo(self):
361389 self.cpucount = 0
362390 fp = open('/proc/cpuinfo', 'r')
@@ -376,7 +404,7 @@ class SystemValues: · 13 unmodified lines
376404 def initTestOutput(self, name):
377405 self.prefix = self.hostname
378406 v = open('/proc/version', 'r').read().strip()
379− kver = string.split(v)[2]
407+ kver = v.split()[2]
380408 fmt = name+'-%m%d%y-%H%M%S'
381409 testtime = datetime.now().strftime(fmt)
382410 self.teststamp = \
@@ -391,7 +419,7 @@ class SystemValues: · 8 unmodified lines
391419 self.htmlfile = \
392420 self.testdir+'/'+self.prefix+'_'+self.suspendmode+'.html'
393421 if not os.path.isdir(self.testdir):
394− os.mkdir(self.testdir)
422+ os.makedirs(self.testdir)
395423 def getValueList(self, value):
396424 out = []
397425 for i in value.split(','):
@@ -402,6 +430,12 @@ class SystemValues: · 4 unmodified lines
402430 self.devicefilter = self.getValueList(value)
403431 def setCallgraphFilter(self, value):
404432 self.cgfilter = self.getValueList(value)
433+ def skipKprobes(self, value):
434+ for k in self.getValueList(value):
435+ if k in self.tracefuncs:
436+ del self.tracefuncs[k]
437+ if k in self.dev_tracefuncs:
438+ del self.dev_tracefuncs[k]
405439 def setCallgraphBlacklist(self, file):
406440 self.cgblacklist = self.listFromFile(file)
407441 def rtcWakeAlarmOn(self):
@@ -471,9 +505,9 @@ class SystemValues: · 63 unmodified lines
471505 if 'func' in self.tracefuncs[i]:
472506 i = self.tracefuncs[i]['func']
473507 if i in master:
474− print i
508+ print(i)
475509 else:
476− print self.colorText(i)
510+ print(self.colorText(i))
477511 def setFtraceFilterFunctions(self, list):
478512 master = self.listFromFile(self.tpath+'available_filter_functions')
479513 flist = ''
@@ -680,7 +714,8 @@ class SystemValues: · 200 unmodified lines
680714 if self.bufsize > 0:
681715 tgtsize = self.bufsize
682716 elif self.usecallgraph or self.usedevsrc:
683− bmax = (1*1024*1024) if self.suspendmode == 'disk' else (3*1024*1024)
717+ bmax = (1*1024*1024) if self.suspendmode in ['disk', 'command'] \
718+ else (3*1024*1024)
684719 tgtsize = min(self.memfree, bmax)
685720 else:
686721 tgtsize = 65536
@@ -715,7 +750,10 @@ class SystemValues: · 28 unmodified lines
715750 cf.append(self.tracefuncs[fn]['func'])
716751 else:
717752 cf.append(fn)
718− self.setFtraceFilterFunctions(cf)
753+ if self.ftop:
754+ self.setFtraceFilterFunctions([self.ftopfunc])
755+ else:
756+ self.setFtraceFilterFunctions(cf)
719757 # initialize the kprobe trace
720758 elif self.usekprobes:
721759 for name in self.tracefuncs:
@@ -768,9 +806,21 @@ class SystemValues: · 46 unmodified lines
768806 fw = test['fw']
769807 if(fw):
770808 fp.write('# fwsuspend %u fwresume %u\n' % (fw[0], fw[1]))
809+ if 'mcelog' in test:
810+ fp.write('# mcelog %s\n' % test['mcelog'])
811+ if 'turbo' in test:
812+ fp.write('# turbostat %s\n' % test['turbo'])
771813 if 'bat' in test:
772814 (a1, c1), (a2, c2) = test['bat']
773815 fp.write('# battery %s %d %s %d\n' % (a1, c1, a2, c2))
816+ if 'wifi' in test:
817+ wstr = []
818+ for wifi in test['wifi']:
819+ tmp = []
820+ for key in sorted(wifi):
821+ tmp.append('%s:%s' % (key, wifi[key]))
822+ wstr.append('|'.join(tmp))
823+ fp.write('# wifi %s\n' % (','.join(wstr)))
774824 if test['error'] or len(testdata) > 1:
775825 fp.write('# enter_sleep_error %s\n' % test['error'])
776826 return fp
@@ -821,6 +871,106 @@ class SystemValues: · 44 unmodified lines
821871 if isgz:
822872 return gzip.open(filename, mode+'b')
823873 return open(filename, mode)
874+ def mcelog(self, clear=False):
875+ cmd = self.getExec('mcelog')
876+ if not cmd:
877+ return ''
878+ if clear:
879+ call(cmd+' > /dev/null 2>&1', shell=True)
880+ return ''
881+ fp = Popen([cmd], stdout=PIPE, stderr=PIPE).stdout
882+ out = fp.read().strip()
883+ fp.close()
884+ if not out:
885+ return ''
886+ return base64.b64encode(out.encode('zlib'))
887+ def haveTurbostat(self):
888+ if not self.tstat:
889+ return False
890+ cmd = self.getExec('turbostat')
891+ if not cmd:
892+ return False
893+ fp = Popen([cmd, '-v'], stdout=PIPE, stderr=PIPE).stderr
894+ out = fp.read().strip()
895+ fp.close()
896+ return re.match('turbostat version [0-9\.]* .*', out)
897+ def turbostat(self):
898+ cmd = self.getExec('turbostat')
899+ if not cmd:
900+ return 'missing turbostat executable'
901+ text = []
902+ fullcmd = '%s -q -S echo freeze > %s' % (cmd, self.powerfile)
903+ fp = Popen(['sh', '-c', fullcmd], stdout=PIPE, stderr=PIPE).stderr
904+ for line in fp:
905+ if re.match('[0-9.]* sec', line):
906+ continue
907+ text.append(line.split())
908+ fp.close()
909+ if len(text) < 2:
910+ return 'turbostat output format error'
911+ out = []
912+ for key in text[0]:
913+ values = []
914+ idx = text[0].index(key)
915+ for line in text[1:]:
916+ if len(line) > idx:
917+ values.append(line[idx])
918+ out.append('%s=%s' % (key, ','.join(values)))
919+ return '|'.join(out)
920+ def checkWifi(self):
921+ out = dict()
922+ iwcmd, ifcmd = self.getExec('iwconfig'), self.getExec('ifconfig')
923+ if not iwcmd or not ifcmd:
924+ return out
925+ fp = Popen(iwcmd, stdout=PIPE, stderr=PIPE).stdout
926+ for line in fp:
927+ m = re.match('(?P<dev>\S*) .* ESSID:(?P<ess>\S*)', line)
928+ if not m:
929+ continue
930+ out['device'] = m.group('dev')
931+ if '"' in m.group('ess'):
932+ out['essid'] = m.group('ess').strip('"')
933+ break
934+ fp.close()
935+ if 'device' in out:
936+ fp = Popen([ifcmd, out['device']], stdout=PIPE, stderr=PIPE).stdout
937+ for line in fp:
938+ m = re.match('.* inet (?P<ip>[0-9\.]*)', line)
939+ if m:
940+ out['ip'] = m.group('ip')
941+ break
942+ fp.close()
943+ return out
944+ def errorSummary(self, errinfo, msg):
945+ found = False
946+ for entry in errinfo:
947+ if re.match(entry['match'], msg):
948+ entry['count'] += 1
949+ if self.hostname not in entry['urls']:
950+ entry['urls'][self.hostname] = [self.htmlfile]
951+ elif self.htmlfile not in entry['urls'][self.hostname]:
952+ entry['urls'][self.hostname].append(self.htmlfile)
953+ found = True
954+ break
955+ if found:
956+ return
957+ arr = msg.split()
958+ for j in range(len(arr)):
959+ if re.match('^[0-9,\-\.]*$', arr[j]):
960+ arr[j] = '[0-9,\-\.]*'
961+ else:
962+ arr[j] = arr[j]\
963+ .replace('\\', '\\\\').replace(']', '\]').replace('[', '\[')\
964+ .replace('.', '\.').replace('+', '\+').replace('*', '\*')\
965+ .replace('(', '\(').replace(')', '\)')
966+ mstr = ' '.join(arr)
967+ entry = {
968+ 'line': msg,
969+ 'match': mstr,
970+ 'count': 1,
971+ 'urls': {self.hostname: [self.htmlfile]}
972+ }
973+ errinfo.append(entry)
824974
825975 sysvals = SystemValues()
826976 switchvalues = ['enable', 'disable', 'on', 'off', 'true', 'false', '1', '0']
@@ -915,7 +1065,14 @@ class Data: · 88 unmodified lines
9151065 'ERROR' : '.*ERROR.*',
9161066 'WARNING' : '.*WARNING.*',
9171067 'IRQ' : '.*genirq: .*',
918− 'TASKFAIL': '.*Freezing of tasks failed.*',
1068+ 'TASKFAIL': '.*Freezing of tasks *.*',
1069+ 'ACPI' : '.*ACPI *(?P<b>[A-Za-z]*) *Error[: ].*',
1070+ 'DEVFAIL' : '.* failed to (?P<b>[a-z]*) async: .*',
1071+ 'DISKFULL': '.*No space left on device.*',
1072+ 'USBERR' : '.*usb .*device .*, error [0-9-]*',
1073+ 'ATAERR' : ' *ata[0-9\.]*: .*failed.*',
1074+ 'MEIERR' : ' *mei.*: .*failed.*',
1075+ 'TPMERR' : '(?i) *tpm *tpm[0-9]*: .*error.*',
9191076 }
9201077 def __init__(self, num):
9211078 idchar = 'abcdefghij'
@@ -933,6 +1090,9 @@ class Data: · 11 unmodified lines
9331090 self.outfile = ''
9341091 self.kerror = False
9351092 self.battery = 0
1093+ self.wifi = 0
1094+ self.turbostat = 0
1095+ self.mcelog = 0
9361096 self.enterfail = ''
9371097 self.currphase = ''
9381098 self.pstl = dict() # process timeline
@@ -967,8 +1127,24 @@ class Data: · 28 unmodified lines
9671127 if len(plist) < 1:
9681128 return ''
9691129 return plist[-1]
1130+ def turbostatInfo(self):
1131+ tp = TestProps()
1132+ out = {'syslpi':'N/A','pkgpc10':'N/A'}
1133+ for line in self.dmesgtext:
1134+ m = re.match(tp.tstatfmt, line)
1135+ if not m:
1136+ continue
1137+ for i in m.group('t').split('|'):
1138+ if 'SYS%LPI' in i:
1139+ out['syslpi'] = i.split('=')[-1]+'%'
1140+ elif 'pc10' in i:
1141+ out['pkgpc10'] = i.split('=')[-1]+'%'
1142+ break
1143+ return out
9701144 def extractErrorInfo(self):
971− lf = sysvals.openlog(sysvals.dmesgfile, 'r')
1145+ lf = self.dmesgtext
1146+ if len(self.dmesgtext) < 1 and sysvals.dmesgfile:
1147+ lf = sysvals.openlog(sysvals.dmesgfile, 'r')
9721148 i = 0
9731149 list = []
9741150 for line in lf:
@@ -983,16 +1159,19 @@ class Data: · 8 unmodified lines
9831159 msg = m.group('msg')
9841160 for err in self.errlist:
9851161 if re.match(self.errlist[err], msg):
986− list.append((err, dir, t, i, i))
1162+ list.append((msg, err, dir, t, i, i))
9871163 self.kerror = True
9881164 break
989− for e in list:
990− type, dir, t, idx1, idx2 = e
1165+ msglist = []
1166+ for msg, type, dir, t, idx1, idx2 in list:
1167+ msglist.append(msg)
9911168 sysvals.vprint('kernel %s found in %s at %f' % (type, dir, t))
9921169 self.errorinfo[dir].append((type, t, idx1, idx2))
9931170 if self.kerror:
9941171 sysvals.dmesglog = True
995− lf.close()
1172+ if len(self.dmesgtext) < 1 and sysvals.dmesgfile:
1173+ lf.close()
1174+ return msglist
9961175 def setStart(self, time):
9971176 self.start = time
9981177 def setEnd(self, time):
@@ -2045,7 +2224,7 @@ class FTraceCallGraph: · 1046 unmodified lines
20452224 if(data.dmesg[p]['start'] <= self.start and
20462225 self.start <= data.dmesg[p]['end']):
20472226 list = data.dmesg[p]['list']
2048− for devname in list:
2227+ for devname in sorted(list, key=lambda k:list[k]['start']):
20492228 dev = list[devname]
20502229 if(pid == dev['pid'] and
20512230 self.start <= dev['start'] and
@@ -2350,6 +2529,9 @@ class TestProps: · 298 unmodified lines
23502529 '(?P<H>[0-9]{2})(?P<M>[0-9]{2})(?P<S>[0-9]{2})'+\
23512530 ' (?P<host>.*) (?P<mode>.*) (?P<kernel>.*)$'
23522531 batteryfmt = '^# battery (?P<a1>\w*) (?P<c1>\d*) (?P<a2>\w*) (?P<c2>\d*)'
2532+ wififmt = '^# wifi (?P<w>.*)'
2533+ tstatfmt = '^# turbostat (?P<t>\S*)'
2534+ mcelogfmt = '^# mcelog (?P<m>\S*)'
23532535 testerrfmt = '^# enter_sleep_error (?P<e>.*)'
23542536 sysinfofmt = '^# sysinfo .*'
23552537 cmdlinefmt = '^# command \| (?P<cmd>.*)'
@@ -2372,7 +2554,10 @@ class TestProps: · 16 unmodified lines
23722554 self.cmdline = ''
23732555 self.kparams = ''
23742556 self.testerror = []
2557+ self.mcelog = []
2558+ self.turbostat = []
23752559 self.battery = []
2560+ self.wifi = []
23762561 self.fwdata = []
23772562 self.ftrace_line_fmt = self.ftrace_line_fmt_nop
23782563 self.cgformat = False
@@ -2386,6 +2571,44 @@ class TestProps: · 7 unmodified lines
23862571 self.ftrace_line_fmt = self.ftrace_line_fmt_nop
23872572 else:
23882573 doError('Invalid tracer format: [%s]' % tracer)
2574+ def decode(self, data):
2575+ try:
2576+ out = base64.b64decode(data).decode('zlib')
2577+ except:
2578+ out = data
2579+ return out
2580+ def stampInfo(self, line):
2581+ if re.match(self.stampfmt, line):
2582+ self.stamp = line
2583+ return True
2584+ elif re.match(self.sysinfofmt, line):
2585+ self.sysinfo = line
2586+ return True
2587+ elif re.match(self.kparamsfmt, line):
2588+ self.kparams = line
2589+ return True
2590+ elif re.match(self.cmdlinefmt, line):
2591+ self.cmdline = line
2592+ return True
2593+ elif re.match(self.mcelogfmt, line):
2594+ self.mcelog.append(line)
2595+ return True
2596+ elif re.match(self.tstatfmt, line):
2597+ self.turbostat.append(line)
2598+ return True
2599+ elif re.match(self.batteryfmt, line):
2600+ self.battery.append(line)
2601+ return True
2602+ elif re.match(self.wififmt, line):
2603+ self.wifi.append(line)
2604+ return True
2605+ elif re.match(self.testerrfmt, line):
2606+ self.testerror.append(line)
2607+ return True
2608+ elif re.match(self.firmwarefmt, line):
2609+ self.fwdata.append(line)
2610+ return True
2611+ return False
23892612 def parseStamp(self, data, sv):
23902613 # global test data
23912614 m = re.match(self.stampfmt, self.stamp)
@@ -2428,14 +2651,31 @@ class TestProps: · 36 unmodified lines
24282651 sv.stamp = data.stamp
24292652 # firmware data
24302653 if sv.suspendmode == 'mem' and len(self.fwdata) > data.testnumber:
2431− data.fwSuspend, data.fwResume = self.fwdata[data.testnumber]
2432− if(data.fwSuspend > 0 or data.fwResume > 0):
2433− data.fwValid = True
2654+ m = re.match(self.firmwarefmt, self.fwdata[data.testnumber])
2655+ if m:
2656+ data.fwSuspend, data.fwResume = int(m.group('s')), int(m.group('r'))
2657+ if(data.fwSuspend > 0 or data.fwResume > 0):
2658+ data.fwValid = True
2659+ # mcelog data
2660+ if len(self.mcelog) > data.testnumber:
2661+ m = re.match(self.mcelogfmt, self.mcelog[data.testnumber])
2662+ if m:
2663+ data.mcelog = self.decode(m.group('m'))
2664+ # turbostat data
2665+ if len(self.turbostat) > data.testnumber:
2666+ m = re.match(self.tstatfmt, self.turbostat[data.testnumber])
2667+ if m:
2668+ data.turbostat = m.group('t')
24342669 # battery data
24352670 if len(self.battery) > data.testnumber:
24362671 m = re.match(self.batteryfmt, self.battery[data.testnumber])
24372672 if m:
24382673 data.battery = m.groups()
2674+ # wifi data
2675+ if len(self.wifi) > data.testnumber:
2676+ m = re.match(self.wififmt, self.wifi[data.testnumber])
2677+ if m:
2678+ data.wifi = m.group('w')
24392679 # sleep mode enter errors
24402680 if len(self.testerror) > data.testnumber:
24412681 m = re.match(self.testerrfmt, self.testerror[data.testnumber])
@@ -2505,9 +2745,9 @@ class ProcessMonitor: · 63 unmodified lines
25052745 # Quickly determine if the ftrace log has all of the trace events,
25062746 # markers, and/or kprobes required for primary parsing.
25072747 def doesTraceLogHaveTraceEvents():
2508− kpcheck = ['_cal: (', '_cpu_down()']
2748+ kpcheck = ['_cal: (', '_ret: (']
25092749 techeck = ['suspend_resume', 'device_pm_callback']
2510− tmcheck = ['tracing_mark_write']
2750+ tmcheck = ['SUSPEND START', 'RESUME COMPLETE']
25112751 sysvals.usekprobes = False
25122752 fp = sysvals.openlog(sysvals.ftracefile, 'r')
25132753 for line in fp:
@@ -2556,21 +2796,7 @@ def appendIncompleteTraceLog(testruns): · 42 unmodified lines
25562796 for line in tf:
25572797 # remove any latent carriage returns
25582798 line = line.replace('\r\n', '')
2559− # grab the stamp and sysinfo
2560− if re.match(tp.stampfmt, line):
2561− tp.stamp = line
2562− continue
2563− elif re.match(tp.sysinfofmt, line):
2564− tp.sysinfo = line
2565− continue
2566− elif re.match(tp.cmdlinefmt, line):
2567− tp.cmdline = line
2568− continue
2569− elif re.match(tp.batteryfmt, line):
2570− tp.battery.append(line)
2571− continue
2572− elif re.match(tp.testerrfmt, line):
2573− tp.testerror.append(line)
2799+ if tp.stampInfo(line):
25742800 continue
25752801 # determine the trace data type (required for further parsing)
25762802 m = re.match(tp.tracertypefmt, line)
@@ -2693,26 +2919,7 @@ def parseTraceLog(live=False): · 116 unmodified lines
26932919 for line in tf:
26942920 # remove any latent carriage returns
26952921 line = line.replace('\r\n', '')
2696− # stamp and sysinfo lines
2697− if re.match(tp.stampfmt, line):
2698− tp.stamp = line
2699− continue
2700− elif re.match(tp.sysinfofmt, line):
2701− tp.sysinfo = line
2702− continue
2703− elif re.match(tp.cmdlinefmt, line):
2704− tp.cmdline = line
2705− continue
2706− elif re.match(tp.batteryfmt, line):
2707− tp.battery.append(line)
2708− continue
2709− elif re.match(tp.testerrfmt, line):
2710− tp.testerror.append(line)
2711− continue
2712− # firmware line: pull out any firmware data
2713− m = re.match(tp.firmwarefmt, line)
2714− if(m):
2715− tp.fwdata.append((int(m.group('s')), int(m.group('r'))))
2922+ if tp.stampInfo(line):
27162923 continue
27172924 # tracer type line: determine the trace data type
27182925 m = re.match(tp.tracertypefmt, line)
@@ -2925,7 +3132,7 @@ def parseTraceLog(live=False): · 206 unmodified lines
29253132 tp.ktemp[key].append({
29263133 'pid': pid,
29273134 'begin': t.time,
2928− 'end': t.time,
3135+ 'end': -1,
29293136 'name': displayname,
29303137 'cdata': kprobedata,
29313138 'proc': m_proc,
@@ -2936,12 +3143,11 @@ def parseTraceLog(live=False): · 4 unmodified lines
29363143 elif(t.freturn):
29373144 if(key not in tp.ktemp) or len(tp.ktemp[key]) < 1:
29383145 continue
2939− e = tp.ktemp[key][-1]
2940− if e['begin'] < 0.0 or t.time - e['begin'] < 0.000001:
2941− tp.ktemp[key].pop()
2942− else:
2943− e['end'] = t.time
2944− e['rdata'] = kprobedata
3146+ e = next((x for x in reversed(tp.ktemp[key]) if x['end'] < 0), 0)
3147+ if not e:
3148+ continue
3149+ e['end'] = t.time
3150+ e['rdata'] = kprobedata
29453151 # end of kernel resume
29463152 if(phase != 'suspend_prepare' and kprobename in krescalls):
29473153 if phase in data.dmesg:
@@ -2963,8 +3169,10 @@ def parseTraceLog(live=False): · 15 unmodified lines
29633169 if(res == -1):
29643170 testrun.ftemp[key][-1].addLine(t)
29653171 tf.close()
3172+ if len(testdata) < 1:
3173+ sysvals.vprint('WARNING: ftrace start marker is missing')
29663174 if data and not data.devicegroups:
2967− sysvals.vprint('WARNING: end marker is missing')
3175+ sysvals.vprint('WARNING: ftrace end marker is missing')
29683176 data.handleEndMarker(t.time)
29693177
29703178 if sysvals.suspendmode == 'command':
@@ -3013,9 +3221,11 @@ def parseTraceLog(live=False): · 42 unmodified lines
30133221 name, pid = key
30143222 if name not in sysvals.tracefuncs:
30153223 continue
3224+ if pid not in data.devpids:
3225+ data.devpids.append(pid)
30163226 for e in tp.ktemp[key]:
30173227 kb, ke = e['begin'], e['end']
3018− if kb == ke or tlb > kb or tle <= kb:
3228+ if ke - kb < 0.000001 or tlb > kb or tle <= kb:
30193229 continue
30203230 color = sysvals.kprobeColor(name)
30213231 data.newActionGlobal(e['name'], kb, ke, pid, color)
@@ -3027,7 +3237,7 @@ def parseTraceLog(live=False): · 5 unmodified lines
30273237 continue
30283238 for e in tp.ktemp[key]:
30293239 kb, ke = e['begin'], e['end']
3030− if kb == ke or tlb > kb or tle <= kb:
3240+ if ke - kb < 0.000001 or tlb > kb or tle <= kb:
30313241 continue
30323242 data.addDeviceFunctionCall(e['name'], name, e['proc'], pid, kb,
30333243 ke, e['cdata'], e['rdata'])
@@ -3051,7 +3261,7 @@ def parseTraceLog(live=False): · 17 unmodified lines
30513261 if not devname:
30523262 sortkey = '%f%f%d' % (cg.start, cg.end, pid)
30533263 sortlist[sortkey] = cg
3054− elif len(cg.list) > 1000000:
3264+ elif len(cg.list) > 1000000 and cg.name != sysvals.ftopfunc:
30553265 sysvals.vprint('WARNING: the callgraph for %s is massive (%d lines)' %\
30563266 (devname, len(cg.list)))
30573267 # create blocks for orphan cg data
@@ -3133,25 +3343,7 @@ def loadKernelLog(): · 75 unmodified lines
31333343 idx = line.find('[')
31343344 if idx > 1:
31353345 line = line[idx:]
3136− # grab the stamp and sysinfo
3137− if re.match(tp.stampfmt, line):
3138− tp.stamp = line
3139− continue
3140− elif re.match(tp.sysinfofmt, line):
3141− tp.sysinfo = line
3142− continue
3143− elif re.match(tp.cmdlinefmt, line):
3144− tp.cmdline = line
3145− continue
3146− elif re.match(tp.batteryfmt, line):
3147− tp.battery.append(line)
3148− continue
3149− elif re.match(tp.testerrfmt, line):
3150− tp.testerror.append(line)
3151− continue
3152− m = re.match(tp.firmwarefmt, line)
3153− if(m):
3154− tp.fwdata.append((int(m.group('s')), int(m.group('r'))))
3346+ if tp.stampInfo(line):
31553347 continue
31563348 m = re.match('[ \t]*(\[ *)(?P<ktime>[0-9\.]*)(\]) (?P<msg>.*)', line)
31573349 if(not m):
@@ -3176,7 +3368,7 @@ def loadKernelLog(): · 18 unmodified lines
31763368 if data:
31773369 testruns.append(data)
31783370 if len(testruns) < 1:
3179− pprint('ERROR: dmesg log has no suspend/resume data: %s' \
3371+ doError('dmesg log has no suspend/resume data: %s' \
31803372 % sysvals.dmesgfile)
31813373
31823374 # fix lines with same timestamp/function with the call and return swapped
@@ -3515,6 +3707,8 @@ def addCallgraphs(sv, hf, data): · 332 unmodified lines
35153707 name += ' '+p
35163708 if('ftrace' in dev):
35173709 cg = dev['ftrace']
3710+ if cg.name == sv.ftopfunc:
3711+ name = 'top level suspend/resume call'
35183712 num = callgraphHTML(sv, hf, num, cg,
35193713 name, color, dev['id'])
35203714 if('ftraces' in dev):
@@ -3523,22 +3717,16 @@ def addCallgraphs(sv, hf, data): · 2 unmodified lines
35233717 name+' &rarr; '+cg.name, color, dev['id'])
35243718 hf.write('\n\n </section>\n')
35253719
3526−# Function: createHTMLSummarySimple
3527−# Description:
3528−# Create summary html file for a series of tests
3529−# Arguments:
3530−# testruns: array of Data objects from parseTraceLog
3531−def createHTMLSummarySimple(testruns, htmlfile, title):
3532− # write the html header first (html head, css code, up to body start)
3533− html = '<!DOCTYPE html>\n<html>\n<head>\n\
3720+def summaryCSS(title, center=True):
3721+ tdcenter = 'text-align:center;' if center else ''
3722+ out = '<!DOCTYPE html>\n<html>\n<head>\n\
35343723 <meta http-equiv="content-type" content="text/html; charset=UTF-8">\n\
3535− <title>SleepGraph Summary</title>\n\
3724+ <title>'+title+'</title>\n\
35363725 <style type=\'text/css\'>\n\
35373726 .stamp {width: 100%;text-align:center;background:#888;line-height:30px;color:white;font: 25px Arial;}\n\
3538− table {width:100%;border-collapse: collapse;}\n\
3539− .summary {border:1px solid;}\n\
3727+ table {width:100%;border-collapse: collapse;border:1px solid;}\n\
35403728 th {border: 1px solid black;background:#222;color:white;}\n\
3541− td {font: 14px "Times New Roman";text-align: center;}\n\
3729+ td {font: 14px "Times New Roman";'+tdcenter+'}\n\
35423730 tr.head td {border: 1px solid black;background:#aaa;}\n\
35433731 tr.alt {background-color:#ddd;}\n\
35443732 tr.notice {color:red;}\n\
@@ -3547,12 +3735,23 @@ def createHTMLSummarySimple(testruns, htmlfile, title): · 2 unmodified lines
35473735 .maxval {background-color:#FFBBBB;}\n\
35483736 .head a {color:#000;text-decoration: none;}\n\
35493737 </style>\n</head>\n<body>\n'
3738+ return out
3739+
3740+# Function: createHTMLSummarySimple
3741+# Description:
3742+# Create summary html file for a series of tests
3743+# Arguments:
3744+# testruns: array of Data objects from parseTraceLog
3745+def createHTMLSummarySimple(testruns, htmlfile, title):
3746+ # write the html header first (html head, css code, up to body start)
3747+ html = summaryCSS('Summary - SleepGraph')
35503748
35513749 # extract the test data into list
35523750 list = dict()
3553− tAvg, tMin, tMax, tMed = [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [[], []]
3751+ tAvg, tMin, tMax, tMed = [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [dict(), dict()]
35543752 iMin, iMed, iMax = [0, 0], [0, 0], [0, 0]
35553753 num = 0
3754+ useturbo = False
35563755 lastmode = ''
35573756 cnt = dict()
35583757 for data in sorted(testruns, key=lambda v:(v['mode'], v['host'], v['kernel'], v['time'])):
@@ -3563,27 +3762,35 @@ def createHTMLSummarySimple(testruns, htmlfile, title): · 4 unmodified lines
35633762 for i in range(2):
35643763 s = sorted(tMed[i])
35653764 list[lastmode]['med'][i] = s[int(len(s)/2)]
3566− iMed[i] = tMed[i].index(list[lastmode]['med'][i])
3765+ iMed[i] = tMed[i][list[lastmode]['med'][i]]
35673766 list[lastmode]['avg'] = [tAvg[0] / num, tAvg[1] / num]
35683767 list[lastmode]['min'] = tMin
35693768 list[lastmode]['max'] = tMax
35703769 list[lastmode]['idx'] = (iMin, iMed, iMax)
3571− tAvg, tMin, tMax, tMed = [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [[], []]
3770+ tAvg, tMin, tMax, tMed = [0.0, 0.0], [0.0, 0.0], [0.0, 0.0], [dict(), dict()]
35723771 iMin, iMed, iMax = [0, 0], [0, 0], [0, 0]
35733772 num = 0
3773+ pkgpc10 = syslpi = ''
3774+ if 'pkgpc10' in data and 'syslpi' in data:
3775+ pkgpc10 = data['pkgpc10']
3776+ syslpi = data['syslpi']
3777+ useturbo = True
3778+ res = data['result']
35743779 tVal = [float(data['suspend']), float(data['resume'])]
35753780 list[mode]['data'].append([data['host'], data['kernel'],
3576− data['time'], tVal[0], tVal[1], data['url'], data['result'],
3781+ data['time'], tVal[0], tVal[1], data['url'], res,
35773782 data['issues'], data['sus_worst'], data['sus_worsttime'],
3578− data['res_worst'], data['res_worsttime']])
3783+ data['res_worst'], data['res_worsttime'], pkgpc10, syslpi])
35793784 idx = len(list[mode]['data']) - 1
3580− if data['result'] not in cnt:
3581− cnt[data['result']] = 1
3785+ if res.startswith('fail in'):
3786+ res = 'fail'
3787+ if res not in cnt:
3788+ cnt[res] = 1
35823789 else:
3583− cnt[data['result']] += 1
3584− if data['result'] == 'pass':
3790+ cnt[res] += 1
3791+ if res == 'pass':
35853792 for i in range(2):
3586− tMed[i].append(tVal[i])
3793+ tMed[i][tVal[i]] = idx
35873794 tAvg[i] += tVal[i]
35883795 if tMin[i] == 0 or tVal[i] < tMin[i]:
35893796 iMin[i] = idx
@@ -3597,7 +3804,7 @@ def createHTMLSummarySimple(testruns, htmlfile, title): · 7 unmodified lines
35973804 for i in range(2):
35983805 s = sorted(tMed[i])
35993806 list[lastmode]['med'][i] = s[int(len(s)/2)]
3600− iMed[i] = tMed[i].index(list[lastmode]['med'][i])
3807+ iMed[i] = tMed[i][list[lastmode]['med'][i]]
36013808 list[lastmode]['avg'] = [tAvg[0] / num, tAvg[1] / num]
36023809 list[lastmode]['min'] = tMin
36033810 list[lastmode]['max'] = tMax
@@ -3613,19 +3820,21 @@ def createHTMLSummarySimple(testruns, htmlfile, title): · 9 unmodified lines
36133820 td = '\t<td>{0}</td>\n'
36143821 tdh = '\t<td{1}>{0}</td>\n'
36153822 tdlink = '\t<td><a href="{0}">html</a></td>\n'
3823+ colspan = '14' if useturbo else '12'
36163824
36173825 # table header
3618− html += '<table class="summary">\n<tr>\n' + th.format('#') +\
3826+ html += '<table>\n<tr>\n' + th.format('#') +\
36193827 th.format('Mode') + th.format('Host') + th.format('Kernel') +\
36203828 th.format('Test Time') + th.format('Result') + th.format('Issues') +\
36213829 th.format('Suspend') + th.format('Resume') +\
36223830 th.format('Worst Suspend Device') + th.format('SD Time') +\
3623− th.format('Worst Resume Device') + th.format('RD Time') +\
3624− th.format('Detail') + '</tr>\n'
3625−
3831+ th.format('Worst Resume Device') + th.format('RD Time')
3832+ if useturbo:
3833+ html += th.format('PkgPC10') + th.format('SysLPI')
3834+ html += th.format('Detail')+'</tr>\n'
36263835 # export list into html
36273836 head = '<tr class="head"><td>{0}</td><td>{1}</td>'+\
3628− '<td colspan=12 class="sus">Suspend Avg={2} '+\
3837+ '<td colspan='+colspan+' class="sus">Suspend Avg={2} '+\
36293838 '<span class=minval><a href="#s{10}min">Min={3}</a></span> '+\
36303839 '<span class=medval><a href="#s{10}med">Med={4}</a></span> '+\
36313840 '<span class=maxval><a href="#s{10}max">Max={5}</a></span> '+\
@@ -3634,7 +3843,8 @@ def createHTMLSummarySimple(testruns, htmlfile, title): · 2 unmodified lines
36343843 '<span class=medval><a href="#r{10}med">Med={8}</a></span> '+\
36353844 '<span class=maxval><a href="#r{10}max">Max={9}</a></span></td>'+\
36363845 '</tr>\n'
3637− headnone = '<tr class="head"><td>{0}</td><td>{1}</td><td colspan=12></td></tr>\n'
3846+ headnone = '<tr class="head"><td>{0}</td><td>{1}</td><td colspan='+\
3847+ colspan+'></td></tr>\n'
36383848 for mode in list:
36393849 # header line for each suspend mode
36403850 num = 0
@@ -3681,6 +3891,9 @@ def createHTMLSummarySimple(testruns, htmlfile, title): · 40 unmodified lines
36813891 html += td.format('%.3f ms' % d[9]) if d[9] else td.format('') # sus_worst time
36823892 html += td.format(d[10]) # res_worst
36833893 html += td.format('%.3f ms' % d[11]) if d[11] else td.format('') # res_worst time
3894+ if useturbo:
3895+ html += td.format(d[12]) # pkg_pc10
3896+ html += td.format(d[13]) # syslpi
36843897 html += tdlink.format(d[5]) if d[5] else td.format('') # url
36853898 html += '</tr>\n'
36863899 num += 1
@@ -3690,6 +3903,115 @@ def createHTMLSummarySimple(testruns, htmlfile, title): · 3 unmodified lines
36903903 hf.write(html+'</table>\n</body>\n</html>\n')
36913904 hf.close()
36923905
3906+def createHTMLDeviceSummary(testruns, htmlfile, title):
3907+ html = summaryCSS('Device Summary - SleepGraph', False)
3908+
3909+ # create global device list from all tests
3910+ devall = dict()
3911+ for data in testruns:
3912+ host, url, devlist = data['host'], data['url'], data['devlist']
3913+ for type in devlist:
3914+ if type not in devall:
3915+ devall[type] = dict()
3916+ mdevlist, devlist = devall[type], data['devlist'][type]
3917+ for name in devlist:
3918+ length = devlist[name]
3919+ if name not in mdevlist:
3920+ mdevlist[name] = {'name': name, 'host': host,
3921+ 'worst': length, 'total': length, 'count': 1,
3922+ 'url': url}
3923+ else:
3924+ if length > mdevlist[name]['worst']:
3925+ mdevlist[name]['worst'] = length
3926+ mdevlist[name]['url'] = url
3927+ mdevlist[name]['host'] = host
3928+ mdevlist[name]['total'] += length
3929+ mdevlist[name]['count'] += 1
3930+
3931+ # generate the html
3932+ th = '\t<th>{0}</th>\n'
3933+ td = '\t<td align=center>{0}</td>\n'
3934+ tdr = '\t<td align=right>{0}</td>\n'
3935+ tdlink = '\t<td align=center><a href="{0}">html</a></td>\n'
3936+ limit = 1
3937+ for type in sorted(devall, reverse=True):
3938+ num = 0
3939+ devlist = devall[type]
3940+ # table header
3941+ html += '<div class="stamp">%s (%s devices > %d ms)</div><table>\n' % \
3942+ (title, type.upper(), limit)
3943+ html += '<tr>\n' + '<th align=right>Device Name</th>' +\
3944+ th.format('Average Time') + th.format('Count') +\
3945+ th.format('Worst Time') + th.format('Host (worst time)') +\
3946+ th.format('Link (worst time)') + '</tr>\n'
3947+ for name in sorted(devlist, key=lambda k:devlist[k]['worst'], reverse=True):
3948+ data = devall[type][name]
3949+ data['average'] = data['total'] / data['count']
3950+ if data['average'] < limit:
3951+ continue
3952+ # row classes - alternate row color
3953+ rcls = ['alt'] if num % 2 == 1 else []
3954+ html += '<tr class="'+(' '.join(rcls))+'">\n' if len(rcls) > 0 else '<tr>\n'
3955+ html += tdr.format(data['name']) # name
3956+ html += td.format('%.3f ms' % data['average']) # average
3957+ html += td.format(data['count']) # count
3958+ html += td.format('%.3f ms' % data['worst']) # worst
3959+ html += td.format(data['host']) # host
3960+ html += tdlink.format(data['url']) # url
3961+ html += '</tr>\n'
3962+ num += 1
3963+ html += '</table>\n'
3964+
3965+ # flush the data to file
3966+ hf = open(htmlfile, 'w')
3967+ hf.write(html+'</body>\n</html>\n')
3968+ hf.close()
3969+ return devall
3970+
3971+def createHTMLIssuesSummary(testruns, issues, htmlfile, title, extra=''):
3972+ multihost = len([e for e in issues if len(e['urls']) > 1]) > 0
3973+ html = summaryCSS('Issues Summary - SleepGraph', False)
3974+ total = len(testruns)
3975+
3976+ # generate the html
3977+ th = '\t<th>{0}</th>\n'
3978+ td = '\t<td align={0}>{1}</td>\n'
3979+ tdlink = '<a href="{1}">{0}</a>'
3980+ subtitle = '%d issues' % len(issues) if len(issues) > 0 else 'no issues'
3981+ html += '<div class="stamp">%s (%s)</div><table>\n' % (title, subtitle)
3982+ html += '<tr>\n' + th.format('Issue') + th.format('Count')
3983+ if multihost:
3984+ html += th.format('Hosts')
3985+ html += th.format('Tests') + th.format('Fail Rate') +\
3986+ th.format('First Instance') + '</tr>\n'
3987+
3988+ num = 0
3989+ for e in sorted(issues, key=lambda v:v['count'], reverse=True):
3990+ testtotal = 0
3991+ links = []
3992+ for host in sorted(e['urls']):
3993+ links.append(tdlink.format(host, e['urls'][host][0]))
3994+ testtotal += len(e['urls'][host])
3995+ rate = '%d/%d (%.2f%%)' % (testtotal, total, 100*float(testtotal)/float(total))
3996+ # row classes - alternate row color
3997+ rcls = ['alt'] if num % 2 == 1 else []
3998+ html += '<tr class="'+(' '.join(rcls))+'">\n' if len(rcls) > 0 else '<tr>\n'
3999+ html += td.format('left', e['line']) # issue
4000+ html += td.format('center', e['count']) # count
4001+ if multihost:
4002+ html += td.format('center', len(e['urls'])) # hosts
4003+ html += td.format('center', testtotal) # test count
4004+ html += td.format('center', rate) # test rate
4005+ html += td.format('center nowrap', '<br>'.join(links)) # links
4006+ html += '</tr>\n'
4007+ num += 1
4008+
4009+ # flush the data to file
4010+ hf = open(htmlfile, 'w')
4011+ hf.write(html+'</table>\n'+extra+'</body>\n</html>\n')
4012+ hf.close()
4013+ return issues
4014+
36934015 def ordinal(value):
36944016 suffix = 'th'
36954017 if value < 10 or value > 19:
@@ -3991,7 +4313,7 @@ def createHTML(testruns, testfail): · 295 unmodified lines
39914313 for word in phase.split('_'):
39924314 id += word[0]
39934315 order = '%.2f' % ((p['order'] * pdelta) + pmargin)
3994− name = string.replace(phase, '_', ' &nbsp;')
4316+ name = phase.replace('_', ' &nbsp;')
39954317 devtl.html += devtl.html_legend.format(order, p['color'], name, id)
39964318 devtl.html += '</div>\n'
39974319
@@ -4580,6 +4902,7 @@ def setRuntimeSuspend(before=True): · 582 unmodified lines
45804902 def executeSuspend():
45814903 pm = ProcessMonitor()
45824904 tp = sysvals.tpath
4905+ wifi = sysvals.checkWifi()
45834906 testdata = []
45844907 battery = True if getBattery() else False
45854908 # run these commands to prepare the system for suspend
@@ -4613,6 +4936,7 @@ def executeSuspend(): · 27 unmodified lines
46134936 pprint('SUSPEND START')
46144937 else:
46154938 pprint('SUSPEND START (press a key to resume)')
4939+ sysvals.mcelog(True)
46164940 bat1 = getBattery() if battery else False
46174941 # set rtcwake
46184942 if(sysvals.rtcwake):
@@ -4644,13 +4968,23 @@ def executeSuspend(): · 25 unmodified lines
46444968 pf = open(sysvals.diskpowerfile, 'w')
46454969 pf.write(sysvals.diskmode)
46464970 pf.close()
4647− pf = open(sysvals.powerfile, 'w')
4648− pf.write(mode)
4649− # execution will pause here
4650− try:
4651− pf.close()
4652− except Exception as e:
4653− tdata['error'] = str(e)
4971+ if mode == 'freeze' and sysvals.haveTurbostat():
4972+ # execution will pause here
4973+ turbo = sysvals.turbostat()
4974+ if '|' in turbo:
4975+ tdata['turbo'] = turbo
4976+ else:
4977+ tdata['error'] = turbo
4978+ else:
4979+ if sysvals.haveTurbostat():
4980+ sysvals.vprint('WARNING: ignoring turbostat in mode "%s"' % mode)
4981+ pf = open(sysvals.powerfile, 'w')
4982+ pf.write(mode)
4983+ # execution will pause here
4984+ try:
4985+ pf.close()
4986+ except Exception as e:
4987+ tdata['error'] = str(e)
46544988 if(sysvals.rtcwake):
46554989 sysvals.rtcWakeAlarmOff()
46564990 # postdelay delay
@@ -4664,9 +4998,14 @@ def executeSuspend(): · 7 unmodified lines
46644998 sysvals.fsetVal('RESUME COMPLETE', 'trace_marker')
46654999 if(sysvals.suspendmode == 'mem' or sysvals.suspendmode == 'command'):
46665000 tdata['fw'] = getFPDT(False)
5001+ mcelog = sysvals.mcelog()
5002+ if mcelog:
5003+ tdata['mcelog'] = mcelog
46675004 bat2 = getBattery() if battery else False
46685005 if battery and bat1 and bat2:
46695006 tdata['bat'] = (bat1, bat2)
5007+ if 'device' in wifi and 'ip' in wifi:
5008+ tdata['wifi'] = (wifi, sysvals.checkWifi())
46705009 testdata.append(tdata)
46715010 # stop ftrace
46725011 if(sysvals.usecallgraph or sysvals.usetraceevents):
@@ -4686,6 +5025,7 @@ def executeSuspend(): · 13 unmodified lines
46865025 op.close()
46875026 sysvals.fsetVal('', 'trace')
46885027 devProps()
5028+ return testdata
46895029
46905030 def readFile(file):
46915031 if os.path.islink(file):
@@ -4772,7 +5112,7 @@ def deviceInfo(output=''): · 80 unmodified lines
47725112 ms2nice(power['runtime_active_time']), \
47735113 ms2nice(power['runtime_suspended_time']))
47745114 for i in sorted(lines):
4775− print lines[i]
5115+ print(lines[i])
47765116 return res
47775117
47785118 # Function: devProps
@@ -4905,12 +5245,12 @@ def getModes(): · 126 unmodified lines
49055245 modes = []
49065246 if(os.path.exists(sysvals.powerfile)):
49075247 fp = open(sysvals.powerfile, 'r')
4908− modes = string.split(fp.read())
5248+ modes = fp.read().split()
49095249 fp.close()
49105250 if(os.path.exists(sysvals.mempowerfile)):
49115251 deep = False
49125252 fp = open(sysvals.mempowerfile, 'r')
4913− for m in string.split(fp.read()):
5253+ for m in fp.read().split():
49145254 memmode = m.strip('[]')
49155255 if memmode == 'deep':
49165256 deep = True
@@ -4921,7 +5261,7 @@ def getModes(): · 4 unmodified lines
49215261 modes.remove('mem')
49225262 if('disk' in modes and os.path.exists(sysvals.diskpowerfile)):
49235263 fp = open(sysvals.diskpowerfile, 'r')
4924− for m in string.split(fp.read()):
5264+ for m in fp.read().split():
49255265 modes.append('disk-%s' % m.strip('[]'))
49265266 fp.close()
49275267 return modes
@@ -4984,14 +5324,15 @@ def dmidecode(mempath, fatal=False): · 56 unmodified lines
49845324 continue
49855325
49865326 # read in the memory for scanning
4987− fp = open(mempath, 'rb')
49885327 try:
5328+ fp = open(mempath, 'rb')
49895329 fp.seek(memaddr)
49905330 buf = fp.read(memsize)
49915331 except:
49925332 if(fatal):
49935333 doError('DMI table is unreachable, sorry')
49945334 else:
5335+ pprint('WARNING: /dev/mem is not readable, ignoring DMI data')
49955336 return out
49965337 fp.close()
49975338
@@ -5014,14 +5355,15 @@ def dmidecode(mempath, fatal=False): · 16 unmodified lines
50145355 return out
50155356
50165357 # read in the SM or DMI table
5017− fp = open(mempath, 'rb')
50185358 try:
5359+ fp = open(mempath, 'rb')
50195360 fp.seek(base)
50205361 buf = fp.read(length)
50215362 except:
50225363 if(fatal):
50235364 doError('DMI table is unreachable, sorry')
50245365 else:
5366+ pprint('WARNING: /dev/mem is not readable, ignoring DMI data')
50255367 return out
50265368 fp.close()
50275369
@@ -5165,7 +5507,11 @@ def getFPDT(output): · 137 unmodified lines
51655507 i = 0
51665508 fwData = [0, 0]
51675509 records = buf[36:]
5168− fp = open(sysvals.mempath, 'rb')
5510+ try:
5511+ fp = open(sysvals.mempath, 'rb')
5512+ except:
5513+ pprint('WARNING: /dev/mem is not readable, ignoring the FPDT data')
5514+ return False
51695515 while(i < len(records)):
51705516 header = struct.unpack('HBB', records[i:i+4])
51715517 if(header[0] not in rectype):
@@ -5282,13 +5628,14 @@ def statusCheck(probecheck=False): · 110 unmodified lines
52825628 pprint(' is ftrace supported: %s' % res)
52835629
52845630 # check if kprobes are available
5285− res = sysvals.colorText('NO')
5286− sysvals.usekprobes = sysvals.verifyKprobes()
5287− if(sysvals.usekprobes):
5288− res = 'YES'
5289− else:
5290− sysvals.usedevsrc = False
5291− pprint(' are kprobes supported: %s' % res)
5631+ if sysvals.usekprobes:
5632+ res = sysvals.colorText('NO')
5633+ sysvals.usekprobes = sysvals.verifyKprobes()
5634+ if(sysvals.usekprobes):
5635+ res = 'YES'
5636+ else:
5637+ sysvals.usedevsrc = False
5638+ pprint(' are kprobes supported: %s' % res)
52925639
52935640 # what data source are we using
52945641 res = 'DMESG'
@@ -5376,6 +5723,8 @@ def getArgFloat(name, args, min, max, main=True): · 81 unmodified lines
53765723
53775724 def processData(live=False):
53785725 pprint('PROCESSING DATA')
5726+ sysvals.vprint('usetraceevents=%s, usetracemarkers=%s, usekprobes=%s' % \
5727+ (sysvals.usetraceevents, sysvals.usetracemarkers, sysvals.usekprobes))
53795728 error = ''
53805729 if(sysvals.usetraceevents):
53815730 testruns, error = parseTraceLog(live)
@@ -5388,13 +5737,36 @@ def processData(live=False): · 6 unmodified lines
53885737 parseKernelLog(data)
53895738 if(sysvals.ftracefile and (sysvals.usecallgraph or sysvals.usetraceevents)):
53905739 appendIncompleteTraceLog(testruns)
5740+ sysvals.vprint('System Info:')
5741+ for key in sorted(sysvals.stamp):
5742+ sysvals.vprint(' %-8s : %s' % (key.upper(), sysvals.stamp[key]))
5743+ if sysvals.kparams:
5744+ sysvals.vprint('Kparams:\n %s' % sysvals.kparams)
53915745 sysvals.vprint('Command:\n %s' % sysvals.cmdline)
53925746 for data in testruns:
5747+ if data.mcelog:
5748+ sysvals.vprint('MCELOG Data:')
5749+ for line in data.mcelog.split('\n'):
5750+ sysvals.vprint(' %s' % line)
5751+ if data.turbostat:
5752+ idx, s = 0, 'Turbostat:\n '
5753+ for val in data.turbostat.split('|'):
5754+ idx += len(val) + 1
5755+ if idx >= 80:
5756+ idx = 0
5757+ s += '\n '
5758+ s += val + ' '
5759+ sysvals.vprint(s)
53935760 if data.battery:
53945761 a1, c1, a2, c2 = data.battery
53955762 s = 'Battery:\n Before - AC: %s, Charge: %d\n After - AC: %s, Charge: %d' % \
53965763 (a1, int(c1), a2, int(c2))
53975764 sysvals.vprint(s)
5765+ if data.wifi:
5766+ w = data.wifi.replace('|', ' ').split(',')
5767+ s = 'Wifi:\n Before %s\n After %s' % \
5768+ (w[0], w[1])
5769+ sysvals.vprint(s)
53985770 data.printDetails()
53995771 if sysvals.cgdump:
54005772 for data in testruns:
@@ -5418,12 +5790,15 @@ def processData(live=False): · 17 unmodified lines
54185790 # Function: rerunTest
54195791 # Description:
54205792 # generate an output from an existing set of ftrace/dmesg logs
5421−def rerunTest():
5793+def rerunTest(htmlfile=''):
54225794 if sysvals.ftracefile:
54235795 doesTraceLogHaveTraceEvents()
54245796 if not sysvals.dmesgfile and not sysvals.usetraceevents:
54255797 doError('recreating this html output requires a dmesg file')
5426− sysvals.setOutputFile()
5798+ if htmlfile:
5799+ sysvals.htmlfile = htmlfile
5800+ else:
5801+ sysvals.setOutputFile()
54275802 if os.path.exists(sysvals.htmlfile):
54285803 if not os.path.isfile(sysvals.htmlfile):
54295804 doError('a directory already exists with this name: %s' % sysvals.htmlfile)
@@ -5442,14 +5817,18 @@ def runTest(n=0): · 12 unmodified lines
54425817 sysvals.initTestOutput('suspend')
54435818
54445819 # execute the test
5445− executeSuspend()
5820+ testdata = executeSuspend()
54465821 sysvals.cleanupFtrace()
54475822 if sysvals.skiphtml:
54485823 sysvals.sudoUserchown(sysvals.testdir)
54495824 return
5450− testruns, stamp = processData(True)
5451− for data in testruns:
5452− del data
5825+ if not testdata[0]['error']:
5826+ testruns, stamp = processData(True)
5827+ for data in testruns:
5828+ del data
5829+ else:
5830+ stamp = testdata[0]
5831+
54535832 sysvals.sudoUserchown(sysvals.testdir)
54545833 sysvals.outputResult(stamp, n)
54555834 if 'error' in stamp:
@@ -5479,10 +5858,13 @@ def find_in_html(html, start, end, firstonly=True): · 23 unmodified lines
54795858 return ''
54805859 return out
54815860
5482−def data_from_html(file, outpath, devlist=False):
5861+def data_from_html(file, outpath, issues, fulldetail=False):
54835862 html = open(file, 'r').read()
5863+ sysvals.htmlfile = os.path.relpath(file, outpath)
5864+ # extract general info
54845865 suspend = find_in_html(html, 'Kernel Suspend', 'ms')
54855866 resume = find_in_html(html, 'Kernel Resume', 'ms')
5867+ sysinfo = find_in_html(html, '<div class="stamp sysinfo">', '</div>')
54865868 line = find_in_html(html, '<div class="stamp">', '</div>')
54875869 stmp = line.split()
54885870 if not suspend or not resume or len(stmp) != 8:
@@ -5491,6 +5873,7 @@ def data_from_html(file, outpath, devlist=False): · 2 unmodified lines
54915873 dt = datetime.strptime(' '.join(stmp[3:]), '%B %d %Y, %I:%M:%S %p')
54925874 except:
54935875 return False
5876+ sysvals.hostname = stmp[0]
54945877 tstr = dt.strftime('%Y/%m/%d %H:%M:%S')
54955878 error = find_in_html(html, '<table class="testfail"><tr><td>', '</td>')
54965879 if error:
@@ -5501,13 +5884,45 @@ def data_from_html(file, outpath, devlist=False): · 4 unmodified lines
55015884 result = 'fail'
55025885 else:
55035886 result = 'pass'
5887+ # extract error info
55045888 ilist = []
5505− e = find_in_html(html, 'class="err"[\w=":;\.%\- ]*>', '&rarr;</div>', False)
5506− for i in list(set(e)):
5507− ilist.append('%sx%d' % (i, e.count(i)) if e.count(i) > 1 else i)
5889+ extra = dict()
5890+ log = find_in_html(html, '<div id="dmesglog" style="display:none;">',
5891+ '</div>').strip()
5892+ if log:
5893+ d = Data(0)
5894+ d.end = 999999999
5895+ d.dmesgtext = log.split('\n')
5896+ msglist = d.extractErrorInfo()
5897+ for msg in msglist:
5898+ sysvals.errorSummary(issues, msg)
5899+ if stmp[2] == 'freeze':
5900+ extra = d.turbostatInfo()
5901+ elist = dict()
5902+ for dir in d.errorinfo:
5903+ for err in d.errorinfo[dir]:
5904+ if err[0] not in elist:
5905+ elist[err[0]] = 0
5906+ elist[err[0]] += 1
5907+ for i in elist:
5908+ ilist.append('%sx%d' % (i, elist[i]) if elist[i] > 1 else i)
55085909 low = find_in_html(html, 'freeze time: <b>', ' ms</b>')
55095910 if low and '|' in low:
5510− ilist.append('FREEZEx%d' % len(low.split('|')))
5911+ issue = 'FREEZEx%d' % len(low.split('|'))
5912+ match = [i for i in issues if i['match'] == issue]
5913+ if len(match) > 0:
5914+ match[0]['count'] += 1
5915+ if sysvals.hostname not in match[0]['urls']:
5916+ match[0]['urls'][sysvals.hostname] = [sysvals.htmlfile]
5917+ elif sysvals.htmlfile not in match[0]['urls'][sysvals.hostname]:
5918+ match[0]['urls'][sysvals.hostname].append(sysvals.htmlfile)
5919+ else:
5920+ issues.append({
5921+ 'match': issue, 'count': 1, 'line': issue,
5922+ 'urls': {sysvals.hostname: [sysvals.htmlfile]},
5923+ })
5924+ ilist.append(issue)
5925+ # extract device info
55115926 devices = dict()
55125927 for line in html.split('\n'):
55135928 m = re.match(' *<div id=\"[a,0-9]*\" *title=\"(?P<title>.*)\" class=\"thread.*', line)
@@ -5519,82 +5934,98 @@ def data_from_html(file, outpath, devlist=False): · 5 unmodified lines
55195934 name, time, phase = m.group('n'), m.group('t'), m.group('p')
55205935 if ' async' in name or ' sync' in name:
55215936 name = ' '.join(name.split(' ')[:-1])
5522− d = phase.split('_')[0]
5937+ if phase.startswith('suspend'):
5938+ d = 'suspend'
5939+ elif phase.startswith('resume'):
5940+ d = 'resume'
5941+ else:
5942+ continue
55235943 if d not in devices:
55245944 devices[d] = dict()
55255945 if name not in devices[d]:
55265946 devices[d][name] = 0.0
55275947 devices[d][name] += float(time)
5528− worst = {'suspend': {'name':'', 'time': 0.0},
5529− 'resume': {'name':'', 'time': 0.0}}
5530− for d in devices:
5531− if d not in worst:
5532− worst[d] = dict()
5533− dev = devices[d]
5534− if len(dev.keys()) > 0:
5948+ # create worst device info
5949+ worst = dict()
5950+ for d in ['suspend', 'resume']:
5951+ worst[d] = {'name':'', 'time': 0.0}
5952+ dev = devices[d] if d in devices else 0
5953+ if dev and len(dev.keys()) > 0:
55355954 n = sorted(dev, key=dev.get, reverse=True)[0]
55365955 worst[d]['name'], worst[d]['time'] = n, dev[n]
55375956 data = {
55385957 'mode': stmp[2],
55395958 'host': stmp[0],
55405959 'kernel': stmp[1],
5960+ 'sysinfo': sysinfo,
55415961 'time': tstr,
55425962 'result': result,
55435963 'issues': ' '.join(ilist),
55445964 'suspend': suspend,
55455965 'resume': resume,
5966+ 'devlist': devices,
55465967 'sus_worst': worst['suspend']['name'],
55475968 'sus_worsttime': worst['suspend']['time'],
55485969 'res_worst': worst['resume']['name'],
55495970 'res_worsttime': worst['resume']['time'],
5550− 'url': os.path.relpath(file, outpath),
5971+ 'url': sysvals.htmlfile,
55515972 }
5552− if devlist:
5553− data['devlist'] = devices
5973+ for key in extra:
5974+ data[key] = extra[key]
5975+ if fulldetail:
5976+ data['funclist'] = find_in_html(html, '<div title="', '" class="traceevent"', False)
55545977 return data
55555978
5979+def genHtml(subdir):
5980+ for dirname, dirnames, filenames in os.walk(subdir):
5981+ sysvals.dmesgfile = sysvals.ftracefile = sysvals.htmlfile = ''
5982+ for filename in filenames:
5983+ if(re.match('.*_dmesg.txt', filename)):
5984+ sysvals.dmesgfile = os.path.join(dirname, filename)
5985+ elif(re.match('.*_ftrace.txt', filename)):
5986+ sysvals.ftracefile = os.path.join(dirname, filename)
5987+ sysvals.setOutputFile()
5988+ if sysvals.ftracefile and sysvals.htmlfile and \
5989+ not os.path.exists(sysvals.htmlfile):
5990+ pprint('FTRACE: %s' % sysvals.ftracefile)
5991+ if sysvals.dmesgfile:
5992+ pprint('DMESG : %s' % sysvals.dmesgfile)
5993+ rerunTest()
5994+
55565995 # Function: runSummary
55575996 # Description:
55585997 # create a summary of tests in a sub-directory
55595998 def runSummary(subdir, local=True, genhtml=False):
55605999 inpath = os.path.abspath(subdir)
55616000 outpath = os.path.abspath('.') if local else inpath
5562− pprint('Generating a summary of folder "%s"' % inpath)
6001+ pprint('Generating a summary of folder:\n %s' % inpath)
55636002 if genhtml:
5564− for dirname, dirnames, filenames in os.walk(subdir):
5565− sysvals.dmesgfile = sysvals.ftracefile = sysvals.htmlfile = ''
5566− for filename in filenames:
5567− if(re.match('.*_dmesg.txt', filename)):
5568− sysvals.dmesgfile = os.path.join(dirname, filename)
5569− elif(re.match('.*_ftrace.txt', filename)):
5570− sysvals.ftracefile = os.path.join(dirname, filename)
5571− sysvals.setOutputFile()
5572− if sysvals.ftracefile and sysvals.htmlfile and \
5573− not os.path.exists(sysvals.htmlfile):
5574− pprint('FTRACE: %s' % sysvals.ftracefile)
5575− if sysvals.dmesgfile:
5576− pprint('DMESG : %s' % sysvals.dmesgfile)
5577− rerunTest()
6003+ genHtml(subdir)
6004+ issues = []
55786005 testruns = []
55796006 desc = {'host':[],'mode':[],'kernel':[]}
55806007 for dirname, dirnames, filenames in os.walk(subdir):
55816008 for filename in filenames:
55826009 if(not re.match('.*.html', filename)):
55836010 continue
5584− data = data_from_html(os.path.join(dirname, filename), outpath)
6011+ data = data_from_html(os.path.join(dirname, filename), outpath, issues)
55856012 if(not data):
55866013 continue
55876014 testruns.append(data)
55886015 for key in desc:
55896016 if data[key] not in desc[key]:
55906017 desc[key].append(data[key])
5591− outfile = os.path.join(outpath, 'summary.html')
5592− pprint('Summary file: %s' % outfile)
6018+ pprint('Summary files:')
55936019 if len(desc['host']) == len(desc['mode']) == len(desc['kernel']) == 1:
55946020 title = '%s %s %s' % (desc['host'][0], desc['kernel'][0], desc['mode'][0])
55956021 else:
55966022 title = inpath
5597− createHTMLSummarySimple(testruns, outfile, title)
6023+ createHTMLSummarySimple(testruns, os.path.join(outpath, 'summary.html'), title)
6024+ pprint(' summary.html - tabular list of test data found')
6025+ createHTMLDeviceSummary(testruns, os.path.join(outpath, 'summary-devices.html'), title)
6026+ pprint(' summary-devices.html - kernel device list sorted by total execution time')
6027+ createHTMLIssuesSummary(testruns, issues, os.path.join(outpath, 'summary-issues.html'), title)
6028+ pprint(' summary-issues.html - kernel issues found sorted by frequency')
55986029
55996030 # Function: checkArgBool
56006031 # Description:
@@ -5839,6 +6270,7 @@ def printHelp(): · 238 unmodified lines
58396270 ' default: suspend-{date}-{time}\n'\
58406271 ' -rtcwake t Wakeup t seconds after suspend, set t to "off" to disable (default: 15)\n'\
58416272 ' -addlogs Add the dmesg and ftrace logs to the html output\n'\
6273+ ' -turbostat Use turbostat to execute the command in freeze mode (default: disabled)\n'\
58426274 ' -srgap Add a visible gap in the timeline between sus/res (default: disabled)\n'\
58436275 ' -skiphtml Run the test and capture the trace logs, but skip the timeline (default: disabled)\n'\
58446276 ' -result fn Export a results table to a text file for parsing.\n'\
@@ -5860,6 +6292,7 @@ def printHelp(): · 15 unmodified lines
58606292 ' be created in a new subdirectory with a summary page.\n'\
58616293 ' [debug]\n'\
58626294 ' -f Use ftrace to create device callgraphs (default: disabled)\n'\
6295+ ' -ftop Use ftrace on the top level call: "%s" (default: disabled)\n'\
58636296 ' -maxdepth N limit the callgraph data to N call levels (default: 0=all)\n'\
58646297 ' -expandcg pre-expand the callgraph data in the html output (default: disabled)\n'\
58656298 ' -fadd file Add functions to be graphed in the timeline from a list in a text file\n'\
@@ -5879,6 +6312,7 @@ def printHelp(): · 13 unmodified lines
58796312 ' -status Test to see if the system is enabled to run this tool\n'\
58806313 ' -fpdt Print out the contents of the ACPI Firmware Performance Data Table\n'\
58816314 ' -battery Print out battery info (if available)\n'\
6315+ ' -wifi Print out wifi connection info (if wireless-tools and device exists)\n'\
58826316 ' -x<mode> Test xset by toggling the given mode (on/off/standby/suspend)\n'\
58836317 ' -sysinfo Print out system info extracted from BIOS\n'\
58846318 ' -devinfo Print out the pm settings of all devices which support runtime suspend\n'\
@@ -5888,7 +6322,7 @@ def printHelp(): · 3 unmodified lines
58886322 ' [redo]\n'\
58896323 ' -ftrace ftracefile Create HTML output using ftrace input (used with -dmesg)\n'\
58906324 ' -dmesg dmesgfile Create HTML output using dmesg (used with -ftrace)\n'\
5891− '' % (sysvals.title, sysvals.version, sysvals.suspendmode))
6325+ '' % (sysvals.title, sysvals.version, sysvals.suspendmode, sysvals.ftopfunc))
58926326 return True
58936327
58946328 # ----------------- MAIN --------------------
@@ -5898,7 +6332,7 @@ if __name__ == '__main__': · 3 unmodified lines
58986332 cmd = ''
58996333 simplecmds = ['-sysinfo', '-modes', '-fpdt', '-flist', '-flistall',
59006334 '-devinfo', '-status', '-battery', '-xon', '-xoff', '-xstandby',
5901− '-xsuspend', '-xinit', '-xreset', '-xstat']
6335+ '-xsuspend', '-xinit', '-xreset', '-xstat', '-wifi']
59026336 if '-f' in sys.argv:
59036337 sysvals.cgskip = sysvals.configFile('cgskip.txt')
59046338 # loop through the command line arguments
@@ -5930,6 +6364,10 @@ if __name__ == '__main__': · 25 unmodified lines
59306364 sysvals.postdelay = getArgInt('-postdelay', args, 0, 60000)
59316365 elif(arg == '-f'):
59326366 sysvals.usecallgraph = True
6367+ elif(arg == '-ftop'):
6368+ sysvals.usecallgraph = True
6369+ sysvals.ftop = True
6370+ sysvals.usekprobes = False
59336371 elif(arg == '-skiphtml'):
59346372 sysvals.skiphtml = True
59356373 elif(arg == '-cgdump'):
@@ -5940,10 +6378,16 @@ if __name__ == '__main__': · 4 unmodified lines
59406378 genhtml = True
59416379 elif(arg == '-addlogs'):
59426380 sysvals.dmesglog = sysvals.ftracelog = True
6381+ elif(arg == '-nologs'):
6382+ sysvals.dmesglog = sysvals.ftracelog = False
59436383 elif(arg == '-addlogdmesg'):
59446384 sysvals.dmesglog = True
59456385 elif(arg == '-addlogftrace'):
59466386 sysvals.ftracelog = True
6387+ elif(arg == '-turbostat'):
6388+ sysvals.tstat = True
6389+ if not sysvals.haveTurbostat():
6390+ doError('Turbostat command not found')
59476391 elif(arg == '-verbose'):
59486392 sysvals.verbose = True
59496393 elif(arg == '-proc'):
@@ -6013,6 +6457,12 @@ if __name__ == '__main__': · 63 unmodified lines
60136457 except:
60146458 doError('No callgraph functions supplied', True)
60156459 sysvals.setCallgraphFilter(val)
6460+ elif(arg == '-skipkprobe'):
6461+ try:
6462+ val = args.next()
6463+ except:
6464+ doError('No kprobe functions supplied', True)
6465+ sysvals.skipKprobes(val)
60166466 elif(arg == '-cgskip'):
60176467 try:
60186468 val = args.next()
@@ -6151,7 +6601,7 @@ if __name__ == '__main__': · 132 unmodified lines
61516601 elif(cmd == 'devinfo'):
61526602 deviceInfo()
61536603 elif(cmd == 'modes'):
6154− print getModes()
6604+ pprint(getModes())
61556605 elif(cmd == 'flist'):
61566606 sysvals.getFtraceFilterFunctions(True)
61576607 elif(cmd == 'flistall'):
@@ -6163,11 +6613,18 @@ if __name__ == '__main__': · 5 unmodified lines
61636613 ret = displayControl(cmd[1:])
61646614 elif(cmd == 'xstat'):
61656615 pprint('Display Status: %s' % displayControl('stat').upper())
6616+ elif(cmd == 'wifi'):
6617+ out = sysvals.checkWifi()
6618+ if 'device' not in out:
6619+ pprint('WIFI interface not found')
6620+ else:
6621+ for key in sorted(out):
6622+ pprint('%6s: %s' % (key.upper(), out[key]))
61666623 sys.exit(ret)
61676624
61686625 # if instructed, re-analyze existing data files
61696626 if(sysvals.notestrun):
6170− stamp = rerunTest()
6627+ stamp = rerunTest(sysvals.outdir)
61716628 sysvals.outputResult(stamp)
61726629 sys.exit(0)
61736630
@@ -6204,7 +6661,7 @@ if __name__ == '__main__': · 30 unmodified lines
62046661 s = 'suspend-x%d' % sysvals.multitest['count']
62056662 sysvals.outdir = datetime.now().strftime(s+'-%y%m%d-%H%M%S')
62066663 if not os.path.isdir(sysvals.outdir):
6207− os.mkdir(sysvals.outdir)
6664+ os.makedirs(sysvals.outdir)
62086665 for i in range(sysvals.multitest['count']):
62096666 if(i != 0):
62106667 pprint('Waiting %d seconds...' % (sysvals.multitest['delay']))

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t