diff options
Diffstat (limited to 'mm/mempolicy.c')
-rw-r--r-- | mm/mempolicy.c | 51 |
1 files changed, 38 insertions, 13 deletions
diff --git a/mm/mempolicy.c b/mm/mempolicy.c index d76e8eb342d0..188f8d9c4aed 100644 --- a/mm/mempolicy.c +++ b/mm/mempolicy.c | |||
@@ -101,8 +101,6 @@ | |||
101 | static struct kmem_cache *policy_cache; | 101 | static struct kmem_cache *policy_cache; |
102 | static struct kmem_cache *sn_cache; | 102 | static struct kmem_cache *sn_cache; |
103 | 103 | ||
104 | #define PDprintk(fmt...) | ||
105 | |||
106 | /* Highest zone. An specific allocation for a zone below that is not | 104 | /* Highest zone. An specific allocation for a zone below that is not |
107 | policied. */ | 105 | policied. */ |
108 | enum zone_type policy_zone = 0; | 106 | enum zone_type policy_zone = 0; |
@@ -175,7 +173,9 @@ static struct mempolicy *mpol_new(int mode, nodemask_t *nodes) | |||
175 | { | 173 | { |
176 | struct mempolicy *policy; | 174 | struct mempolicy *policy; |
177 | 175 | ||
178 | PDprintk("setting mode %d nodes[0] %lx\n", mode, nodes_addr(*nodes)[0]); | 176 | pr_debug("setting mode %d nodes[0] %lx\n", |
177 | mode, nodes ? nodes_addr(*nodes)[0] : -1); | ||
178 | |||
179 | if (mode == MPOL_DEFAULT) | 179 | if (mode == MPOL_DEFAULT) |
180 | return NULL; | 180 | return NULL; |
181 | policy = kmem_cache_alloc(policy_cache, GFP_KERNEL); | 181 | policy = kmem_cache_alloc(policy_cache, GFP_KERNEL); |
@@ -379,7 +379,7 @@ static int policy_vma(struct vm_area_struct *vma, struct mempolicy *new) | |||
379 | int err = 0; | 379 | int err = 0; |
380 | struct mempolicy *old = vma->vm_policy; | 380 | struct mempolicy *old = vma->vm_policy; |
381 | 381 | ||
382 | PDprintk("vma %lx-%lx/%lx vm_ops %p vm_file %p set_policy %p\n", | 382 | pr_debug("vma %lx-%lx/%lx vm_ops %p vm_file %p set_policy %p\n", |
383 | vma->vm_start, vma->vm_end, vma->vm_pgoff, | 383 | vma->vm_start, vma->vm_end, vma->vm_pgoff, |
384 | vma->vm_ops, vma->vm_file, | 384 | vma->vm_ops, vma->vm_file, |
385 | vma->vm_ops ? vma->vm_ops->set_policy : NULL); | 385 | vma->vm_ops ? vma->vm_ops->set_policy : NULL); |
@@ -776,8 +776,8 @@ long do_mbind(unsigned long start, unsigned long len, | |||
776 | if (!new) | 776 | if (!new) |
777 | flags |= MPOL_MF_DISCONTIG_OK; | 777 | flags |= MPOL_MF_DISCONTIG_OK; |
778 | 778 | ||
779 | PDprintk("mbind %lx-%lx mode:%ld nodes:%lx\n",start,start+len, | 779 | pr_debug("mbind %lx-%lx mode:%ld nodes:%lx\n",start,start+len, |
780 | mode,nodes_addr(nodes)[0]); | 780 | mode, nmask ? nodes_addr(*nmask)[0] : -1); |
781 | 781 | ||
782 | down_write(&mm->mmap_sem); | 782 | down_write(&mm->mmap_sem); |
783 | vma = check_range(mm, start, end, nmask, | 783 | vma = check_range(mm, start, end, nmask, |
@@ -1434,7 +1434,7 @@ static void sp_insert(struct shared_policy *sp, struct sp_node *new) | |||
1434 | } | 1434 | } |
1435 | rb_link_node(&new->nd, parent, p); | 1435 | rb_link_node(&new->nd, parent, p); |
1436 | rb_insert_color(&new->nd, &sp->root); | 1436 | rb_insert_color(&new->nd, &sp->root); |
1437 | PDprintk("inserting %lx-%lx: %d\n", new->start, new->end, | 1437 | pr_debug("inserting %lx-%lx: %d\n", new->start, new->end, |
1438 | new->policy ? new->policy->policy : 0); | 1438 | new->policy ? new->policy->policy : 0); |
1439 | } | 1439 | } |
1440 | 1440 | ||
@@ -1459,7 +1459,7 @@ mpol_shared_policy_lookup(struct shared_policy *sp, unsigned long idx) | |||
1459 | 1459 | ||
1460 | static void sp_delete(struct shared_policy *sp, struct sp_node *n) | 1460 | static void sp_delete(struct shared_policy *sp, struct sp_node *n) |
1461 | { | 1461 | { |
1462 | PDprintk("deleting %lx-l%x\n", n->start, n->end); | 1462 | pr_debug("deleting %lx-l%lx\n", n->start, n->end); |
1463 | rb_erase(&n->nd, &sp->root); | 1463 | rb_erase(&n->nd, &sp->root); |
1464 | mpol_free(n->policy); | 1464 | mpol_free(n->policy); |
1465 | kmem_cache_free(sn_cache, n); | 1465 | kmem_cache_free(sn_cache, n); |
@@ -1558,10 +1558,10 @@ int mpol_set_shared_policy(struct shared_policy *info, | |||
1558 | struct sp_node *new = NULL; | 1558 | struct sp_node *new = NULL; |
1559 | unsigned long sz = vma_pages(vma); | 1559 | unsigned long sz = vma_pages(vma); |
1560 | 1560 | ||
1561 | PDprintk("set_shared_policy %lx sz %lu %d %lx\n", | 1561 | pr_debug("set_shared_policy %lx sz %lu %d %lx\n", |
1562 | vma->vm_pgoff, | 1562 | vma->vm_pgoff, |
1563 | sz, npol? npol->policy : -1, | 1563 | sz, npol? npol->policy : -1, |
1564 | npol ? nodes_addr(npol->v.nodes)[0] : -1); | 1564 | npol ? nodes_addr(npol->v.nodes)[0] : -1); |
1565 | 1565 | ||
1566 | if (npol) { | 1566 | if (npol) { |
1567 | new = sp_alloc(vma->vm_pgoff, vma->vm_pgoff + sz, npol); | 1567 | new = sp_alloc(vma->vm_pgoff, vma->vm_pgoff + sz, npol); |
@@ -1597,6 +1597,10 @@ void mpol_free_shared_policy(struct shared_policy *p) | |||
1597 | /* assumes fs == KERNEL_DS */ | 1597 | /* assumes fs == KERNEL_DS */ |
1598 | void __init numa_policy_init(void) | 1598 | void __init numa_policy_init(void) |
1599 | { | 1599 | { |
1600 | nodemask_t interleave_nodes; | ||
1601 | unsigned long largest = 0; | ||
1602 | int nid, prefer = 0; | ||
1603 | |||
1600 | policy_cache = kmem_cache_create("numa_policy", | 1604 | policy_cache = kmem_cache_create("numa_policy", |
1601 | sizeof(struct mempolicy), | 1605 | sizeof(struct mempolicy), |
1602 | 0, SLAB_PANIC, NULL, NULL); | 1606 | 0, SLAB_PANIC, NULL, NULL); |
@@ -1605,10 +1609,31 @@ void __init numa_policy_init(void) | |||
1605 | sizeof(struct sp_node), | 1609 | sizeof(struct sp_node), |
1606 | 0, SLAB_PANIC, NULL, NULL); | 1610 | 0, SLAB_PANIC, NULL, NULL); |
1607 | 1611 | ||
1608 | /* Set interleaving policy for system init. This way not all | 1612 | /* |
1609 | the data structures allocated at system boot end up in node zero. */ | 1613 | * Set interleaving policy for system init. Interleaving is only |
1614 | * enabled across suitably sized nodes (default is >= 16MB), or | ||
1615 | * fall back to the largest node if they're all smaller. | ||
1616 | */ | ||
1617 | nodes_clear(interleave_nodes); | ||
1618 | for_each_online_node(nid) { | ||
1619 | unsigned long total_pages = node_present_pages(nid); | ||
1620 | |||
1621 | /* Preserve the largest node */ | ||
1622 | if (largest < total_pages) { | ||
1623 | largest = total_pages; | ||
1624 | prefer = nid; | ||
1625 | } | ||
1626 | |||
1627 | /* Interleave this node? */ | ||
1628 | if ((total_pages << PAGE_SHIFT) >= (16 << 20)) | ||
1629 | node_set(nid, interleave_nodes); | ||
1630 | } | ||
1631 | |||
1632 | /* All too small, use the largest */ | ||
1633 | if (unlikely(nodes_empty(interleave_nodes))) | ||
1634 | node_set(prefer, interleave_nodes); | ||
1610 | 1635 | ||
1611 | if (do_set_mempolicy(MPOL_INTERLEAVE, &node_online_map)) | 1636 | if (do_set_mempolicy(MPOL_INTERLEAVE, &interleave_nodes)) |
1612 | printk("numa_policy_init: interleaving failed\n"); | 1637 | printk("numa_policy_init: interleaving failed\n"); |
1613 | } | 1638 | } |
1614 | 1639 | ||