Re: [PATCH]Fix usemap for DISCONTIG/FLATMEM with not-aligned zoneinitilaization.

From: Dave Hansen
Date: Fri Apr 18 2008 - 13:42:41 EST



On Fri, 2008-04-18 at 17:15 +0100, Mel Gorman wrote:
> -void __meminit memmap_init_zone(unsigned long size, int nid, unsigned long zone,
> +void __meminit memmap_init_zone(unsigned long size, int nid, struct zone *zone,
> unsigned long start_pfn, enum memmap_context context)
> {
> struct page *page;
> unsigned long end_pfn = start_pfn + size;
> unsigned long pfn;
> + int zoneidx = zone_idx(zone);
> +
> + /*
> + * Sanity check the values passed in. It is possible an architecture
> + * calling this function directly will use values outside of the memory
> + * they registered
> + */
> + if (start_pfn < zone->zone_start_pfn) {
> + WARN_ON_ONCE(1);
> + start_pfn = zone->zone_start_pfn;
> + }
> +
> + if (size > zone->spanned_pages) {
> + WARN_ON_ONCE(1);
> + size = zone->spanned_pages;
> + }

I was thinking about whether size needs to be modified in there like
this:

if (start_pfn < zone->zone_start_pfn) {
WARN_ON_ONCE(1);
+ size -= zone->zone_start_pfn - start_pfn;
start_pfn = zone->zone_start_pfn;
}

and I realized that your modification of size actually happens after its
only use in the function (to calculate end_pfn). Seems like we either
be error-checking end_pfn or delaying its calculation until after 'size'
is fixed.

-- Dave

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/