aboutsummaryrefslogtreecommitdiffstats
path: root/mm/mempolicy.c
diff options
context:
space:
mode:
authorLee Schermerhorn <lee.schermerhorn@hp.com>2008-04-28 05:13:08 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-28 11:58:23 -0400
commitf0be3d32b05d3fea2fcdbbb81a39dac2a7163169 (patch)
tree5794ce6a8befbce82cd3e44ff15fbf3bb5f2f3bf /mm/mempolicy.c
parent3b1163006332302117b1b2acf226d4014ff46525 (diff)
mempolicy: rename mpol_free to mpol_put
This is a change that was requested some time ago by Mel Gorman. Makes sense to me, so here it is. Note: I retain the name "mpol_free_shared_policy()" because it actually does free the shared_policy, which is NOT a reference counted object. However, ... The mempolicy object[s] referenced by the shared_policy are reference counted, so mpol_put() is used to release the reference held by the shared_policy. The mempolicy might not be freed at this time, because some task attached to the shared object associated with the shared policy may be in the process of allocating a page based on the mempolicy. In that case, the task performing the allocation will hold a reference on the mempolicy, obtained via mpol_shared_policy_lookup(). The mempolicy will be freed when all tasks holding such a reference have called mpol_put() for the mempolicy. Signed-off-by: Lee Schermerhorn <lee.schermerhorn@hp.com> Cc: Christoph Lameter <clameter@sgi.com> Cc: David Rientjes <rientjes@google.com> Cc: Mel Gorman <mel@csn.ul.ie> Cc: Andi Kleen <ak@suse.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/mempolicy.c')
-rw-r--r--mm/mempolicy.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/mm/mempolicy.c b/mm/mempolicy.c
index c1b907789d84..ce2c5b6bf9f8 100644
--- a/mm/mempolicy.c
+++ b/mm/mempolicy.c
@@ -529,7 +529,7 @@ static int policy_vma(struct vm_area_struct *vma, struct mempolicy *new)
529 if (!err) { 529 if (!err) {
530 mpol_get(new); 530 mpol_get(new);
531 vma->vm_policy = new; 531 vma->vm_policy = new;
532 mpol_free(old); 532 mpol_put(old);
533 } 533 }
534 return err; 534 return err;
535} 535}
@@ -595,7 +595,7 @@ static long do_set_mempolicy(unsigned short mode, unsigned short flags,
595 new = mpol_new(mode, flags, nodes); 595 new = mpol_new(mode, flags, nodes);
596 if (IS_ERR(new)) 596 if (IS_ERR(new))
597 return PTR_ERR(new); 597 return PTR_ERR(new);
598 mpol_free(current->mempolicy); 598 mpol_put(current->mempolicy);
599 current->mempolicy = new; 599 current->mempolicy = new;
600 mpol_set_task_struct_flag(); 600 mpol_set_task_struct_flag();
601 if (new && new->policy == MPOL_INTERLEAVE && 601 if (new && new->policy == MPOL_INTERLEAVE &&
@@ -948,7 +948,7 @@ static long do_mbind(unsigned long start, unsigned long len,
948 } 948 }
949 949
950 up_write(&mm->mmap_sem); 950 up_write(&mm->mmap_sem);
951 mpol_free(new); 951 mpol_put(new);
952 return err; 952 return err;
953} 953}
954 954
@@ -1446,14 +1446,14 @@ struct zonelist *huge_zonelist(struct vm_area_struct *vma, unsigned long addr,
1446 nid = interleave_nid(pol, vma, addr, HPAGE_SHIFT); 1446 nid = interleave_nid(pol, vma, addr, HPAGE_SHIFT);
1447 if (unlikely(pol != &default_policy && 1447 if (unlikely(pol != &default_policy &&
1448 pol != current->mempolicy)) 1448 pol != current->mempolicy))
1449 __mpol_free(pol); /* finished with pol */ 1449 __mpol_put(pol); /* finished with pol */
1450 return node_zonelist(nid, gfp_flags); 1450 return node_zonelist(nid, gfp_flags);
1451 } 1451 }
1452 1452
1453 zl = zonelist_policy(GFP_HIGHUSER, pol); 1453 zl = zonelist_policy(GFP_HIGHUSER, pol);
1454 if (unlikely(pol != &default_policy && pol != current->mempolicy)) { 1454 if (unlikely(pol != &default_policy && pol != current->mempolicy)) {
1455 if (pol->policy != MPOL_BIND) 1455 if (pol->policy != MPOL_BIND)
1456 __mpol_free(pol); /* finished with pol */ 1456 __mpol_put(pol); /* finished with pol */
1457 else 1457 else
1458 *mpol = pol; /* unref needed after allocation */ 1458 *mpol = pol; /* unref needed after allocation */
1459 } 1459 }
@@ -1512,7 +1512,7 @@ alloc_page_vma(gfp_t gfp, struct vm_area_struct *vma, unsigned long addr)
1512 nid = interleave_nid(pol, vma, addr, PAGE_SHIFT); 1512 nid = interleave_nid(pol, vma, addr, PAGE_SHIFT);
1513 if (unlikely(pol != &default_policy && 1513 if (unlikely(pol != &default_policy &&
1514 pol != current->mempolicy)) 1514 pol != current->mempolicy))
1515 __mpol_free(pol); /* finished with pol */ 1515 __mpol_put(pol); /* finished with pol */
1516 return alloc_page_interleave(gfp, 0, nid); 1516 return alloc_page_interleave(gfp, 0, nid);
1517 } 1517 }
1518 zl = zonelist_policy(gfp, pol); 1518 zl = zonelist_policy(gfp, pol);
@@ -1522,7 +1522,7 @@ alloc_page_vma(gfp_t gfp, struct vm_area_struct *vma, unsigned long addr)
1522 */ 1522 */
1523 struct page *page = __alloc_pages_nodemask(gfp, 0, 1523 struct page *page = __alloc_pages_nodemask(gfp, 0,
1524 zl, nodemask_policy(gfp, pol)); 1524 zl, nodemask_policy(gfp, pol));
1525 __mpol_free(pol); 1525 __mpol_put(pol);
1526 return page; 1526 return page;
1527 } 1527 }
1528 /* 1528 /*
@@ -1624,7 +1624,7 @@ int __mpol_equal(struct mempolicy *a, struct mempolicy *b)
1624} 1624}
1625 1625
1626/* Slow path of a mpol destructor. */ 1626/* Slow path of a mpol destructor. */
1627void __mpol_free(struct mempolicy *p) 1627void __mpol_put(struct mempolicy *p)
1628{ 1628{
1629 if (!atomic_dec_and_test(&p->refcnt)) 1629 if (!atomic_dec_and_test(&p->refcnt))
1630 return; 1630 return;
@@ -1720,7 +1720,7 @@ static void sp_delete(struct shared_policy *sp, struct sp_node *n)
1720{ 1720{
1721 pr_debug("deleting %lx-l%lx\n", n->start, n->end); 1721 pr_debug("deleting %lx-l%lx\n", n->start, n->end);
1722 rb_erase(&n->nd, &sp->root); 1722 rb_erase(&n->nd, &sp->root);
1723 mpol_free(n->policy); 1723 mpol_put(n->policy);
1724 kmem_cache_free(sn_cache, n); 1724 kmem_cache_free(sn_cache, n);
1725} 1725}
1726 1726
@@ -1780,7 +1780,7 @@ restart:
1780 sp_insert(sp, new); 1780 sp_insert(sp, new);
1781 spin_unlock(&sp->lock); 1781 spin_unlock(&sp->lock);
1782 if (new2) { 1782 if (new2) {
1783 mpol_free(new2->policy); 1783 mpol_put(new2->policy);
1784 kmem_cache_free(sn_cache, new2); 1784 kmem_cache_free(sn_cache, new2);
1785 } 1785 }
1786 return 0; 1786 return 0;
@@ -1805,7 +1805,7 @@ void mpol_shared_policy_init(struct shared_policy *info, unsigned short policy,
1805 /* Policy covers entire file */ 1805 /* Policy covers entire file */
1806 pvma.vm_end = TASK_SIZE; 1806 pvma.vm_end = TASK_SIZE;
1807 mpol_set_shared_policy(info, &pvma, newpol); 1807 mpol_set_shared_policy(info, &pvma, newpol);
1808 mpol_free(newpol); 1808 mpol_put(newpol);
1809 } 1809 }
1810 } 1810 }
1811} 1811}
@@ -1848,7 +1848,7 @@ void mpol_free_shared_policy(struct shared_policy *p)
1848 n = rb_entry(next, struct sp_node, nd); 1848 n = rb_entry(next, struct sp_node, nd);
1849 next = rb_next(&n->nd); 1849 next = rb_next(&n->nd);
1850 rb_erase(&n->nd, &p->root); 1850 rb_erase(&n->nd, &p->root);
1851 mpol_free(n->policy); 1851 mpol_put(n->policy);
1852 kmem_cache_free(sn_cache, n); 1852 kmem_cache_free(sn_cache, n);
1853 } 1853 }
1854 spin_unlock(&p->lock); 1854 spin_unlock(&p->lock);
@@ -2068,7 +2068,7 @@ int show_numa_map(struct seq_file *m, void *v)
2068 * unref shared or other task's mempolicy 2068 * unref shared or other task's mempolicy
2069 */ 2069 */
2070 if (pol != &default_policy && pol != current->mempolicy) 2070 if (pol != &default_policy && pol != current->mempolicy)
2071 __mpol_free(pol); 2071 __mpol_put(pol);
2072 2072
2073 seq_printf(m, "%08lx %s", vma->vm_start, buffer); 2073 seq_printf(m, "%08lx %s", vma->vm_start, buffer);
2074 2074