* [PATCH v2 1/2] power/hibernate: Make passing hibernate offsets more friendly
@ 2018-03-27 20:58 Mario Limonciello
2018-03-27 20:58 ` [PATCH v2 2/2] power/hibernate: Change message when writing to /sys/power/resume Mario Limonciello
2018-03-28 14:01 ` [PATCH v2 1/2] power/hibernate: Make passing hibernate offsets more friendly kbuild test robot
0 siblings, 2 replies; 3+ messages in thread
From: Mario Limonciello @ 2018-03-27 20:58 UTC (permalink / raw)
To: Rafael J . Wysocki; +Cc: linux-acpi, LKML, Mario Limonciello
Currently the only way to specify a hibernate offset for a
swap file is on the kernel command line.
Add a new /sys/power/resume_offset that lets userspace
specify the offset and disk to use when initiating a hibernate
cycle.
Signed-off-by: Mario Limonciello <mario.limonciello@dell.com>
---
Documentation/ABI/testing/sysfs-power | 14 ++++++++++++++
Documentation/power/swsusp.txt | 10 +++++++++-
kernel/power/hibernate.c | 21 +++++++++++++++++++++
3 files changed, 44 insertions(+), 1 deletion(-)
diff --git a/Documentation/ABI/testing/sysfs-power b/Documentation/ABI/testing/sysfs-power
index 1e0d1da..2f813d6 100644
--- a/Documentation/ABI/testing/sysfs-power
+++ b/Documentation/ABI/testing/sysfs-power
@@ -287,3 +287,17 @@ Description:
Writing a "1" to this file enables the debug messages and
writing a "0" (default) to it disables them. Reads from
this file return the current value.
+
+What: /sys/power/resume_offset
+Date: April 2018
+Contact: Mario Limonciello <mario.limonciello@dell.com>
+Description:
+ This file is used for telling the kernel an offset into a disk
+ to use when hibernating the system such as with a swap file.
+
+ Reads from this file will display the current offset
+ the kernel will be using on the next hibernation
+ attempt.
+
+ Using this sysfs file will override any values that were
+ set using the kernel command line for disk offset.
\ No newline at end of file
diff --git a/Documentation/power/swsusp.txt b/Documentation/power/swsusp.txt
index 9f2f942..cc87adf 100644
--- a/Documentation/power/swsusp.txt
+++ b/Documentation/power/swsusp.txt
@@ -24,8 +24,16 @@ Some warnings, first.
* see the FAQ below for details. (This is not true for more traditional
* power states like "standby", which normally don't turn USB off.)
+Swap partition:
You need to append resume=/dev/your_swap_partition to kernel command
-line. Then you suspend by
+line or specify it using /sys/power/resume.
+
+Swap file:
+If using a swapfile you can also specify a resume offset using
+resume_offset=<number> on the kernel command line or specify it
+in /sys/power/resume_offset.
+
+After preparing then you suspend by
echo shutdown > /sys/power/disk; echo disk > /sys/power/state
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index a5c36e9..16e8645 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -1061,6 +1061,26 @@ static ssize_t resume_store(struct kobject *kobj, struct kobj_attribute *attr,
power_attr(resume);
+static ssize_t resume_offset_show(struct kobject *kobj,
+ struct kobj_attribute *attr, char *buf)
+{
+ return sprintf(buf, "%lu\n", swsusp_resume_block);
+}
+
+static ssize_t resume_offset_store(struct kobject *kobj,
+ struct kobj_attribute *attr, const char *buf,
+ size_t n)
+{
+ int rc = kstrtoul(buf, 0, &swsusp_resume_block);
+
+ if (rc)
+ return rc;
+
+ return n;
+}
+
+power_attr(resume_offset);
+
static ssize_t image_size_show(struct kobject *kobj, struct kobj_attribute *attr,
char *buf)
{
@@ -1106,6 +1126,7 @@ power_attr(reserved_size);
static struct attribute * g[] = {
&disk_attr.attr,
+ &resume_offset_attr.attr,
&resume_attr.attr,
&image_size_attr.attr,
&reserved_size_attr.attr,
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH v2 2/2] power/hibernate: Change message when writing to /sys/power/resume
2018-03-27 20:58 [PATCH v2 1/2] power/hibernate: Make passing hibernate offsets more friendly Mario Limonciello
@ 2018-03-27 20:58 ` Mario Limonciello
2018-03-28 14:01 ` [PATCH v2 1/2] power/hibernate: Make passing hibernate offsets more friendly kbuild test robot
1 sibling, 0 replies; 3+ messages in thread
From: Mario Limonciello @ 2018-03-27 20:58 UTC (permalink / raw)
To: Rafael J . Wysocki; +Cc: linux-acpi, LKML, Mario Limonciello
This file is used both for setting the wakeup device without kernel
command line as well as for actually waking the system (when appropriate
swap header is in place).
To avoid confusion on incorrect logs in system log downgrade the
message to debug and make it clearer.
Signed-off-by: Mario Limonciello <mario.limonciello@dell.com>
---
kernel/power/hibernate.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
index 16e8645..15bc3cd 100644
--- a/kernel/power/hibernate.c
+++ b/kernel/power/hibernate.c
@@ -1053,7 +1053,7 @@ static ssize_t resume_store(struct kobject *kobj, struct kobj_attribute *attr,
lock_system_sleep();
swsusp_resume_device = res;
unlock_system_sleep();
- pr_info("Starting manual resume from disk\n");
+ pm_pr_dbg("Configured resume from disk to %u\n", swsusp_resume_device);
noresume = 0;
software_resume();
return n;
--
2.7.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2 1/2] power/hibernate: Make passing hibernate offsets more friendly
2018-03-27 20:58 [PATCH v2 1/2] power/hibernate: Make passing hibernate offsets more friendly Mario Limonciello
2018-03-27 20:58 ` [PATCH v2 2/2] power/hibernate: Change message when writing to /sys/power/resume Mario Limonciello
@ 2018-03-28 14:01 ` kbuild test robot
1 sibling, 0 replies; 3+ messages in thread
From: kbuild test robot @ 2018-03-28 14:01 UTC (permalink / raw)
To: Mario Limonciello
Cc: kbuild-all, Rafael J . Wysocki, linux-acpi, LKML, Mario Limonciello
[-- Attachment #1: Type: text/plain, Size: 2636 bytes --]
Hi Mario,
I love your patch! Yet something to improve:
[auto build test ERROR on linus/master]
[also build test ERROR on v4.16-rc7 next-20180328]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Mario-Limonciello/power-hibernate-Make-passing-hibernate-offsets-more-friendly/20180328-212230
config: i386-randconfig-x006-201812 (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
# save the attached .config to linux build tree
make ARCH=i386
All errors (new ones prefixed by >>):
kernel/power/hibernate.c: In function 'resume_offset_show':
kernel/power/hibernate.c:1067:25: warning: format '%lu' expects argument of type 'long unsigned int', but argument 3 has type 'sector_t {aka long long unsigned int}' [-Wformat=]
return sprintf(buf, "%lu\n", swsusp_resume_block);
~~^
%llu
kernel/power/hibernate.c: In function 'resume_offset_store':
>> kernel/power/hibernate.c:1074:28: error: passing argument 3 of 'kstrtoul' from incompatible pointer type [-Werror=incompatible-pointer-types]
int rc = kstrtoul(buf, 0, &swsusp_resume_block);
^
In file included from include/linux/list.h:9:0,
from include/linux/preempt.h:11,
from include/linux/spinlock.h:51,
from include/linux/swap.h:5,
from include/linux/suspend.h:5,
from kernel/power/hibernate.c:16:
include/linux/kernel.h:332:32: note: expected 'long unsigned int *' but argument is of type 'sector_t * {aka long long unsigned int *}'
static inline int __must_check kstrtoul(const char *s, unsigned int base, unsigned long *res)
^~~~~~~~
cc1: some warnings being treated as errors
vim +/kstrtoul +1074 kernel/power/hibernate.c
1063
1064 static ssize_t resume_offset_show(struct kobject *kobj,
1065 struct kobj_attribute *attr, char *buf)
1066 {
> 1067 return sprintf(buf, "%lu\n", swsusp_resume_block);
1068 }
1069
1070 static ssize_t resume_offset_store(struct kobject *kobj,
1071 struct kobj_attribute *attr, const char *buf,
1072 size_t n)
1073 {
> 1074 int rc = kstrtoul(buf, 0, &swsusp_resume_block);
1075
1076 if (rc)
1077 return rc;
1078
1079 return n;
1080 }
1081
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 25524 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-03-28 14:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-27 20:58 [PATCH v2 1/2] power/hibernate: Make passing hibernate offsets more friendly Mario Limonciello
2018-03-27 20:58 ` [PATCH v2 2/2] power/hibernate: Change message when writing to /sys/power/resume Mario Limonciello
2018-03-28 14:01 ` [PATCH v2 1/2] power/hibernate: Make passing hibernate offsets more friendly kbuild test robot
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).