Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp11335262ybi; Thu, 25 Jul 2019 14:27:58 -0700 (PDT) X-Google-Smtp-Source: APXvYqxjpXtJqEi3e93i5CNW527rib+QTttxnmoU397hCnGK+jA9QVBfHikWkNbYLMRZlF+uhGD3 X-Received: by 2002:a17:902:7791:: with SMTP id o17mr94047473pll.27.1564090078177; Thu, 25 Jul 2019 14:27:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564090078; cv=none; d=google.com; s=arc-20160816; b=HYawiAtDm5qGvuAx4sgJ+ZS0bDesrv/DVVAvl1fw1qeiRM0DA5dyXjmZh00yjLBmJt TKzfnH+fkyHUDj9oiSZQ4yf6CwVN/BQ2M+YYL88JUa0u0Y3EH2Q9mnGGULsuXadsrXLU xZQxdBUIJVPZgH1VHLodPviL1jDqXhrdwLjXRO42FiGHwbd5F3Fbl+QNU2abfHz8uQju ShkWbMlx1LlXkvhmWuCOyz5BnPYlRyBNMHXH6owcGC5fDeaRy3IygWegoeSf/r6guIlv 3UW5WZPdY6hQ+POTwviLOf3N9K81UM2FAkHcqXp9rbquH98xVMH0FyC8UARTAj2Yc/MY xOzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=O0UmOEll5P5bq+KvZPjJWKwttFJXxKJl59AMR2dnMK0=; b=fETac0klDxnmHxEgXP890cQJUlWmnPwCIN4sLgsEvzCILD/8n8uWdXjiLv3zQ6Nx+B rOJsERv8j89asbUulurTHUESccAYZyZJ/B5Bc6H/Amr9lWjWcLSzme/20erVbD/lC++K A5s0RQ4W5GE5Pv4JJhzRwJGmNtQZwqd2wfuTb8Mhjw/rOGiz0WlJ3tN8Xlo/tFk1ugBc 2N75BIqCtgine5hHbRK6DmeWuC56gXq2ASZK4BLHHzXUcKfe0YWObO5pyaCVR3tLm/vi 8uQTyFrHKHsTIFXqIO9DrWK7jpc/x7JEXH6aVDN7LUzPiSrpdX3Qx5RoC/LemgRk12T4 X4bA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=Ns4MMCbS; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l28si25718828pgm.311.2019.07.25.14.27.44; Thu, 25 Jul 2019 14:27:58 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=Ns4MMCbS; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725819AbfGYVZr (ORCPT + 99 others); Thu, 25 Jul 2019 17:25:47 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:44962 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726661AbfGYVZp (ORCPT ); Thu, 25 Jul 2019 17:25:45 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x6PLNhCW032788; Thu, 25 Jul 2019 21:25:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2018-07-02; bh=O0UmOEll5P5bq+KvZPjJWKwttFJXxKJl59AMR2dnMK0=; b=Ns4MMCbS55UXepOeLOQaILMTY2brbxqSFrZM+ANcYDFrSlwZOozFAndEk2JWDda8SSe1 KjG1I9XECKKb2FUi0ULxdEvRnKgdgEobv4+l//19zCnmiHpsSAWZNwlOhq9O2f1LI5bb gcTtWD2fAsqqhHqK+phAjq/FHfxfBevnXsjIJzqtcUTCiSZmJS9qL+vmuBYO0+ui5qgZ l89QhxpaN3SV7CnGK1XuC8Km0Ej8wEP4UdyBmNyyit52FKBVQ7MJLFls8qs8yjAN/mXF 7pvkTpjUPXUOx+n0ElYb3+dcg8IXEQcc4meaPFFXlU4GC1Qx6cFeC/+yv6mlyLPpzTNs JA== Received: from userp3030.oracle.com (userp3030.oracle.com [156.151.31.80]) by userp2120.oracle.com with ESMTP id 2tx61c6nac-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Jul 2019 21:25:25 +0000 Received: from pps.filterd (userp3030.oracle.com [127.0.0.1]) by userp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x6PLNGt3066923; Thu, 25 Jul 2019 21:25:25 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3030.oracle.com with ESMTP id 2tx60yj90g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 25 Jul 2019 21:25:24 +0000 Received: from abhmp0015.oracle.com (abhmp0015.oracle.com [141.146.116.21]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x6PLPMoX016472; Thu, 25 Jul 2019 21:25:24 GMT Received: from localhost.localdomain (/73.60.114.248) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 25 Jul 2019 14:25:21 -0700 From: Daniel Jordan To: Steffen Klassert , Herbert Xu Cc: Tejun Heo , Lai Jiangshan , Peter Zijlstra , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Daniel Jordan Subject: [RFC 6/9] padata, pcrypt: take CPU hotplug lock internally in padata_alloc_possible Date: Thu, 25 Jul 2019 17:25:02 -0400 Message-Id: <20190725212505.15055-7-daniel.m.jordan@oracle.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190725212505.15055-1-daniel.m.jordan@oracle.com> References: <20190725212505.15055-1-daniel.m.jordan@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9329 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=2 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1907250257 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9329 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1907250257 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org With pcrypt's cpumask no longer used, take the CPU hotplug lock inside padata_alloc_possible. Useful later in the series for avoiding nested acquisition of the CPU hotplug lock in padata when padata_alloc_possible is allocating an unbound workqueue. Without this patch, this nested acquisition would happen later in the series: pcrypt_init_padata get_online_cpus alloc_padata_possible alloc_padata alloc_workqueue(WQ_UNBOUND) // later in the series alloc_and_link_pwqs apply_wqattrs_lock get_online_cpus // recursive rwsem acquisition Signed-off-by: Daniel Jordan --- crypto/pcrypt.c | 4 ---- kernel/padata.c | 17 +++++++++-------- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/crypto/pcrypt.c b/crypto/pcrypt.c index 2ec36e6a132f..543792e0ebf0 100644 --- a/crypto/pcrypt.c +++ b/crypto/pcrypt.c @@ -308,8 +308,6 @@ static int pcrypt_init_padata(struct padata_instance **pinst, const char *name) { int ret = -ENOMEM; - get_online_cpus(); - *pinst = padata_alloc_possible(name); if (!*pinst) return ret; @@ -318,8 +316,6 @@ static int pcrypt_init_padata(struct padata_instance **pinst, const char *name) if (ret) padata_free(*pinst); - put_online_cpus(); - return ret; } diff --git a/kernel/padata.c b/kernel/padata.c index 9d9e7f5e89cb..82edd5f88a32 100644 --- a/kernel/padata.c +++ b/kernel/padata.c @@ -955,8 +955,6 @@ static struct kobj_type padata_attr_type = { * @name: used to identify the 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(const char *name, const struct cpumask *pcpumask, @@ -974,11 +972,13 @@ static struct padata_instance *padata_alloc(const char *name, if (!pinst->wq) goto err_free_inst; + get_online_cpus(); + if (!alloc_cpumask_var(&pinst->cpumask.pcpu, GFP_KERNEL)) - goto err_free_wq; + goto err_put_cpus; if (!alloc_cpumask_var(&pinst->cpumask.cbcpu, GFP_KERNEL)) { free_cpumask_var(pinst->cpumask.pcpu); - goto err_free_wq; + goto err_put_cpus; } if (!padata_validate_cpumask(pinst, pcpumask) || !padata_validate_cpumask(pinst, cbcpumask)) @@ -1002,12 +1002,16 @@ static struct padata_instance *padata_alloc(const char *name, #ifdef CONFIG_HOTPLUG_CPU cpuhp_state_add_instance_nocalls_cpuslocked(hp_online, &pinst->node); #endif + + put_online_cpus(); + return pinst; err_free_masks: free_cpumask_var(pinst->cpumask.pcpu); free_cpumask_var(pinst->cpumask.cbcpu); -err_free_wq: +err_put_cpus: + put_online_cpus(); destroy_workqueue(pinst->wq); err_free_inst: kfree(pinst); @@ -1021,12 +1025,9 @@ static struct padata_instance *padata_alloc(const char *name, * parallel workers. * * @name: used to identify the instance - * - * Must be called from a cpus_read_lock() protected region */ struct padata_instance *padata_alloc_possible(const char *name) { - lockdep_assert_cpus_held(); return padata_alloc(name, cpu_possible_mask, cpu_possible_mask); } EXPORT_SYMBOL(padata_alloc_possible); -- 2.22.0