From: Linus Torvalds <torvalds@linux-foundation.org>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Hugh Dickins <hughd@google.com>,
Tim Chen <tim.c.chen@linux.intel.com>,
Andi Kleen <ak@linux.intel.com>,
Shaohua Li <shaohua.li@intel.com>,
Andrew Morton <akpm@linux-foundation.org>,
KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>,
Benjamin Herrenschmidt <benh@kernel.crashing.org>,
David Miller <davem@davemloft.net>,
Martin Schwidefsky <schwidefsky@de.ibm.com>,
Russell King <rmk@arm.linux.org.uk>,
Paul Mundt <lethal@linux-sh.org>, Jeff Dike <jdike@addtoit.com>,
Richard Weinberger <richard@nod.at>,
"Luck, Tony" <tony.luck@intel.com>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
Mel Gorman <mel@csn.ul.ie>, Nick Piggin <npiggin@kernel.dk>,
Namhyung Kim <namhyung@gmail.com>,
"Shi, Alex" <alex.shi@intel.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"linux-mm@kvack.org" <linux-mm@kvack.org>,
"Rafael J. Wysocki" <rjw@sisk.pl>
Subject: Re: REGRESSION: Performance regressions from switching anon_vma->lock to mutex
Date: Fri, 17 Jun 2011 11:39:04 -0700 [thread overview]
Message-ID: <BANLkTimStT22tA2YkeuYBzarnnWTnMjiKQ@mail.gmail.com> (raw)
In-Reply-To: <1308335557.12801.24.camel@laptop>
[-- Attachment #1: Type: text/plain, Size: 689 bytes --]
On Fri, Jun 17, 2011 at 11:32 AM, Peter Zijlstra <peterz@infradead.org> wrote:
>
> something like so I guess, completely untested etc..
Having gone over it a bit more, I actually think I prefer to just
special-case the allocation instead.
We already have to drop the anon_vma lock for the "out of memory"
case, and a slight re-organization of clone_anon_vma() makes it easy
to just first try a NOIO allocation with the lock still held, and then
if that fails do the "drop lock, retry, and hard-fail" case.
IOW, something like the attached (on top of the patches already posted
except for your memory reclaim thing)
Hugh, does this fix the lockdep issue?
Linus
[-- Attachment #2: patch.diff --]
[-- Type: text/x-patch, Size: 2009 bytes --]
mm/rmap.c | 20 ++++++++++++--------
1 files changed, 12 insertions(+), 8 deletions(-)
diff --git a/mm/rmap.c b/mm/rmap.c
index 68756a77ef87..27dfd3b82b0f 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -112,9 +112,9 @@ static inline void anon_vma_free(struct anon_vma *anon_vma)
kmem_cache_free(anon_vma_cachep, anon_vma);
}
-static inline struct anon_vma_chain *anon_vma_chain_alloc(void)
+static inline struct anon_vma_chain *anon_vma_chain_alloc(gfp_t gfp)
{
- return kmem_cache_alloc(anon_vma_chain_cachep, GFP_KERNEL);
+ return kmem_cache_alloc(anon_vma_chain_cachep, gfp);
}
static void anon_vma_chain_free(struct anon_vma_chain *anon_vma_chain)
@@ -159,7 +159,7 @@ int anon_vma_prepare(struct vm_area_struct *vma)
struct mm_struct *mm = vma->vm_mm;
struct anon_vma *allocated;
- avc = anon_vma_chain_alloc();
+ avc = anon_vma_chain_alloc(GFP_KERNEL);
if (!avc)
goto out_enomem;
@@ -253,9 +253,14 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
list_for_each_entry_reverse(pavc, &src->anon_vma_chain, same_vma) {
struct anon_vma *anon_vma;
- avc = anon_vma_chain_alloc();
- if (!avc)
- goto enomem_failure;
+ avc = anon_vma_chain_alloc(GFP_NOWAIT | __GFP_NOWARN);
+ if (unlikely(!avc)) {
+ unlock_anon_vma_root(root);
+ root = NULL;
+ avc = anon_vma_chain_alloc(GFP_KERNEL);
+ if (!avc)
+ goto enomem_failure;
+ }
anon_vma = pavc->anon_vma;
root = lock_anon_vma_root(root, anon_vma);
anon_vma_chain_link(dst, avc, anon_vma);
@@ -264,7 +269,6 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
return 0;
enomem_failure:
- unlock_anon_vma_root(root);
unlink_anon_vmas(dst);
return -ENOMEM;
}
@@ -294,7 +298,7 @@ int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
anon_vma = anon_vma_alloc();
if (!anon_vma)
goto out_error;
- avc = anon_vma_chain_alloc();
+ avc = anon_vma_chain_alloc(GFP_KERNEL);
if (!avc)
goto out_error_free_anon_vma;
next prev parent reply other threads:[~2011-06-17 18:46 UTC|newest]
Thread overview: 86+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-06-15 0:29 REGRESSION: Performance regressions from switching anon_vma->lock to mutex Tim Chen
2011-06-15 0:36 ` Andi Kleen
2011-06-17 19:07 ` Ingo Molnar
2011-06-15 1:21 ` Linus Torvalds
2011-06-15 3:42 ` Linus Torvalds
2011-06-15 1:26 ` Shaohua Li
2011-06-15 11:52 ` Peter Zijlstra
2011-06-15 12:49 ` Peter Zijlstra
2011-06-15 16:18 ` Andi Kleen
2011-06-15 16:45 ` Peter Zijlstra
2011-06-15 16:47 ` Andi Kleen
2011-06-15 18:43 ` Tim Chen
2011-06-15 20:32 ` Peter Zijlstra
2011-06-15 20:57 ` Andi Kleen
2011-06-15 21:12 ` Tim Chen
2011-06-15 21:37 ` Peter Zijlstra
2011-06-15 21:51 ` Linus Torvalds
2011-06-15 22:19 ` Andi Kleen
2011-06-16 0:16 ` Linus Torvalds
2011-06-16 20:14 ` Andi Kleen
2011-06-16 20:37 ` Linus Torvalds
2011-06-17 0:24 ` Andi Kleen
2011-06-17 9:13 ` Ingo Molnar
2011-06-15 22:15 ` Andi Kleen
2011-06-16 1:08 ` Tim Chen
2011-06-16 1:50 ` Linus Torvalds
2011-06-16 20:26 ` Tim Chen
2011-06-16 20:47 ` Linus Torvalds
2011-06-16 21:05 ` Linus Torvalds
2011-06-16 21:06 ` Linus Torvalds
2011-06-16 21:26 ` Linus Torvalds
2011-06-17 3:58 ` Linus Torvalds
2011-06-17 11:28 ` Peter Zijlstra
2011-06-17 11:54 ` Peter Zijlstra
2011-06-17 16:36 ` Linus Torvalds
2011-06-17 17:41 ` Hugh Dickins
2011-06-17 17:55 ` Peter Zijlstra
2011-06-17 18:01 ` Linus Torvalds
2011-06-17 18:18 ` Peter Zijlstra
2011-06-17 18:32 ` Peter Zijlstra
2011-06-17 18:39 ` Linus Torvalds [this message]
2011-06-17 18:41 ` Linus Torvalds
2011-06-17 20:19 ` Tim Chen
2011-06-17 22:20 ` Hugh Dickins
2011-06-18 4:47 ` Linus Torvalds
2011-06-17 19:53 ` [PATCH] mm, memory-failure: Fix spinlock vs mutex order Peter Zijlstra
2011-06-17 20:04 ` Andi Kleen
2011-06-17 16:46 ` REGRESSION: Performance regressions from switching anon_vma->lock to mutex Linus Torvalds
2011-06-17 17:28 ` Linus Torvalds
2011-06-17 19:40 ` Andi Kleen
2011-06-18 8:08 ` Ingo Molnar
2011-06-17 18:22 ` Tim Chen
2011-06-17 19:05 ` Ray Lee
2011-06-16 22:00 ` Andi Kleen
2011-06-15 10:36 ` Peter Zijlstra
2011-06-15 10:58 ` Peter Zijlstra
2011-06-15 11:41 ` Peter Zijlstra
2011-06-15 19:11 ` Linus Torvalds
2011-06-15 19:24 ` Andrew Morton
2011-06-15 20:16 ` Ingo Molnar
2011-06-15 20:55 ` Linus Torvalds
2011-06-15 20:12 ` [GIT PULL] " Ingo Molnar
2011-06-15 20:29 ` Paul E. McKenney
2011-06-15 20:47 ` Linus Torvalds
2011-06-15 20:54 ` Paul E. McKenney
2011-06-15 21:05 ` Linus Torvalds
2011-06-15 21:15 ` Paul E. McKenney
2011-06-15 21:27 ` Linus Torvalds
2011-06-16 7:03 ` Ingo Molnar
2011-06-16 17:16 ` Paul E. McKenney
2011-06-16 20:25 ` Ingo Molnar
2011-06-16 21:01 ` Frederic Weisbecker
2011-06-16 23:02 ` Ingo Molnar
2011-06-17 15:19 ` Frederic Weisbecker
2011-06-16 21:02 ` Andi Kleen
2011-06-16 22:21 ` Benjamin Herrenschmidt
2011-06-16 22:38 ` Ingo Molnar
2011-06-16 22:47 ` Andi Kleen
2011-06-16 22:58 ` Ingo Molnar
2011-06-17 0:45 ` Paul E. McKenney
2011-06-17 9:43 ` Ingo Molnar
2011-06-17 16:48 ` Paul E. McKenney
2011-06-16 23:37 ` Paul E. McKenney
2011-06-15 20:13 ` Tim Chen
2011-06-15 20:17 ` Ingo Molnar
2011-06-15 20:21 ` Tim Chen
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=BANLkTimStT22tA2YkeuYBzarnnWTnMjiKQ@mail.gmail.com \
--to=torvalds@linux-foundation.org \
--cc=ak@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=alex.shi@intel.com \
--cc=benh@kernel.crashing.org \
--cc=davem@davemloft.net \
--cc=hughd@google.com \
--cc=jdike@addtoit.com \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=kosaki.motohiro@jp.fujitsu.com \
--cc=lethal@linux-sh.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mel@csn.ul.ie \
--cc=namhyung@gmail.com \
--cc=npiggin@kernel.dk \
--cc=peterz@infradead.org \
--cc=richard@nod.at \
--cc=rjw@sisk.pl \
--cc=rmk@arm.linux.org.uk \
--cc=schwidefsky@de.ibm.com \
--cc=shaohua.li@intel.com \
--cc=tim.c.chen@linux.intel.com \
--cc=tony.luck@intel.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).