Skip to contentSkip to conversation

net: netpoll: remove dead code and speed up rtnl-locked region

PATCH Applied Breno Leitao 2 participants 4 messages Sep 18, 2025 – Sep 20, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover net: netpoll: remove dead code and speed up rtnl-locked region

This patchset introduces two minor modernizations to the netpoll infrastructure:

The first patch removes the unused netpoll pointer from the netpoll_info structure. This member is redundant and its presence does not benefit multi-instance setups, as reported by Jay Vosburgh. Eliminating it cleans up the structure and removes unnecessary code.

The second patch updates the netpoll resource cleanup routine to use synchronize_net() instead of synchronize_rcu(). As __netpoll_free() is always called under the RTNL lock, using synchronize_net() leverages the more efficient synchronize_rcu_expedited() in these contexts, reducing time spent in critical sections and improving performance.

Both changes simplify maintenance and enhance efficiency without altering netpoll behavior.

This is not expected to conflict with the other netpoll fix into net.

---
Breno Leitao (2):
net: netpoll: remove unused netpoll pointer from netpoll_info
net: netpoll: use synchronize_net() instead of synchronize_rcu()

 include/linux/netpoll.h | 1 -
 net/core/netpoll.c      | 3 +--
 2 files changed, 1 insertion(+), 3 deletions(-)

---
base-commit: 64d2616972b77506731fa0122d3c48cb04dbe21b
change-id: 20250918-netpoll_jv-9bf6f640f308

Best regards,

Signature · 1 line
Breno Leitao <[email protected]>
#1 lore raw

PATCH 1/2 net: netpoll: remove unused netpoll pointer from netpoll_info

The netpoll_info structure contains an useless pointer back to its associated netpoll. This field is never used, and the assignment in __netpoll_setup() is does not comtemplate multiple instances, as reported by Jay[1].

Drop both the member and its initialization to simplify the structure.

---
 include/linux/netpoll.h | 1 -
 net/core/netpoll.c      | 1 -
 2 files changed, 2 deletions(-)
include/linux/netpoll.h +0 -1
index b5ea9882eda8b..f22eec4660405 100644
@@ -55,7 +55,6 @@ struct netpoll_info {
 
 	struct delayed_work tx_work;
 
-	struct netpoll *netpoll;
 	struct rcu_head rcu;
 };
 
net/core/netpoll.c +0 -1
index 5f65b62346d4e..c58faa7471650 100644
@@ -591,7 +591,6 @@ int __netpoll_setup(struct netpoll *np, struct net_device *ndev)
 
 	np->dev = ndev;
 	strscpy(np->dev_name, ndev->name, IFNAMSIZ);
-	npinfo->netpoll = np;
 
 	/* fill up the skb queue */
 	refill_skbs(np);
Signature · 1 line
2.47.3
#2 lore raw

PATCH 2/2 net: netpoll: use synchronize_net() instead of synchronize_rcu()

In reply to Breno Leitao

Replace synchronize_rcu() with synchronize_net() in __netpoll_free().

synchronize_net() is RTNL-aware and will use the more efficient synchronize_rcu_expedited() when called under RTNL lock, avoiding the potentially expensive synchronize_rcu() in RTNL critical sections.

Since __netpoll_free() is called with RTNL held (as indicated by ASSERT_RTNL()), this change improves performance by reducing the time spent in the RTNL critical section.

---
 net/core/netpoll.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
net/core/netpoll.c +1 -1
index c58faa7471650..60a05d3b7c249 100644
@@ -834,7 +834,7 @@ void __netpoll_free(struct netpoll *np)
 	ASSERT_RTNL();
 
 	/* Wait for transmitting packets to finish before freeing. */
-	synchronize_rcu();
+	synchronize_net();
 	__netpoll_cleanup(np);
 	kfree(np);
 }
Signature · 1 line
2.47.3
#3 lore raw
In reply to Breno Leitao
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 9 lines · On Thu, 18 Sep 2025 05:25:56 -0700 you wrote:

This patchset introduces two minor modernizations to the netpoll infrastructure:

The first patch removes the unused netpoll pointer from the netpoll_info structure. This member is redundant and its presence does not benefit multi-instance setups, as reported by Jay Vosburgh. Eliminating it cleans up the structure and removes unnecessary code.

[...]

Here is the summary with links:
- [net-next,1/2] net: netpoll: remove unused netpoll pointer from netpoll_info

    https://git.kernel.org/netdev/net-next/c/b34df17d588d
  - [net-next,2/2] net: netpoll: use synchronize_net() instead of synchronize_rcu()
    https://git.kernel.org/netdev/net-next/c/614accf54553

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html