lkml.org 
[lkml]   [2011]   [Nov]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [patch] hugetlb: add hugepage reservation upon mremap expansion.
From
On Fri, Nov 4, 2011 at 3:13 PM, Hugh Dickins <hughd@google.com> wrote:
> But changing i_size in mmap and mremap is unusual, if not simply wrong.
> The size of mmap or mremap is the size of a userspace mapping, which
> is modified by mmap, mremap, munmap.  The size of the underlying object
> is usually independent of that, and modified by ftruncate or write.
>
> It was suggested a few years ago that it would be helpful if mremap of
> a shared anonymous shmem object would change the size of the underlying
> object, instead of just giving SIGBUS on the enlargement; but in the
> end I played cautious, and made no change there.

Indeed, that would be undesirable to modify i_size in mremap(). For small
page, the only mapping one can truly expand beyond file size via mremap()
is private anon. All other cases it will SIGBUS at the time of fault. In
that respect, I think hugetlb should match the behavior of small page as
well. I will add a size check for hugetlb mapping and disallow new size
to pass beyond i_size.

Then there are cases of taking partial region and perform an mremap
expansion: e.g.
addr = mmap(.., SIZE, ..)
mremap(addr, SIZE / 2, SIZE, ...);

Which for shared mapping, it is fine because everything is already
reserved. For private mapping, a new set of expansion would be needed.
I will re-post with updated changes on this.

- Ken
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2011-11-09 21:51    [W:0.683 / U:0.084 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site