0001 .TH SLEEPGRAPH 8
0002 .SH NAME
0003 sleepgraph \- Suspend/Resume timing analysis
0004 .SH SYNOPSIS
0005 .ft B
0006 .B sleepgraph
0007 .RB [ OPTIONS ]
0008 .RB [ COMMAND ]
0009 .SH DESCRIPTION
0010 \fBsleepgraph \fP is designed to assist kernel and OS developers
0011 in optimizing their linux stack's suspend/resume time. Using a kernel
0012 image built with a few extra options enabled, the tool will execute a
0013 suspend and capture dmesg and ftrace data until resume is complete.
0014 This data is transformed into a device timeline and an optional
0015 callgraph to give a detailed view of which devices/subsystems are
0016 taking the most time in suspend/resume.
0017 .PP
0018 If no specific command is given, the default behavior is to initiate
0019 a suspend/resume.
0020 .PP
0021 Generates output files in subdirectory: suspend-yymmdd-HHMMSS
0022 html timeline : <hostname>_<mode>.html
0023 raw dmesg file : <hostname>_<mode>_dmesg.txt
0024 raw ftrace file : <hostname>_<mode>_ftrace.txt
0025 .SH OPTIONS
0026 .TP
0027 \fB-h\fR
0028 Print the help text.
0029 .TP
0030 \fB-v\fR
0031 Print the current tool version.
0032 .TP
0033 \fB-verbose\fR
0034 Print extra information during execution and analysis.
0035 .TP
0036 \fB-config \fIfile\fR
0037 Pull arguments and config options from a file.
0038 .TP
0039 \fB-m \fImode\fR
0040 Mode to initiate for suspend e.g. standby, freeze, mem (default: mem).
0041 .TP
0042 \fB-o \fIname\fR
0043 Overrides the output subdirectory name when running a new test.
0044 Use {date}, {time}, {hostname} for current values.
0045 .sp
0046 e.g. suspend-{hostname}-{date}-{time}
0047 .TP
0048 \fB-rtcwake \fIt\fR | off
0049 Use rtcwake to autoresume after \fIt\fR seconds (default: 15). Set t to "off" to
0050 disable rtcwake and require a user keypress to resume.
0051 .TP
0052 \fB-addlogs\fR
0053 Add the dmesg and ftrace logs to the html output. They will be viewable by
0054 clicking buttons in the timeline.
0055 .TP
0056 \fB-noturbostat\fR
0057 By default, if turbostat is found and the requested mode is freeze, sleepgraph
0058 will execute the suspend via turbostat and collect data in the timeline log.
0059 This option disables the use of turbostat.
0060 .TP
0061 \fB-result \fIfile\fR
0062 Export a results table to a text file for parsing.
0063 .TP
0064 \fB-sync\fR
0065 Sync the filesystems before starting the test. This reduces the size of
0066 the sys_sync call which happens in the suspend_prepare phase.
0067 .TP
0068 \fB-rs \fIenable/disable\fR
0069 During test, enable/disable runtime suspend for all devices. The test is delayed
0070 by 5 seconds to allow runtime suspend changes to occur. The settings are restored
0071 after the test is complete.
0072 .TP
0073 \fB-display \fIon/off/standby/suspend\fR
0074 Switch the display to the requested mode for the test using the xset command.
0075 This helps maintain the consistency of test data for better comparison.
0076 .TP
0077 \fB-wifi\fR
0078 If a wifi connection is available, check that it reconnects after resume. Include
0079 the reconnect time in the total resume time calculation and treat wifi timeouts
0080 as resume failures.
0081
0082 .SS "advanced"
0083 .TP
0084 \fB-gzip\fR
0085 Gzip the trace and dmesg logs to save space. The tool can also read in gzipped
0086 logs for processing.
0087 .TP
0088 \fB-cmd \fIstr\fR
0089 Run the timeline over a custom suspend command, e.g. pm-suspend. By default
0090 the tool forces suspend via /sys/power/state so this allows testing over
0091 an OS's official suspend method. The output file will change to
0092 hostname_command.html and will autodetect which suspend mode was triggered.
0093 .TP
0094 \fB-filter \fI"d1,d2,..."\fR
0095 Filter out all but these device callbacks. These strings can be device names
0096 or module names. e.g. 0000:00:02.0, ata5, i915, usb, etc.
0097 .TP
0098 \fB-mindev \fIt\fR
0099 Discard all device callbacks shorter than \fIt\fR milliseconds (default: 0.0).
0100 This reduces the html file size as there can be many tiny callbacks which are barely
0101 visible. The value is a float: e.g. 0.001 represents 1 us.
0102 .TP
0103 \fB-proc\fR
0104 Add usermode process info into the timeline (default: disabled).
0105 .TP
0106 \fB-dev\fR
0107 Add kernel source calls and threads to the timeline (default: disabled).
0108 .TP
0109 \fB-x2\fR
0110 Run two suspend/resumes back to back (default: disabled).
0111 .TP
0112 \fB-x2delay \fIt\fR
0113 Include \fIt\fR ms delay between multiple test runs (default: 0 ms).
0114 .TP
0115 \fB-predelay \fIt\fR
0116 Include \fIt\fR ms delay before 1st suspend (default: 0 ms).
0117 .TP
0118 \fB-postdelay \fIt\fR
0119 Include \fIt\fR ms delay after last resume (default: 0 ms).
0120 .TP
0121 \fB-multi \fIn d\fR
0122 Used for endurance testing. If \fIn\fR is entirely numeric, it's treated as a count:
0123 Execute \fIn\fR consecutive tests at \fId\fR second intervals.
0124 If \fIn\fR is an integer followed by a "d", "h", or "m", it's treated as a duration:
0125 Execute tests continuously over \fIn\fR days, hours, or minutes at \fId\fR second intervals.
0126 The outputs will be created in a new subdirectory, for count: suspend-{date}-{time}-xN,
0127 for duration: suspend-{date}-{time}-Nm. When the multitest run is done, the \fI-summary\fR
0128 command is called automatically to create summary html files for all the data (unless you
0129 use \fI-skiphtml\fR). \fI-skiphtml\fR will speed up the testing by not creating timelines
0130 or summary html files. You can then run the tool again at a later time with \fI-summary\fR
0131 and \fI-genhtml\fR to create the timelines.
0132 .TP
0133 \fB-maxfail \fIn\fR
0134 Abort a -multi run after \fIn\fR consecutive fails. 0 means never abort (default = 0).
0135 .TP
0136 \fB-skiphtml\fR
0137 Run the test and capture the trace logs, but skip the timeline generation.
0138 You can generate the html timelines later with \fI-dmesg\fR & \fI-ftrace\fR, or
0139 by running \fI-summary\fR and \fI-genhtml\fR.
0140
0141 .SS "ftrace debug"
0142 .TP
0143 \fB-f\fR
0144 Use ftrace to create device callgraphs (default: disabled). This can produce
0145 very large outputs, i.e. 10MB - 100MB.
0146 .TP
0147 \fB-ftop\fR
0148 Use ftrace on the top level call: "suspend_devices_and_enter" only (default: disabled).
0149 This option implies -f and creates a single callgraph covering all of suspend/resume.
0150 .TP
0151 \fB-maxdepth \fIlevel\fR
0152 limit the callgraph trace depth to \fIlevel\fR (default: 0=all). This is
0153 the best way to limit the output size when using callgraphs via -f.
0154 .TP
0155 \fB-expandcg\fR
0156 pre-expand the callgraph data in the html output (default: disabled)
0157 .TP
0158 \fB-fadd \fIfile\fR
0159 Add functions to be graphed in the timeline from a list in a text file
0160 .TP
0161 \fB-mincg \fIt\fR
0162 Discard all callgraphs shorter than \fIt\fR milliseconds (default: 0.0).
0163 This reduces the html file size as there can be many tiny callgraphs
0164 which are barely visible in the timeline.
0165 The value is a float: e.g. 0.001 represents 1 us.
0166 .TP
0167 \fB-cgfilter \fI"func1,func2,..."\fR
0168 Reduce callgraph output in the timeline by limiting it certain devices. The
0169 argument can be a single device name or a comma delimited list.
0170 (default: none)
0171 .TP
0172 \fB-cgskip \fIfile\fR
0173 Reduce callgraph timeline size by skipping over uninteresting functions
0174 in the trace, e.g. printk or console_unlock. The functions listed
0175 in this file will show up as empty leaves in the callgraph with only the start/end
0176 times displayed. cgskip.txt is used automatically if found in the path, so
0177 use "off" to disable completely (default: cgskip.txt)
0178 .TP
0179 \fB-cgphase \fIp\fR
0180 Only show callgraph data for phase \fIp\fR (e.g. suspend_late).
0181 .TP
0182 \fB-cgtest \fIn\fR
0183 In an x2 run, only show callgraph data for test \fIn\fR (e.g. 0 or 1).
0184 .TP
0185 \fB-timeprec \fIn\fR
0186 Number of significant digits in timestamps (0:S, [3:ms], 6:us).
0187 .TP
0188 \fB-bufsize \fIN\fR
0189 Set trace buffer size to N kilo-bytes (default: all of free memory up to 3GB)
0190
0191 .SH COMMANDS
0192 .TP
0193 \fB-summary \fIindir\fR
0194 Create a set of summary pages for all tests in \fIindir\fR recursively.
0195 Creates summary.html, summary-issues.html, and summary-devices.html in the current folder.
0196 summary.html is a table of tests with relevant info sorted by kernel/host/mode,
0197 and links to the test html files. It identifies the minimum, maximum, and median
0198 suspend and resume times for you with highlights and links in the header.
0199 summary-issues.html is a list of kernel issues found in dmesg from all the tests.
0200 summary-devices.html is a list of devices and times from all the tests.
0201
0202 Use \fI-genhtml\fR to regenerate any tests with missing html.
0203 .TP
0204 \fB-genhtml\fR
0205 Used with \fI-summary\fR to regenerate any missing html timelines from their
0206 dmesg and ftrace logs. This will require a significant amount of time if there
0207 are thousands of tests.
0208 .TP
0209 \fB-modes\fR
0210 List available suspend modes.
0211 .TP
0212 \fB-status\fR
0213 Test to see if the system is able to run this tool. Use this along
0214 with any options you intend to use to see if they will work.
0215 .TP
0216 \fB-fpdt\fR
0217 Print out the contents of the ACPI Firmware Performance Data Table.
0218 .TP
0219 \fB-wificheck\fR
0220 Print out wifi status and connection details.
0221 .TP
0222 \fB-xon/-xoff/-xstandby/-xsuspend\fR
0223 Test xset by attempting to switch the display to the given mode. This
0224 is the same command which will be issued by \fB-display \fImode\fR.
0225 .TP
0226 \fB-xstat\fR
0227 Get the current DPMS display mode.
0228 .TP
0229 \fB-sysinfo\fR
0230 Print out system info extracted from BIOS. Reads /dev/mem directly instead of going through dmidecode.
0231 .TP
0232 \fB-devinfo\fR
0233 Print out the pm settings of all devices which support runtime suspend.
0234 .TP
0235 \fB-cmdinfo\fR
0236 Print out all the platform data collected from the system that makes it into the logs.
0237 .TP
0238 \fB-flist\fR
0239 Print the list of ftrace functions currently being captured. Functions
0240 that are not available as symbols in the current kernel are shown in red.
0241 By default, the tool traces a list of important suspend/resume functions
0242 in order to better fill out the timeline. If the user has added their own
0243 with -fadd they will also be checked.
0244 .TP
0245 \fB-flistall\fR
0246 Print all ftrace functions capable of being captured. These are all the
0247 possible values you can add to trace via the -fadd argument.
0248 .SS "rebuild"
0249 .TP
0250 \fB-ftrace \fIfile\fR
0251 Create HTML output from an existing ftrace file.
0252 .TP
0253 \fB-dmesg \fIfile\fR
0254 Create HTML output from an existing dmesg file.
0255
0256 .SH EXAMPLES
0257 .SS "simple commands"
0258 Check which suspend modes are currently supported.
0259 .IP
0260 \f(CW$ sleepgraph -modes\fR
0261 .PP
0262 Read the Firmware Performance Data Table (FPDT)
0263 .IP
0264 \f(CW$ sudo sleepgraph -fpdt\fR
0265 .PP
0266 Print out the current USB power topology
0267 .IP
0268 \f(CW$ sleepgraph -usbtopo
0269 .PP
0270 Verify that you can run a command with a set of arguments
0271 .IP
0272 \f(CW$ sudo sleepgraph -f -rtcwake 30 -status
0273 .PP
0274 Generate a summary of all timelines in a particular folder.
0275 .IP
0276 \f(CW$ sleepgraph -summary ~/workspace/myresults/\fR
0277 .PP
0278
0279 .SS "capturing basic timelines"
0280 Execute a mem suspend with a 15 second wakeup. Include the logs in the html.
0281 .IP
0282 \f(CW$ sudo sleepgraph -rtcwake 15 -addlogs\fR
0283 .PP
0284 Execute a standby with a 15 second wakeup. Change the output folder name.
0285 .IP
0286 \f(CW$ sudo sleepgraph -m standby -rtcwake 15 -o "standby-{host}-{date}-{time}"\fR
0287 .PP
0288 Execute a freeze with no wakeup (require keypress). Change output folder name.
0289 .IP
0290 \f(CW$ sudo sleepgraph -m freeze -rtcwake off -o "freeze-{hostname}-{date}-{time}"\fR
0291 .PP
0292
0293 .SS "capturing advanced timelines"
0294 Execute a suspend & include dev mode source calls, limit callbacks to 5ms or larger.
0295 .IP
0296 \f(CW$ sudo sleepgraph -m mem -rtcwake 15 -dev -mindev 5\fR
0297 .PP
0298 Run two suspends back to back, include a 500ms delay before, after, and in between runs.
0299 .IP
0300 \f(CW$ sudo sleepgraph -m mem -rtcwake 15 -x2 -predelay 500 -x2delay 500 -postdelay 500\fR
0301 .PP
0302 Execute a suspend using a custom command.
0303 .IP
0304 \f(CW$ sudo sleepgraph -cmd "echo mem > /sys/power/state" -rtcwake 15\fR
0305 .PP
0306
0307 .SS "endurance testing using -multi"
0308 .PP
0309 Do a batch run of 10 freezes with 30 seconds delay between runs.
0310 .IP
0311 \f(CW$ sudo sleepgraph -m freeze -rtcwake 15 -multi 10 30\fR
0312 .PP
0313 Do a batch run of freezes for 24 hours.
0314 .IP
0315 \f(CW$ sudo sleepgraph -m freeze -rtcwake 15 -multi 24h 0\fR
0316
0317 .SS "adding callgraph data"
0318 Add device callgraphs. Limit the trace depth and only show callgraphs 10ms or larger.
0319 .IP
0320 \f(CW$ sudo sleepgraph -m mem -rtcwake 15 -f -maxdepth 5 -mincg 10\fR
0321 .PP
0322 Capture a full callgraph across all suspend, then filter the html by a single phase.
0323 .IP
0324 \f(CW$ sudo sleepgraph -m mem -rtcwake 15 -f\fR
0325 .IP
0326 \f(CW$ sleepgraph -dmesg host_mem_dmesg.txt -ftrace host_mem_ftrace.txt -f -cgphase resume
0327 .PP
0328
0329 .SS "rebuild timeline from logs"
0330 .PP
0331 Rebuild the html from a previous run's logs, using the same options.
0332 .IP
0333 \f(CW$ sleepgraph -dmesg dmesg.txt -ftrace ftrace.txt -callgraph\fR
0334 .PP
0335 Rebuild the html with different options.
0336 .IP
0337 \f(CW$ sleepgraph -dmesg dmesg.txt -ftrace ftrace.txt -addlogs -srgap\fR
0338
0339 .SH "SEE ALSO"
0340 dmesg(1)
0341 .PP
0342 .SH AUTHOR
0343 .nf
0344 Written by Todd Brandt <todd.e.brandt@linux.intel.com>