From: David Gibson <david@gibson.dropbear.id.au>
To: Joonsoo Kim <iamjoonsoo.kim@lge.com>
Cc: Rik van Riel <riel@redhat.com>,
Davidlohr Bueso <davidlohr.bueso@hp.com>,
Hugh Dickins <hughd@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
Michel Lespinasse <walken@google.com>,
Mel Gorman <mgorman@suse.de>,
Konstantin Khlebnikov <khlebnikov@openvz.org>,
Michal Hocko <mhocko@suse.cz>,
"AneeshKumarK.V" <aneesh.kumar@linux.vnet.ibm.com>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
Hillf Danton <dhillf@gmail.com>,
linux-mm@kvack.org, LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] mm/hugetlb: per-vma instantiation mutexes
Date: Tue, 16 Jul 2013 20:01:46 +1000 [thread overview]
Message-ID: <20130716100146.GC8925@voom.fritz.box> (raw)
In-Reply-To: <20130716053424.GB30116@lge.com>
[-- Attachment #1: Type: text/plain, Size: 2458 bytes --]
On Tue, Jul 16, 2013 at 02:34:24PM +0900, Joonsoo Kim wrote:
> On Mon, Jul 15, 2013 at 09:51:21PM -0400, Rik van Riel wrote:
> > On 07/15/2013 03:24 AM, David Gibson wrote:
> > >On Sun, Jul 14, 2013 at 08:16:44PM -0700, Davidlohr Bueso wrote:
> >
> > >>>Reading the existing comment, this change looks very suspicious to me.
> > >>>A per-vma mutex is just not going to provide the necessary exclusion, is
> > >>>it? (But I recall next to nothing about these regions and
> > >>>reservations.)
> > >
> > >A per-VMA lock is definitely wrong. I think it handles one form of
> > >the race, between threads sharing a VM on a MAP_PRIVATE mapping.
> > >However another form of the race can and does occur between different
> > >MAP_SHARED VMAs in the same or different processes. I think there may
> > >be edge cases involving mremap() and MAP_PRIVATE that will also be
> > >missed by a per-VMA lock.
> > >
> > >Note that the libhugetlbfs testsuite contains tests for both PRIVATE
> > >and SHARED variants of the race.
> >
> > Can we get away with simply using a mutex in the file?
> > Say vma->vm_file->mapping->i_mmap_mutex?
>
> I totally agree with this approach :)
>
> >
> > That might help with multiple processes initializing
> > multiple shared memory segments at the same time, and
> > should not hurt the case of a process mapping its own
> > hugetlbfs area.
> >
> > It might have the potential to hurt when getting private
> > copies on a MAP_PRIVATE area, though. I have no idea
> > how common it is for multiple processes to MAP_PRIVATE
> > the same hugetlbfs file, though...
>
> Currently, getting private copies on a MAP_PRIVATE area is also
> serialized by hugetlb_instantiation_mutex.
> How do we get worse with your approach?
>
> BTW, we have one race problem related to hugetlb_instantiation_mutex.
> It is not right protection for region structure handling. We map the
> area without holding a hugetlb_instantiation_mutex, so there is
> race condition between mapping a new area and faulting the other area.
> Am I missing?
The hugetlb_instantiation_mutex has nothing to do with protecting
region structures. It exists only to address one very specific and
frequently misunderstood race.
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: Type: application/pgp-signature, Size: 198 bytes --]
next prev parent reply other threads:[~2013-07-16 10:04 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-12 23:28 [PATCH] mm/hugetlb: per-vma instantiation mutexes Davidlohr Bueso
2013-07-13 0:54 ` Hugh Dickins
2013-07-15 3:16 ` Davidlohr Bueso
2013-07-15 7:24 ` David Gibson
2013-07-15 23:08 ` Andrew Morton
2013-07-16 0:12 ` Davidlohr Bueso
2013-07-16 8:00 ` David Gibson
2013-07-17 19:50 ` [PATCH] hugepage: allow parallelization of the hugepage fault path Davidlohr Bueso
2013-07-18 8:42 ` Joonsoo Kim
2013-07-19 7:14 ` David Gibson
2013-07-19 21:24 ` Davidlohr Bueso
2013-07-22 0:59 ` Joonsoo Kim
2013-07-18 9:07 ` Joonsoo Kim
2013-07-19 0:19 ` Davidlohr Bueso
2013-07-19 0:35 ` Davidlohr Bueso
2013-07-23 7:04 ` Hush Bensen
2013-07-23 6:55 ` Hush Bensen
2013-07-16 1:51 ` [PATCH] mm/hugetlb: per-vma instantiation mutexes Rik van Riel
2013-07-16 5:34 ` Joonsoo Kim
2013-07-16 10:01 ` David Gibson [this message]
2013-07-18 6:50 ` Joonsoo Kim
2013-07-16 8:20 ` David Gibson
2013-07-15 4:18 ` Konstantin Khlebnikov
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=20130716100146.GC8925@voom.fritz.box \
--to=david@gibson.dropbear.id.au \
--cc=akpm@linux-foundation.org \
--cc=aneesh.kumar@linux.vnet.ibm.com \
--cc=davidlohr.bueso@hp.com \
--cc=dhillf@gmail.com \
--cc=hughd@google.com \
--cc=iamjoonsoo.kim@lge.com \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=khlebnikov@openvz.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mgorman@suse.de \
--cc=mhocko@suse.cz \
--cc=riel@redhat.com \
--cc=walken@google.com \
/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;
as well as URLs for NNTP newsgroup(s).