From: Yuanhan Liu <yuanhan.liu@linux.intel.com>
To: Peter Zijlstra <peterz@infradead.org>
Cc: Michel Lespinasse <walken@google.com>,
linux-kernel@vger.kernel.org, Ingo Molnar <mingo@kernel.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Andrew Morton <akpm@linux-foundation.org>,
Rik van Riel <riel@redhat.com>
Subject: Re: [PATCH 1/4] mm/rmap: per anon_vma lock
Date: Fri, 1 Nov 2013 22:02:44 +0800 [thread overview]
Message-ID: <20131101140244.GE30123@yliu-dev.sh.intel.com> (raw)
In-Reply-To: <20131101120745.GC10651@twins.programming.kicks-ass.net>
On Fri, Nov 01, 2013 at 01:07:45PM +0100, Peter Zijlstra wrote:
> On Fri, Nov 01, 2013 at 07:44:29PM +0800, Yuanhan Liu wrote:
> > commit 012f18004da33ba672e3c60838cc4898126174d3
> > Author: Rik van Riel <riel@redhat.com>
> > Date: Mon Aug 9 17:18:40 2010 -0700
> >
> > mm: always lock the root (oldest) anon_vma
> >
> > Always (and only) lock the root (oldest) anon_vma whenever we do something
> > in an anon_vma. The recently introduced anon_vma scalability is due to
> > the rmap code scanning only the VMAs that need to be scanned. Many common
> > operations still took the anon_vma lock on the root anon_vma, so always
> > taking that lock is not expected to introduce any scalability issues.
> >
> > However, always taking the same lock does mean we only need to take one
> > lock, which means rmap_walk on pages from any anon_vma in the vma is
> > excluded from occurring during an munmap, expand_stack or other operation
> > that needs to exclude rmap_walk and similar functions.
> >
> > Also add the proper locking to vma_adjust.
> >
> > Signed-off-by: Rik van Riel <riel@redhat.com>
> > Tested-by: Larry Woodman <lwoodman@redhat.com>
> > Acked-by: Larry Woodman <lwoodman@redhat.com>
> > Reviewed-by: Minchan Kim <minchan.kim@gmail.com>
> > Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
> > Acked-by: Mel Gorman <mel@csn.ul.ie>
> > Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
> > Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
> > Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
>
> Right that commit did.
Sorry again for that! I was jusy being brain dead :(
> I'm still not sure why you change both the
> locking proper and the locking primitive used in one patch set.
convert rwsem to rwlock silightly depends on per anon_vma lock, as it's
a bad idea to do avc allocation inside a spin lock.
Without converting rwsem to rwlock, it's not that useful to introduce
per anon_vma lock, or worse, it may introduce regressions.
>
> Also, changing the locking proper requires a very detailed explanation
> on why it is correct;
Thanks for the tip. And yes, this patch really lacks of some explanation.
I tried to find some potentional races. I then digged the git history
and found it was per anon_lock at the first time avc was introduced.
It was changed to root locking not for fixing race, thus I think we
can changed it back, and this time, for performance boost.
anon_vma lock owns biggest lock contention on our many-core(say 120)servers
from /proc/lock_stat. I found Ingo's patch makes it better, and since
it's a spin lock, I then tried to narrow down the lock range. Hence,
I wrote this patch.
This patch may be wrong, but I guess it's somehow worthy sending out
for comments.
> we've had far too many 'fun' issues with the
> anon_vma locking in the past.
Yeah, I know. Say, http://lwn.net/Articles/383162/ ;)
Thanks.
--yliu
next prev parent reply other threads:[~2013-11-01 14:02 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-01 7:54 [PATCH 0/4] per anon_vma lock and turn anon_vma rwsem lock to rwlock_t Yuanhan Liu
2013-11-01 7:54 ` [PATCH 1/4] mm/rmap: per anon_vma lock Yuanhan Liu
2013-11-01 8:43 ` Peter Zijlstra
2013-11-01 9:22 ` Michel Lespinasse
2013-11-01 9:29 ` Ingo Molnar
2013-11-01 10:07 ` Yuanhan Liu
2013-11-01 10:15 ` Peter Zijlstra
2013-11-01 11:44 ` Yuanhan Liu
2013-11-01 12:07 ` Peter Zijlstra
2013-11-01 14:02 ` Yuanhan Liu [this message]
2013-11-01 9:38 ` Yuanhan Liu
2013-11-01 10:22 ` Peter Zijlstra
2013-11-01 14:09 ` Yuanhan Liu
2013-11-01 17:47 ` Linus Torvalds
2013-11-01 7:54 ` [PATCH 2/4] mm/rmap: convert anon_vma rwsem to rwlock_t Yuanhan Liu
2013-11-01 8:46 ` Peter Zijlstra
2013-11-01 7:54 ` [PATCH 3/4] mm/rmap: cleanup unnecessary code Yuanhan Liu
2013-11-01 7:54 ` [PATCH 4/4] mm/rmap.c: move anon_vma initialization code into anon_vma_ctor Yuanhan Liu
2013-11-01 18:04 ` Linus Torvalds
2013-11-04 3:37 ` Yuanhan Liu
2013-11-01 8:01 ` [PATCH 0/4] per anon_vma lock and turn anon_vma rwsem lock to rwlock_t Ingo Molnar
2013-11-01 8:11 ` Yuanhan Liu
2013-11-01 8:21 ` Ingo Molnar
2013-11-01 10:16 ` Yuanhan Liu
2013-11-02 3:15 ` Davidlohr Bueso
2013-11-04 3:59 ` Yuanhan Liu
2013-11-05 1:44 ` Tim Chen
2013-11-05 2:03 ` Tim Chen
2013-11-05 3:41 ` Yuanhan Liu
2013-11-05 3:10 ` Yuanhan Liu
2013-11-05 14:43 ` Yuanhan Liu
2013-11-01 17:49 ` Davidlohr Bueso
2013-11-01 18:09 ` Linus Torvalds
2013-11-01 18:47 ` Michel Lespinasse
2013-11-01 18:55 ` Linus Torvalds
2013-11-02 3:18 ` Davidlohr Bueso
2013-11-01 19:01 ` KOSAKI Motohiro
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=20131101140244.GE30123@yliu-dev.sh.intel.com \
--to=yuanhan.liu@linux.intel.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=riel@redhat.com \
--cc=torvalds@linux-foundation.org \
--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