]> git.neil.brown.name Git - history.git/commitdiff
[PATCH] slab: Use CPU notifiers
authorAndrew Morton <akpm@digeo.com>
Wed, 30 Oct 2002 07:25:42 +0000 (23:25 -0800)
committerLinus Torvalds <torvalds@penguin.transmeta.com>
Wed, 30 Oct 2002 07:25:42 +0000 (23:25 -0800)
- 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.

mm/slab.c

index 2f090f0bbbc22168bb137a0ea332f54de862beef..e6434da2b762712c3a36cdbe6699e6766b6cd22b 100644 (file)
--- a/mm/slab.c
+++ b/mm/slab.c
@@ -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) {
-               struct list_head *p;
-               struct array_cache *nc;
+       long cpu = (long)hcpu;
+       struct list_head *p;
 
+       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);