[Suspend2][ 07/20] [Suspend2] Display image vital statistics.

Nigel Cunningham
2006-06-26T23:34:15Z

Display the vital statistics of the image.

Signed-off-by: Nigel Cunningham <nigel@suspend2.net>

kernel/power/prepare_image.c | 36 ++++++++++++++++++++++++++++++++++++
1 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/kernel/power/prepare_image.c b/kernel/power/prepare_image.c
index 5070735..e54865a 100644
--- a/kernel/power/prepare_image.c
+++ b/kernel/power/prepare_image.c
@@ -133,3 +133,39 @@ static int header_storage_needed(void)
return ((int) ((bytes + (int) PAGE_SIZE - 1) >> PAGE_SHIFT));
}

+static void display_stats(int always, int sub_extra_pd1_allow)
+{
+ char buffer[255];
+ snprintf(buffer, 254,
+ "Free:%d(%d). Sets:%ld(%ld),%ld(%ld). Header:%d. Nosave:%d-%d=%d. Storage:%lu/%lu(%lu). Needed:%ld|%ld|%ld.\n",
+
+ /* Free */
+ nr_free_pages(),
+ nr_free_pages() - nr_free_highpages(),
+
+ /* Sets */
+ pagedir1.pageset_size, pageset1_sizelow,
+ pagedir2.pageset_size, pageset2_sizelow,
+
+ /* Header */
+ header_storage_needed(),
+
+ /* Nosave */
+ num_nosave, extra_pagedir_pages_allocated,
+ num_nosave - extra_pagedir_pages_allocated,
+
+ /* Storage - converted to pages for comparison */
+ storage_allocated,
+ storage_needed(1, sub_extra_pd1_allow),
+ storage_available,
+
+ /* Needed */
+ ram_to_suspend() - nr_free_pages() - nr_free_highpages(),
+ storage_needed(1, sub_extra_pd1_allow) - storage_available,
+ (image_size_limit > 0) ? (storage_needed(1, sub_extra_pd1_allow) - (image_size_limit << 8)) : 0);
+ if (always)
+ printk(buffer);
+ else
+ suspend_message(SUSPEND_EAT_MEMORY, SUSPEND_MEDIUM, 1, buffer);