From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EE3D925C6E2 for ; Mon, 7 Apr 2025 19:01:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744052480; cv=none; b=bYdgB57Q86jtFqxUDbGZnrsEnlMOBfrSa2OjcS31OLxkgHn9bl//JD+T0P7hdweZkTefibEL2YI5/E/4MSBnLCVwBnfaPCx/8vRRF5p4X8yXqW5UYAgRUap0MSqyVF1McRasoqG2zaV94KsLvaDMjbrx3QlVwJMzmfyPlWXIPf8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1744052480; c=relaxed/simple; bh=KtUGbnMVjTJzA4LrwSh6i3lHe0lOhPLH4wdwxBedvcU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MjzwhMrX1b8gNa67evauv41DA7lBDlpFmGKkdK18KphW76gkBSoTLeDTYHmprQTGxijP+WLVe3VT16xE1valOIEZZx6jEdYTULZbzqi0XnwrfTmoqTGnopn/THXSWxkAOX0pp0Uw3p/CdF0jwMx8UbrDc0vDjblfOFrX7uAphdU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=db00389w; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="db00389w" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8802CC4CEDD; Mon, 7 Apr 2025 19:01:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1744052479; bh=KtUGbnMVjTJzA4LrwSh6i3lHe0lOhPLH4wdwxBedvcU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=db00389wtI5w34jMsP2sJPk4nhQyjGGyo0wBhWRGCbEXoEjEEp6oSbcQEjKX6rFEb MbeoL0VKMpX5HkOPo+H6FWihObJPlhq1sgHAotSdh+8FnR7ReXTIeH/q6p11SC28Ez 4Sv0YCvIXVNkR250jjrZfOae3LWdZvUGqANCEcaoEcaCu4OntCWIhAESxmarnhPliT J/6quaus4mRPfYgrVoc5hPnxJ4pKpbIR7g4UYtZc4052pdc0sLQzYwJspp76TAHIDG TyPCReNnXYvZlH4Ah6Dp0WxS2Ac9AHzKGWcgqcU2oqAzW0saNAXnFehKhM4bA2nIHb L10it78zEg/uQ== From: Jakub Kicinski To: davem@davemloft.net Cc: netdev@vger.kernel.org, edumazet@google.com, pabeni@redhat.com, andrew+netdev@lunn.ch, horms@kernel.org, sdf@fomichev.me, hramamurthy@google.com, kuniyu@amazon.com, jdamato@fastly.com Subject: [PATCH net-next 4/8] netdev: don't hold rtnl_lock over nl queue info get when possible Date: Mon, 7 Apr 2025 12:01:13 -0700 Message-ID: <20250407190117.16528-5-kuba@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250407190117.16528-1-kuba@kernel.org> References: <20250407190117.16528-1-kuba@kernel.org> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Netdev queue dump accesses: NAPI, memory providers, XSk pointers. All three are "ops protected" now, switch to the op compat locking. rtnl lock does not have to be taken for "ops locked" devices. Signed-off-by: Jakub Kicinski --- net/core/netdev-genl.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/net/core/netdev-genl.c b/net/core/netdev-genl.c index 5d7af50fe702..7ef9b0191936 100644 --- a/net/core/netdev-genl.c +++ b/net/core/netdev-genl.c @@ -481,18 +481,15 @@ int netdev_nl_queue_get_doit(struct sk_buff *skb, struct genl_info *info) if (!rsp) return -ENOMEM; - rtnl_lock(); - - netdev = netdev_get_by_index_lock(genl_info_net(info), ifindex); + netdev = netdev_get_by_index_lock_ops_compat(genl_info_net(info), + ifindex); if (netdev) { err = netdev_nl_queue_fill(rsp, netdev, q_id, q_type, info); - netdev_unlock(netdev); + netdev_unlock_ops_compat(netdev); } else { err = -ENODEV; } - rtnl_unlock(); - if (err) goto err_free_msg; @@ -541,17 +538,17 @@ int netdev_nl_queue_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb) if (info->attrs[NETDEV_A_QUEUE_IFINDEX]) ifindex = nla_get_u32(info->attrs[NETDEV_A_QUEUE_IFINDEX]); - rtnl_lock(); if (ifindex) { - netdev = netdev_get_by_index_lock(net, ifindex); + netdev = netdev_get_by_index_lock_ops_compat(net, ifindex); if (netdev) { err = netdev_nl_queue_dump_one(netdev, skb, info, ctx); - netdev_unlock(netdev); + netdev_unlock_ops_compat(netdev); } else { err = -ENODEV; } } else { - for_each_netdev_lock_scoped(net, netdev, ctx->ifindex) { + for_each_netdev_lock_ops_compat_scoped(net, netdev, + ctx->ifindex) { err = netdev_nl_queue_dump_one(netdev, skb, info, ctx); if (err < 0) break; @@ -559,7 +556,6 @@ int netdev_nl_queue_get_dumpit(struct sk_buff *skb, struct netlink_callback *cb) ctx->txq_idx = 0; } } - rtnl_unlock(); return err; } -- 2.49.0