From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S943534AbdEZIjK (ORCPT ); Fri, 26 May 2017 04:39:10 -0400 Received: from terminus.zytor.com ([65.50.211.136]:44071 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S943531AbdEZIhj (ORCPT ); Fri, 26 May 2017 04:37:39 -0400 Date: Fri, 26 May 2017 01:35:02 -0700 From: tip-bot for Sebastian Andrzej Siewior Message-ID: Cc: steffen.klassert@secunet.com, tglx@linutronix.de, bigeasy@linutronix.de, mingo@kernel.org, peterz@infradead.org, paulmck@linux.vnet.ibm.com, rostedt@goodmis.org, hpa@zytor.com, linux-kernel@vger.kernel.org Reply-To: steffen.klassert@secunet.com, tglx@linutronix.de, bigeasy@linutronix.de, paulmck@linux.vnet.ibm.com, peterz@infradead.org, mingo@kernel.org, linux-kernel@vger.kernel.org, hpa@zytor.com, rostedt@goodmis.org In-Reply-To: <20170524081547.571278910@linutronix.de> References: <20170524081547.571278910@linutronix.de> To: linux-tip-commits@vger.kernel.org Subject: [tip:smp/hotplug] padata: Avoid nested calls to cpus_read_lock() in pcrypt_init_padata() Git-Commit-ID: c5a81c8ff816d89941fe86961b286765d6ca2f5f X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: c5a81c8ff816d89941fe86961b286765d6ca2f5f Gitweb: http://git.kernel.org/tip/c5a81c8ff816d89941fe86961b286765d6ca2f5f Author: Sebastian Andrzej Siewior AuthorDate: Wed, 24 May 2017 10:15:18 +0200 Committer: Thomas Gleixner CommitDate: Fri, 26 May 2017 10:10:37 +0200 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 Signed-off-by: Thomas Gleixner Tested-by: Paul E. McKenney Acked-by: Ingo Molnar Cc: Steffen Klassert Cc: Peter Zijlstra Cc: Steven Rostedt Cc: linux-crypto@vger.kernel.org Link: http://lkml.kernel.org/r/20170524081547.571278910@linutronix.de --- kernel/padata.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/kernel/padata.c b/kernel/padata.c index 0c708f6..868f947 100644 --- a/kernel/padata.c +++ b/kernel/padata.c @@ -940,6 +940,8 @@ static struct kobj_type padata_attr_type = { * @wq: workqueue to use for the allocated padata instance * @pcpumask: cpumask that will be used for padata parallelization * @cbcpumask: cpumask that will be used for padata serialization + * + * Must be called from a cpus_read_lock() protected region */ static struct padata_instance *padata_alloc(struct workqueue_struct *wq, const struct cpumask *pcpumask, @@ -952,7 +954,6 @@ static struct padata_instance *padata_alloc(struct workqueue_struct *wq, if (!pinst) goto err; - get_online_cpus(); if (!alloc_cpumask_var(&pinst->cpumask.pcpu, GFP_KERNEL)) goto err_free_inst; if (!alloc_cpumask_var(&pinst->cpumask.cbcpu, GFP_KERNEL)) { @@ -976,14 +977,12 @@ static struct padata_instance *padata_alloc(struct workqueue_struct *wq, pinst->flags = 0; - put_online_cpus(); - BLOCKING_INIT_NOTIFIER_HEAD(&pinst->cpumask_change_notifier); kobject_init(&pinst->kobj, &padata_attr_type); mutex_init(&pinst->lock); #ifdef CONFIG_HOTPLUG_CPU - cpuhp_state_add_instance_nocalls(hp_online, &pinst->node); + cpuhp_state_add_instance_nocalls_cpuslocked(hp_online, &pinst->node); #endif return pinst; @@ -992,7 +991,6 @@ err_free_masks: free_cpumask_var(pinst->cpumask.cbcpu); err_free_inst: kfree(pinst); - put_online_cpus(); err: return NULL; } @@ -1003,9 +1001,12 @@ err: * parallel workers. * * @wq: workqueue to use for the allocated padata instance + * + * Must be called from a cpus_read_lock() protected region */ struct padata_instance *padata_alloc_possible(struct workqueue_struct *wq) { + lockdep_assert_cpus_held(); return padata_alloc(wq, cpu_possible_mask, cpu_possible_mask); } EXPORT_SYMBOL(padata_alloc_possible);