mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-29 13:53:33 +00:00
slub: Convert to hotplug state machine
Install the callbacks via the state machine. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Pekka Enberg <penberg@kernel.org> Cc: linux-mm@kvack.org Cc: rt@linutronix.de Cc: David Rientjes <rientjes@google.com> Cc: Christoph Lameter <cl@linux.com> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com> Link: http://lkml.kernel.org/r/20160818125731.27256-5-bigeasy@linutronix.de Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
This commit is contained in:
parent
6731d4f123
commit
a96a87bf94
2 changed files with 22 additions and 44 deletions
|
@ -15,6 +15,7 @@ enum cpuhp_state {
|
||||||
CPUHP_X86_HPET_DEAD,
|
CPUHP_X86_HPET_DEAD,
|
||||||
CPUHP_X86_APB_DEAD,
|
CPUHP_X86_APB_DEAD,
|
||||||
CPUHP_VIRT_NET_DEAD,
|
CPUHP_VIRT_NET_DEAD,
|
||||||
|
CPUHP_SLUB_DEAD,
|
||||||
CPUHP_WORKQUEUE_PREP,
|
CPUHP_WORKQUEUE_PREP,
|
||||||
CPUHP_POWER_NUMA_PREPARE,
|
CPUHP_POWER_NUMA_PREPARE,
|
||||||
CPUHP_HRTIMERS_PREPARE,
|
CPUHP_HRTIMERS_PREPARE,
|
||||||
|
|
65
mm/slub.c
65
mm/slub.c
|
@ -194,10 +194,6 @@ static inline bool kmem_cache_has_cpu_partial(struct kmem_cache *s)
|
||||||
#define __OBJECT_POISON 0x80000000UL /* Poison object */
|
#define __OBJECT_POISON 0x80000000UL /* Poison object */
|
||||||
#define __CMPXCHG_DOUBLE 0x40000000UL /* Use cmpxchg_double */
|
#define __CMPXCHG_DOUBLE 0x40000000UL /* Use cmpxchg_double */
|
||||||
|
|
||||||
#ifdef CONFIG_SMP
|
|
||||||
static struct notifier_block slab_notifier;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Tracking user of a slab.
|
* Tracking user of a slab.
|
||||||
*/
|
*/
|
||||||
|
@ -2304,6 +2300,25 @@ static void flush_all(struct kmem_cache *s)
|
||||||
on_each_cpu_cond(has_cpu_slab, flush_cpu_slab, s, 1, GFP_ATOMIC);
|
on_each_cpu_cond(has_cpu_slab, flush_cpu_slab, s, 1, GFP_ATOMIC);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Use the cpu notifier to insure that the cpu slabs are flushed when
|
||||||
|
* necessary.
|
||||||
|
*/
|
||||||
|
static int slub_cpu_dead(unsigned int cpu)
|
||||||
|
{
|
||||||
|
struct kmem_cache *s;
|
||||||
|
unsigned long flags;
|
||||||
|
|
||||||
|
mutex_lock(&slab_mutex);
|
||||||
|
list_for_each_entry(s, &slab_caches, list) {
|
||||||
|
local_irq_save(flags);
|
||||||
|
__flush_cpu_slab(s, cpu);
|
||||||
|
local_irq_restore(flags);
|
||||||
|
}
|
||||||
|
mutex_unlock(&slab_mutex);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check if the objects in a per cpu structure fit numa
|
* Check if the objects in a per cpu structure fit numa
|
||||||
* locality expectations.
|
* locality expectations.
|
||||||
|
@ -4144,9 +4159,8 @@ void __init kmem_cache_init(void)
|
||||||
/* Setup random freelists for each cache */
|
/* Setup random freelists for each cache */
|
||||||
init_freelist_randomization();
|
init_freelist_randomization();
|
||||||
|
|
||||||
#ifdef CONFIG_SMP
|
cpuhp_setup_state_nocalls(CPUHP_SLUB_DEAD, "slub:dead", NULL,
|
||||||
register_cpu_notifier(&slab_notifier);
|
slub_cpu_dead);
|
||||||
#endif
|
|
||||||
|
|
||||||
pr_info("SLUB: HWalign=%d, Order=%d-%d, MinObjects=%d, CPUs=%d, Nodes=%d\n",
|
pr_info("SLUB: HWalign=%d, Order=%d-%d, MinObjects=%d, CPUs=%d, Nodes=%d\n",
|
||||||
cache_line_size(),
|
cache_line_size(),
|
||||||
|
@ -4210,43 +4224,6 @@ int __kmem_cache_create(struct kmem_cache *s, unsigned long flags)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_SMP
|
|
||||||
/*
|
|
||||||
* Use the cpu notifier to insure that the cpu slabs are flushed when
|
|
||||||
* necessary.
|
|
||||||
*/
|
|
||||||
static int slab_cpuup_callback(struct notifier_block *nfb,
|
|
||||||
unsigned long action, void *hcpu)
|
|
||||||
{
|
|
||||||
long cpu = (long)hcpu;
|
|
||||||
struct kmem_cache *s;
|
|
||||||
unsigned long flags;
|
|
||||||
|
|
||||||
switch (action) {
|
|
||||||
case CPU_UP_CANCELED:
|
|
||||||
case CPU_UP_CANCELED_FROZEN:
|
|
||||||
case CPU_DEAD:
|
|
||||||
case CPU_DEAD_FROZEN:
|
|
||||||
mutex_lock(&slab_mutex);
|
|
||||||
list_for_each_entry(s, &slab_caches, list) {
|
|
||||||
local_irq_save(flags);
|
|
||||||
__flush_cpu_slab(s, cpu);
|
|
||||||
local_irq_restore(flags);
|
|
||||||
}
|
|
||||||
mutex_unlock(&slab_mutex);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
return NOTIFY_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
static struct notifier_block slab_notifier = {
|
|
||||||
.notifier_call = slab_cpuup_callback
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void *__kmalloc_track_caller(size_t size, gfp_t gfpflags, unsigned long caller)
|
void *__kmalloc_track_caller(size_t size, gfp_t gfpflags, unsigned long caller)
|
||||||
{
|
{
|
||||||
struct kmem_cache *s;
|
struct kmem_cache *s;
|
||||||
|
|
Loading…
Reference in a new issue