On 06/11/2014 03:23 AM, Li Zhong wrote:
> vmemmap_populated() checks whether the [start, start + page_size) has valid
> pfn numbers, to know whether a vmemmap mapping has been created that includes
> this range.
> 
> Some range before end might not be checked by this loop:
>   sec11start......start11..sec11end/sec12start..end....start12..sec12end
> as the above, for start11(section 11), it checks [sec11start, sec11end), and
> loop ends as the next start(start12) is bigger than end. However,
> [sec11end/sec12start, end) is not checked here.
> 
> So before the loop, adjust the start to be the start of the section, so we 
> don't miss ranges like the above.
> 
> After we adjust start to be the start of the section, it also means it's
> aligned with vmemmap as of the sizeof struct page, so we could use
> page_to_pfn directly in the loop.
> 
> Signed-off-by: Li Zhong <zh...@linux.vnet.ibm.com>
> Cc: Nathan Fontenot <nf...@linux.vnet.ibm.com>

Acked-by: Nathan Fontenot <nf...@linux.vnet.ibm.com>

> ---
>  arch/powerpc/mm/init_64.c |    3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/mm/init_64.c b/arch/powerpc/mm/init_64.c
> index 4963790..253b4b9 100644
> --- a/arch/powerpc/mm/init_64.c
> +++ b/arch/powerpc/mm/init_64.c
> @@ -175,9 +175,10 @@ static unsigned long __meminit 
> vmemmap_section_start(unsigned long page)
>  static int __meminit vmemmap_populated(unsigned long start, int page_size)
>  {
>       unsigned long end = start + page_size;
> +     start = (unsigned long)(pfn_to_page(vmemmap_section_start(start)));
>  
>       for (; start < end; start += (PAGES_PER_SECTION * sizeof(struct page)))
> -             if (pfn_valid(vmemmap_section_start(start)))
> +             if (pfn_valid(page_to_pfn((struct page *)start)))
>                       return 1;
>  
>       return 0;
> 

_______________________________________________
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Reply via email to