Skip to contentSkip to conversation

net: drv: netdevsim: don't napi_complete() from netpoll

PATCH Applied Jakub Kicinski 4 participants 6 messages Jun 11, 2025 – Jun 12, 2025

Subsystems (3)
lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

PATCH 1/1 net: drv: netdevsim: don't napi_complete() from netpoll

netdevsim supports netpoll. Make sure we don't call napi_complete() from it, since it may not be scheduled. Breno reports hitting a warning in napi_complete_done():

WARNING: CPU: 14 PID: 104 at net/core/dev.c:6592 napi_complete_done+0x2cc/0x560
  __napi_poll+0x2d8/0x3a0
  handle_softirqs+0x1fe/0x710

This is presumably after netpoll stole the SCHED bit prematurely.

Fixes 3762ec05a9fb ("netdevsim: add NAPI support")

---
CC: [email protected]

---
 drivers/net/netdevsim/netdev.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/netdevsim/netdev.c +2 -1
index af545d42961c..fa5fbd97ad69 100644
@@ -371,7 +371,8 @@ static int nsim_poll(struct napi_struct *napi, int budget)
 	int done;
 
 	done = nsim_rcv(rq, budget);
-	napi_complete(napi);
+	if (done < budget)
+		napi_complete_done(napi, done);
 
 	return done;
 }
Signature · 1 line
2.49.0
#1 lore raw
Quoted 3 lines · Jakub Kicinski

netdevsim supports netpoll. Make sure we don't call napi_complete() from it, since it may not be scheduled. Breno reports hitting a warning in napi_complete_done():

I decided to go learn a bit more about netdevsim, and ran across a typo in Documentation/networking/devlink/netdevsim.rst:

The ``netdevsim`` driver supports rate objects management, which includes:

- registerging/unregistering leaf rate objects per VF devlink port; ^^^^^^^^^^^^

-Dave

#2 lore raw

Hello Dave,

Quoted 8 lines · Dave Marquardt
Quoted 3 lines · Jakub Kicinski

netdevsim supports netpoll. Make sure we don't call napi_complete() from it, since it may not be scheduled. Breno reports hitting a warning in napi_complete_done():

I decided to go learn a bit more about netdevsim, and ran across a typo in Documentation/networking/devlink/netdevsim.rst:

I acknowledge the bug exists in the latest netnext/main repo. Would you like to send a patch and fix it, or, should we?

Thanks for reporting it.
--breno

#3 lore raw
Quoted 9 lines · Breno Leitao

Hello Dave,

Quoted 6 lines · Dave Marquardt
Quoted 3 lines · Jakub Kicinski

netdevsim supports netpoll. Make sure we don't call napi_complete() from it, since it may not be scheduled. Breno reports hitting a warning in napi_complete_done():

Quoted 5 lines
Quoted 2 lines

I decided to go learn a bit more about netdevsim, and ran across a typo in Documentation/networking/devlink/netdevsim.rst:

I acknowledge the bug exists in the latest netnext/main repo. Would you like to send a patch and fix it, or, should we?

I'll send in a patch. Thanks.

Quoted 1 line

Thanks for reporting it.

You're welcome!

-Dave

Tested-by on v1 1/1
#4 lore raw
In reply to Jakub Kicinski

Hello Jakub,

Quoted 8 lines · Jakub Kicinski

netdevsim supports netpoll. Make sure we don't call napi_complete() from it, since it may not be scheduled. Breno reports hitting a warning in napi_complete_done():

WARNING: CPU: 14 PID: 104 at net/core/dev.c:6592 napi_complete_done+0x2cc/0x560
  __napi_poll+0x2d8/0x3a0
  handle_softirqs+0x1fe/0x710
Quoted 5 lines

This is presumably after netpoll stole the SCHED bit prematurely.

Fixes 3762ec05a9fb ("netdevsim: add NAPI support")

Thanks for the quick fix,
--breno

#5 lore raw
In reply to Jakub Kicinski
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

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

Quoted 9 lines · On Wed, 11 Jun 2025 10:46:43 -0700 you wrote:

netdevsim supports netpoll. Make sure we don't call napi_complete() from it, since it may not be scheduled. Breno reports hitting a warning in napi_complete_done():

WARNING: CPU: 14 PID: 104 at net/core/dev.c:6592 napi_complete_done+0x2cc/0x560
  __napi_poll+0x2d8/0x3a0
  handle_softirqs+0x1fe/0x710

[...]

Here is the summary with links:
- [net] net: drv: netdevsim: don't napi_complete() from netpoll

    https://git.kernel.org/netdev/net/c/1264971017b4

You are awesome, thank you!

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