Commit 6751fb3c authored by Steffen Klassert's avatar Steffen Klassert Committed by Herbert Xu

padata: Use get_online_cpus/put_online_cpus

This patch puts get_online_cpus/put_online_cpus around the places
we modify the padata cpumask to ensure that no cpu goes offline
during this operation.
Signed-off-by: default avatarSteffen Klassert <steffen.klassert@secunet.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 7b389b2c
...@@ -441,6 +441,8 @@ int padata_set_cpumask(struct padata_instance *pinst, ...@@ -441,6 +441,8 @@ int padata_set_cpumask(struct padata_instance *pinst,
mutex_lock(&pinst->lock); mutex_lock(&pinst->lock);
get_online_cpus();
pd = padata_alloc_pd(pinst, cpumask); pd = padata_alloc_pd(pinst, cpumask);
if (!pd) { if (!pd) {
err = -ENOMEM; err = -ENOMEM;
...@@ -452,6 +454,8 @@ int padata_set_cpumask(struct padata_instance *pinst, ...@@ -452,6 +454,8 @@ int padata_set_cpumask(struct padata_instance *pinst,
padata_replace(pinst, pd); padata_replace(pinst, pd);
out: out:
put_online_cpus();
mutex_unlock(&pinst->lock); mutex_unlock(&pinst->lock);
return err; return err;
...@@ -485,8 +489,10 @@ int padata_add_cpu(struct padata_instance *pinst, int cpu) ...@@ -485,8 +489,10 @@ int padata_add_cpu(struct padata_instance *pinst, int cpu)
mutex_lock(&pinst->lock); mutex_lock(&pinst->lock);
get_online_cpus();
cpumask_set_cpu(cpu, pinst->cpumask); cpumask_set_cpu(cpu, pinst->cpumask);
err = __padata_add_cpu(pinst, cpu); err = __padata_add_cpu(pinst, cpu);
put_online_cpus();
mutex_unlock(&pinst->lock); mutex_unlock(&pinst->lock);
...@@ -521,8 +527,10 @@ int padata_remove_cpu(struct padata_instance *pinst, int cpu) ...@@ -521,8 +527,10 @@ int padata_remove_cpu(struct padata_instance *pinst, int cpu)
mutex_lock(&pinst->lock); mutex_lock(&pinst->lock);
get_online_cpus();
cpumask_clear_cpu(cpu, pinst->cpumask); cpumask_clear_cpu(cpu, pinst->cpumask);
err = __padata_remove_cpu(pinst, cpu); err = __padata_remove_cpu(pinst, cpu);
put_online_cpus();
mutex_unlock(&pinst->lock); mutex_unlock(&pinst->lock);
...@@ -626,6 +634,8 @@ struct padata_instance *padata_alloc(const struct cpumask *cpumask, ...@@ -626,6 +634,8 @@ struct padata_instance *padata_alloc(const struct cpumask *cpumask,
if (!pinst) if (!pinst)
goto err; goto err;
get_online_cpus();
pd = padata_alloc_pd(pinst, cpumask); pd = padata_alloc_pd(pinst, cpumask);
if (!pd) if (!pd)
goto err_free_inst; goto err_free_inst;
...@@ -647,6 +657,8 @@ struct padata_instance *padata_alloc(const struct cpumask *cpumask, ...@@ -647,6 +657,8 @@ struct padata_instance *padata_alloc(const struct cpumask *cpumask,
register_hotcpu_notifier(&pinst->cpu_notifier); register_hotcpu_notifier(&pinst->cpu_notifier);
#endif #endif
put_online_cpus();
mutex_init(&pinst->lock); mutex_init(&pinst->lock);
return pinst; return pinst;
...@@ -655,6 +667,7 @@ struct padata_instance *padata_alloc(const struct cpumask *cpumask, ...@@ -655,6 +667,7 @@ struct padata_instance *padata_alloc(const struct cpumask *cpumask,
padata_free_pd(pd); padata_free_pd(pd);
err_free_inst: err_free_inst:
kfree(pinst); kfree(pinst);
put_online_cpus();
err: err:
return NULL; return NULL;
} }
......
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