mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 19:51:31 -04:00
cpu-hotplug: replace per-subsystem mutexes with get_online_cpus()
This patch converts the known per-subsystem mutexes to get_online_cpus put_online_cpus. It also eliminates the CPU_LOCK_ACQUIRE and CPU_LOCK_RELEASE hotplug notification events. Signed-off-by: Gautham R Shenoy <[email protected]> Signed-off-by: Ingo Molnar <[email protected]>
This commit is contained in:
parent
86ef5c9a8e
commit
95402b3829
5 changed files with 36 additions and 50 deletions
18
mm/slab.c
18
mm/slab.c
|
|
@ -730,8 +730,7 @@ static inline void init_lock_keys(void)
|
|||
#endif
|
||||
|
||||
/*
|
||||
* 1. Guard access to the cache-chain.
|
||||
* 2. Protect sanity of cpu_online_map against cpu hotplug events
|
||||
* Guard access to the cache-chain.
|
||||
*/
|
||||
static DEFINE_MUTEX(cache_chain_mutex);
|
||||
static struct list_head cache_chain;
|
||||
|
|
@ -1331,12 +1330,11 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
|
|||
int err = 0;
|
||||
|
||||
switch (action) {
|
||||
case CPU_LOCK_ACQUIRE:
|
||||
mutex_lock(&cache_chain_mutex);
|
||||
break;
|
||||
case CPU_UP_PREPARE:
|
||||
case CPU_UP_PREPARE_FROZEN:
|
||||
mutex_lock(&cache_chain_mutex);
|
||||
err = cpuup_prepare(cpu);
|
||||
mutex_unlock(&cache_chain_mutex);
|
||||
break;
|
||||
case CPU_ONLINE:
|
||||
case CPU_ONLINE_FROZEN:
|
||||
|
|
@ -1373,9 +1371,8 @@ static int __cpuinit cpuup_callback(struct notifier_block *nfb,
|
|||
#endif
|
||||
case CPU_UP_CANCELED:
|
||||
case CPU_UP_CANCELED_FROZEN:
|
||||
mutex_lock(&cache_chain_mutex);
|
||||
cpuup_canceled(cpu);
|
||||
break;
|
||||
case CPU_LOCK_RELEASE:
|
||||
mutex_unlock(&cache_chain_mutex);
|
||||
break;
|
||||
}
|
||||
|
|
@ -2170,6 +2167,7 @@ kmem_cache_create (const char *name, size_t size, size_t align,
|
|||
* We use cache_chain_mutex to ensure a consistent view of
|
||||
* cpu_online_map as well. Please see cpuup_callback
|
||||
*/
|
||||
get_online_cpus();
|
||||
mutex_lock(&cache_chain_mutex);
|
||||
|
||||
list_for_each_entry(pc, &cache_chain, next) {
|
||||
|
|
@ -2396,6 +2394,7 @@ oops:
|
|||
panic("kmem_cache_create(): failed to create slab `%s'\n",
|
||||
name);
|
||||
mutex_unlock(&cache_chain_mutex);
|
||||
put_online_cpus();
|
||||
return cachep;
|
||||
}
|
||||
EXPORT_SYMBOL(kmem_cache_create);
|
||||
|
|
@ -2547,9 +2546,11 @@ int kmem_cache_shrink(struct kmem_cache *cachep)
|
|||
int ret;
|
||||
BUG_ON(!cachep || in_interrupt());
|
||||
|
||||
get_online_cpus();
|
||||
mutex_lock(&cache_chain_mutex);
|
||||
ret = __cache_shrink(cachep);
|
||||
mutex_unlock(&cache_chain_mutex);
|
||||
put_online_cpus();
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL(kmem_cache_shrink);
|
||||
|
|
@ -2575,6 +2576,7 @@ void kmem_cache_destroy(struct kmem_cache *cachep)
|
|||
BUG_ON(!cachep || in_interrupt());
|
||||
|
||||
/* Find the cache in the chain of caches. */
|
||||
get_online_cpus();
|
||||
mutex_lock(&cache_chain_mutex);
|
||||
/*
|
||||
* the chain is never empty, cache_cache is never destroyed
|
||||
|
|
@ -2584,6 +2586,7 @@ void kmem_cache_destroy(struct kmem_cache *cachep)
|
|||
slab_error(cachep, "Can't free all objects");
|
||||
list_add(&cachep->next, &cache_chain);
|
||||
mutex_unlock(&cache_chain_mutex);
|
||||
put_online_cpus();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -2592,6 +2595,7 @@ void kmem_cache_destroy(struct kmem_cache *cachep)
|
|||
|
||||
__kmem_cache_destroy(cachep);
|
||||
mutex_unlock(&cache_chain_mutex);
|
||||
put_online_cpus();
|
||||
}
|
||||
EXPORT_SYMBOL(kmem_cache_destroy);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue