diff options
author | Konstantin Khlebnikov <koct9i@gmail.com> | 2015-01-08 14:32:15 -0800 |
---|---|---|
committer | Luis Henriques <luis.henriques@canonical.com> | 2015-01-16 14:34:31 +0000 |
commit | d2453b3b57c8b701dcbe02dd4552d0e57655544a (patch) | |
tree | d3621c44519573085bc7c51534ded818ad3ca17b /include | |
parent | d8cb06ebefb3a43cc5eb841eec3c0b9bda235490 (diff) | |
download | linux-stable-d2453b3b57c8b701dcbe02dd4552d0e57655544a.tar.gz linux-stable-d2453b3b57c8b701dcbe02dd4552d0e57655544a.tar.bz2 linux-stable-d2453b3b57c8b701dcbe02dd4552d0e57655544a.zip |
mm: prevent endless growth of anon_vma hierarchy
commit 7a3ef208e662f4b63d43a23f61a64a129c525bbc upstream.
Constantly forking task causes unlimited grow of anon_vma chain. Each
next child allocates new level of anon_vmas and links vma to all
previous levels because pages might be inherited from any level.
This patch adds heuristic which decides to reuse existing anon_vma
instead of forking new one. It adds counter anon_vma->degree which
counts linked vmas and directly descending anon_vmas and reuses anon_vma
if counter is lower than two. As a result each anon_vma has either vma
or at least two descending anon_vmas. In such trees half of nodes are
leafs with alive vmas, thus count of anon_vmas is no more than two times
bigger than count of vmas.
This heuristic reuses anon_vmas as few as possible because each reuse
adds false aliasing among vmas and rmap walker ought to scan more ptes
when it searches where page is might be mapped.
Link: http://lkml.kernel.org/r/20120816024610.GA5350@evergreen.ssec.wisc.edu
Fixes: 5beb49305251 ("mm: change anon_vma linking to fix multi-process server scalability issue")
[akpm@linux-foundation.org: fix typo, per Rik]
Signed-off-by: Konstantin Khlebnikov <koct9i@gmail.com>
Reported-by: Daniel Forrest <dan.forrest@ssec.wisc.edu>
Tested-by: Michal Hocko <mhocko@suse.cz>
Tested-by: Jerome Marchand <jmarchan@redhat.com>
Reviewed-by: Michal Hocko <mhocko@suse.cz>
Reviewed-by: Rik van Riel <riel@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Luis Henriques <luis.henriques@canonical.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/rmap.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/include/linux/rmap.h b/include/linux/rmap.h index be574506e6a9..28349a8fd08b 100644 --- a/include/linux/rmap.h +++ b/include/linux/rmap.h @@ -37,6 +37,16 @@ struct anon_vma { atomic_t refcount; /* + * Count of child anon_vmas and VMAs which points to this anon_vma. + * + * This counter is used for making decision about reusing anon_vma + * instead of forking new one. See comments in function anon_vma_clone. + */ + unsigned degree; + + struct anon_vma *parent; /* Parent of this anon_vma */ + + /* * NOTE: the LSB of the rb_root.rb_node is set by * mm_take_all_locks() _after_ taking the above lock. So the * rb_root must only be read/written after taking the above lock |