PM: HIBERNATION: skip the swap size check if the snapshot image size is anticipative
Subsystems (3)
PATCH 1/1 PM: HIBERNATION: skip the swap size check if the snapshot image size is anticipative
From: Barry Song <[email protected]>
Current swsusp requires swap partitions even larger than real saved pages due to the worst compress ratio:
but for an embedded system, which has limited storage space, then it might can't give the big size partition to save snapshot.
In the another way, some embedded systems can definitely know the most size needed for snapshot since they run some specific application lists. So this patch provides the possibility for bootloader to tell kernel even the system has a little snapshot partition, but it is still enough. For example, if the system need to save 120MB memory, origin swsusp will require a 130MB partition to save snapshot. but if users know 30MB is enough for them( compressed image will be less than 30MB), they just make a 30MB partition.
---
this is another patch after I provide resumewait/resumedelay kernel params to make swsusp support embedded systems better.
This patch is tested on CSR SiRFprimaII platform.
Documentation/kernel-parameters.txt | 7 +++++++ kernel/power/swap.c | 13 +++++++++++++ 2 files changed, 20 insertions(+), 0 deletions(-)
Documentation/kernel-parameters.txt +7 -0
@@ -2277,6 +2277,13 @@ bytes respectively. Such letter suffixes can also be entirely omitted. in <PAGE_SIZE> units (needed only for swap files). See Documentation/power/swsusp-and-swap-files.txt + swapenough [SWSUSP] + Tell kernel the swap partition size is enough and let kernel + skip checking whether the swap partition has enough size to + save snapshot. + It is used for embedded systems, typically using NAND and SD + card, which have not large space. + resumedelay= [HIBERNATION] Delay (in seconds) to pause before attempting to read the resume files
kernel/power/swap.c +13 -0
@@ -36,6 +36,8 @@#define HIBERNATE_SIG "S1SUSPEND" +static int swapenough; +/* * The swap map is a data structure used for keeping track of each page * written to a swap partition. It consists of many swap_map_page
@@ -772,6 +774,9 @@ static int enough_swap(unsigned int nr_pages, unsigned int flags)unsigned int free_swap =count_swap_pages (root_swap,1 );unsigned int required; +if (swapenough) +return 1 ; +pr_debug ("PM: Free swap pages: %u\n" , free_swap); required = PAGES_FOR_IO + ((flags & SF_NOCOMPRESS_MODE) ?
@@ -1449,3 +1454,11 @@ static int swsusp_header_init(void) }core_initcall (swsusp_header_init); + +static int __init swapenough_setup (char *str) +{ + swapenough =1 ; +return 1 ; +} + +__setup ("swapenough" , swapenough_setup);
Signature · 6 lines
1.7.1 Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our blog at www.csr.com/blog
Quoted 14 lines · Barry Song
From: Barry Song <[email protected]>
Current swsusp requires swap partitions even larger than real saved pages due to the worst compress ratio:
but for an embedded system, which has limited storage space, then it might can't give the big size partition to save snapshot.
In the another way, some embedded systems can definitely know the most size needed for snapshot since they run some specific application lists. So this patch provides the possibility for bootloader to tell kernel even the system has a little snapshot partition, but it is still enough. For example, if the system need to save 120MB memory, origin swsusp will require a 130MB partition to save snapshot. but if users know 30MB is enough for them( compressed image will be less than 30MB), they just make a 30MB partition.
Quoted 2 lines
Signed-off-by Barry Song <[email protected]>Cc Xiangzhen Ye <[email protected]>
I'm considering this as 3.3 material, so I'll take care of it after the current merge window closes.
Thanks,
Rafael
Quoted 63 lines
---
this is another patch after I provide resumewait/resumedelay kernel params to make swsusp support embedded systems better.
This patch is tested on CSR SiRFprimaII platform.Documentation/kernel-parameters.txt | 7 +++++++ kernel/power/swap.c | 13 +++++++++++++ 2 files changed, 20 insertions(+), 0 deletions(-)Documentation/kernel-parameters.txt +7
-0@@ -2277,6 +2277,13 @@ bytes respectively. Such letter suffixes can also be entirely omitted. in <PAGE_SIZE> units (needed only for swap files). See Documentation/power/swsusp-and-swap-files.txt + swapenough [SWSUSP] + Tell kernel the swap partition size is enough and let kernel + skip checking whether the swap partition has enough size to + save snapshot. + It is used for embedded systems, typically using NAND and SD + card, which have not large space. + resumedelay= [HIBERNATION] Delay (in seconds) to pause before attempting to read the resume fileskernel/power/swap.c +13
-0@@ -36,6 +36,8 @@#define HIBERNATE_SIG "S1SUSPEND" +static int swapenough; +/* * The swap map is a data structure used for keeping track of each page * written to a swap partition. It consists of many swap_map_page @@ -772,6 +774,9 @@ static int enough_swap(unsigned int nr_pages, unsigned int flags)unsigned int free_swap =count_swap_pages (root_swap,1 );unsigned int required; +if (swapenough) +return 1 ; +pr_debug ("PM: Free swap pages: %u\n" , free_swap); required = PAGES_FOR_IO + ((flags & SF_NOCOMPRESS_MODE) ?@@ -1449,3 +1454,11 @@ static int swsusp_header_init(void) }core_initcall (swsusp_header_init); + +static int __init swapenough_setup (char *str) +{ + swapenough =1 ; +return 1 ; +} + +__setup ("swapenough" , swapenough_setup);
2011/11/5 Rafael J. Wysocki <[email protected]>:
Quoted 15 lines · Barry Song
Quoted 14 lines
From: Barry Song <[email protected]>
Current swsusp requires swap partitions even larger than real saved pages due to the worst compress ratio:
but for an embedded system, which has limited storage space, then it might can't give the big size partition to save snapshot.
In the another way, some embedded systems can definitely know the most size needed for snapshot since they run some specific application lists. So this patch provides the possibility for bootloader to tell kernel even the system has a little snapshot partition, but it is still enough. For example, if the system need to save 120MB memory, origin swsusp will require a 130MB partition to save snapshot. but if users know 30MB is enough for them( compressed image will be less than 30MB), they just make a 30MB partition.
Quoted 6 lines
Quoted 2 lines
Signed-off-by Barry Song <[email protected]>Cc Xiangzhen Ye <[email protected]>I'm considering this as 3.3 material, so I'll take care of it after the current merge window closes.
ok. thanks. the idea is making swsusp support embedded systems with limited resources better.
we can get into details after the current merge window.
Quoted 57 lines
Thanks,
RafaelQuoted 53 lines
---
?this is another patch after I provide resumewait/resumedelay kernel params ?to make swsusp support embedded systems better.
?This patch is tested on CSR SiRFprimaII platform.?Documentation/kernel-parameters.txt | ? ?7 +++++++ ?kernel/power/swap.c ? ? ? ? ? ? ? ? | ? 13 +++++++++++++ ?2 files changed, 20 insertions(+), 0 deletions(-)
Documentation/kernel-parameters.txt +0
-0@@ -2277,6 +2277,13 @@ bytes respectively. Such letter suffixes can also be entirely omitted.? ? ? ? ? ? ? ? ? ? ? in <
PAGE_SIZE> units (needed only for swap files). ? ? ? ? ? ? ? ? ? ? ? See ?Documentation/power/swsusp-and-swap-files.txt+ ? ? swapenough ? ? ?[SWSUSP]
+ ? ? ? ? ? ? ? ? ? ? Tell kernel the swap partition size is enough and let kernel
+ ? ? ? ? ? ? ? ? ? ? skip checking whether the swap partition has enough size to
+ ? ? ? ? ? ? ? ? ? ? save snapshot.
+ ? ? ? ? ? ? ? ? ? ? It is used for embedded systems, typically using NAND and SD
+ ? ? ? ? ? ? ? ? ? ? card, which have not large space.
+
? ? ? resumedelay= ? ?[HIBERNATION] Delay (in seconds) to pause before attempting to ? ? ? ? ? ? ? ? ? ? ? read the resume fileskernel/power/swap.c +0
-0@@ -36,6 +36,8 @@?#define
HIBERNATE_SIG? ? ? ?"S1SUSPEND"kernel/power/swap.c +2
-0+static int swapenough; +?/*
? * ? The swap map is a data structure used for keeping track of each page ? * ? written to a swap partition. ?It consists of manyswap_map_pagekernel/power/swap.c +3
-0@@ -772,6 +774,9 @@ static int enough_swap(unsigned int nr_pages, unsigned int flags) ? ? ? unsigned int free_swap = count_swap_pages(root_swap, 1); ? ? ? unsigned int required; + ? ? if (swapenough) + ? ? ? ? ? ? return 1; + ? ? ? pr_debug("PM: Free swap pages: %u\n", free_swap);? ? ? required =
PAGES_FOR_IO+ ((flags &SF_NOCOMPRESS_MODE) ?kernel/power/swap.c +0
-0@@ -1449,3 +1454,11 @@ static int swsusp_header_init(void) ?}
Quoted 10 lines
kernel/power/swap.c static int swsusp_header_init(void) · line 1464
Quoted 10 lines
kernel/power/swap.c +8
-0?core_initcall(swsusp_header_init); + +static int __init swapenough_setup (char *str) +{ + ? ? swapenough = 1; + ? ? return 1; +} + +__setup ("swapenough" , swapenough_setup);
-barry
Hi!
Quoted 14 lines
From: Barry Song <[email protected]>
Current swsusp requires swap partitions even larger than real saved pages due to the worst compress ratio:
but for an embedded system, which has limited storage space, then it might can't give the big size partition to save snapshot.
In the another way, some embedded systems can definitely know the most size needed for snapshot since they run some specific application lists. So this patch provides the possibility for bootloader to tell kernel even the system has a little snapshot partition, but it is still enough. For example, if the system need to save 120MB memory, origin swsusp will require a 130MB partition to save snapshot. but if users know 30MB is enough for them( compressed image will be less than 30MB), they just make a 30MB partition.
Would it be better to have /sys/power/... entry which would allow configuring expected compression ratio at runtime?
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Hi!
Quoted 14 lines
From: Barry Song <[email protected]>
Current swsusp requires swap partitions even larger than real saved pages due to the worst compress ratio:
but for an embedded system, which has limited storage space, then it might can't give the big size partition to save snapshot.
In the another way, some embedded systems can definitely know the most size needed for snapshot since they run some specific application lists. So this patch provides the possibility for bootloader to tell kernel even the system has a little snapshot partition, but it is still enough. For example, if the system need to save 120MB memory, origin swsusp will require a 130MB partition to save snapshot. but if users know 30MB is enough for them( compressed image will be less than 30MB), they just make a 30MB partition.
Would it be better to have /sys/power/... entry which would allow configuring expected compression ratio at runtime?
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
2011/11/6 Pavel Machek <[email protected]>:
Quoted 17 lines
Hi!
Quoted 14 lines
From: Barry Song <[email protected]>
Current swsusp requires swap partitions even larger than real saved pages due to the worst compress ratio:
but for an embedded system, which has limited storage space, then it might can't give the big size partition to save snapshot.
In the another way, some embedded systems can definitely know the most size needed for snapshot since they run some specific application lists. So this patch provides the possibility for bootloader to tell kernel even the system has a little snapshot partition, but it is still enough. For example, if the system need to save 120MB memory, origin swsusp will require a 130MB partition to save snapshot. but if users know 30MB is enough for them( compressed image will be less than 30MB), they just make a 30MB partition.
Quoted 2 lines
Would it be better to have
/sys/power/... entry which would allow configuring expected compression ratio at runtime?
i think it is better to have a sys node than add another kernel param. but the point is i only care about the final image size but not compression ratio. i don't care how well lzo will do for me since i only have limited disk space and know how many pages want to be saved. there has been a image_size node, will we have a expected_image_size node?
Quoted 3 lines
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Pavel
--
Thanks
barry
2011/11/6 Barry Song <[email protected]>:
Quoted 18 lines
2011/11/6 Pavel Machek <[email protected]>:
Quoted 17 lines
Hi!
Quoted 14 lines
From: Barry Song <[email protected]>
Current swsusp requires swap partitions even larger than real saved pages due to the worst compress ratio:
but for an embedded system, which has limited storage space, then it might can't give the big size partition to save snapshot.
In the another way, some embedded systems can definitely know the most size needed for snapshot since they run some specific application lists. So this patch provides the possibility for bootloader to tell kernel even the system has a little snapshot partition, but it is still enough. For example, if the system need to save 120MB memory, origin swsusp will require a 130MB partition to save snapshot. but if users know 30MB is enough for them( compressed image will be less than 30MB), they just make a 30MB partition.
Quoted 8 lines
Quoted 2 lines
Would it be better to have
/sys/power/... entry which would allow configuring expected compression ratio at runtime?i think it is better to have a sys node than add another kernel param. but the point is i only care about the final image size but not compression ratio. i don't care how well lzo will do for me since i only have limited disk space and know how many pages want to be saved. there has been a
image_sizenode, will we have aexpected_image_sizenode?
or will we have just a node named /sys/power/check_size, if 1(default), check, otherwise(0 set by users), skip checking?
Quoted 1 line
Quoted 1 line
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Pavel
-barry
Quoted 22 lines · Barry Song
2011/11/6 Barry Song <[email protected]>:
Quoted 21 lines
2011/11/6 Pavel Machek <[email protected]>:
Quoted 19 lines
Hi!
Quoted 14 lines
From: Barry Song <[email protected]>
Current swsusp requires swap partitions even larger than real saved pages due to the worst compress ratio:
but for an embedded system, which has limited storage space, then it might can't give the big size partition to save snapshot.
In the another way, some embedded systems can definitely know the most size needed for snapshot since they run some specific application lists. So this patch provides the possibility for bootloader to tell kernel even the system has a little snapshot partition, but it is still enough. For example, if the system need to save 120MB memory, origin swsusp will require a 130MB partition to save snapshot. but if users know 30MB is enough for them( compressed image will be less than 30MB), they just make a 30MB partition.Would it be better to have
/sys/power/... entry which would allow configuring expected compression ratio at runtime?
Quoted 8 lines
Quoted 5 lines
i think it is better to have a sys node than add another kernel param. but the point is i only care about the final image size but not compression ratio. i don't care how well lzo will do for me since i only have limited disk space and know how many pages want to be saved. there has been a
image_sizenode, will we have aexpected_image_sizenode?or will we have just a node named
/sys/power/check_size, if 1(default), check, otherwise(0 set by users), skip checking?
Or just avoid the check at all, since it no longer makes sense with compression?
What is the failure scenario? Hibernation still fails, but it takes longer to fail?
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Quoted 22 lines · Barry Song
2011/11/6 Barry Song <[email protected]>:
Quoted 21 lines
2011/11/6 Pavel Machek <[email protected]>:
Quoted 19 lines
Hi!
Quoted 14 lines
From: Barry Song <[email protected]>
Current swsusp requires swap partitions even larger than real saved pages due to the worst compress ratio:
but for an embedded system, which has limited storage space, then it might can't give the big size partition to save snapshot.
In the another way, some embedded systems can definitely know the most size needed for snapshot since they run some specific application lists. So this patch provides the possibility for bootloader to tell kernel even the system has a little snapshot partition, but it is still enough. For example, if the system need to save 120MB memory, origin swsusp will require a 130MB partition to save snapshot. but if users know 30MB is enough for them( compressed image will be less than 30MB), they just make a 30MB partition.Would it be better to have
/sys/power/... entry which would allow configuring expected compression ratio at runtime?
Quoted 8 lines
Quoted 5 lines
i think it is better to have a sys node than add another kernel param. but the point is i only care about the final image size but not compression ratio. i don't care how well lzo will do for me since i only have limited disk space and know how many pages want to be saved. there has been a
image_sizenode, will we have aexpected_image_sizenode?or will we have just a node named
/sys/power/check_size, if 1(default), check, otherwise(0 set by users), skip checking?
Or just avoid the check at all, since it no longer makes sense with compression?
What is the failure scenario? Hibernation still fails, but it takes longer to fail?
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
2011/11/19 Pavel Machek <[email protected]>:
Quoted 29 lines · Barry Song
Quoted 28 lines
2011/11/6 Barry Song <[email protected]>:
Quoted 26 lines
2011/11/6 Pavel Machek <[email protected]>:
Quoted 17 lines
Hi!
Quoted 14 lines
From: Barry Song <[email protected]>
Current swsusp requires swap partitions even larger than real saved pages due to the worst compress ratio:
but for an embedded system, which has limited storage space, then it might can't give the big size partition to save snapshot.
In the another way, some embedded systems can definitely know the most size needed for snapshot since they run some specific application lists. So this patch provides the possibility for bootloader to tell kernel even the system has a little snapshot partition, but it is still enough. For example, if the system need to save 120MB memory, origin swsusp will require a 130MB partition to save snapshot. but if users know 30MB is enough for them( compressed image will be less than 30MB), they just make a 30MB partition.Quoted 2 lines
Would it be better to have
/sys/power/... entry which would allow configuring expected compression ratio at runtime?i think it is better to have a sys node than add another kernel param. but the point is i only care about the final image size but not compression ratio. i don't care how well lzo will do for me since i only have limited disk space and know how many pages want to be saved. there has been a
image_sizenode, will we have aexpected_image_sizenode?
Quoted 5 lines
Quoted 2 lines
or will we have just a node named
/sys/power/check_size, if 1(default), check, otherwise(0 set by users), skip checking?Or just avoid the check at all, since it no longer makes sense with compression?
current early check just makes the failure happen earier. in the check, it requires more space than uncompressed data due to the worst compress ratio. some users might have big space and complex scenerios, they might want the earlier check. but it is really a big waste considering text, data sections of programs are actually data which can be compressed in a big ratio.
but for some other embedded system users, they have limited storage and known sw list, then they know their little space is enough for compressed image.
i think we can make the function as a option for users. provide a node /sys/power/check_swap_size, if users set it to 0, ignore the check. otherwise, check by the worst compress ratio.
Quoted 3 lines
What is the failure scenario? Hibernation still fails, but it takes longer to fail?
it will fail some later. but i still expect the system can restore to be normal even it fails in the saving stage. i can give a test.
Quoted 3 lines
? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?Pavel --
-barry