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 58CBD2222AC; Tue, 6 Jan 2026 17:31:06 +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=1767720666; cv=none; b=UrXMIFpDxcuXtZ6J7vjEg1lILZFOmGBKt+KJ6Nm7ziByXA2//qlBr8+MvPHGWcQNpwNfRBK6WeCFO56GcNi+m7MURLLQt3xWmhudMRADQUd+skSunXEO+lAGHR1bG8AVWqxYLUzA3JkoxyFtfHhbr7qTfSe9lfvZixzhin5sMi0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767720666; c=relaxed/simple; bh=jLaFlpUlogtTiAuX0v4S0BIv+lZxa1hUpDSyM2T97gs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=qDDt9H4LgTgr4CqaZ1viyEGgND4WokmmYa3q0jnSs8PW7MSUjYhOVO6DkKjqzNeB6us+DXhxTH4BxBKIon1s2/QIVAxO+OKJrgOEA0gLrjgA6rhyYwBEOWV6anLvXEgEt8xCq1FArJySI8RC5gX063eiRSMHnV94CGv9UGKnpss= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=efjutA5X; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="efjutA5X" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BDB7AC116C6; Tue, 6 Jan 2026 17:31:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1767720666; bh=jLaFlpUlogtTiAuX0v4S0BIv+lZxa1hUpDSyM2T97gs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=efjutA5Xh/h1PBHkIpFT/efXf77CUoulHbDrktf432s2JhxSY0XKpQ1Nd+2SGE0fW 9rkercHG9yrK6sjIPHUT+3EZfoggamixsXu2xYqYWOCMUGl2/PHLsTDyxGtC3DY3KA BCebAs4WjLHP82T0bH5fJI5ts/LLVC6IyNBaIoOs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Adrian Moreno , =?UTF-8?q?Toke=20H=C3=B8iland-J=C3=B8rgensen?= , Eelco Chaudron , Aaron Conole , Paolo Abeni , Sasha Levin Subject: [PATCH 6.12 305/567] net: openvswitch: Avoid needlessly taking the RTNL on vport destroy Date: Tue, 6 Jan 2026 18:01:27 +0100 Message-ID: <20260106170502.613658641@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260106170451.332875001@linuxfoundation.org> References: <20260106170451.332875001@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.12-stable review patch. If anyone has any objections, please let me know. ------------------ From: Toke Høiland-Jørgensen [ Upstream commit 5498227676303e3ffa9a3a46214af96bc3e81314 ] The openvswitch teardown code will immediately call ovs_netdev_detach_dev() in response to a NETDEV_UNREGISTER notification. It will then start the dp_notify_work workqueue, which will later end up calling the vport destroy() callback. This callback takes the RTNL to do another ovs_netdev_detach_port(), which in this case is unnecessary. This causes extra pressure on the RTNL, in some cases leading to "unregister_netdevice: waiting for XX to become free" warnings on teardown. We can straight-forwardly avoid the extra RTNL lock acquisition by checking the device flags before taking the lock, and skip the locking altogether if the IFF_OVS_DATAPATH flag has already been unset. Fixes: b07c26511e94 ("openvswitch: fix vport-netdev unregister") Tested-by: Adrian Moreno Signed-off-by: Toke Høiland-Jørgensen Acked-by: Eelco Chaudron Acked-by: Aaron Conole Link: https://patch.msgid.link/20251211115006.228876-1-toke@redhat.com Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin --- net/openvswitch/vport-netdev.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/net/openvswitch/vport-netdev.c b/net/openvswitch/vport-netdev.c index 91a11067e458..6574f9bcdc02 100644 --- a/net/openvswitch/vport-netdev.c +++ b/net/openvswitch/vport-netdev.c @@ -160,10 +160,19 @@ void ovs_netdev_detach_dev(struct vport *vport) static void netdev_destroy(struct vport *vport) { - rtnl_lock(); - if (netif_is_ovs_port(vport->dev)) - ovs_netdev_detach_dev(vport); - rtnl_unlock(); + /* When called from ovs_db_notify_wq() after a dp_device_event(), the + * port has already been detached, so we can avoid taking the RTNL by + * checking this first. + */ + if (netif_is_ovs_port(vport->dev)) { + rtnl_lock(); + /* Check again while holding the lock to ensure we don't race + * with the netdev notifier and detach twice. + */ + if (netif_is_ovs_port(vport->dev)) + ovs_netdev_detach_dev(vport); + rtnl_unlock(); + } call_rcu(&vport->rcu, vport_netdev_free); } -- 2.51.0