From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756076AbdDORe4 (ORCPT ); Sat, 15 Apr 2017 13:34:56 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:44457 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754787AbdDORbL (ORCPT ); Sat, 15 Apr 2017 13:31:11 -0400 Message-Id: <20170415171651.562519657@linutronix.de> User-Agent: quilt/0.63-1 Date: Sat, 15 Apr 2017 19:01:11 +0200 From: Thomas Gleixner To: LKML Cc: Peter Zijlstra , Ingo Molnar , Steven Rostedt , Sebastian Siewior , Steffen Klassert , linux-crypto@vger.kernel.org Subject: [patch 04/20] padata: Avoid nested calls to get_online_cpus() in pcrypt_init_padata() References: <20170415170107.643253702@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Disposition: inline; filename=kernelpadata_Avoid_get_online_cpus()_recursion_via_pcrypt_init_padata().patch Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Sebastian Andrzej Siewior pcrypt_init_padata() get_online_cpus() padata_alloc_possible() padata_alloc() get_online_cpus() The nested call to get_online_cpus() 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 get_online_cpus() protected region as well. Remove the get_online_cpus() call in padata_alloc() and document the calling convention. Signed-off-by: Sebastian Andrzej Siewior Signed-off-by: Thomas Gleixner Cc: Steffen Klassert Cc: linux-crypto@vger.kernel.org --- kernel/padata.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) --- a/kernel/padata.c +++ b/kernel/padata.c @@ -913,7 +913,7 @@ static ssize_t padata_sysfs_show(struct } static ssize_t padata_sysfs_store(struct kobject *kobj, struct attribute *attr, -s const char *buf, size_t count) + const char *buf, size_t count) { struct padata_instance *pinst; struct padata_sysfs_entry *pentry; @@ -945,6 +945,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 get_online_cpus() protected region */ static struct padata_instance *padata_alloc(struct workqueue_struct *wq, const struct cpumask *pcpumask, @@ -957,7 +959,6 @@ static struct padata_instance *padata_al 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)) { @@ -997,7 +998,6 @@ static struct padata_instance *padata_al free_cpumask_var(pinst->cpumask.cbcpu); err_free_inst: kfree(pinst); - put_online_cpus(); err: return NULL; } @@ -1008,6 +1008,8 @@ static struct padata_instance *padata_al * parallel workers. * * @wq: workqueue to use for the allocated padata instance + * + * Must be called from a get_online_cpus() protected region */ struct padata_instance *padata_alloc_possible(struct workqueue_struct *wq) {