aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/padata.c
diff options
context:
space:
mode:
authorSebastian Andrzej Siewior <bigeasy@linutronix.de>2017-05-24 04:15:18 -0400
committerThomas Gleixner <tglx@linutronix.de>2017-05-26 04:10:37 -0400
commitc5a81c8ff816d89941fe86961b286765d6ca2f5f (patch)
treee0b18776387a4f5759065ea2bfa271ea521a90bd /kernel/padata.c
parent9596695ee1e7eedd743c43811fe68299eb005b5c (diff)
padata: Avoid nested calls to cpus_read_lock() in pcrypt_init_padata()
pcrypt_init_padata() cpus_read_lock() padata_alloc_possible() padata_alloc() cpus_read_lock() The nested call to cpus_read_lock() works with the current implementation, but prevents the conversion to a percpu rwsem. The other caller of padata_alloc_possible() is pcrypt_init_padata() which calls from a cpus_read_lock() protected region as well. Remove the cpus_read_lock() call in padata_alloc() and document the calling convention. Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Acked-by: Ingo Molnar <mingo@kernel.org> Cc: Steffen Klassert <steffen.klassert@secunet.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: linux-crypto@vger.kernel.org Link: http://lkml.kernel.org/r/20170524081547.571278910@linutronix.de
Diffstat (limited to 'kernel/padata.c')
-rw-r--r--kernel/padata.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/kernel/padata.c b/kernel/padata.c
index 0c708f648853..868f947166d7 100644
--- a/kernel/padata.c
+++ b/kernel/padata.c
@@ -940,6 +940,8 @@ static struct kobj_type padata_attr_type = {
940 * @wq: workqueue to use for the allocated padata instance 940 * @wq: workqueue to use for the allocated padata instance
941 * @pcpumask: cpumask that will be used for padata parallelization 941 * @pcpumask: cpumask that will be used for padata parallelization
942 * @cbcpumask: cpumask that will be used for padata serialization 942 * @cbcpumask: cpumask that will be used for padata serialization
943 *
944 * Must be called from a cpus_read_lock() protected region
943 */ 945 */
944static struct padata_instance *padata_alloc(struct workqueue_struct *wq, 946static struct padata_instance *padata_alloc(struct workqueue_struct *wq,
945 const struct cpumask *pcpumask, 947 const struct cpumask *pcpumask,
@@ -952,7 +954,6 @@ static struct padata_instance *padata_alloc(struct workqueue_struct *wq,
952 if (!pinst) 954 if (!pinst)
953 goto err; 955 goto err;
954 956
955 get_online_cpus();
956 if (!alloc_cpumask_var(&pinst->cpumask.pcpu, GFP_KERNEL)) 957 if (!alloc_cpumask_var(&pinst->cpumask.pcpu, GFP_KERNEL))
957 goto err_free_inst; 958 goto err_free_inst;
958 if (!alloc_cpumask_var(&pinst->cpumask.cbcpu, GFP_KERNEL)) { 959 if (!alloc_cpumask_var(&pinst->cpumask.cbcpu, GFP_KERNEL)) {
@@ -976,14 +977,12 @@ static struct padata_instance *padata_alloc(struct workqueue_struct *wq,
976 977
977 pinst->flags = 0; 978 pinst->flags = 0;
978 979
979 put_online_cpus();
980
981 BLOCKING_INIT_NOTIFIER_HEAD(&pinst->cpumask_change_notifier); 980 BLOCKING_INIT_NOTIFIER_HEAD(&pinst->cpumask_change_notifier);
982 kobject_init(&pinst->kobj, &padata_attr_type); 981 kobject_init(&pinst->kobj, &padata_attr_type);
983 mutex_init(&pinst->lock); 982 mutex_init(&pinst->lock);
984 983
985#ifdef CONFIG_HOTPLUG_CPU 984#ifdef CONFIG_HOTPLUG_CPU
986 cpuhp_state_add_instance_nocalls(hp_online, &pinst->node); 985 cpuhp_state_add_instance_nocalls_cpuslocked(hp_online, &pinst->node);
987#endif 986#endif
988 return pinst; 987 return pinst;
989 988
@@ -992,7 +991,6 @@ err_free_masks:
992 free_cpumask_var(pinst->cpumask.cbcpu); 991 free_cpumask_var(pinst->cpumask.cbcpu);
993err_free_inst: 992err_free_inst:
994 kfree(pinst); 993 kfree(pinst);
995 put_online_cpus();
996err: 994err:
997 return NULL; 995 return NULL;
998} 996}
@@ -1003,9 +1001,12 @@ err:
1003 * parallel workers. 1001 * parallel workers.
1004 * 1002 *
1005 * @wq: workqueue to use for the allocated padata instance 1003 * @wq: workqueue to use for the allocated padata instance
1004 *
1005 * Must be called from a cpus_read_lock() protected region
1006 */ 1006 */
1007struct padata_instance *padata_alloc_possible(struct workqueue_struct *wq) 1007struct padata_instance *padata_alloc_possible(struct workqueue_struct *wq)
1008{ 1008{
1009 lockdep_assert_cpus_held();
1009 return padata_alloc(wq, cpu_possible_mask, cpu_possible_mask); 1010 return padata_alloc(wq, cpu_possible_mask, cpu_possible_mask);
1010} 1011}
1011EXPORT_SYMBOL(padata_alloc_possible); 1012EXPORT_SYMBOL(padata_alloc_possible);