import PULS_20160108
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / Documentation / power / tuxonice.txt
1 --- TuxOnIce, version 3.0 ---
2
3 1. What is it?
4 2. Why would you want it?
5 3. What do you need to use it?
6 4. Why not just use the version already in the kernel?
7 5. How do you use it?
8 6. What do all those entries in /sys/power/tuxonice do?
9 7. How do you get support?
10 8. I think I've found a bug. What should I do?
11 9. When will XXX be supported?
12 10 How does it work?
13 11. Who wrote TuxOnIce?
14
15 1. What is it?
16
17 Imagine you're sitting at your computer, working away. For some reason, you
18 need to turn off your computer for a while - perhaps it's time to go home
19 for the day. When you come back to your computer next, you're going to want
20 to carry on where you left off. Now imagine that you could push a button and
21 have your computer store the contents of its memory to disk and power down.
22 Then, when you next start up your computer, it loads that image back into
23 memory and you can carry on from where you were, just as if you'd never
24 turned the computer off. You have far less time to start up, no reopening of
25 applications or finding what directory you put that file in yesterday.
26 That's what TuxOnIce does.
27
28 TuxOnIce has a long heritage. It began life as work by Gabor Kuti, who,
29 with some help from Pavel Machek, got an early version going in 1999. The
30 project was then taken over by Florent Chabaud while still in alpha version
31 numbers. Nigel Cunningham came on the scene when Florent was unable to
32 continue, moving the project into betas, then 1.0, 2.0 and so on up to
33 the present series. During the 2.0 series, the name was contracted to
34 Suspend2 and the website suspend2.net created. Beginning around July 2007,
35 a transition to calling the software TuxOnIce was made, to seek to help
36 make it clear that TuxOnIce is more concerned with hibernation than suspend
37 to ram.
38
39 Pavel Machek's swsusp code, which was merged around 2.5.17 retains the
40 original name, and was essentially a fork of the beta code until Rafael
41 Wysocki came on the scene in 2005 and began to improve it further.
42
43 2. Why would you want it?
44
45 Why wouldn't you want it?
46
47 Being able to save the state of your system and quickly restore it improves
48 your productivity - you get a useful system in far less time than through
49 the normal boot process. You also get to be completely 'green', using zero
50 power, or as close to that as possible (the computer may still provide
51 minimal power to some devices, so they can initiate a power on, but that
52 will be the same amount of power as would be used if you told the computer
53 to shutdown.
54
55 3. What do you need to use it?
56
57 a. Kernel Support.
58
59 i) The TuxOnIce patch.
60
61 TuxOnIce is part of the Linux Kernel. This version is not part of Linus's
62 2.6 tree at the moment, so you will need to download the kernel source and
63 apply the latest patch. Having done that, enable the appropriate options in
64 make [menu|x]config (under Power Management Options - look for "Enhanced
65 Hibernation"), compile and install your kernel. TuxOnIce works with SMP,
66 Highmem, preemption, fuse filesystems, x86-32, PPC and x86_64.
67
68 TuxOnIce patches are available from http://tuxonice.net.
69
70 ii) Compression support.
71
72 Compression support is implemented via the cryptoapi. You will therefore want
73 to select any Cryptoapi transforms that you want to use on your image from
74 the Cryptoapi menu while configuring your kernel. We recommend the use of the
75 LZO compression method - it is very fast and still achieves good compression.
76
77 You can also tell TuxOnIce to write its image to an encrypted and/or
78 compressed filesystem/swap partition. In that case, you don't need to do
79 anything special for TuxOnIce when it comes to kernel configuration.
80
81 iii) Configuring other options.
82
83 While you're configuring your kernel, try to configure as much as possible
84 to build as modules. We recommend this because there are a number of drivers
85 that are still in the process of implementing proper power management
86 support. In those cases, the best way to work around their current lack is
87 to build them as modules and remove the modules while hibernating. You might
88 also bug the driver authors to get their support up to speed, or even help!
89
90 b. Storage.
91
92 i) Swap.
93
94 TuxOnIce can store the hibernation image in your swap partition, a swap file or
95 a combination thereof. Whichever combination you choose, you will probably
96 want to create enough swap space to store the largest image you could have,
97 plus the space you'd normally use for swap. A good rule of thumb would be
98 to calculate the amount of swap you'd want without using TuxOnIce, and then
99 add the amount of memory you have. This swapspace can be arranged in any way
100 you'd like. It can be in one partition or file, or spread over a number. The
101 only requirement is that they be active when you start a hibernation cycle.
102
103 There is one exception to this requirement. TuxOnIce has the ability to turn
104 on one swap file or partition at the start of hibernating and turn it back off
105 at the end. If you want to ensure you have enough memory to store a image
106 when your memory is fully used, you might want to make one swap partition or
107 file for 'normal' use, and another for TuxOnIce to activate & deactivate
108 automatically. (Further details below).
109
110 ii) Normal files.
111
112 TuxOnIce includes a 'file allocator'. The file allocator can store your
113 image in a simple file. Since Linux has the concept of everything being a
114 file, this is more powerful than it initially sounds. If, for example, you
115 were to set up a network block device file, you could hibernate to a network
116 server. This has been tested and works to a point, but nbd itself isn't
117 stateless enough for our purposes.
118
119 Take extra care when setting up the file allocator. If you just type
120 commands without thinking and then try to hibernate, you could cause
121 irreversible corruption on your filesystems! Make sure you have backups.
122
123 Most people will only want to hibernate to a local file. To achieve that, do
124 something along the lines of:
125
126 echo "TuxOnIce" > /hibernation-file
127 dd if=/dev/zero bs=1M count=512 >> /hibernation-file
128
129 This will create a 512MB file called /hibernation-file. To get TuxOnIce to use
130 it:
131
132 echo /hibernation-file > /sys/power/tuxonice/file/target
133
134 Then
135
136 cat /sys/power/tuxonice/resume
137
138 Put the results of this into your bootloader's configuration (see also step
139 C, below):
140
141 ---EXAMPLE-ONLY-DON'T-COPY-AND-PASTE---
142 # cat /sys/power/tuxonice/resume
143 file:/dev/hda2:0x1e001
144
145 In this example, we would edit the append= line of our lilo.conf|menu.lst
146 so that it included:
147
148 resume=file:/dev/hda2:0x1e001
149 ---EXAMPLE-ONLY-DON'T-COPY-AND-PASTE---
150
151 For those who are thinking 'Could I make the file sparse?', the answer is
152 'No!'. At the moment, there is no way for TuxOnIce to fill in the holes in
153 a sparse file while hibernating. In the longer term (post merge!), I'd like
154 to change things so that the file could be dynamically resized and have
155 holes filled as needed. Right now, however, that's not possible and not a
156 priority.
157
158 c. Bootloader configuration.
159
160 Using TuxOnIce also requires that you add an extra parameter to
161 your lilo.conf or equivalent. Here's an example for a swap partition:
162
163 append="resume=swap:/dev/hda1"
164
165 This would tell TuxOnIce that /dev/hda1 is a swap partition you
166 have. TuxOnIce will use the swap signature of this partition as a
167 pointer to your data when you hibernate. This means that (in this example)
168 /dev/hda1 doesn't need to be _the_ swap partition where all of your data
169 is actually stored. It just needs to be a swap partition that has a
170 valid signature.
171
172 You don't need to have a swap partition for this purpose. TuxOnIce
173 can also use a swap file, but usage is a little more complex. Having made
174 your swap file, turn it on and do
175
176 cat /sys/power/tuxonice/swap/headerlocations
177
178 (this assumes you've already compiled your kernel with TuxOnIce
179 support and booted it). The results of the cat command will tell you
180 what you need to put in lilo.conf:
181
182 For swap partitions like /dev/hda1, simply use resume=/dev/hda1.
183 For swapfile `swapfile`, use resume=swap:/dev/hda2:0x242d.
184
185 If the swapfile changes for any reason (it is moved to a different
186 location, it is deleted and recreated, or the filesystem is
187 defragmented) then you will have to check
188 /sys/power/tuxonice/swap/headerlocations for a new resume_block value.
189
190 Once you've compiled and installed the kernel and adjusted your bootloader
191 configuration, you should only need to reboot for the most basic part
192 of TuxOnIce to be ready.
193
194 If you only compile in the swap allocator, or only compile in the file
195 allocator, you don't need to add the "swap:" part of the resume=
196 parameters above. resume=/dev/hda2:0x242d will work just as well. If you
197 have compiled both and your storage is on swap, you can also use this
198 format (the swap allocator is the default allocator).
199
200 When compiling your kernel, one of the options in the 'Power Management
201 Support' menu, just above the 'Enhanced Hibernation (TuxOnIce)' entry is
202 called 'Default resume partition'. This can be used to set a default value
203 for the resume= parameter.
204
205 d. The hibernate script.
206
207 Since the driver model in 2.6 kernels is still being developed, you may need
208 to do more than just configure TuxOnIce. Users of TuxOnIce usually start the
209 process via a script which prepares for the hibernation cycle, tells the
210 kernel to do its stuff and then restore things afterwards. This script might
211 involve:
212
213 - Switching to a text console and back if X doesn't like the video card
214 status on resume.
215 - Un/reloading drivers that don't play well with hibernation.
216
217 Note that you might not be able to unload some drivers if there are
218 processes using them. You might have to kill off processes that hold
219 devices open. Hint: if your X server accesses an USB mouse, doing a
220 'chvt' to a text console releases the device and you can unload the
221 module.
222
223 Check out the latest script (available on tuxonice.net).
224
225 e. The userspace user interface.
226
227 TuxOnIce has very limited support for displaying status if you only apply
228 the kernel patch - it can printk messages, but that is all. In addition,
229 some of the functions mentioned in this document (such as cancelling a cycle
230 or performing interactive debugging) are unavailable. To utilise these
231 functions, or simply get a nice display, you need the 'userui' component.
232 Userui comes in three flavours, usplash, fbsplash and text. Text should
233 work on any console. Usplash and fbsplash require the appropriate
234 (distro specific?) support.
235
236 To utilise a userui, TuxOnIce just needs to be told where to find the
237 userspace binary:
238
239 echo "/usr/local/sbin/tuxoniceui_fbsplash" > /sys/power/tuxonice/user_interface/program
240
241 The hibernate script can do this for you, and a default value for this
242 setting can be configured when compiling the kernel. This path is also
243 stored in the image header, so if you have an initrd or initramfs, you can
244 use the userui during the first part of resuming (prior to the atomic
245 restore) by putting the binary in the same path in your initrd/ramfs.
246 Alternatively, you can put it in a different location and do an echo
247 similar to the above prior to the echo > do_resume. The value saved in the
248 image header will then be ignored.
249
250 4. Why not just use the version already in the kernel?
251
252 The version in the vanilla kernel has a number of drawbacks. The most
253 serious of these are:
254 - it has a maximum image size of 1/2 total memory;
255 - it doesn't allocate storage until after it has snapshotted memory.
256 This means that you can't be sure hibernating will work until you
257 see it start to write the image;
258 - it does not allow you to press escape to cancel a cycle;
259 - it does not allow you to press escape to cancel resuming;
260 - it does not allow you to automatically swapon a file when
261 starting a cycle;
262 - it does not allow you to use multiple swap partitions or files;
263 - it does not allow you to use ordinary files;
264 - it just invalidates an image and continues to boot if you
265 accidentally boot the wrong kernel after hibernating;
266 - it doesn't support any sort of nice display while hibernating;
267 - it is moving toward requiring that you have an initrd/initramfs
268 to ever have a hope of resuming (uswsusp). While uswsusp will
269 address some of the concerns above, it won't address all of them,
270 and will be more complicated to get set up;
271 - it doesn't have support for suspend-to-both (write a hibernation
272 image, then suspend to ram; I think this is known as ReadySafe
273 under M$).
274
275 5. How do you use it?
276
277 A hibernation cycle can be started directly by doing:
278
279 echo > /sys/power/tuxonice/do_hibernate
280
281 In practice, though, you'll probably want to use the hibernate script
282 to unload modules, configure the kernel the way you like it and so on.
283 In that case, you'd do (as root):
284
285 hibernate
286
287 See the hibernate script's man page for more details on the options it
288 takes.
289
290 If you're using the text or splash user interface modules, one feature of
291 TuxOnIce that you might find useful is that you can press Escape at any time
292 during hibernating, and the process will be aborted.
293
294 Due to the way hibernation works, this means you'll have your system back and
295 perfectly usable almost instantly. The only exception is when it's at the
296 very end of writing the image. Then it will need to reload a small (usually
297 4-50MBs, depending upon the image characteristics) portion first.
298
299 Likewise, when resuming, you can press escape and resuming will be aborted.
300 The computer will then powerdown again according to settings at that time for
301 the powerdown method or rebooting.
302
303 You can change the settings for powering down while the image is being
304 written by pressing 'R' to toggle rebooting and 'O' to toggle between
305 suspending to ram and powering down completely).
306
307 If you run into problems with resuming, adding the "noresume" option to
308 the kernel command line will let you skip the resume step and recover your
309 system. This option shouldn't normally be needed, because TuxOnIce modifies
310 the image header prior to the atomic restore, and will thus prompt you
311 if it detects that you've tried to resume an image before (this flag is
312 removed if you press Escape to cancel a resume, so you won't be prompted
313 then).
314
315 Recent kernels (2.6.24 onwards) add support for resuming from a different
316 kernel to the one that was hibernated (thanks to Rafael for his work on
317 this - I've just embraced and enhanced the support for TuxOnIce). This
318 should further reduce the need for you to use the noresume option.
319
320 6. What do all those entries in /sys/power/tuxonice do?
321
322 /sys/power/tuxonice is the directory which contains files you can use to
323 tune and configure TuxOnIce to your liking. The exact contents of
324 the directory will depend upon the version of TuxOnIce you're
325 running and the options you selected at compile time. In the following
326 descriptions, names in brackets refer to compile time options.
327 (Note that they're all dependant upon you having selected CONFIG_TUXONICE
328 in the first place!).
329
330 Since the values of these settings can open potential security risks, the
331 writeable ones are accessible only to the root user. You may want to
332 configure sudo to allow you to invoke your hibernate script as an ordinary
333 user.
334
335 - alloc/failure_test
336
337 This debugging option provides a way of testing TuxOnIce's handling of
338 memory allocation failures. Each allocation type that TuxOnIce makes has
339 been given a unique number (see the source code). Echo the appropriate
340 number into this entry, and when TuxOnIce attempts to do that allocation,
341 it will pretend there was a failure and act accordingly.
342
343 - alloc/find_max_mem_allocated
344
345 This debugging option will cause TuxOnIce to find the maximum amount of
346 memory it used during a cycle, and report that information in debugging
347 information at the end of the cycle.
348
349 - alt_resume_param
350
351 Instead of powering down after writing a hibernation image, TuxOnIce
352 supports resuming from a different image. This entry lets you set the
353 location of the signature for that image (the resume= value you'd use
354 for it). Using an alternate image and keep_image mode, you can do things
355 like using an alternate image to power down an uninterruptible power
356 supply.
357
358 - block_io/target_outstanding_io
359
360 This value controls the amount of memory that the block I/O code says it
361 needs when the core code is calculating how much memory is needed for
362 hibernating and for resuming. It doesn't directly control the amount of
363 I/O that is submitted at any one time - that depends on the amount of
364 available memory (we may have more available than we asked for), the
365 throughput that is being achieved and the ability of the CPU to keep up
366 with disk throughput (particularly where we're compressing pages).
367
368 - checksum/enabled
369
370 Use cryptoapi hashing routines to verify that Pageset2 pages don't change
371 while we're saving the first part of the image, and to get any pages that
372 do change resaved in the atomic copy. This should normally not be needed,
373 but if you're seeing issues, please enable this. If your issues stop you
374 being able to resume, enable this option, hibernate and cancel the cycle
375 after the atomic copy is done. If the debugging info shows a non-zero
376 number of pages resaved, please report this to Nigel.
377
378 - compression/algorithm
379
380 Set the cryptoapi algorithm used for compressing the image.
381
382 - compression/expected_compression
383
384 These values allow you to set an expected compression ratio, which TuxOnice
385 will use in calculating whether it meets constraints on the image size. If
386 this expected compression ratio is not attained, the hibernation cycle will
387 abort, so it is wise to allow some spare. You can see what compression
388 ratio is achieved in the logs after hibernating.
389
390 - debug_info:
391
392 This file returns information about your configuration that may be helpful
393 in diagnosing problems with hibernating.
394
395 - did_suspend_to_both:
396
397 This file can be used when you hibernate with powerdown method 3 (ie suspend
398 to ram after writing the image). There can be two outcomes in this case. We
399 can resume from the suspend-to-ram before the battery runs out, or we can run
400 out of juice and and up resuming like normal. This entry lets you find out,
401 post resume, which way we went. If the value is 1, we resumed from suspend
402 to ram. This can be useful when actions need to be run post suspend-to-ram
403 that don't need to be run if we did the normal resume from power off.
404
405 - do_hibernate:
406
407 When anything is written to this file, the kernel side of TuxOnIce will
408 begin to attempt to write an image to disk and power down. You'll normally
409 want to run the hibernate script instead, to get modules unloaded first.
410
411 - do_resume:
412
413 When anything is written to this file TuxOnIce will attempt to read and
414 restore an image. If there is no image, it will return almost immediately.
415 If an image exists, the echo > will never return. Instead, the original
416 kernel context will be restored and the original echo > do_hibernate will
417 return.
418
419 - */enabled
420
421 These option can be used to temporarily disable various parts of TuxOnIce.
422
423 - extra_pages_allowance
424
425 When TuxOnIce does its atomic copy, it calls the driver model suspend
426 and resume methods. If you have DRI enabled with a driver such as fglrx,
427 this can result in the driver allocating a substantial amount of memory
428 for storing its state. Extra_pages_allowance tells TuxOnIce how much
429 extra memory it should ensure is available for those allocations. If
430 your attempts at hibernating end with a message in dmesg indicating that
431 insufficient extra pages were allowed, you need to increase this value.
432
433 - file/target:
434
435 Read this value to get the current setting. Write to it to point TuxOnice
436 at a new storage location for the file allocator. See section 3.b.ii above
437 for details of how to set up the file allocator.
438
439 - freezer_test
440
441 This entry can be used to get TuxOnIce to just test the freezer and prepare
442 an image without actually doing a hibernation cycle. It is useful for
443 diagnosing freezing and image preparation issues.
444
445 - full_pageset2
446
447 TuxOnIce divides the pages that are stored in an image into two sets. The
448 difference between the two sets is that pages in pageset 1 are atomically
449 copied, and pages in pageset 2 are written to disk without being copied
450 first. A page CAN be written to disk without being copied first if and only
451 if its contents will not be modified or used at any time after userspace
452 processes are frozen. A page MUST be in pageset 1 if its contents are
453 modified or used at any time after userspace processes have been frozen.
454
455 Normally (ie if this option is enabled), TuxOnIce will put all pages on the
456 per-zone LRUs in pageset2, then remove those pages used by any userspace
457 user interface helper and TuxOnIce storage manager that are running,
458 together with pages used by the GEM memory manager introduced around 2.6.28
459 kernels.
460
461 If this option is disabled, a much more conservative approach will be taken.
462 The only pages in pageset2 will be those belonging to userspace processes,
463 with the exclusion of those belonging to the TuxOnIce userspace helpers
464 mentioned above. This will result in a much smaller pageset2, and will
465 therefore result in smaller images than are possible with this option
466 enabled.
467
468 - ignore_rootfs
469
470 TuxOnIce records which device is mounted as the root filesystem when
471 writing the hibernation image. It will normally check at resume time that
472 this device isn't already mounted - that would be a cause of filesystem
473 corruption. In some particular cases (RAM based root filesystems), you
474 might want to disable this check. This option allows you to do that.
475
476 - image_exists:
477
478 Can be used in a script to determine whether a valid image exists at the
479 location currently pointed to by resume=. Returns up to three lines.
480 The first is whether an image exists (-1 for unsure, otherwise 0 or 1).
481 If an image eixsts, additional lines will return the machine and version.
482 Echoing anything to this entry removes any current image.
483
484 - image_size_limit:
485
486 The maximum size of hibernation image written to disk, measured in megabytes
487 (1024*1024).
488
489 - last_result:
490
491 The result of the last hibernation cycle, as defined in
492 include/linux/suspend-debug.h with the values SUSPEND_ABORTED to
493 SUSPEND_KEPT_IMAGE. This is a bitmask.
494
495 - late_cpu_hotplug:
496
497 This sysfs entry controls whether cpu hotplugging is done - as normal - just
498 before (unplug) and after (replug) the atomic copy/restore (so that all
499 CPUs/cores are available for multithreaded I/O). The alternative is to
500 unplug all secondary CPUs/cores at the start of hibernating/resuming, and
501 replug them at the end of resuming. No multithreaded I/O will be possible in
502 this configuration, but the odd machine has been reported to require it.
503
504 - lid_file:
505
506 This determines which ACPI button file we look in to determine whether the
507 lid is open or closed after resuming from suspend to disk or power off.
508 If the entry is set to "lid/LID", we'll open /proc/acpi/button/lid/LID/state
509 and check its contents at the appropriate moment. See post_wake_state below
510 for more details on how this entry is used.
511
512 - log_everything (CONFIG_PM_DEBUG):
513
514 Setting this option results in all messages printed being logged. Normally,
515 only a subset are logged, so as to not slow the process and not clutter the
516 logs. Useful for debugging. It can be toggled during a cycle by pressing
517 'L'.
518
519 - no_load_direct:
520
521 This is a debugging option. If, when loading the atomically copied pages of
522 an image, TuxOnIce finds that the destination address for a page is free,
523 it will normally allocate the image, load the data directly into that
524 address and skip it in the atomic restore. If this option is disabled, the
525 page will be loaded somewhere else and atomically restored like other pages.
526
527 - no_flusher_thread:
528
529 When doing multithreaded I/O (see below), the first online CPU can be used
530 to _just_ submit compressed pages when writing the image, rather than
531 compressing and submitting data. This option is normally disabled, but has
532 been included because Nigel would like to see whether it will be more useful
533 as the number of cores/cpus in computers increases.
534
535 - no_multithreaded_io:
536
537 TuxOnIce will normally create one thread per cpu/core on your computer,
538 each of which will then perform I/O. This will generally result in
539 throughput that's the maximum the storage medium can handle. There
540 shouldn't be any reason to disable multithreaded I/O now, but this option
541 has been retained for debugging purposes.
542
543 - no_pageset2
544
545 See the entry for full_pageset2 above for an explanation of pagesets.
546 Enabling this option causes TuxOnIce to do an atomic copy of all pages,
547 thereby limiting the maximum image size to 1/2 of memory, as swsusp does.
548
549 - no_pageset2_if_unneeded
550
551 See the entry for full_pageset2 above for an explanation of pagesets.
552 Enabling this option causes TuxOnIce to act like no_pageset2 was enabled
553 if and only it isn't needed anyway. This option may still make TuxOnIce
554 less reliable because pageset2 pages are normally used to store the
555 atomic copy - drivers that want to do allocations of larger amounts of
556 memory in one shot will be more likely to find that those amounts aren't
557 available if this option is enabled.
558
559 - pause_between_steps (CONFIG_PM_DEBUG):
560
561 This option is used during debugging, to make TuxOnIce pause between
562 each step of the process. It is ignored when the nice display is on.
563
564 - post_wake_state:
565
566 TuxOnIce provides support for automatically waking after a user-selected
567 delay, and using a different powerdown method if the lid is still closed.
568 (Yes, we're assuming a laptop). This entry lets you choose what state
569 should be entered next. The values are those described under
570 powerdown_method, below. It can be used to suspend to RAM after hibernating,
571 then powerdown properly (say) 20 minutes. It can also be used to power down
572 properly, then wake at (say) 6.30am and suspend to RAM until you're ready
573 to use the machine.
574
575 - powerdown_method:
576
577 Used to select a method by which TuxOnIce should powerdown after writing the
578 image. Currently:
579
580 0: Don't use ACPI to power off.
581 3: Attempt to enter Suspend-to-ram.
582 4: Attempt to enter ACPI S4 mode.
583 5: Attempt to power down via ACPI S5 mode.
584
585 Note that these options are highly dependant upon your hardware & software:
586
587 3: When succesful, your machine suspends to ram instead of powering off.
588 The advantage of using this mode is that it doesn't matter whether your
589 battery has enough charge to make it through to your next resume. If it
590 lasts, you will simply resume from suspend to ram (and the image on disk
591 will be discarded). If the battery runs out, you will resume from disk
592 instead. The disadvantage is that it takes longer than a normal
593 suspend-to-ram to enter the state, since the suspend-to-disk image needs
594 to be written first.
595 4/5: When successful, your machine will be off and comsume (almost) no power.
596 But it might still react to some external events like opening the lid or
597 trafic on a network or usb device. For the bios, resume is then the same
598 as warm boot, similar to a situation where you used the command `reboot'
599 to reboot your machine. If your machine has problems on warm boot or if
600 you want to protect your machine with the bios password, this is probably
601 not the right choice. Mode 4 may be necessary on some machines where ACPI
602 wake up methods need to be run to properly reinitialise hardware after a
603 hibernation cycle.
604 0: Switch the machine completely off. The only possible wakeup is the power
605 button. For the bios, resume is then the same as a cold boot, in
606 particular you would have to provide your bios boot password if your
607 machine uses that feature for booting.
608
609 - progressbar_granularity_limit:
610
611 This option can be used to limit the granularity of the progress bar
612 displayed with a bootsplash screen. The value is the maximum number of
613 steps. That is, 10 will make the progress bar jump in 10% increments.
614
615 - reboot:
616
617 This option causes TuxOnIce to reboot rather than powering down
618 at the end of saving an image. It can be toggled during a cycle by pressing
619 'R'.
620
621 - resume:
622
623 This sysfs entry can be used to read and set the location in which TuxOnIce
624 will look for the signature of an image - the value set using resume= at
625 boot time or CONFIG_PM_STD_PARTITION ("Default resume partition"). By
626 writing to this file as well as modifying your bootloader's configuration
627 file (eg menu.lst), you can set or reset the location of your image or the
628 method of storing the image without rebooting.
629
630 - replace_swsusp (CONFIG_TOI_REPLACE_SWSUSP):
631
632 This option makes
633
634 echo disk > /sys/power/state
635
636 activate TuxOnIce instead of swsusp. Regardless of whether this option is
637 enabled, any invocation of swsusp's resume time trigger will cause TuxOnIce
638 to check for an image too. This is due to the fact that at resume time, we
639 can't know whether this option was enabled until we see if an image is there
640 for us to resume from. (And when an image exists, we don't care whether we
641 did replace swsusp anyway - we just want to resume).
642
643 - resume_commandline:
644
645 This entry can be read after resuming to see the commandline that was used
646 when resuming began. You might use this to set up two bootloader entries
647 that are the same apart from the fact that one includes a extra append=
648 argument "at_work=1". You could then grep resume_commandline in your
649 post-resume scripts and configure networking (for example) differently
650 depending upon whether you're at home or work. resume_commandline can be
651 set to arbitrary text if you wish to remove sensitive contents.
652
653 - swap/swapfilename:
654
655 This entry is used to specify the swapfile or partition that
656 TuxOnIce will attempt to swapon/swapoff automatically. Thus, if
657 I normally use /dev/hda1 for swap, and want to use /dev/hda2 for specifically
658 for my hibernation image, I would
659
660 echo /dev/hda2 > /sys/power/tuxonice/swap/swapfile
661
662 /dev/hda2 would then be automatically swapon'd and swapoff'd. Note that the
663 swapon and swapoff occur while other processes are frozen (including kswapd)
664 so this swap file will not be used up when attempting to free memory. The
665 parition/file is also given the highest priority, so other swapfiles/partitions
666 will only be used to save the image when this one is filled.
667
668 The value of this file is used by headerlocations along with any currently
669 activated swapfiles/partitions.
670
671 - swap/headerlocations:
672
673 This option tells you the resume= options to use for swap devices you
674 currently have activated. It is particularly useful when you only want to
675 use a swap file to store your image. See above for further details.
676
677 - test_bio
678
679 This is a debugging option. When enabled, TuxOnIce will not hibernate.
680 Instead, when asked to write an image, it will skip the atomic copy,
681 just doing the writing of the image and then returning control to the
682 user at the point where it would have powered off. This is useful for
683 testing throughput in different configurations.
684
685 - test_filter_speed
686
687 This is a debugging option. When enabled, TuxOnIce will not hibernate.
688 Instead, when asked to write an image, it will not write anything or do
689 an atomic copy, but will only run any enabled compression algorithm on the
690 data that would have been written (the source pages of the atomic copy in
691 the case of pageset 1). This is useful for comparing the performance of
692 compression algorithms and for determining the extent to which an upgrade
693 to your storage method would improve hibernation speed.
694
695 - user_interface/debug_sections (CONFIG_PM_DEBUG):
696
697 This value, together with the console log level, controls what debugging
698 information is displayed. The console log level determines the level of
699 detail, and this value determines what detail is displayed. This value is
700 a bit vector, and the meaning of the bits can be found in the kernel tree
701 in include/linux/tuxonice.h. It can be overridden using the kernel's
702 command line option suspend_dbg.
703
704 - user_interface/default_console_level (CONFIG_PM_DEBUG):
705
706 This determines the value of the console log level at the start of a
707 hibernation cycle. If debugging is compiled in, the console log level can be
708 changed during a cycle by pressing the digit keys. Meanings are:
709
710 0: Nice display.
711 1: Nice display plus numerical progress.
712 2: Errors only.
713 3: Low level debugging info.
714 4: Medium level debugging info.
715 5: High level debugging info.
716 6: Verbose debugging info.
717
718 - user_interface/enable_escape:
719
720 Setting this to "1" will enable you abort a hibernation cycle or resuming by
721 pressing escape, "0" (default) disables this feature. Note that enabling
722 this option means that you cannot initiate a hibernation cycle and then walk
723 away from your computer, expecting it to be secure. With feature disabled,
724 you can validly have this expectation once TuxOnice begins to write the
725 image to disk. (Prior to this point, it is possible that TuxOnice might
726 about because of failure to freeze all processes or because constraints
727 on its ability to save the image are not met).
728
729 - user_interface/program
730
731 This entry is used to tell TuxOnice what userspace program to use for
732 providing a user interface while hibernating. The program uses a netlink
733 socket to pass messages back and forward to the kernel, allowing all of the
734 functions formerly implemented in the kernel user interface components.
735
736 - version:
737
738 The version of TuxOnIce you have compiled into the currently running kernel.
739
740 - wake_alarm_dir:
741
742 As mentioned above (post_wake_state), TuxOnIce supports automatically waking
743 after some delay. This entry allows you to select which wake alarm to use.
744 It should contain the value "rtc0" if you're wanting to use
745 /sys/class/rtc/rtc0.
746
747 - wake_delay:
748
749 This value determines the delay from the end of writing the image until the
750 wake alarm is triggered. You can set an absolute time by writing the desired
751 time into /sys/class/rtc/<wake_alarm_dir>/wakealarm and leaving these values
752 empty.
753
754 Note that for the wakeup to actually occur, you may need to modify entries
755 in /proc/acpi/wakeup. This is done by echoing the name of the button in the
756 first column (eg PBTN) into the file.
757
758 7. How do you get support?
759
760 Glad you asked. TuxOnIce is being actively maintained and supported
761 by Nigel (the guy doing most of the kernel coding at the moment), Bernard
762 (who maintains the hibernate script and userspace user interface components)
763 and its users.
764
765 Resources availble include HowTos, FAQs and a Wiki, all available via
766 tuxonice.net. You can find the mailing lists there.
767
768 8. I think I've found a bug. What should I do?
769
770 By far and a way, the most common problems people have with TuxOnIce
771 related to drivers not having adequate power management support. In this
772 case, it is not a bug with TuxOnIce, but we can still help you. As we
773 mentioned above, such issues can usually be worked around by building the
774 functionality as modules and unloading them while hibernating. Please visit
775 the Wiki for up-to-date lists of known issues and work arounds.
776
777 If this information doesn't help, try running:
778
779 hibernate --bug-report
780
781 ..and sending the output to the users mailing list.
782
783 Good information on how to provide us with useful information from an
784 oops is found in the file REPORTING-BUGS, in the top level directory
785 of the kernel tree. If you get an oops, please especially note the
786 information about running what is printed on the screen through ksymoops.
787 The raw information is useless.
788
789 9. When will XXX be supported?
790
791 If there's a feature missing from TuxOnIce that you'd like, feel free to
792 ask. We try to be obliging, within reason.
793
794 Patches are welcome. Please send to the list.
795
796 10. How does it work?
797
798 TuxOnIce does its work in a number of steps.
799
800 a. Freezing system activity.
801
802 The first main stage in hibernating is to stop all other activity. This is
803 achieved in stages. Processes are considered in fours groups, which we will
804 describe in reverse order for clarity's sake: Threads with the PF_NOFREEZE
805 flag, kernel threads without this flag, userspace processes with the
806 PF_SYNCTHREAD flag and all other processes. The first set (PF_NOFREEZE) are
807 untouched by the refrigerator code. They are allowed to run during hibernating
808 and resuming, and are used to support user interaction, storage access or the
809 like. Other kernel threads (those unneeded while hibernating) are frozen last.
810 This leaves us with userspace processes that need to be frozen. When a
811 process enters one of the *_sync system calls, we set a PF_SYNCTHREAD flag on
812 that process for the duration of that call. Processes that have this flag are
813 frozen after processes without it, so that we can seek to ensure that dirty
814 data is synced to disk as quickly as possible in a situation where other
815 processes may be submitting writes at the same time. Freezing the processes
816 that are submitting data stops new I/O from being submitted. Syncthreads can
817 then cleanly finish their work. So the order is:
818
819 - Userspace processes without PF_SYNCTHREAD or PF_NOFREEZE;
820 - Userspace processes with PF_SYNCTHREAD (they won't have NOFREEZE);
821 - Kernel processes without PF_NOFREEZE.
822
823 b. Eating memory.
824
825 For a successful hibernation cycle, you need to have enough disk space to store the
826 image and enough memory for the various limitations of TuxOnIce's
827 algorithm. You can also specify a maximum image size. In order to attain
828 to those constraints, TuxOnIce may 'eat' memory. If, after freezing
829 processes, the constraints aren't met, TuxOnIce will thaw all the
830 other processes and begin to eat memory until its calculations indicate
831 the constraints are met. It will then freeze processes again and recheck
832 its calculations.
833
834 c. Allocation of storage.
835
836 Next, TuxOnIce allocates the storage that will be used to save
837 the image.
838
839 The core of TuxOnIce knows nothing about how or where pages are stored. We
840 therefore request the active allocator (remember you might have compiled in
841 more than one!) to allocate enough storage for our expect image size. If
842 this request cannot be fulfilled, we eat more memory and try again. If it
843 is fulfiled, we seek to allocate additional storage, just in case our
844 expected compression ratio (if any) isn't achieved. This time, however, we
845 just continue if we can't allocate enough storage.
846
847 If these calls to our allocator change the characteristics of the image
848 such that we haven't allocated enough memory, we also loop. (The allocator
849 may well need to allocate space for its storage information).
850
851 d. Write the first part of the image.
852
853 TuxOnIce stores the image in two sets of pages called 'pagesets'.
854 Pageset 2 contains pages on the active and inactive lists; essentially
855 the page cache. Pageset 1 contains all other pages, including the kernel.
856 We use two pagesets for one important reason: We need to make an atomic copy
857 of the kernel to ensure consistency of the image. Without a second pageset,
858 that would limit us to an image that was at most half the amount of memory
859 available. Using two pagesets allows us to store a full image. Since pageset
860 2 pages won't be needed in saving pageset 1, we first save pageset 2 pages.
861 We can then make our atomic copy of the remaining pages using both pageset 2
862 pages and any other pages that are free. While saving both pagesets, we are
863 careful not to corrupt the image. Among other things, we use lowlevel block
864 I/O routines that don't change the pagecache contents.
865
866 The next step, then, is writing pageset 2.
867
868 e. Suspending drivers and storing processor context.
869
870 Having written pageset2, TuxOnIce calls the power management functions to
871 notify drivers of the hibernation, and saves the processor state in preparation
872 for the atomic copy of memory we are about to make.
873
874 f. Atomic copy.
875
876 At this stage, everything else but the TuxOnIce code is halted. Processes
877 are frozen or idling, drivers are quiesced and have stored (ideally and where
878 necessary) their configuration in memory we are about to atomically copy.
879 In our lowlevel architecture specific code, we have saved the CPU state.
880 We can therefore now do our atomic copy before resuming drivers etc.
881
882 g. Save the atomic copy (pageset 1).
883
884 TuxOnice can then write the atomic copy of the remaining pages. Since we
885 have copied the pages into other locations, we can continue to use the
886 normal block I/O routines without fear of corruption our image.
887
888 f. Save the image header.
889
890 Nearly there! We save our settings and other parameters needed for
891 reloading pageset 1 in an 'image header'. We also tell our allocator to
892 serialise its data at this stage, so that it can reread the image at resume
893 time.
894
895 g. Set the image header.
896
897 Finally, we edit the header at our resume= location. The signature is
898 changed by the allocator to reflect the fact that an image exists, and to
899 point to the start of that data if necessary (swap allocator).
900
901 h. Power down.
902
903 Or reboot if we're debugging and the appropriate option is selected.
904
905 Whew!
906
907 Reloading the image.
908 --------------------
909
910 Reloading the image is essentially the reverse of all the above. We load
911 our copy of pageset 1, being careful to choose locations that aren't going
912 to be overwritten as we copy it back (We start very early in the boot
913 process, so there are no other processes to quiesce here). We then copy
914 pageset 1 back to its original location in memory and restore the process
915 context. We are now running with the original kernel. Next, we reload the
916 pageset 2 pages, free the memory and swap used by TuxOnIce, restore
917 the pageset header and restart processes. Sounds easy in comparison to
918 hibernating, doesn't it!
919
920 There is of course more to TuxOnIce than this, but this explanation
921 should be a good start. If there's interest, I'll write further
922 documentation on range pages and the low level I/O.
923
924 11. Who wrote TuxOnIce?
925
926 (Answer based on the writings of Florent Chabaud, credits in files and
927 Nigel's limited knowledge; apologies to anyone missed out!)
928
929 The main developers of TuxOnIce have been...
930
931 Gabor Kuti
932 Pavel Machek
933 Florent Chabaud
934 Bernard Blackham
935 Nigel Cunningham
936
937 Significant portions of swsusp, the code in the vanilla kernel which
938 TuxOnIce enhances, have been worked on by Rafael Wysocki. Thanks should
939 also be expressed to him.
940
941 The above mentioned developers have been aided in their efforts by a host
942 of hundreds, if not thousands of testers and people who have submitted bug
943 fixes & suggestions. Of special note are the efforts of Michael Frank, who
944 had his computers repetitively hibernate and resume for literally tens of
945 thousands of cycles and developed scripts to stress the system and test
946 TuxOnIce far beyond the point most of us (Nigel included!) would consider
947 testing. His efforts have contributed as much to TuxOnIce as any of the
948 names above.