From: Paul Mundt <lethal@linux-sh.org>
To: David Howells <dhowells@redhat.com>
Cc: Pekka Enberg <penberg@cs.helsinki.fi>, Mel Gorman <mel@csn.ul.ie>,
Christoph Lameter <cl@linux-foundation.org>,
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Nick Piggin <nickpiggin@yahoo.com.au>,
Dave Hansen <dave@linux.vnet.ibm.com>,
Lee Schermerhorn <Lee.Schermerhorn@hp.com>,
Andrew Morton <akpm@linux-foundation.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: page allocator regression on nommu
Date: Tue, 1 Sep 2009 23:27:17 +0900 [thread overview]
Message-ID: <20090901142716.GA16759@linux-sh.org> (raw)
In-Reply-To: <12589.1251812805@redhat.com>
On Tue, Sep 01, 2009 at 02:46:45PM +0100, David Howells wrote:
> Paul Mundt <lethal@linux-sh.org> wrote:
>
> > Yeah, that looks a bit suspect. __put_nommu_region() is safe to be called
> > without a call to add_nommu_region(), but we happen to trip over the
> > BUG_ON() in this case because we've never made a single addition to the
> > region tree.
> >
> > We probably ought to just up_write() and return if nommu_region_tree ==
> > RB_ROOT, which is what I'll do unless David objects.
>
> I think that's the wrong thing to do. I think we're better moving the call to
> add_nommu_region() to above the "/* set up the mapping */" comment. We hold
> the region semaphore at this point, so the fact that it winds up in the tree
> briefly won't cause a race, and it means __put_nommu_region() can be used with
> impunity to correctly clean up.
>
[snip]
> From: David Howells <dhowells@redhat.com>
> Subject: [PATCH] NOMMU: Fix error handling in do_mmap_pgoff()
>
> Fix the error handling in do_mmap_pgoff(). If do_mmap_shared_file() or
> do_mmap_private() fail, we jump to the error_put_region label at which point we
> cann __put_nommu_region() on the region - but we haven't yet added the region
> to the tree, and so __put_nommu_region() may BUG because the region tree is
> empty or it may corrupt the region tree.
>
> To get around this, we can afford to add the region to the region tree before
> calling do_mmap_shared_file() or do_mmap_private() as we keep nommu_region_sem
> write-locked, so no-one can race with us by seeing a transient region.
>
> Signed-off-by: David Howells <dhowells@redhat.com>
Agreed, that does look cleaner. After playing around with it a bit, I concede
that the BUG_ON() is definitely worth preserving. :-)
Acked-by: Paul Mundt <lethal@linux-sh.org>
WARNING: multiple messages have this Message-ID (diff)
From: Paul Mundt <lethal@linux-sh.org>
To: David Howells <dhowells@redhat.com>
Cc: Pekka Enberg <penberg@cs.helsinki.fi>, Mel Gorman <mel@csn.ul.ie>,
Christoph Lameter <cl@linux-foundation.org>,
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Nick Piggin <nickpiggin@yahoo.com.au>,
Dave Hansen <dave@linux.vnet.ibm.com>,
Lee Schermerhorn <Lee.Schermerhorn@hp.com>,
Andrew Morton <akpm@linux-foundation.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: page allocator regression on nommu
Date: Tue, 1 Sep 2009 23:27:17 +0900 [thread overview]
Message-ID: <20090901142716.GA16759@linux-sh.org> (raw)
In-Reply-To: <12589.1251812805@redhat.com>
On Tue, Sep 01, 2009 at 02:46:45PM +0100, David Howells wrote:
> Paul Mundt <lethal@linux-sh.org> wrote:
>
> > Yeah, that looks a bit suspect. __put_nommu_region() is safe to be called
> > without a call to add_nommu_region(), but we happen to trip over the
> > BUG_ON() in this case because we've never made a single addition to the
> > region tree.
> >
> > We probably ought to just up_write() and return if nommu_region_tree ==
> > RB_ROOT, which is what I'll do unless David objects.
>
> I think that's the wrong thing to do. I think we're better moving the call to
> add_nommu_region() to above the "/* set up the mapping */" comment. We hold
> the region semaphore at this point, so the fact that it winds up in the tree
> briefly won't cause a race, and it means __put_nommu_region() can be used with
> impunity to correctly clean up.
>
[snip]
> From: David Howells <dhowells@redhat.com>
> Subject: [PATCH] NOMMU: Fix error handling in do_mmap_pgoff()
>
> Fix the error handling in do_mmap_pgoff(). If do_mmap_shared_file() or
> do_mmap_private() fail, we jump to the error_put_region label at which point we
> cann __put_nommu_region() on the region - but we haven't yet added the region
> to the tree, and so __put_nommu_region() may BUG because the region tree is
> empty or it may corrupt the region tree.
>
> To get around this, we can afford to add the region to the region tree before
> calling do_mmap_shared_file() or do_mmap_private() as we keep nommu_region_sem
> write-locked, so no-one can race with us by seeing a transient region.
>
> Signed-off-by: David Howells <dhowells@redhat.com>
Agreed, that does look cleaner. After playing around with it a bit, I concede
that the BUG_ON() is definitely worth preserving. :-)
Acked-by: Paul Mundt <lethal@linux-sh.org>
--
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:[~2009-09-01 14:27 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-31 7:48 page allocator regression on nommu Paul Mundt
2009-08-31 7:48 ` Paul Mundt
2009-08-31 10:08 ` Pekka Enberg
2009-08-31 10:08 ` Pekka Enberg
2009-08-31 10:26 ` Paul Mundt
2009-08-31 10:26 ` Paul Mundt
2009-09-01 13:46 ` David Howells
2009-09-01 13:46 ` David Howells
2009-09-01 13:48 ` Pekka Enberg
2009-09-01 13:48 ` Pekka Enberg
2009-09-01 14:27 ` Paul Mundt [this message]
2009-09-01 14:27 ` Paul Mundt
2009-09-01 13:35 ` David Howells
2009-09-01 13:35 ` David Howells
2009-08-31 10:30 ` Mel Gorman
2009-08-31 10:30 ` Mel Gorman
2009-08-31 10:43 ` Paul Mundt
2009-08-31 10:43 ` Paul Mundt
2009-08-31 10:59 ` Mel Gorman
2009-08-31 10:59 ` Mel Gorman
2009-09-01 0:46 ` Paul Mundt
2009-09-01 0:46 ` Paul Mundt
2009-09-01 10:03 ` Mel Gorman
2009-09-01 10:03 ` Mel Gorman
2009-09-01 10:20 ` Paul Mundt
2009-09-01 10:20 ` Paul Mundt
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=20090901142716.GA16759@linux-sh.org \
--to=lethal@linux-sh.org \
--cc=Lee.Schermerhorn@hp.com \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=cl@linux-foundation.org \
--cc=dave@linux.vnet.ibm.com \
--cc=dhowells@redhat.com \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mel@csn.ul.ie \
--cc=nickpiggin@yahoo.com.au \
--cc=penberg@cs.helsinki.fi \
--cc=torvalds@linux-foundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.