Re: [PATCH 1/3] swsusp: Fix mark_free_pages

Dave Hansen
2006-08-02T19:51:36Z

On Wed, 2006-08-02 at 18:48 +0200, Rafael J. Wysocki wrote:
> + max_zone_pfn = zone->zone_start_pfn + zone->spanned_pages;
> + for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++) {
> + struct page *page = pfn_to_page(pfn);
> +
> + if (!PageNosave(page))
> + ClearPageNosaveFree(page);
> + }

This is certainly not the only place in swsusp where there is a bug like
this, but it is not correct to assume that each page inside of a zone is
valid. With sparsemem, you need to do pfn_valid() on each pfn before
calling pfn_to_page().

Something like:

max_zone_pfn = zone->zone_start_pfn + zone->spanned_pages;
for (pfn = zone->zone_start_pfn; pfn < max_zone_pfn; pfn++) {
struct page *page;
if (!pfn_valid(pfn))
continue;

page = pfn_to_page(pfn);
if (!PageNosave(page))
ClearPageNosaveFree(page);
}

-- Dave