From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.201.71 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1796218783; b=nUuuAuDYUPtAdfaGk+bBIwrJmvQUryfba3D4HIM/W3QN2dai0crS2patok3piBExLtsE L03zIPytpsaAOloPjYg5jGdYWw8aR2lT9FKhWrf6xr+KhqM/LzJNYgZEWkyafJ+LLKLgW WLzbDQ7v1tNBbKl1SiNjnUVXkDQCTOnzpOy4FeRTf9xqOVtXPtzwSLIs2rsV6phk0EI2W 9lY9HIjAzbuHTCnS5bXL/SSB3zpTTxS3T+tSlrFxlYG1GZI0DPgbxgfs0ROnW5PB7oPA4 2y5fHTrNhD/wmLTJJeTEiHN3U5TdUN4Pp1fkat4mAp9Gw4zXG4SUr8w6zx2nt/hSGDA== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796218783; h=DMARC-Filter:DKIM-Signature:Received:Received: X-MS-Exchange-Authentication-Results:Received-SPF:Received:Received: Received:From:To:CC:Subject:Date:Message-ID:X-Mailer:In-Reply-To: References:MIME-Version:Content-Transfer-Encoding:Content-Type: X-Originating-IP:X-ClientProxiedBy:X-EOPAttributedMessage: X-MS-PublicTrafficType:X-MS-TrafficTypeDiagnostic: X-MS-Office365-Filtering-Correlation-Id:X-MS-Exchange-SenderADCheck: X-MS-Exchange-AntiSpam-Relay:X-Microsoft-Antispam: X-Microsoft-Antispam-Message-Info:X-Forefront-Antispam-Report: X-MS-Exchange-AntiSpam-MessageData-ChunkCount: X-MS-Exchange-AntiSpam-MessageData-0:X-OriginatorOrg: X-MS-Exchange-CrossTenant-OriginalArrivalTime: X-MS-Exchange-CrossTenant-Network-Message-Id: X-MS-Exchange-CrossTenant-Id: X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: X-MS-Exchange-CrossTenant-AuthSource:X-MS-Exchange-CrossTenant-AuthAs: X-MS-Exchange-CrossTenant-FromEntityHeader: X-MS-Exchange-Transport-CrossTenantHeadersStamped; bh=lMjsniX8AsMDusdFmHA95po3up48Jh3mj8hpAOwcWoY=; b=vlw8ftmVgSehH6c3mOqcTXS3nf+sgJrgSBLxjHXSiJhu0FRp0P7B2n2eTlIR3fwmsyJ6 0sg7xVPR55zYsJ6rlZlzVXqH96fi/9CTtgo44MJSGcUyp7DDy/8Sa7xPRsXshNaiBIAaO BD47EjGHOK/yL+8i55HEq6kOyFzeETW3zCIfsgr+wuXEQJur2P4ECXFBgjfC/FOpe5/0G cCEM2Oq7HjSayz8gDltLpcEAb8JF8uVkVxDd2ToXO/FA9n65cChkdLJKoxszhmPpBiuCN YrSw5nzdkCJYEYA/xthcuK7HKpgX+aE2Ntf32RDfWXJZ9bsmTdn79NP3iB5RkQVaNWQ== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=nvidia.com; spf=fail smtp.mailfrom=nvidia.com; dkim=pass header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=UihPd2cb; arc=pass header.oldest-pass=0 smtp.remote-ip=52.101.201.71 Received: from PH7PR06CU001.outbound.protection.outlook.com (mail-westus3azon11010071.outbound.protection.outlook.com [52.101.201.71]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (secp384r1) server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2401D606A32D; Wed, 2 Dec 2026 13:39:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2401D606A32D Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=nvidia.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=nvidia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=Nvidia.com header.i=@Nvidia.com header.a=rsa-sha256 header.s=selector2 header.b=UihPd2cb ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FW2qlip/kDIbtdewl1BfZiUYvLEGQF42x7yqUXxUqGKnvs+0ZlrkjjhgDvN2NFau+/zdS5L/Vd2Bbxs8n/ucZ+qwnOy4bg90Pni9Xt03rjZCZ077PGztYjGO/vyM9JUjJeGVnY1OLZ5YcBErQwjjqgwnaSgY/krvNE3qTHETL1T4MKa54aOLfa1YllsFoayvtFxLTlUGQKQBrTlytOG1/YNmS32HIoeXoRhpjbW+9cvQi5I91BJdX9b/J46qCLDGuUVL+0Z3t/ZKVR2qy+IttSbAy1PKju7n5hkDm0kbLaqthsPejB2atFGLpI6HVas2bEbWxqRahQsMLIQdq7quXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=lMjsniX8AsMDusdFmHA95po3up48Jh3mj8hpAOwcWoY=; b=MsH+DFNmF3gKjeVvz7QHUcgYNZKtC4XRFH1bDwLdUUgTq+xED+FNQ+Q2vx05Z0/FjLjcIL1Xr5thjBCqK5+cLCvFWdRMJXASECECLBgpdwjIPyY8foy5+uLe0B9Co1aaUuheXoBJ3znZsnVLkFUJAHLdUqkdYKRVeJczfuoMjx8zQTngQezO+VRHiE6yhstYTzEK9JrhMFGS53SUzqgCdeKhQEcPRyRIBRwio/k5pvyirDr4FjZ5oQ1pxZrm+QuvEC4vI4Bh8KA3+E/vs1qjv/4QQAZ4j7aHuxT1I5mxpShuAcqPVzkrQXvIR/vYF6FEkOyjAwtKpm8344VyuGzdYQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lMjsniX8AsMDusdFmHA95po3up48Jh3mj8hpAOwcWoY=; b=UihPd2cbnLBI5a/x5KT1nVyfSDABkjvqmqMPF1Zn6/SZy0fn8JQ2NgW7nIaDJJmEt7HCwuYv04nfsuvYzAZVU0QOhP0s76E8cN73EZovoSLHUhRAzG2x/UhQ5qwVTaSbf8IhL8NTmDM0N+mGyHdSlGQRt2nZYduflXSFVJNYCDgQFfzCDC67pQ/PDv58uWmvd2OXBCaNjZXDx2YtLssTuRBN8peNfAT9rFVBQ7Y2ApG6t7FU3ZeJWcTON11ax001EYA6qsxiSq/yfRmnSVSAald0ryKQTg8NPEPJAEFe3nzwMtIg9Q18WJ4crW2Xo1Kjxbz2nkVMP7XNpPZdHcoqWA== Received: from CH0PR13CA0057.namprd13.prod.outlook.com (2603:10b6:610:b2::32) by SA1PR12MB6917.namprd12.prod.outlook.com (2603:10b6:806:24c::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.10; Wed, 2 Dec 2026 13:39:35 +0000 Received: from CH2PEPF000166BB.namprd04.prod.outlook.com (2603:10b6:610:b2:cafe::78) by CH0PR13CA0057.outlook.office365.com (2603:10b6:610:b2::32) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.21.709.5 via Frontend Transport; Wed, 2 Dec 2026 13:39:35 +0000 X-MS-Exchange-Authentication-Results: mx.microsoft.com 1; spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by CH2PEPF000166BB.mail.protection.outlook.com (10.167.252.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.21.688.5 via Frontend Transport; Wed, 2 Dec 2026 13:39:35 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Wed, 2 Dec 2026 05:39:16 -0800 Received: from c-237-113-240-247.mtl.labs.mlnx (10.126.230.37) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.57; Wed, 2 Dec 2026 05:39:11 -0800 From: Cosmin Ratiu To: CC: Jiri Pirko , "David S . Miller" , Eric Dumazet , Jakub Kicinski , "Paolo Abeni" , Willem de Bruijn , "Simon Horman" , Jonathan Corbet , Shuah Khan , Randy Dunlap , "Tariq Toukan" , Cosmin Ratiu , Carolina Jubran , Dmytro Linkin , Vlad Buslov , Subject: [PATCH net 2/2] devlink: Restore parent -> nested instance locking order Date: Wed, 2 Dec 2026 15:38:38 +0200 Message-ID: <20261202133838.834971-3-cratiu@nvidia.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20261202133838.834971-1-cratiu@nvidia.com> References: <20261202133838.834971-1-cratiu@nvidia.com> X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH2PEPF000166BB:EE_|SA1PR12MB6917:EE_ X-MS-Office365-Filtering-Correlation-Id: cc274cbc-44ef-4717-bb2c-08df5079b40e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|82310400026|23010399003|36860700016|1800799024|376014|7416014|11063799006|18002099003|261009223027099003|22082099003|10067099003|56012099006|261022075727099003|261102123227099003|261026140227099003|261028144727099003|261026121527099003|261021123027099003|261021121427099003|261022105027099003; X-Microsoft-Antispam-Message-Info: 1gBRGjN0tzQS9mU2DO6FneV2YpqMiXMQzW8qreZoDWsJofKwVTOnDEXhizqsCgmYfE1AG7gM8trgidQ3+3IYRIshm/iuIVAJ3u1btyI1FC9zm0bnomTdNnYXOKhLZTuMg3Ypzzq0jDY3X3aYP+5OWfS5g87mFmfwnIIu8mK4dJYq5UPh0YWVruakBYkNcY/yXmbOXmS9hEFE1up4JW+9uKR5GhcN+CqFk5ExZjF3rwgNkvDsVwi+LYaz+5I8tS024uU9EoiFxu086r+PX3olCXaEUshc64RRM8sA/YXKcnn2ZNrgN8tjI52k0pjvfy4AQY9cOZ9G0ur1asm3R8IixvfwGYx1gpTWcEHbtGO8HsA1My1gnYOE9IBDWRZs0ZkJyf9zYlriVtDSbD3srZN/d5JamThSw2RdUf/6gwETVC3mkLwf49w8PTOvAEXY8vF6Mtq6/mCq0QjSliW4+Bas/CK37vqn8cv6dFR9GvLmMGANFe5pg1P23t+iPki08k9uJwglEdbMGvDDSr/vaWxoV+M/cyJuxEe5QmPJNy5MhAv8Y6TYxvMEUUuj8sGSx2J62fSjbGcHcMPenLHfAkNVhwFs0eBLws1QlrVCfFS/DAlJ9ry+3CysUkUMsDnctkKICyLg8g8hbIYpoHy8XtqX+sssRFaeaMHueoJyM0KW9LvGtIWrKuSUIXo2DA7Lv5MkQOBw+GSi6JBBdm8RQAxatQ== X-Forefront-Antispam-Report: CIP:216.228.117.160;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:mail.nvidia.com;PTR:dc6edge1.nvidia.com;CAT:NONE;SFS:(13230040)(82310400026)(23010399003)(36860700016)(1800799024)(376014)(7416014)(11063799006)(18002099003)(261009223027099003)(22082099003)(10067099003)(56012099006)(261022075727099003)(261102123227099003)(261026140227099003)(261028144727099003)(261026121527099003)(261021123027099003)(261021121427099003)(261022105027099003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kXuCKhlhQgIDYLvAXRRjO9BRdyRUO6A+GE5ZCv/34RzGR8ROEgAIudPcAFTHGBQKPPyUrOXzpjws7bB9qvpSKK2/7a5zRNd3h6pGjYPaH/q9bdzrS/5oxDASOth5sU+i8pEQySzEKPMTc2YxzJkox2SCG1FJy8967JC8SS21Yf8vCTrx2hqEIYJ8izEH3qxJ/6Sx83UafLXKR94f4ZizoghoP8X8G+XSgknrWX9gvO1/VqmbCUUTWJRYGSLzzYPpQ3ifBApIU8nPbzhohW9fs/zo2EXjizBOClgG2QqnNyLEV8i97AiSnQiMWSPJlmDidF/BNAXZa7MJx2VEcn5RCqAsB4KN5rDqqwPjxyJlWNEifOJR9yW8EIOU3R+DC3/ApoTHTjiRXwu5dwksP4Xe1oR+jxs98WLnlGaNfNRrW0S4npUFZDPb7LXvNrOOiDju X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Dec 2026 13:39:35.0647 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cc274cbc-44ef-4717-bb2c-08df5079b40e X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a;Ip=[216.228.117.160];Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: CH2PEPF000166BB.namprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6917 Commit 0061b5199d7c ("devlink: Reverse locking order for nested instances") and commit 3bf4c5970ca8 ("devlink: Update nested instance locking comment") documented that a nested instance lock must be taken before its nested-in (parent) instance lock, in preparation for cross-device rates walking up the nested devlink chain. The previous commit removed that walk. Devlink core now only takes the shared instance lock while holding a nested instance lock, never the lock of an intermediate parent. Drivers, on the other hand, take the parent lock first, e.g. mlx5 holds the PF devlink lock while tearing down its SFs. Restore the original parent -> nested order in the documentation and in the devlink_rel_nested_in_notify() comment, and document the shared instance lock as the exception, always taken last. Also update devlink-shared.rst, which described the shared instance lock order as following the general nested instance rule. Fixes: 0061b5199d7c ("devlink: Reverse locking order for nested instances") Fixes: 3bf4c5970ca8 ("devlink: Update nested instance locking comment") Signed-off-by: Cosmin Ratiu --- Documentation/networking/devlink/devlink-shared.rst | 7 +++++-- Documentation/networking/devlink/index.rst | 12 ++++++------ net/devlink/core.c | 4 +++- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/Documentation/networking/devlink/devlink-shared.rst b/Documentation/networking/devlink/devlink-shared.rst index 16bf6a7d25d9..aa594c06d552 100644 --- a/Documentation/networking/devlink/devlink-shared.rst +++ b/Documentation/networking/devlink/devlink-shared.rst @@ -85,8 +85,11 @@ Locking A global mutex (``shd_mutex``) protects the shared instances list during registration/deregistration. -Similarly to other nested devlink instance relationships, devlink lock of -the shared instance should be always taken after the devlink lock of PF. +Unlike other nested devlink instance relationships, devlink lock of the +shared instance is always taken last, after the devlink lock of the PF or +of any other instance nested in it. It must not be held while taking +another instance lock or while waiting for a nested instance to be torn +down. Reference Counting ------------------ diff --git a/Documentation/networking/devlink/index.rst b/Documentation/networking/devlink/index.rst index aebfa5c06751..2fc929bf5544 100644 --- a/Documentation/networking/devlink/index.rst +++ b/Documentation/networking/devlink/index.rst @@ -31,8 +31,8 @@ sure to respect following rules: - Lock ordering should be maintained. If driver needs to take instance lock of both nested and parent instances at the same time, devlink - instance lock of the nested instance should be taken first, only then - instance lock of the parent instance could be taken. + instance lock of the parent instance should be taken first, only then + instance lock of the nested instance could be taken. - Driver should use object-specific helpers to setup the nested relationship before registering the nested devlink instance: @@ -48,10 +48,10 @@ attributes of devlink netlink. A shared devlink instance (see ``devlink_shd_get()``) is inherited at register time by all instances nested in it, directly or indirectly, and -can be obtained with ``devlink_shd()``. Devlink core may take the shared -instance lock while holding a nested instance lock, without taking the -locks of intermediate instances. Hence, the shared instance lock must not -be held while waiting for any nested instance to be torn down. +can be obtained with ``devlink_shd()``. As an exception to the rule above, +the shared instance lock is taken last, after any other instance lock it +may be nested with. Hence, it must not be held while taking another +instance lock or while waiting for any nested instance to be torn down. Interface documentation ----------------------- diff --git a/net/devlink/core.c b/net/devlink/core.c index 07b409198e41..009df043d253 100644 --- a/net/devlink/core.c +++ b/net/devlink/core.c @@ -184,7 +184,9 @@ int devlink_rel_nested_in_add(u32 *rel_index, u32 devlink_index, * a notification of a change of this object should be sent * over netlink. The parent devlink instance lock needs to be * taken during the notification preparation. - * Since the parent may or may not be locked, 'work' is utilized. + * However, since the devlink lock of nested instance is held here, + * we would end with wrong devlink instance lock ordering and + * deadlock. Therefore the work is utilized to avoid that. */ void devlink_rel_nested_in_notify(struct devlink *devlink) { -- 2.53.0