Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp1718959ybl; Tue, 3 Dec 2019 11:32:50 -0800 (PST) X-Google-Smtp-Source: APXvYqxcdriTzX8XhahuRn4y1Jvmu7O/EgfeGAB6fVLkh/rO3Bcu4bvQ/vhGlCSOqYGVaqDP0E/x X-Received: by 2002:aca:c692:: with SMTP id w140mr5423969oif.139.1575401570414; Tue, 03 Dec 2019 11:32:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575401570; cv=none; d=google.com; s=arc-20160816; b=kpi8jzQdpqdhSQKYiOBHkW7rI4QfvIJI1MkXLgXAjBhWZEmJ87gBZ/0IV3Syjq3pxf mjIgqmVw3f/7VbHbhCmUXHoT62+117nhLrEhRTb4veqz8LP/L818cqVL7lTO39H17DhU tbAhGnXzZQiXZWqAp+rAKD2tZ/wFMiE+oi/Hl4efn65xj+3JFcB9GQXuhRmp+PPwqb+y C7hxhPkh0UhLmyvHrkfoq3o3+rRgU82gm/NA30W5PdSKaVbPlKd2PY8BLMu2y14+mT2q UzSx6gqahC+grrmcvcQ5dAQHBS3Z8QQwVkE6w7iqQ3H+YgP8+RijRB2ggTlf4cXnfOce Dq9A== 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=MUbfG5faWslW5pyLZ/WZp1I6bOT027aSp0AGL2Rkjgs=; b=tRw+elwJLrQz+O9CCWsXd0dVyo+vYvObTU8vp2ReGHs3H3zL+Fxn4Y4yxhTKIsV+qO fb+1YsGkvzOTM7AxaF/RJS4qpgFj1vkxQ1O56pOypFhhiwQV7JYCRI0T8iD9XZCdf2wE n0vhGmnAdcd60PjC0cP6DBX1jgY8fy7WJjYanw9gp99QrngbnZbNCuTgRFlUibf0FuSd XLEeGgC1K+F2X7wvPuzDhvMJgB468awIsBuzrxrNT0ZUY9BNCfHUEx71wzM0JKn6NO+Z NRcpe5UVOMa9qg1WZlplh0Ch3ykGEA39hbaqYZAFGVpBO1LuW8wKR4Dgnd43c0LSBcVJ EHGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2019-08-05 header.b="dhdRJ/I2"; 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 x24si1931050otk.188.2019.12.03.11.32.38; Tue, 03 Dec 2019 11:32:50 -0800 (PST) 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="dhdRJ/I2"; 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 S1727553AbfLCTcE (ORCPT + 99 others); Tue, 3 Dec 2019 14:32:04 -0500 Received: from userp2130.oracle.com ([156.151.31.86]:35538 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727477AbfLCTbq (ORCPT ); Tue, 3 Dec 2019 14:31:46 -0500 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xB3JNFgF169967; Tue, 3 Dec 2019 19:31:36 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=MUbfG5faWslW5pyLZ/WZp1I6bOT027aSp0AGL2Rkjgs=; b=dhdRJ/I29gPD+xxOpd3npxt7bBZSHNtHl+E9548pgLzG2UG8PIzCW8T0f+umupcBY7no o+aJ296T0e0Ytmb1+LlCHJyNK1sTgjy1CCyf3hocMYzYVlxJcVTp/++hLaTyTK4O6KdQ ENjxhor4+EzIvgWkHOjzXygBAX0RWRpiq/OYJwla1oqREukG7V90XjZsY/Zvv/qyCSA6 //dPTxJOn5GDeIQNLBGD4TMy4J76g4t0CKhSOSun7ktclqA8b1et9HxGTqfVPAX87y1p FJoKIYOHP4bNZcaJktrNTYgkFvnFnb7FzV6ek44iSIcHQfYG0T1e8c51tQAwU18NgBsn mA== Received: from aserp3030.oracle.com (aserp3030.oracle.com [141.146.126.71]) by userp2130.oracle.com with ESMTP id 2wkfuua3q1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Dec 2019 19:31:36 +0000 Received: from pps.filterd (aserp3030.oracle.com [127.0.0.1]) by aserp3030.oracle.com (8.16.0.27/8.16.0.27) with SMTP id xB3JEnlQ032059; Tue, 3 Dec 2019 19:31:35 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserp3030.oracle.com with ESMTP id 2wn8k35hdr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 03 Dec 2019 19:31:35 +0000 Received: from abhmp0008.oracle.com (abhmp0008.oracle.com [141.146.116.14]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id xB3JVWmW009256; Tue, 3 Dec 2019 19:31:32 GMT Received: from localhost.localdomain (/98.229.125.203) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 03 Dec 2019 11:31:32 -0800 From: Daniel Jordan To: Herbert Xu , Steffen Klassert Cc: Eric Biggers , Jonathan Corbet , linux-crypto@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, Daniel Jordan Subject: [PATCH v2 2/5] padata: always acquire cpu_hotplug_lock before pinst->lock Date: Tue, 3 Dec 2019 14:31:11 -0500 Message-Id: <20191203193114.238912-3-daniel.m.jordan@oracle.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191203193114.238912-1-daniel.m.jordan@oracle.com> References: <20191203193114.238912-1-daniel.m.jordan@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9460 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-1911140001 definitions=main-1912030143 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9460 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-1911140001 definitions=main-1912030143 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org lockdep complains when padata's paths to update cpumasks via CPU hotplug and sysfs are both taken: # echo 0 > /sys/devices/system/cpu/cpu1/online # echo ff > /sys/kernel/pcrypt/pencrypt/parallel_cpumask ====================================================== WARNING: possible circular locking dependency detected 5.4.0-rc8-padata-cpuhp-v3+ #1 Not tainted ------------------------------------------------------ bash/205 is trying to acquire lock: ffffffff8286bcd0 (cpu_hotplug_lock.rw_sem){++++}, at: padata_set_cpumask+0x2b/0x120 but task is already holding lock: ffff8880001abfa0 (&pinst->lock){+.+.}, at: padata_set_cpumask+0x26/0x120 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: Eric Biggers Cc: Herbert Xu Cc: Steffen Klassert 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 a2fa6223e1a0..2f8db63aefc4 100644 --- a/kernel/padata.c +++ b/kernel/padata.c @@ -643,8 +643,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: @@ -662,8 +662,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.24.0