linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: mel@skynet.ie (Mel Gorman)
To: Ken Chen <kenchen@google.com>
Cc: Adam Litke <agl@us.ibm.com>,
	linux-mm@kvack.org, libhugetlbfs-devel@lists.sourceforge.net,
	Andy Whitcroft <apw@shadowen.org>,
	Bill Irwin <bill.irwin@oracle.com>,
	Dave McCracken <dave.mccracken@oracle.com>
Subject: Re: [PATCH 1/5] hugetlb: Account for hugepages as locked_vm
Date: Fri, 14 Sep 2007 10:15:23 +0100	[thread overview]
Message-ID: <20070914091522.GB30407@skynet.ie> (raw)
In-Reply-To: <b040c32a0709132241t7d464a2x68d1194887cd8e93@mail.gmail.com>

On (13/09/07 22:41), Ken Chen didst pronounce:
> On 9/13/07, Adam Litke <agl@us.ibm.com> wrote:
> > Hugepages allocated to a process are pinned into memory and are not
> > reclaimable.  Currently they do not contribute towards the process' locked
> > memory.  This patch includes those pages in the process' 'locked_vm' pages.
> 
> On x86_64, hugetlb can share page table entry if multiple processes
> have their virtual addresses all lined up perfectly.  Because of that,
> mm->locked_vm can go negative with this patch depending on the order
> of which process fault in hugetlb pages and which one unmaps it last.
> 

hmmm, on close inspection you are right. The worst case is where two processes
share a PMD and fault half of the hugepages in that region each. Whichever
of them unmaps last will get bad values.

> Have you checked all user of mm->locked_vm that a negative number
> won't trigger unpleasant result?
> 

This, if it can occur is bad. It's looks stupid if absolutly nothing
else. Besides, locked_vm is an unsigned long. Wrapping negative would
actually be a huge positive so it's possible that a hostile process A
could cause a situation where innocent process B gets a large locked_vm
value and cannot dynamically resize the hugepage pool any more.

The choices for a fix I can think of are;

a) Do not use locked_vm at all. Instead use filesystem quotas to prevent the
pool growing in an unbounded fashion (this is Adam and Andy Whitcrofts idea,
not mine but it makes sense in light of this problem with locked_vm). I
liked the idea of being able to limit additional hugepage usage with
RLIMIT_LOCKED but maybe that is not such a great plan.

b) Double-count locked_vm. i.e. when pagetables are shared, the process
about to share increments it's locked_vm based on the pages already
faulted. On fault, all mm's sharing get their locked_vm increased and
unmap acts as it does. This would require the taking of many
page_table_locks to update locked_vm which would be very expensive.

Anyone got better suggestions than this? Mr. McCracken, how did you
handle the mlocked case in your pagetable sharing patches back when you
were working on them? I am assuming the problem is somewhat similar.

-- 
Mel Gorman
Part-time Phd Student                          Linux Technology Center
University of Limerick                         IBM Dublin Software Lab

--
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>

  reply	other threads:[~2007-09-14  9:15 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 [this message]
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
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=20070914091522.GB30407@skynet.ie \
    --to=mel@skynet.ie \
    --cc=agl@us.ibm.com \
    --cc=apw@shadowen.org \
    --cc=bill.irwin@oracle.com \
    --cc=dave.mccracken@oracle.com \
    --cc=kenchen@google.com \
    --cc=libhugetlbfs-devel@lists.sourceforge.net \
    --cc=linux-mm@kvack.org \
    /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