[PATCH 1/2] napi_synchronize: waiting for NAPI

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: David S. Miller <davem@...>, Jeff Garzik <jgarzik@...>
Cc: <netdev@...>
Date: Wednesday, October 17, 2007 - 4:26 pm

Some drivers with shared NAPI need a synchronization barrier.
Also suggested by Benjamin Herrenschmidt for EMAC.

Signed-off-by: Stephen Hemminger <shemminger@linux-foundation.org>

--- a/include/linux/netdevice.h	2007-10-17 08:45:32.000000000 -0700
+++ b/include/linux/netdevice.h	2007-10-17 08:47:54.000000000 -0700
@@ -407,6 +407,24 @@ static inline void napi_enable(struct na
 	clear_bit(NAPI_STATE_SCHED, &n->state);
 }
 
+#ifdef CONFIG_SMP
+/**
+ *	napi_synchronize - wait until NAPI is not running
+ *	@n: napi context
+ *
+ * Wait until NAPI is done being scheduled on this context.
+ * Waits till any outstanding processing completes but
+ * does not disable future activations.
+ */
+static inline void napi_synchronize(const struct napi_struct *n)
+{
+	while (test_bit(NAPI_STATE_SCHED, &n->state))
+		msleep(1);
+}
+#else
+# define napi_synchronize(n)	barrier()
+#endif
+
 /*
  *	The DEVICE structure.
  *	Actually, this whole structure is a big mistake.  It mixes I/O

-- 
Stephen Hemminger <shemminger@linux-foundation.org>

-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 1/2] napi_synchronize: waiting for NAPI, Stephen Hemminger, (Wed Oct 17, 4:26 pm)
Re: [PATCH 1/2] napi_synchronize: waiting for NAPI, Benjamin Herrenschmidt, (Wed Oct 17, 8:28 pm)
Re: [PATCH 1/2] napi_synchronize: waiting for NAPI, Stephen Hemminger, (Wed Oct 17, 9:26 pm)
Re: [PATCH 1/2] napi_synchronize: waiting for NAPI, Benjamin Herrenschmidt, (Wed Oct 17, 9:33 pm)
Re: [PATCH 1/2] napi_synchronize: waiting for NAPI, Jeff Garzik, (Wed Oct 17, 8:21 pm)