Re: [PATCH] hibernate / memory hotplug: always usefor_each_populated_zone()

From: KAMEZAWA Hiroyuki
Date: Tue Jul 21 2009 - 20:40:44 EST


On Wed, 22 Jul 2009 09:25:35 +0900
KAMEZAWA Hiroyuki <kamezawa.hiroyu@xxxxxxxxxxxxxx> wrote:

> See ia64's ia64_pfn_valid(). It uses get_user() very effectively.
> (I think this cost cost is small in any arch...)
>
> 523 ia64_pfn_valid (unsigned long pfn)
> 524 {
> 525 char byte;
> 526 struct page *pg = pfn_to_page(pfn);
> 527
> 528 return (__get_user(byte, (char __user *) pg) == 0)
> 529 && ((((u64)pg & PAGE_MASK) == (((u64)(pg + 1) - 1) & PAGE_MASK))
> 530 || (__get_user(byte, (char __user *) (pg + 1) - 1) == 0));
> 531 }
>
Just an explanation. This code is for checking "there is memmap or not" for
CONFIG_VIRTUAL_MEMMAP+CONFIG_DISCONTIGMEM, which allocates memmap in virtually
contiguous area. Because ia64 tends to have very sparse memory map,
memmap cannot be allocated in continuous area and memmap has holes.

This code checkes first byte and last byte of "struct page" is valid.

Thanks,
-Kame

--
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/