Index: linux-2.6.18-rc4/mm/mempolicy.c =================================================================== --- linux-2.6.18-rc4.orig/mm/mempolicy.c 2006-08-06 11:20:11.000000000 -0700 +++ linux-2.6.18-rc4/mm/mempolicy.c 2006-08-12 08:00:53.694023478 -0700 @@ -89,6 +89,7 @@ #include #include #include +#include #include #include @@ -98,8 +99,8 @@ #define MPOL_MF_INVERT (MPOL_MF_INTERNAL << 1) /* Invert check for nodemask */ #define MPOL_MF_STATS (MPOL_MF_INTERNAL << 2) /* Gather statistics */ -static struct kmem_cache *policy_cache; -static struct kmem_cache *sn_cache; +static struct slab policy_cache; +static struct slab sn_cache; #define PDprintk(fmt...) @@ -167,7 +168,7 @@ static struct mempolicy *mpol_new(int mo PDprintk("setting mode %d nodes[0] %lx\n", mode, nodes_addr(*nodes)[0]); if (mode == MPOL_DEFAULT) return NULL; - policy = kmem_cache_alloc(policy_cache, GFP_KERNEL); + policy = slab_alloc(&policy_cache, GFP_KERNEL); if (!policy) return ERR_PTR(-ENOMEM); atomic_set(&policy->refcnt, 1); @@ -175,7 +176,7 @@ static struct mempolicy *mpol_new(int mo case MPOL_INTERLEAVE: policy->v.nodes = *nodes; if (nodes_weight(*nodes) == 0) { - kmem_cache_free(policy_cache, policy); + slab_free(&policy_cache, policy); return ERR_PTR(-EINVAL); } break; @@ -187,7 +188,7 @@ static struct mempolicy *mpol_new(int mo case MPOL_BIND: policy->v.zonelist = bind_zonelist(nodes); if (policy->v.zonelist == NULL) { - kmem_cache_free(policy_cache, policy); + slab_free(&policy_cache, policy); return ERR_PTR(-ENOMEM); } break; @@ -1297,7 +1298,7 @@ void *cpuset_being_rebound; /* Slow path of a mempolicy copy */ struct mempolicy *__mpol_copy(struct mempolicy *old) { - struct mempolicy *new = kmem_cache_alloc(policy_cache, GFP_KERNEL); + struct mempolicy *new = slab_alloc(&policy_cache, GFP_KERNEL); if (!new) return ERR_PTR(-ENOMEM); @@ -1311,7 +1312,7 @@ struct mempolicy *__mpol_copy(struct mem int sz = ksize(old->v.zonelist); new->v.zonelist = kmalloc(sz, SLAB_KERNEL); if (!new->v.zonelist) { - kmem_cache_free(policy_cache, new); + slab_free(&policy_cache, new); return ERR_PTR(-ENOMEM); } memcpy(new->v.zonelist, old->v.zonelist, sz); @@ -1354,7 +1355,7 @@ void __mpol_free(struct mempolicy *p) if (p->policy == MPOL_BIND) kfree(p->v.zonelist); p->policy = MPOL_DEFAULT; - kmem_cache_free(policy_cache, p); + slab_free(&policy_cache, p); } /* @@ -1446,13 +1447,13 @@ static void sp_delete(struct shared_poli PDprintk("deleting %lx-l%x\n", n->start, n->end); rb_erase(&n->nd, &sp->root); mpol_free(n->policy); - kmem_cache_free(sn_cache, n); + slab_free(&sn_cache, n); } struct sp_node * sp_alloc(unsigned long start, unsigned long end, struct mempolicy *pol) { - struct sp_node *n = kmem_cache_alloc(sn_cache, GFP_KERNEL); + struct sp_node *n = slab_alloc(&sn_cache, GFP_KERNEL); if (!n) return NULL; @@ -1506,7 +1507,7 @@ restart: spin_unlock(&sp->lock); if (new2) { mpol_free(new2->policy); - kmem_cache_free(sn_cache, new2); + slab_free(&sn_cache, new2); } return 0; } @@ -1554,7 +1555,7 @@ int mpol_set_shared_policy(struct shared } err = shared_policy_replace(info, vma->vm_pgoff, vma->vm_pgoff+sz, new); if (err && new) - kmem_cache_free(sn_cache, new); + slab_free(&sn_cache, new); return err; } @@ -1573,7 +1574,7 @@ void mpol_free_shared_policy(struct shar next = rb_next(&n->nd); rb_erase(&n->nd, &p->root); mpol_free(n->policy); - kmem_cache_free(sn_cache, n); + slab_free(&sn_cache, n); } spin_unlock(&p->lock); } @@ -1581,13 +1582,17 @@ void mpol_free_shared_policy(struct shar /* assumes fs == KERNEL_DS */ void __init numa_policy_init(void) { - policy_cache = kmem_cache_create("numa_policy", - sizeof(struct mempolicy), - 0, SLAB_PANIC, NULL, NULL); - - sn_cache = kmem_cache_create("shared_policy_node", - sizeof(struct sp_node), - 0, SLAB_PANIC, NULL, NULL); + if (slab_create(&policy_cache, + ALIGN(sizeof(struct mempolicy), + L1_CACHE_BYTES), + 2, &page_allocator, 0)) + panic("Failed to initialize policy cache\n"); + + if (slab_create(&sn_cache, + ALIGN(sizeof(struct sp_node), + L1_CACHE_BYTES), + 2, &page_allocator, 0)) + panic("Failed to initialize shared_policy cache\n"); /* Set interleaving policy for system init. This way not all the data structures allocated at system boot end up in node zero. */