Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp1565545ybl; Wed, 28 Aug 2019 17:14:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqzoh96Xo+5KJQQuCAYP47tCOl4f2Q/3tf16uhLD6Syt9ceIwTP/UG5W/NCPigMSVwqOss/v X-Received: by 2002:a63:29c4:: with SMTP id p187mr5861806pgp.330.1567037662668; Wed, 28 Aug 2019 17:14:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1567037662; cv=none; d=google.com; s=arc-20160816; b=zZGmEYP+MCen7G5rwrnTKR/W0jbimtyuh3UKSf92pRZ3DDDOYtLJ4gee3UAUyQQatG r7Mcdqwi8qeycni2Tfyc3Ojq27WTlqQrOKD/xjR+n9pneXZWKkENBvKE5XKazK+BLeGz z4ZRvPolTfMl1SttQ2h/cPVNOcl/MMMvkBuBPytU1bc8uSuKKoRGNV7xTokVDgvyXebY vOljbJcTKNxq/UjNGWwRpzQ7dy09qporNhJLMiFSV8bpQgld/jzSyblAJZCYAsD4vxUJ 7hCrvT69VJcUPAyfjNLR+Rq6YPBCYEAcqaTw83EXRGD5lFQiAqzxbd48hd41Nzy4KeWO DPeg== 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=7wG5y7dKyypT4n5VfzMGBXRCZUmNViG9gJEJUq/OhLo=; b=wDMtpTOiHAswdpEHXf9ThlI5XtRTMrywSjTIxRIw3NEJ3mB2CpCEV1EqQYUcE1PY+y lGMkMKFQb8AZFxxtCTA0UcVGq1nL8Kr4QtekeQd1joQn9t7LJmaeblas/Fmugf7b+WDS pXJ+/ijYWWJLCCtKruONs3fQTbvx+UDJVJmn1E3aKHvWbUfKj21qRJ1udA7x5Z/sU1tB yZiKTMnxflGLkbzVQDG26bt971VOZzbNU43zYL/0c7gr2srCY2X1Ra5VTrZF3xpbK9Rk 9RZ/prniMYF+zkEqcC8n6XnigjmRMcqGJEOtNGWg6MweBjGpM8kFaE9hacbfKGlmfCvm nltw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2019-08-05 header.b=sctmNZVM; 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 s9si721775pfh.75.2019.08.28.17.13.56; Wed, 28 Aug 2019 17:14:22 -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-2019-08-05 header.b=sctmNZVM; 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 S1726828AbfH2ANx (ORCPT + 99 others); Wed, 28 Aug 2019 20:13:53 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:48630 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726825AbfH2ANw (ORCPT ); Wed, 28 Aug 2019 20:13:52 -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 x7T0DNVB005044; Thu, 29 Aug 2019 00:13:35 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-2019-08-05; bh=7wG5y7dKyypT4n5VfzMGBXRCZUmNViG9gJEJUq/OhLo=; b=sctmNZVMbDTpDSLMErdcAI8t4Py/Pltzk73Oud6ZLkclBxdvkwOGuhTgeDT3au9c7tBr 7ujUB8iiDY78b9DvgG8GbPKW+DSI3hs52BrtklO2I6WR2G47pA/7d9TL/pNsEGrpcZLn DojgCf+4T23dJABggFF4eVPXRwWmEkqNoWc2MtdfdZh2bxFNvzMDZV0YiZzBjgLnT6M2 Qqvyxh+BQg+b4buhdTbRMNSPIbxjB37Z3VSxk3eFD0Wh3e+lGbhwlG/r+X+jZj1Y0Zps w62kPSVnyZVKo1iE+CLFi6ukyKDzfWBE2mHJ5WdHtJDQ2pv6whZ0S2O7dFORd/hbzuJh ww== Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2120.oracle.com with ESMTP id 2up3vmr0k6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 29 Aug 2019 00:13:35 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7SMDOC0007324; Wed, 28 Aug 2019 22:16:33 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userp3020.oracle.com with ESMTP id 2untetyqhw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 28 Aug 2019 22:16:33 +0000 Received: from abhmp0010.oracle.com (abhmp0010.oracle.com [141.146.116.16]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x7SMGWex020546; Wed, 28 Aug 2019 22:16:32 GMT Received: from zissou.us.oracle.com (/10.152.34.58) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 28 Aug 2019 15:16:32 -0700 From: Daniel Jordan To: Herbert Xu , Steffen Klassert Cc: Sebastian Andrzej Siewior , Thomas Gleixner , linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Daniel Jordan Subject: [PATCH v2 4/5] padata: always acquire cpu_hotplug_lock before pinst->lock Date: Wed, 28 Aug 2019 18:14:24 -0400 Message-Id: <20190828221425.22701-5-daniel.m.jordan@oracle.com> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190828221425.22701-1-daniel.m.jordan@oracle.com> References: <20190828221425.22701-1-daniel.m.jordan@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9363 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 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-1908280214 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9363 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 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-1908290001 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org lockdep complains when... # echo 0 > /sys/devices/system/cpu/cpu1/online # echo ff > /sys/kernel/pcrypt/pencrypt/parallel_cpumask ====================================================== WARNING: possible circular locking dependency detected 5.3.0-rc5-padata-base+ #6 Not tainted ------------------------------------------------------ bash/258 is trying to acquire lock: 00000000c43f7f29 (cpu_hotplug_lock.rw_sem){++++}, at: padata_set_cpumask+0x30/0x130 but task is already holding lock: 00000000676aa31d (&pinst->lock){+.+.}, at: padata_set_cpumask+0x2b/0x130 which lock already depends on the new lock. padata doesn't take cpu_hotplug_lock and pinst->lock in a consistent order. Which should be first? CPU hotplug calls into padata with cpu_hotplug_lock already held, so it should have priority. Fixes: 6751fb3c0e0c ("padata: Use get_online_cpus/put_online_cpus") Signed-off-by: Daniel Jordan Cc: Herbert Xu Cc: Sebastian Andrzej Siewior Cc: Steffen Klassert Cc: Thomas Gleixner Cc: linux-crypto@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- kernel/padata.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/kernel/padata.c b/kernel/padata.c index 6adce3b203fe..75e668fedd8d 100644 --- a/kernel/padata.c +++ b/kernel/padata.c @@ -603,8 +603,8 @@ int padata_set_cpumask(struct padata_instance *pinst, int cpumask_type, struct cpumask *serial_mask, *parallel_mask; int err = -EINVAL; - mutex_lock(&pinst->lock); get_online_cpus(); + mutex_lock(&pinst->lock); switch (cpumask_type) { case PADATA_CPU_PARALLEL: @@ -622,8 +622,8 @@ int padata_set_cpumask(struct padata_instance *pinst, int cpumask_type, err = __padata_set_cpumasks(pinst, parallel_mask, serial_mask); out: - put_online_cpus(); mutex_unlock(&pinst->lock); + put_online_cpus(); return err; } -- 2.23.0