RE: [hugepage] Fix unmap_and_free_vma backout path

Adam Litke
2006-11-13T22:07:35Z

On Mon, 2006-11-13 at 20:41 +0000, Hugh Dickins wrote:
> On Mon, 13 Nov 2006, Adam Litke wrote:
>
> > Looks good to me, notwithstanding the nano-nit below.
> >
> > On Mon, 2006-11-13 at 17:00 +0000, Hugh Dickins wrote:
> > > + /*
> > > + * vma alignment has already been checked by prepare_hugepage_range.
> > > + * If you add any error returns here, do so after setting VM_HUGETLB,
> > > + * so is_vm_huge_tlb_page tests below unmap_region go the right way
> > > + * when do_mmap_pgoff unwinds (may be important on powerpc and ia64).
> > > + */
> >
> > Sorry. This is hardly worth it, but the function referred to by this
> > comment is actually is_vm_hugetlb_page() :-/
>
> Indeed, thanks!
>
> [PATCH] hugetlb: prepare_hugepage_range check offset too
>
> prepare_hugepage_range should check file offset alignment when it checks
> virtual address and length, to stop MAP_FIXED with a bad huge offset from
> unmapping before it fails further down. PowerPC should apply the same
> prepare_hugepage_range alignment checks as ia64 and all the others do.
>
> Then none of the alignment checks in hugetlbfs_file_mmap are required
> (nor is the check for too small a mapping); but even so, move up setting
> of VM_HUGETLB and add a comment to warn of what David Gibson discovered -
> if hugetlbfs_file_mmap fails before setting it, do_mmap_pgoff's unmap_region
> when unwinding from error will go the non-huge way, which may cause bad
> behaviour on architectures (powerpc and ia64) which segregate their huge
> mappings into a separate region of the address space.
>
> Signed-off-by: Hugh Dickins <hugh@veritas.com>
Acked-by: Adam Litke <agl@us.ibm.com>
--
Adam Litke - (agl at us.ibm.com)
IBM Linux Technology Center