Messages in this thread Patch in this message | | | From | Nigel Cunningham <> | Subject | [Suspend2][ 08/20] [Suspend2] Generate free page bitmap. | Date | Tue, 27 Jun 2006 08:35:14 +1000 |
| |
Generate a bitmap of pages that are free (including in pcp lists).
Signed-off-by: Nigel Cunningham <nigel@suspend2.net>
kernel/power/prepare_image.c | 53 ++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 53 insertions(+), 0 deletions(-)
diff --git a/kernel/power/prepare_image.c b/kernel/power/prepare_image.c index e54865a..bf38334 100644 --- a/kernel/power/prepare_image.c +++ b/kernel/power/prepare_image.c @@ -169,3 +169,56 @@ static void display_stats(int always, in suspend_message(SUSPEND_EAT_MEMORY, SUSPEND_MEDIUM, 1, buffer); } +/* generate_free_page_map + * + * Description: This routine generates a bitmap of free pages from the + * lists used by the memory manager. We then use the bitmap + * to quickly calculate which pages to save and in which + * pagesets. + */ +static void generate_free_page_map(void) +{ + int i, order, loop, cpu; + struct page *page; + unsigned long flags; + struct zone *zone; + struct per_cpu_pageset *pset; + + for_each_zone(zone) { + if (!zone->present_pages) + continue; + for(i=0; i < zone->spanned_pages; i++) + SetPageInUse(pfn_to_page(zone->zone_start_pfn + i)); + } + + for_each_zone(zone) { + if (!zone->present_pages) + continue; + spin_lock_irqsave(&zone->lock, flags); + for (order = MAX_ORDER - 1; order >= 0; --order) { + list_for_each_entry(page, &zone->free_area[order].free_list, lru) + for(loop=0; loop < (1 << order); loop++) + ClearPageInUse(page+loop); + } + + + for (cpu = 0; cpu < NR_CPUS; cpu++) { + if (!cpu_possible(cpu)) + continue; + + pset = zone_pcp(zone, cpu); + + for (i = 0; i < ARRAY_SIZE(pset->pcp); i++) { + struct per_cpu_pages *pcp; + struct page *page; + + pcp = &pset->pcp[i]; + list_for_each_entry(page, &pcp->list, lru) + ClearPageInUse(page); + } + } + + spin_unlock_irqrestore(&zone->lock, flags); + } +} + -- 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/
| |