Skip to content

Commit 395c434

Browse files
committed
Merge tag 'pm-4.8-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull power management fixes from Rafael Wysocki: "More hibernation-related material: one fix for a recent regression in the core, one small cleanup of the x86-64 resume code and a documentation update. Specifics: - Fix a hibernate core regression resulting from uncovering a latent bug in its implementation of memory bitmaps by a recent commit (James Morse). - Use __pa() to compute a physical address in the x86-64 code finalizing resume from hibernation (Rafael Wysocki). - Update power management documentation related to system sleep states to remove outdated information from it and to add a description of a recently introduced hibernation debug feature to it (Rafael Wysocki)" * tag 'pm-4.8-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: PM / hibernate: Fix rtree_next_node() to avoid walking off list ends x86/power/64: Use __pa() for physical address computation PM / sleep: Update some system sleep documentation
2 parents 76dcd93 + 6c16f42 commit 395c434

File tree

4 files changed

+108
-82
lines changed

4 files changed

+108
-82
lines changed

Documentation/power/basic-pm-debugging.txt

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,32 @@ load n/2 modules more and try again.
164164
Again, if you find the offending module(s), it(they) must be unloaded every time
165165
before hibernation, and please report the problem with it(them).
166166

167-
c) Advanced debugging
167+
c) Using the "test_resume" hibernation option
168+
169+
/sys/power/disk generally tells the kernel what to do after creating a
170+
hibernation image. One of the available options is "test_resume" which
171+
causes the just created image to be used for immediate restoration. Namely,
172+
after doing:
173+
174+
# echo test_resume > /sys/power/disk
175+
# echo disk > /sys/power/state
176+
177+
a hibernation image will be created and a resume from it will be triggered
178+
immediately without involving the platform firmware in any way.
179+
180+
That test can be used to check if failures to resume from hibernation are
181+
related to bad interactions with the platform firmware. That is, if the above
182+
works every time, but resume from actual hibernation does not work or is
183+
unreliable, the platform firmware may be responsible for the failures.
184+
185+
On architectures and platforms that support using different kernels to restore
186+
hibernation images (that is, the kernel used to read the image from storage and
187+
load it into memory is different from the one included in the image) or support
188+
kernel address space randomization, it also can be used to check if failures
189+
to resume may be related to the differences between the restore and image
190+
kernels.
191+
192+
d) Advanced debugging
168193

169194
In case that hibernation does not work on your system even in the minimal
170195
configuration and compiling more drivers as modules is not practical or some

Documentation/power/interface.txt

