[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CABQzsv8RSFfguP2W9EU_TxzCRy3NZR=fmQLj-V7+m2vGY60Szw@mail.gmail.com>
Date: Wed, 9 Nov 2011 12:47:54 -0800
From: Ken Chen <kenchen@...gle.com>
To: Hugh Dickins <hughd@...gle.com>
Cc: akpm@...ux-foundation.org, linux-kernel@...r.kernel.org,
mel@....ul.ie
Subject: Re: [patch] hugetlb: add hugepage reservation upon mremap expansion.
On Fri, Nov 4, 2011 at 3:13 PM, Hugh Dickins <hughd@...gle.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@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists