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 1A4EA3AA1B2; Thu, 15 Jan 2026 17:54:30 +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=1768499670; cv=none; b=XSXDWl9D8EMXLEiLS8uwqOMhQGSbahn9xPc4lIldAoB0FZtcpYwG60sFLMj8aF/kt5glPmUVlGgW9Pxd8rlE7XBZbzCxrUq3TjMF3KiySXu9BYIyERjj8wPzrjo9NW2Wx9hgvpAs9HSwT4kZNuCaB8YLtHkoSiHXWZyKlYFkoY8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768499670; c=relaxed/simple; bh=POrHtl3x8f8nBbA63Od0Y78Xb3flaCv5tbqjuPsxE7M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JEazGe5KRVP10bl39ChLxELN5U6EZrlKwp8nT8Ud7l+D3q2TqPQhxIA267OMvr/8cnH4Re18Z1ZQ6Ott0tod+btjDNH6/FJ0UTOgrLIwmmLuLG7/4BTYYDoGbsPR8Z3tEZpOtKa6VjWnSNozJeVpCKqjFLk0BWijtmrSiRkwh6g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ODCn4z7l; 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="ODCn4z7l" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 97624C116D0; Thu, 15 Jan 2026 17:54:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1768499670; bh=POrHtl3x8f8nBbA63Od0Y78Xb3flaCv5tbqjuPsxE7M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ODCn4z7l0ErmVsR4wCgJu0vt9EXOUhfwj42NzhMPwpId9JRu20zVqFTf7P+nk5n5b InarvO4h5j+JSo4kaVnj3WFIHI09sESsMr1koJhCQ8K05BI9HC23nDt+83bpGRHe+l GjCj8THLXtcqZDC4Fla08ONDh3CoJsd8tV2n5JAQ= 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 5.10 276/451] net: openvswitch: Avoid needlessly taking the RTNL on vport destroy Date: Thu, 15 Jan 2026 17:47:57 +0100 Message-ID: <20260115164240.869129821@linuxfoundation.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260115164230.864985076@linuxfoundation.org> References: <20260115164230.864985076@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 5.10-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 57d6436e6f6a..72cf13bbf3dd 100644 --- a/net/openvswitch/vport-netdev.c +++ b/net/openvswitch/vport-netdev.c @@ -155,10 +155,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