• Martin Peschke's avatar
    [PATCH] CPU hotplug compatible alloc_percpu() · 7ff6f082
    Martin Peschke authored
    This patch splits alloc_percpu() up into two phases.  Likewise for
    free_percpu().  This allows clients to limit initial allocations to online
    cpu's, and to populate or depopulate per-cpu data at run time as needed:
    
      struct my_struct *obj;
    
      /* initial allocation for online cpu's */
      obj = percpu_alloc(sizeof(struct my_struct), GFP_KERNEL);
    
      ...
    
      /* populate per-cpu data for cpu coming online */
      ptr = percpu_populate(obj, sizeof(struct my_struct), GFP_KERNEL, cpu);
    
      ...
    
      /* access per-cpu object */
      ptr = percpu_ptr(obj, smp_processor_id());
    
      ...
    
      /* depopulate per-cpu data for cpu going offline */
      percpu_depopulate(obj, cpu);
    
      ...
    
      /* final removal */
      percpu_free(obj);
    Signed-off-by: default avatarMartin Peschke <mp3@de.ibm.com>
    Cc: Paul Jackson <pj@sgi.com>
    Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
    Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
    7ff6f082
percpu.h 3.05 KB