Skip to content

Commit 853609b

Browse files
rjwysockiLinus Torvalds
authored andcommitted
[PATCH] swsusp: use bytes as image size units
Make swsusp use bytes as the image size units, which is needed for future compatibility. Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl> Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent e8730ea commit 853609b

5 files changed

Lines changed: 11 additions & 11 deletions

File tree

‎Documentation/power/interface.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ it.
4444
/sys/power/image_size controls the size of the image created by
4545
the suspend-to-disk mechanism. It can be written a string
4646
representing a non-negative integer that will be used as an upper
47-
limit of the image size, in megabytes. The suspend-to-disk mechanism will
47+
limit of the image size, in bytes. The suspend-to-disk mechanism will
4848
do its best to ensure the image size will not exceed that number. However,
4949
if this turns out to be impossible, it will try to suspend anyway using the
5050
smallest image possible. In particular, if "0" is written to this file, the

‎Documentation/power/swsusp.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ echo shutdown > /sys/power/disk; echo disk > /sys/power/state
2727

2828
echo platform > /sys/power/disk; echo disk > /sys/power/state
2929

30-
If you want to limit the suspend image size to N megabytes, do
30+
If you want to limit the suspend image size to N bytes, do
3131

3232
echo N > /sys/power/image_size
3333

‎kernel/power/disk.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,14 +367,14 @@ power_attr(resume);
367367

368368
static ssize_t image_size_show(struct subsystem * subsys, char *buf)
369369
{
370-
return sprintf(buf, "%u\n", image_size);
370+
return sprintf(buf, "%lu\n", image_size);
371371
}
372372

373373
static ssize_t image_size_store(struct subsystem * subsys, const char * buf, size_t n)
374374
{
375-
unsigned int size;
375+
unsigned long size;
376376

377-
if (sscanf(buf, "%u", &size) == 1) {
377+
if (sscanf(buf, "%lu", &size) == 1) {
378378
image_size = size;
379379
return n;
380380
}

‎kernel/power/power.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ extern const void __nosave_begin, __nosave_end;
5151
extern unsigned int nr_copy_pages;
5252
extern struct pbe *pagedir_nosave;
5353

54-
/* Preferred image size in MB (default 500) */
55-
extern unsigned int image_size;
54+
/* Preferred image size in bytes (default 500 MB) */
55+
extern unsigned long image_size;
5656

5757
extern asmlinkage int swsusp_arch_suspend(void);
5858
extern asmlinkage int swsusp_arch_resume(void);

‎kernel/power/swsusp.c‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@
7070
#include "power.h"
7171

7272
/*
73-
* Preferred image size in MB (tunable via /sys/power/image_size).
73+
* Preferred image size in bytes (tunable via /sys/power/image_size).
7474
* When it is set to N, swsusp will do its best to ensure the image
75-
* size will not exceed N MB, but if that is impossible, it will
75+
* size will not exceed N bytes, but if that is impossible, it will
7676
* try to create the smallest image possible.
7777
*/
78-
unsigned int image_size = 500;
78+
unsigned long image_size = 500 * 1024 * 1024;
7979

8080
#ifdef CONFIG_HIGHMEM
8181
unsigned int count_highmem_pages(void);
@@ -590,7 +590,7 @@ int swsusp_shrink_memory(void)
590590
if (!tmp)
591591
return -ENOMEM;
592592
pages += tmp;
593-
} else if (size > (image_size * 1024 * 1024) / PAGE_SIZE) {
593+
} else if (size > image_size / PAGE_SIZE) {
594594
tmp = shrink_all_memory(SHRINK_BITE);
595595
pages += tmp;
596596
}

0 commit comments

Comments
 (0)