aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRik van Riel <riel@redhat.com>2010-08-09 20:18:38 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-08-09 23:44:55 -0400
commitcba48b98f2348c814316c4b4f411a07a0e4a2bf9 (patch)
tree49c0426f8d41cb147722305c2c3495dd515c3253
parentbb4a340e075b7897ece109686bfa177f8518d2db (diff)
mm: change direct call of spin_lock(anon_vma->lock) to inline function
Subsitute a direct call of spin_lock(anon_vma->lock) with an inline function doing exactly the same. This makes it easier to do the substitution to the root anon_vma lock in a following patch. We will deal with the handful of special locks (nested, dec_and_lock, etc) separately. Signed-off-by: Rik van Riel <riel@redhat.com> Acked-by: Mel Gorman <mel@csn.ul.ie> Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com> Tested-by: Larry Woodman <lwoodman@redhat.com> Acked-by: Larry Woodman <lwoodman@redhat.com> Reviewed-by: Minchan Kim <minchan.kim@gmail.com> 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>
-rw-r--r--include/linux/rmap.h10
-rw-r--r--mm/ksm.c18
-rw-r--r--mm/migrate.c2
-rw-r--r--mm/mmap.c2
-rw-r--r--mm/rmap.c20
5 files changed, 31 insertions, 21 deletions
diff --git a/include/linux/rmap.h b/include/linux/rmap.h
index 80cd162a8aa6..5f981be61416 100644
--- a/include/linux/rmap.h
+++ b/include/linux/rmap.h
@@ -113,6 +113,16 @@ static inline void vma_unlock_anon_vma(struct vm_area_struct *vma)
113 spin_unlock(&anon_vma->lock); 113 spin_unlock(&anon_vma->lock);
114} 114}
115 115
116static inline void anon_vma_lock(struct anon_vma *anon_vma)
117{
118 spin_lock(&anon_vma->lock);
119}
120
121static inline void anon_vma_unlock(struct anon_vma *anon_vma)
122{
123 spin_unlock(&anon_vma->lock);
124}
125
116/* 126/*
117 * anon_vma helper functions. 127 * anon_vma helper functions.
118 */ 128 */
diff --git a/mm/ksm.c b/mm/ksm.c
index 6c3e99b4ae7c..eb9f6806ed51 100644
--- a/mm/ksm.c
+++ b/mm/ksm.c
@@ -327,7 +327,7 @@ static void drop_anon_vma(struct rmap_item *rmap_item)
327 327
328 if (atomic_dec_and_lock(&anon_vma->external_refcount, &anon_vma->lock)) { 328 if (atomic_dec_and_lock(&anon_vma->external_refcount, &anon_vma->lock)) {
329 int empty = list_empty(&anon_vma->head); 329 int empty = list_empty(&anon_vma->head);
330 spin_unlock(&anon_vma->lock); 330 anon_vma_unlock(anon_vma);
331 if (empty) 331 if (empty)
332 anon_vma_free(anon_vma); 332 anon_vma_free(anon_vma);
333 } 333 }
@@ -1566,7 +1566,7 @@ again:
1566 struct anon_vma_chain *vmac; 1566 struct anon_vma_chain *vmac;
1567 struct vm_area_struct *vma; 1567 struct vm_area_struct *vma;
1568 1568
1569 spin_lock(&anon_vma->lock); 1569 anon_vma_lock(anon_vma);
1570 list_for_each_entry(vmac, &anon_vma->head, same_anon_vma) { 1570 list_for_each_entry(vmac, &anon_vma->head, same_anon_vma) {
1571 vma = vmac->vma; 1571 vma = vmac->vma;
1572 if (rmap_item->address < vma->vm_start || 1572 if (rmap_item->address < vma->vm_start ||
@@ -1589,7 +1589,7 @@ again:
1589 if (!search_new_forks || !mapcount) 1589 if (!search_new_forks || !mapcount)
1590 break; 1590 break;
1591 } 1591 }
1592 spin_unlock(&anon_vma->lock); 1592 anon_vma_unlock(anon_vma);
1593 if (!mapcount) 1593 if (!mapcount)
1594 goto out; 1594 goto out;
1595 } 1595 }
@@ -1619,7 +1619,7 @@ again:
1619 struct anon_vma_chain *vmac; 1619 struct anon_vma_chain *vmac;
1620 struct vm_area_struct *vma; 1620 struct vm_area_struct *vma;
1621 1621
1622 spin_lock(&anon_vma->lock); 1622 anon_vma_lock(anon_vma);
1623 list_for_each_entry(vmac, &anon_vma->head, same_anon_vma) { 1623 list_for_each_entry(vmac, &anon_vma->head, same_anon_vma) {
1624 vma = vmac->vma; 1624 vma = vmac->vma;
1625 if (rmap_item->address < vma->vm_start || 1625 if (rmap_item->address < vma->vm_start ||
@@ -1637,11 +1637,11 @@ again:
1637 ret = try_to_unmap_one(page, vma, 1637 ret = try_to_unmap_one(page, vma,
1638 rmap_item->address, flags); 1638 rmap_item->address, flags);
1639 if (ret != SWAP_AGAIN || !page_mapped(page)) { 1639 if (ret != SWAP_AGAIN || !page_mapped(page)) {
1640 spin_unlock(&anon_vma->lock); 1640 anon_vma_unlock(anon_vma);
1641 goto out; 1641 goto out;
1642 } 1642 }
1643 } 1643 }
1644 spin_unlock(&anon_vma->lock); 1644 anon_vma_unlock(anon_vma);
1645 } 1645 }
1646 if (!search_new_forks++) 1646 if (!search_new_forks++)
1647 goto again; 1647 goto again;
@@ -1671,7 +1671,7 @@ again:
1671 struct anon_vma_chain *vmac; 1671 struct anon_vma_chain *vmac;
1672 struct vm_area_struct *vma; 1672 struct vm_area_struct *vma;
1673 1673
1674 spin_lock(&anon_vma->lock); 1674 anon_vma_lock(anon_vma);
1675 list_for_each_entry(vmac, &anon_vma->head, same_anon_vma) { 1675 list_for_each_entry(vmac, &anon_vma->head, same_anon_vma) {
1676 vma = vmac->vma; 1676 vma = vmac->vma;
1677 if (rmap_item->address < vma->vm_start || 1677 if (rmap_item->address < vma->vm_start ||
@@ -1688,11 +1688,11 @@ again:
1688 1688
1689 ret = rmap_one(page, vma, rmap_item->address, arg); 1689 ret = rmap_one(page, vma, rmap_item->address, arg);
1690 if (ret != SWAP_AGAIN) { 1690 if (ret != SWAP_AGAIN) {
1691 spin_unlock(&anon_vma->lock); 1691 anon_vma_unlock(anon_vma);
1692 goto out; 1692 goto out;
1693 } 1693 }
1694 } 1694 }
1695 spin_unlock(&anon_vma->lock); 1695 anon_vma_unlock(anon_vma);
1696 } 1696 }
1697 if (!search_new_forks++) 1697 if (!search_new_forks++)
1698 goto again; 1698 goto again;
diff --git a/mm/migrate.c b/mm/migrate.c
index 4205b1d6049e..1855f869917d 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -684,7 +684,7 @@ rcu_unlock:
684 /* Drop an anon_vma reference if we took one */ 684 /* Drop an anon_vma reference if we took one */
685 if (anon_vma && atomic_dec_and_lock(&anon_vma->external_refcount, &anon_vma->lock)) { 685 if (anon_vma && atomic_dec_and_lock(&anon_vma->external_refcount, &anon_vma->lock)) {
686 int empty = list_empty(&anon_vma->head); 686 int empty = list_empty(&anon_vma->head);
687 spin_unlock(&anon_vma->lock); 687 anon_vma_unlock(anon_vma);
688 if (empty) 688 if (empty)
689 anon_vma_free(anon_vma); 689 anon_vma_free(anon_vma);
690 } 690 }
diff --git a/mm/mmap.c b/mm/mmap.c
index e26f1ea7c904..f5db18decc2e 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2593,7 +2593,7 @@ static void vm_unlock_anon_vma(struct anon_vma *anon_vma)
2593 if (!__test_and_clear_bit(0, (unsigned long *) 2593 if (!__test_and_clear_bit(0, (unsigned long *)
2594 &anon_vma->head.next)) 2594 &anon_vma->head.next))
2595 BUG(); 2595 BUG();
2596 spin_unlock(&anon_vma->lock); 2596 anon_vma_unlock(anon_vma);
2597 } 2597 }
2598} 2598}
2599 2599
diff --git a/mm/rmap.c b/mm/rmap.c
index 38a336e2eea1..b65f00d1707f 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -134,7 +134,7 @@ int anon_vma_prepare(struct vm_area_struct *vma)
134 allocated = anon_vma; 134 allocated = anon_vma;
135 } 135 }
136 136
137 spin_lock(&anon_vma->lock); 137 anon_vma_lock(anon_vma);
138 /* page_table_lock to protect against threads */ 138 /* page_table_lock to protect against threads */
139 spin_lock(&mm->page_table_lock); 139 spin_lock(&mm->page_table_lock);
140 if (likely(!vma->anon_vma)) { 140 if (likely(!vma->anon_vma)) {
@@ -147,7 +147,7 @@ int anon_vma_prepare(struct vm_area_struct *vma)
147 avc = NULL; 147 avc = NULL;
148 } 148 }
149 spin_unlock(&mm->page_table_lock); 149 spin_unlock(&mm->page_table_lock);
150 spin_unlock(&anon_vma->lock); 150 anon_vma_unlock(anon_vma);
151 151
152 if (unlikely(allocated)) 152 if (unlikely(allocated))
153 anon_vma_free(allocated); 153 anon_vma_free(allocated);
@@ -170,9 +170,9 @@ static void anon_vma_chain_link(struct vm_area_struct *vma,
170 avc->anon_vma = anon_vma; 170 avc->anon_vma = anon_vma;
171 list_add(&avc->same_vma, &vma->anon_vma_chain); 171 list_add(&avc->same_vma, &vma->anon_vma_chain);
172 172
173 spin_lock(&anon_vma->lock); 173 anon_vma_lock(anon_vma);
174 list_add_tail(&avc->same_anon_vma, &anon_vma->head); 174 list_add_tail(&avc->same_anon_vma, &anon_vma->head);
175 spin_unlock(&anon_vma->lock); 175 anon_vma_unlock(anon_vma);
176} 176}
177 177
178/* 178/*
@@ -246,12 +246,12 @@ static void anon_vma_unlink(struct anon_vma_chain *anon_vma_chain)
246 if (!anon_vma) 246 if (!anon_vma)
247 return; 247 return;
248 248
249 spin_lock(&anon_vma->lock); 249 anon_vma_lock(anon_vma);
250 list_del(&anon_vma_chain->same_anon_vma); 250 list_del(&anon_vma_chain->same_anon_vma);
251 251
252 /* We must garbage collect the anon_vma if it's empty */ 252 /* We must garbage collect the anon_vma if it's empty */
253 empty = list_empty(&anon_vma->head) && !anonvma_external_refcount(anon_vma); 253 empty = list_empty(&anon_vma->head) && !anonvma_external_refcount(anon_vma);
254 spin_unlock(&anon_vma->lock); 254 anon_vma_unlock(anon_vma);
255 255
256 if (empty) 256 if (empty)
257 anon_vma_free(anon_vma); 257 anon_vma_free(anon_vma);
@@ -302,7 +302,7 @@ struct anon_vma *page_lock_anon_vma(struct page *page)
302 goto out; 302 goto out;
303 303
304 anon_vma = (struct anon_vma *) (anon_mapping - PAGE_MAPPING_ANON); 304 anon_vma = (struct anon_vma *) (anon_mapping - PAGE_MAPPING_ANON);
305 spin_lock(&anon_vma->lock); 305 anon_vma_lock(anon_vma);
306 return anon_vma; 306 return anon_vma;
307out: 307out:
308 rcu_read_unlock(); 308 rcu_read_unlock();
@@ -311,7 +311,7 @@ out:
311 311
312void page_unlock_anon_vma(struct anon_vma *anon_vma) 312void page_unlock_anon_vma(struct anon_vma *anon_vma)
313{ 313{
314 spin_unlock(&anon_vma->lock); 314 anon_vma_unlock(anon_vma);
315 rcu_read_unlock(); 315 rcu_read_unlock();
316} 316}
317 317
@@ -1389,7 +1389,7 @@ static int rmap_walk_anon(struct page *page, int (*rmap_one)(struct page *,
1389 anon_vma = page_anon_vma(page); 1389 anon_vma = page_anon_vma(page);
1390 if (!anon_vma) 1390 if (!anon_vma)
1391 return ret; 1391 return ret;
1392 spin_lock(&anon_vma->lock); 1392 anon_vma_lock(anon_vma);
1393 list_for_each_entry(avc, &anon_vma->head, same_anon_vma) { 1393 list_for_each_entry(avc, &anon_vma->head, same_anon_vma) {
1394 struct vm_area_struct *vma = avc->vma; 1394 struct vm_area_struct *vma = avc->vma;
1395 unsigned long address = vma_address(page, vma); 1395 unsigned long address = vma_address(page, vma);
@@ -1399,7 +1399,7 @@ static int rmap_walk_anon(struct page *page, int (*rmap_one)(struct page *,
1399 if (ret != SWAP_AGAIN) 1399 if (ret != SWAP_AGAIN)
1400 break; 1400 break;
1401 } 1401 }
1402 spin_unlock(&anon_vma->lock); 1402 anon_vma_unlock(anon_vma);
1403 return ret; 1403 return ret;
1404} 1404}
1405 1405