]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
PM / Hibernate: Make default image size depend on total RAM size
authorRafael J. Wysocki <rjw@sisk.pl>
Mon, 20 Sep 2010 17:44:56 +0000 (19:44 +0200)
committerRafael J. Wysocki <rjw@sisk.pl>
Sat, 16 Oct 2010 23:57:43 +0000 (01:57 +0200)
The default hibernation image size is currently hard coded and euqal
to 500 MB, which is not a reasonable default on many contemporary
systems.  Make it equal 2/5 of the total RAM size (this is slightly
below the maximum, i.e. 1/2 of the total RAM size, and seems to be
generally suitable).

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Tested-by: M. Vefa Bicakci <bicave@superonline.com>
Documentation/power/interface.txt
kernel/power/main.c
kernel/power/power.h
kernel/power/snapshot.c

index e67211fe0ee2f432044efe62e8909702f0b46fc9..c537834af00566e0fee8058a9643803d2c2b3954 100644 (file)
@@ -57,7 +57,7 @@ smallest image possible.  In particular, if "0" is written to this file, the
 suspend image will be as small as possible.
 
 Reading from this file will display the current image size limit, which
-is set to 500 MB by default.
+is set to 2/5 of available RAM by default.
 
 /sys/power/pm_trace controls the code which saves the last PM event point in
 the RTC across reboots, so that you can debug a machine that just hangs
index 0a28d4db35972d21cba44b276f1db88ce665cc08..f06ad6eff37ae8146e2bf548bdafe0796dc7696a 100644 (file)
@@ -321,6 +321,7 @@ static int __init pm_init(void)
        int error = pm_start_workqueue();
        if (error)
                return error;
+       hibernate_image_size_init();
        power_kobj = kobject_create_and_add("power", NULL);
        if (!power_kobj)
                return -ENOMEM;
index c7e42e47eb0b1c32168f340387c3ce58d6c84d4d..03634be55f62aabb407b8797d6a5a74ca6feef96 100644 (file)
@@ -14,6 +14,9 @@ struct swsusp_info {
 } __attribute__((aligned(PAGE_SIZE)));
 
 #ifdef CONFIG_HIBERNATION
+/* kernel/power/snapshot.c */
+extern void __init hibernate_image_size_init(void);
+
 #ifdef CONFIG_ARCH_HIBERNATION_HEADER
 /* Maximum size of architecture specific data in a hibernation header */
 #define MAX_ARCH_HEADER_SIZE   (sizeof(struct new_utsname) + 4)
@@ -49,7 +52,11 @@ static inline char *check_image_kernel(struct swsusp_info *info)
 extern int hibernation_snapshot(int platform_mode);
 extern int hibernation_restore(int platform_mode);
 extern int hibernation_platform_enter(void);
-#endif
+
+#else /* !CONFIG_HIBERNATION */
+
+static inline void hibernate_image_size_init(void) {}
+#endif /* !CONFIG_HIBERNATION */
 
 extern int pfn_is_nosave(unsigned long);
 
index d9191b40cf6e940b4c4c1845a35c41d439addb59..ac7eb109f19635d11930a9cef03ed4cd352cc235 100644 (file)
@@ -46,7 +46,12 @@ static void swsusp_unset_page_forbidden(struct page *);
  * size will not exceed N bytes, but if that is impossible, it will
  * try to create the smallest image possible.
  */
-unsigned long image_size = 500 * 1024 * 1024;
+unsigned long image_size;
+
+void __init hibernate_image_size_init(void)
+{
+       image_size = ((totalram_pages * 2) / 5) * PAGE_SIZE;
+}
 
 /* List of PBEs needed for restoring the pages that were allocated before
  * the suspend and included in the suspend image, but have also been