lkml.org 
[lkml]   [2006]   [Jun]   [26]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[Suspend2][ 09/20] [Suspend2] Get size of a free region.
Date
Get the size of a range of free pages beginning at the given page, and
finishing at the end of the zone in which the page is found if not before.
The page given may not itself be free, in which case the return value will
be zero.

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

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

diff --git a/kernel/power/prepare_image.c b/kernel/power/prepare_image.c
index bf38334..0030661 100644
--- a/kernel/power/prepare_image.c
+++ b/kernel/power/prepare_image.c
@@ -222,3 +222,21 @@ static void generate_free_page_map(void)
}
}

+/* size_of_free_region
+ *
+ * Description: Return the number of pages that are free, beginning with and
+ * including this one.
+ */
+static int size_of_free_region(struct page *page)
+{
+ struct zone *zone = page_zone(page);
+ struct page *posn = page, *last_in_zone =
+ pfn_to_page(zone->zone_start_pfn) + zone->spanned_pages - 1;
+
+ while (posn < last_in_zone && !PageInUse(posn)) {
+ BUG_ON(PagePageset2(posn));
+ posn++;
+ }
+ return (posn - page);
+}
+
--
Nigel Cunningham nigel at suspend2 dot net
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2006-06-27 01:29    [W:0.128 / U:0.152 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site