Re: [PATCH] HUGETLBFS: Align memory request to multiple of hugepage size to avoid underallocating.

From: Andrew Morton
Date: Mon Feb 27 2012 - 22:03:47 EST


On Mon, 27 Feb 2012 21:55:17 -0500 Steven Truelove <steven.truelove@xxxxxxxxxxx> wrote:

> > A few things...
> >
> > - sys_mmap_pgoff() does the rounding up prior to calling
> > hugetlb_file_setup(). ipc/shm.c:newseg() does not.
> >
> > We should be consistent here: do it in the caller or the callee,
> > not both (or neither!). I guess doing it in the callee would be
> > best.
> >
> > - The above code could/should have used ALIGN(). Or round_up(): the
> > difference presently escapes me, even though it was so obvious that
> > we left all these things undocumented.
> >
> > - What's the point in aligning the length if we don't also look at
> > the start address? If that isn't a multiple of huge_page_size(), we
> > will need an additional page.
> >
>
> Since mmap has an address to check and shmget does not, if the address
> is going to be checked it will need to be in the caller.

Or pass a value of 0 from shmget.

> If you like, I
> will leave the size check in hugetlb_file_setup() and remove the size
> check from mmap_pgoff, but replace it with a check of the address. That
> will centralize the common check (size of buffer), and let mmap_pgoff
> check the part that is unique to it. Patch shortly.
>
> Steven Truelove
--
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/