Lines changed: 76 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,76 @@
1-
Power Management Interface
2-
3-
4-
The power management subsystem provides a unified sysfs interface to
5-
userspace, regardless of what architecture or platform one is
6-
running. The interface exists in /sys/power/ directory (assuming sysfs
7-
is mounted at /sys).
8-
9-
/sys/power/state controls system power state. Reading from this file
10-
returns what states are supported, which is hard-coded to 'freeze',
11-
'standby' (Power-On Suspend), 'mem' (Suspend-to-RAM), and 'disk'
12-
(Suspend-to-Disk).
13-
14-
Writing to this file one of those strings causes the system to
15-
transition into that state. Please see the file
16-
Documentation/power/states.txt for a description of each of those
17-
states.
18-
19-
20-
/sys/power/disk controls the operating mode of the suspend-to-disk
21-
mechanism. Suspend-to-disk can be handled in several ways. We have a
22-
few options for putting the system to sleep - using the platform driver
23-
(e.g. ACPI or other suspend_ops), powering off the system or rebooting the
24-
system (for testing).
25-
26-
Additionally, /sys/power/disk can be used to turn on one of the two testing
27-
modes of the suspend-to-disk mechanism: 'testproc' or 'test'. If the
28-
suspend-to-disk mechanism is in the 'testproc' mode, writing 'disk' to
29-
/sys/power/state will cause the kernel to disable nonboot CPUs and freeze
30-
tasks, wait for 5 seconds, unfreeze tasks and enable nonboot CPUs. If it is
31-
in the 'test' mode, writing 'disk' to /sys/power/state will cause the kernel
32-
to disable nonboot CPUs and freeze tasks, shrink memory, suspend devices, wait
33-
for 5 seconds, resume devices, unfreeze tasks and enable nonboot CPUs. Then,
34-
we are able to look in the log messages and work out, for example, which code
35-
is being slow and which device drivers are misbehaving.
36-
37-
Reading from this file will display all supported modes and the currently
38-
selected one in brackets, for example
39-
40-
[shutdown] reboot test testproc
41-
42-
Writing to this file will accept one of
43-
44-
'platform' (only if the platform supports it)
45-
'shutdown'
46-
'reboot'
47-
'testproc'
48-
'test'
49-
50-
/sys/power/image_size controls the size of the image created by
51-
the suspend-to-disk mechanism. It can be written a string
52-
representing a non-negative integer that will be used as an upper
53-
limit of the image size, in bytes. The suspend-to-disk mechanism will
54-
do its best to ensure the image size will not exceed that number. However,
55-
if this turns out to be impossible, it will try to suspend anyway using the
56-
smallest image possible. In particular, if "0" is written to this file, the
57-
suspend image will be as small as possible.
58-
59-
Reading from this file will display the current image size limit, which
60-
is set to 2/5 of available RAM by default.
61-
62-
/sys/power/pm_trace controls the code which saves the last PM event point in
63-
the RTC across reboots, so that you can debug a machine that just hangs
64-
during suspend (or more commonly, during resume). Namely, the RTC is only
65-
used to save the last PM event point if this file contains '1'. Initially it
66-
contains '0' which may be changed to '1' by writing a string representing a
67-
nonzero integer into it.
68-
69-
To use this debugging feature you should attempt to suspend the machine, then
70-
reboot it and run
71-
72-
dmesg -s 1000000 | grep 'hash matches'
73-
74-
CAUTION: Using it will cause your machine's real-time (CMOS) clock to be
75-
set to a random invalid time after a resume.
1+
Power Management Interface for System Sleep
2+
3+
Copyright (c) 2016 Intel Corp., Rafael J. Wysocki <rafael.j.wysocki@intel.com>
4+
5+
The power management subsystem provides userspace with a unified sysfs interface
6+
for system sleep regardless of the underlying system architecture or platform.
7+
The interface is located in the /sys/power/ directory (assuming that sysfs is
8+
mounted at /sys).
9+
10+
/sys/power/state is the system sleep state control file.
11+
12+
Reading from it returns a list of supported sleep states, encoded as:
13+
14+
'freeze' (Suspend-to-Idle)
15+
'standby' (Power-On Suspend)
16+
'mem' (Suspend-to-RAM)
17+
'disk' (Suspend-to-Disk)
18+
19+
Suspend-to-Idle is always supported. Suspend-to-Disk is always supported
20+
too as long the kernel has been configured to support hibernation at all
21+
(ie. CONFIG_HIBERNATION is set in the kernel configuration file). Support
22+
for Suspend-to-RAM and Power-On Suspend depends on the capabilities of the
23+
platform.
24+
25+
If one of the strings listed in /sys/power/state is written to it, the system
26+
will attempt to transition into the corresponding sleep state. Refer to
27+
Documentation/power/states.txt for a description of each of those states.
28+
29+
/sys/power/disk controls the operating mode of hibernation (Suspend-to-Disk).
30+
Specifically, it tells the kernel what to do after creating a hibernation image.
31+
32+
Reading from it returns a list of supported options encoded as:
33+
34+
'platform' (put the system into sleep using a platform-provided method)
35+
'shutdown' (shut the system down)
36+
'reboot' (reboot the system)
37+
'suspend' (trigger a Suspend-to-RAM transition)
38+
'test_resume' (resume-after-hibernation test mode)
39+
40+
The currently selected option is printed in square brackets.
41+
42+
The 'platform' option is only available if the platform provides a special
43+
mechanism to put the system to sleep after creating a hibernation image (ACPI
44+
does that, for example). The 'suspend' option is available if Suspend-to-RAM
45+
is supported. Refer to Documentation/power/basic_pm_debugging.txt for the
46+
description of the 'test_resume' option.
47+
48+
To select an option, write the string representing it to /sys/power/disk.
49+
50+
/sys/power/image_size controls the size of hibernation images.
51+
52+
It can be written a string representing a non-negative integer that will be
53+
used as a best-effort upper limit of the image size, in bytes. The hibernation
54+
core will do its best to ensure that the image size will not exceed that number.
55+
However, if that turns out to be impossible to achieve, a hibernation image will
56+
still be created and its size will be as small as possible. In particular,
57+
writing '0' to this file will enforce hibernation images to be as small as
58+
possible.
59+
60+
Reading from this file returns the current image size limit, which is set to
61+
around 2/5 of available RAM by default.
62+
63+
/sys/power/pm_trace controls the PM trace mechanism saving the last suspend
64+
or resume event point in the RTC across reboots.
65+
66+
It helps to debug hard lockups or reboots due to device driver failures that
67+
occur during system suspend or resume (which is more common) more effectively.
68+
69+
If /sys/power/pm_trace contains '1', the fingerprint of each suspend/resume
70+
event point in turn will be stored in the RTC memory (overwriting the actual
71+
RTC information), so it will survive a system crash if one occurs right after
72+
storing it and it can be used later to identify the driver that caused the crash
73+
to happen (see Documentation/power/s2ram.txt for more information).
74+
75+
Initially it contains '0' which may be changed to '1' by writing a string
76+
representing a nonzero integer into it.

arch/x86/power/hibernate_64.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ static int set_up_temporary_mappings(void)
113113
return result;
114114
}
115115

116-
temp_level4_pgt = (unsigned long)pgd - __PAGE_OFFSET;
116+
temp_level4_pgt = __pa(pgd);
117117
return 0;
118118
}
119119

kernel/power/snapshot.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -835,19 +835,19 @@ static bool memory_bm_pfn_present(struct memory_bitmap *bm, unsigned long pfn)
835835
*/
836836
static bool rtree_next_node(struct memory_bitmap *bm)
837837
{
838-
bm->cur.node = list_entry(bm->cur.node->list.next,
839-
struct rtree_node, list);
840-
if (&bm->cur.node->list != &bm->cur.zone->leaves) {
838+
if (!list_is_last(&bm->cur.node->list, &bm->cur.zone->leaves)) {
839+
bm->cur.node = list_entry(bm->cur.node->list.next,
840+
struct rtree_node, list);
841841
bm->cur.node_pfn += BM_BITS_PER_BLOCK;
842842
bm->cur.node_bit = 0;
843843
touch_softlockup_watchdog();
844844
return true;
845845
}
846846

847847
/* No more nodes, goto next zone */
848-
bm->cur.zone = list_entry(bm->cur.zone->list.next,
848+
if (!list_is_last(&bm->cur.zone->list, &bm->zones)) {
849+
bm->cur.zone = list_entry(bm->cur.zone->list.next,
849850
struct mem_zone_bm_rtree, list);
850-
if (&bm->cur.zone->list != &bm->zones) {
851851
bm->cur.node = list_entry(bm->cur.zone->leaves.next,
852852
struct rtree_node, list);
853853
bm->cur.node_pfn = 0;

0 commit comments

Comments
 (0)