From: Adam Litke <agl@us.ibm.com>
To: David Gibson <dwg@au1.ibm.com>
Cc: Dave Hansen <haveblue@us.ibm.com>,
libhugetlbfs-devel@lists.sourceforge.net,
Dave McCracken <dave.mccracken@oracle.com>,
linux-mm@kvack.org, Mel Gorman <mel@skynet.ie>,
Ken Chen <kenchen@google.com>, Andy Whitcroft <apw@shadowen.org>,
Bill Irwin <bill.irwin@oracle.com>
Subject: Re: [Libhugetlbfs-devel] [PATCH 3/5] hugetlb: Try to grow hugetlb pool for MAP_PRIVATE mappings
Date: Fri, 14 Sep 2007 08:33:33 -0500 [thread overview]
Message-ID: <1189776813.15024.45.camel@localhost.localdomain> (raw)
In-Reply-To: <20070914054615.GL481@localhost.localdomain>
On Fri, 2007-09-14 at 15:46 +1000, David Gibson wrote:
> On Thu, Sep 13, 2007 at 03:21:30PM -0500, Adam Litke wrote:
> > On Thu, 2007-09-13 at 11:06 -0700, Dave Hansen wrote:
> > > On Thu, 2007-09-13 at 10:59 -0700, Adam Litke wrote:
> > > > +static int within_locked_vm_limits(long hpage_delta)
> > > > +{
> > > > + unsigned long locked_pages, locked_pages_limit;
> > > > +
> > > > + /* Check locked page limits */
> > > > + locked_pages = current->mm->locked_vm;
> > > > + locked_pages += hpage_delta * (HPAGE_SIZE >> PAGE_SHIFT);
> > > > + locked_pages_limit = current->signal->rlim[RLIMIT_MEMLOCK].rlim_cur;
> > > > + locked_pages_limit >>= PAGE_SHIFT;
> > > > +
> > > > + /* Return 0 if we would exceed locked_vm limits */
> > > > + if (locked_pages > locked_pages_limit)
> > > > + return 0;
> > > > +
> > > > + /* Nice, we're within limits */
> > > > + return 1;
> > > > +}
> > > > +
> > > > +static struct page *alloc_buddy_huge_page(struct vm_area_struct *vma,
> > > > + unsigned long address)
> > > > +{
> > > > + struct page *page;
> > > > +
> > > > + /* Check we remain within limits if 1 huge page is allocated */
> > > > + if (!within_locked_vm_limits(1))
> > > > + return NULL;
> > > > +
> > > > + page = alloc_pages(htlb_alloc_mask|__GFP_COMP|__GFP_NOWARN,
> > > ...
> > >
> > > Is there locking around this operation? Or, is there a way that a
> > > process could do this concurrently in two different threads, both appear
> > > to be within within_locked_vm_limits(), and both succeed to allocate
> > > when doing so actually takes them over the limit?
> >
> > This case is prevented by hugetlb_instantiation_mutex. I'll include a
> > comment to make that clearer.
>
> Hrm... a number of people are trying to get rid of, or at least reduce
> the scope of the instatiation mutex, since it can be significant
> bottlenect when clearing large numbers of hugepages on big SMP
> systems.
Yes, and with the exception of this bit, this patch series furthers that
goal substantially. With a dynamic hugetlb pool, the
alloc-instantiation race can be handled by stretching the pool during
the race window to accommodate the temporary overage.
As for the safety of within_locked_vm_limits() depending on
hugetlb_instantiation_mutex, perhaps this is another reason to not use
the locked ulimit as a way to manage hugetlb pool growth (since we do
have the fs quota method).
--
Adam Litke - (agl at us.ibm.com)
IBM Linux Technology Center
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2007-09-14 13:33 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-09-13 17:58 [PATCH 0/5] [hugetlb] Dynamic huge page pool resizing Adam Litke
2007-09-13 17:59 ` [PATCH 1/5] hugetlb: Account for hugepages as locked_vm Adam Litke
2007-09-14 5:41 ` Ken Chen
2007-09-14 9:15 ` Mel Gorman
2007-09-13 17:59 ` [PATCH 2/5] hugetlb: Move update_and_free_page Adam Litke
2007-09-13 17:59 ` [PATCH 3/5] hugetlb: Try to grow hugetlb pool for MAP_PRIVATE mappings Adam Litke
2007-09-13 18:06 ` [Libhugetlbfs-devel] " Dave Hansen
2007-09-13 20:21 ` Adam Litke
2007-09-14 5:46 ` David Gibson
2007-09-14 13:33 ` Adam Litke [this message]
2007-09-13 17:59 ` [PATCH 4/5] hugetlb: Try to grow hugetlb pool for MAP_SHARED mappings Adam Litke
2007-09-13 22:24 ` Dave McCracken
2007-09-14 14:03 ` Adam Litke
2007-09-13 17:59 ` [PATCH 5/5] hugetlb: Add hugetlb_dynamic_pool sysctl Adam Litke
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1189776813.15024.45.camel@localhost.localdomain \
--to=agl@us.ibm.com \
--cc=apw@shadowen.org \
--cc=bill.irwin@oracle.com \
--cc=dave.mccracken@oracle.com \
--cc=dwg@au1.ibm.com \
--cc=haveblue@us.ibm.com \
--cc=kenchen@google.com \
--cc=libhugetlbfs-devel@lists.sourceforge.net \
--cc=linux-mm@kvack.org \
--cc=mel@skynet.ie \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox