Commit d544abd5 authored by Sebastian Andrzej Siewior's avatar Sebastian Andrzej Siewior Committed by Thomas Gleixner

lib/radix-tree: Convert to hotplug state machine

Install the callbacks via the state machine.
Signed-off-by: default avatarSebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: rt@linutronix.de
Link: http://lkml.kernel.org/r/20161103145021.28528-6-bigeasy@linutronix.deSigned-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
parent 5588f5af
...@@ -34,6 +34,7 @@ enum cpuhp_state { ...@@ -34,6 +34,7 @@ enum cpuhp_state {
CPUHP_PRINTK_DEAD, CPUHP_PRINTK_DEAD,
CPUHP_MM_MEMCQ_DEAD, CPUHP_MM_MEMCQ_DEAD,
CPUHP_PERCPU_CNT_DEAD, CPUHP_PERCPU_CNT_DEAD,
CPUHP_RADIX_DEAD,
CPUHP_WORKQUEUE_PREP, CPUHP_WORKQUEUE_PREP,
CPUHP_POWER_NUMA_PREPARE, CPUHP_POWER_NUMA_PREPARE,
CPUHP_HRTIMERS_PREPARE, CPUHP_HRTIMERS_PREPARE,
......
...@@ -1642,32 +1642,31 @@ static __init void radix_tree_init_maxnodes(void) ...@@ -1642,32 +1642,31 @@ static __init void radix_tree_init_maxnodes(void)
} }
} }
static int radix_tree_callback(struct notifier_block *nfb, static int radix_tree_cpu_dead(unsigned int cpu)
unsigned long action, void *hcpu)
{ {
int cpu = (long)hcpu;
struct radix_tree_preload *rtp; struct radix_tree_preload *rtp;
struct radix_tree_node *node; struct radix_tree_node *node;
/* Free per-cpu pool of preloaded nodes */ /* Free per-cpu pool of preloaded nodes */
if (action == CPU_DEAD || action == CPU_DEAD_FROZEN) { rtp = &per_cpu(radix_tree_preloads, cpu);
rtp = &per_cpu(radix_tree_preloads, cpu); while (rtp->nr) {
while (rtp->nr) { node = rtp->nodes;
node = rtp->nodes; rtp->nodes = node->private_data;
rtp->nodes = node->private_data; kmem_cache_free(radix_tree_node_cachep, node);
kmem_cache_free(radix_tree_node_cachep, node); rtp->nr--;
rtp->nr--;
}
} }
return NOTIFY_OK; return 0;
} }
void __init radix_tree_init(void) void __init radix_tree_init(void)
{ {
int ret;
radix_tree_node_cachep = kmem_cache_create("radix_tree_node", radix_tree_node_cachep = kmem_cache_create("radix_tree_node",
sizeof(struct radix_tree_node), 0, sizeof(struct radix_tree_node), 0,
SLAB_PANIC | SLAB_RECLAIM_ACCOUNT, SLAB_PANIC | SLAB_RECLAIM_ACCOUNT,
radix_tree_node_ctor); radix_tree_node_ctor);
radix_tree_init_maxnodes(); radix_tree_init_maxnodes();
hotcpu_notifier(radix_tree_callback, 0); ret = cpuhp_setup_state_nocalls(CPUHP_RADIX_DEAD, "lib/radix:dead",
NULL, radix_tree_cpu_dead);
WARN_ON(ret < 0);
} }
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