Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 207198
b: refs/heads/master
c: 5c341ee
h: refs/heads/master
v: v3
  • Loading branch information
Rik van Riel authored and Linus Torvalds committed Aug 10, 2010
1 parent d81215f commit 149df5d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: cba48b98f2348c814316c4b4f411a07a0e4a2bf9
refs/heads/master: 5c341ee1dfc8fe69d66b1c8b19e463c6d7201ae1
1 change: 1 addition & 0 deletions trunk/include/linux/rmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
*/
struct anon_vma {
spinlock_t lock; /* Serialize access to vma list */
struct anon_vma *root; /* Root of this anon_vma tree */
#if defined(CONFIG_KSM) || defined(CONFIG_MIGRATION)

/*
Expand Down
18 changes: 16 additions & 2 deletions trunk/mm/rmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,11 @@ int anon_vma_prepare(struct vm_area_struct *vma)
if (unlikely(!anon_vma))
goto out_enomem_free_avc;
allocated = anon_vma;
/*
* This VMA had no anon_vma yet. This anon_vma is
* the root of any anon_vma tree that might form.
*/
anon_vma->root = anon_vma;
}

anon_vma_lock(anon_vma);
Expand Down Expand Up @@ -224,9 +229,15 @@ int anon_vma_fork(struct vm_area_struct *vma, struct vm_area_struct *pvma)
avc = anon_vma_chain_alloc();
if (!avc)
goto out_error_free_anon_vma;
anon_vma_chain_link(vma, avc, anon_vma);

/*
* The root anon_vma's spinlock is the lock actually used when we
* lock any of the anon_vmas in this anon_vma tree.
*/
anon_vma->root = pvma->anon_vma->root;
/* Mark this anon_vma as the one where our new (COWed) pages go. */
vma->anon_vma = anon_vma;
anon_vma_chain_link(vma, avc, anon_vma);

return 0;

Expand Down Expand Up @@ -261,7 +272,10 @@ void unlink_anon_vmas(struct vm_area_struct *vma)
{
struct anon_vma_chain *avc, *next;

/* Unlink each anon_vma chained to the VMA. */
/*
* Unlink each anon_vma chained to the VMA. This list is ordered
* from newest to oldest, ensuring the root anon_vma gets freed last.
*/
list_for_each_entry_safe(avc, next, &vma->anon_vma_chain, same_vma) {
anon_vma_unlink(avc);
list_del(&avc->same_vma);
Expand Down

0 comments on commit 149df5d

Please sign in to comment.