Re: [hugepage] Fix unmap_and_free_vma backout path

'David Gibson'
2006-11-13T23:53:36Z

On Mon, Nov 13, 2006 at 08:41:49PM +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.

Looks pretty good. There's still a certain amount of wierdness on
powerpc: we can back out after (irreversibly) switching chunks of the
address space over to use for hugepages. I'll try to fix that up
later, but in any case it's certainly more comprehensive than my
original patch.

Acked-by: David Gibson <david@gibson.dropbear.id.au>

--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!