Commit 4524ea04 authored by Andrew Morton's avatar Andrew Morton Committed by Linus Torvalds

[PATCH] slab: Use CPU notifiers

- allocate memory for cpu buffers in cpu_up_prepare

- start the timer in cpu_online

- free the memory for cpu buffers in cpu_up_cancel.
parent b464df2e
......@@ -524,15 +524,15 @@ static int __devinit cpuup_callback(struct notifier_block *nfb,
unsigned long action,
void *hcpu)
{
int cpu = (int)hcpu;
if (action == CPU_ONLINE) {
long cpu = (long)hcpu;
struct list_head *p;
struct array_cache *nc;
switch (action) {
case CPU_UP_PREPARE:
down(&cache_chain_sem);
list_for_each(p, &cache_chain) {
int memsize;
struct array_cache *nc;
kmem_cache_t* cachep = list_entry(p, kmem_cache_t, next);
memsize = sizeof(void*)*cachep->limit+sizeof(struct array_cache);
......@@ -551,12 +551,26 @@ static int __devinit cpuup_callback(struct notifier_block *nfb,
spin_unlock_irq(&cachep->spinlock);
}
up(&cache_chain_sem);
break;
case CPU_ONLINE:
if (g_cpucache_up == FULL)
start_cpu_timer(cpu);
break;
case CPU_UP_CANCELED:
down(&cache_chain_sem);
list_for_each(p, &cache_chain) {
struct array_cache *nc;
kmem_cache_t* cachep = list_entry(p, kmem_cache_t, next);
nc = cachep->array[cpu];
cachep->array[cpu] = NULL;
kfree(nc);
}
up(&cache_chain_sem);
break;
}
return NOTIFY_OK;
bad:
up(&cache_chain_sem);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment