netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: fix hangup on napi_disable for threaded napi
@ 2021-03-31 22:46 Paolo Abeni
  2021-04-01  1:41 ` Jakub Kicinski
  0 siblings, 1 reply; 9+ messages in thread
From: Paolo Abeni @ 2021-03-31 22:46 UTC (permalink / raw)
  To: netdev; +Cc: Eric Dumazet, Wei Wang, David S. Miller, Jakub Kicinski

I hit an hangup on napi_disable(), when the threaded
mode is enabled and the napi is under heavy traffic.

If the relevant napi has been scheduled and the napi_disable()
kicks in before the next napi_threaded_wait() completes - so
that the latter quits due to the napi_disable_pending() condition,
the existing code leaves the NAPI_STATE_SCHED bit set and the
napi_disable() loop waiting for such bit will hang.

Address the issue explicitly clearing the SCHED_BIT on napi_thread
termination, if the thread is owns the napi.

Fixes: 29863d41bb6e ("net: implement threaded-able napi poll loop support")
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
---
 net/core/dev.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/net/core/dev.c b/net/core/dev.c
index b4c67a5be606d..e2e716ba027b8 100644
--- a/net/core/dev.c
+++ b/net/core/dev.c
@@ -7059,6 +7059,14 @@ static int napi_thread_wait(struct napi_struct *napi)
 		set_current_state(TASK_INTERRUPTIBLE);
 	}
 	__set_current_state(TASK_RUNNING);
+
+	/* if the thread owns this napi, and the napi itself has been disabled
+	 * in-between napi_schedule() and the above napi_disable_pending()
+	 * check, we need to clear the SCHED bit here, or napi_disable
+	 * will hang waiting for such bit being cleared
+	 */
+	if (test_bit(NAPI_STATE_SCHED_THREADED, &napi->state) || woken)
+		clear_bit(NAPI_STATE_SCHED, &napi->state);
 	return -1;
 }
 
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2021-04-09 15:15 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-03-31 22:46 [PATCH net] net: fix hangup on napi_disable for threaded napi Paolo Abeni
2021-04-01  1:41 ` Jakub Kicinski
2021-04-01  9:55   ` Paolo Abeni
2021-04-01 23:44     ` Jakub Kicinski
2021-04-07 14:54       ` Paolo Abeni
2021-04-07 18:13         ` Jakub Kicinski
2021-04-09  9:24           ` Paolo Abeni
2021-04-09 10:08             ` Eric Dumazet
2021-04-09 15:15             ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).