linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH/RFC] net: Add __napi_sycnhronize() to sync with napi poll
@ 2007-10-16  5:49 Benjamin Herrenschmidt
  2007-10-16  6:06 ` Herbert Xu
  2007-10-16 18:53 ` Stephen Hemminger
  0 siblings, 2 replies; 21+ messages in thread
From: Benjamin Herrenschmidt @ 2007-10-16  5:49 UTC (permalink / raw)
  To: shemminger; +Cc: netdev, Roland Dreier, David S. Miller, linuxppc-dev list

net: Add __napi_sycnhronize() to sync with napi poll

The EMAC driver which needs to handle multiple devices with one
NAPI instance implements its own per-channel disable bit. However,
when setting such a bit, it needs to synchronize with the poller
(that is make sure that any pending poller instance has completed,
or is started late enough to see that disable bit).

This implements a low level __napi_synchronize() function to acheive
that. The underscores are to emphasis the low level aspect of it and
to discourage driver writers who don't know what they are doing to
use it (to please DaveM :-)

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---

(Use correct address for Stephen this time)

If the approach is accepted, I would like to have this merged now
so the EMAC patch to make it work again can follow :-)

Note: I use msleep_interruptible(1); just like napi_disable(). However
I'm not too happy that the "hot" loop that results of a pending signal
here will spin without even a cpu_relax ... what do you guys think would
be the best way to handle this ?



Index: linux-work/include/linux/netdevice.h
===================================================================
--- linux-work.orig/include/linux/netdevice.h	2007-10-16 15:27:27.000000000 +1000
+++ linux-work/include/linux/netdevice.h	2007-10-16 15:27:38.000000000 +1000
@@ -394,6 +394,21 @@ static inline void napi_disable(struct n
 }
 
 /**
+ *	__napi_synchronize - synchronize with a concurrent poll
+ *	@n: napi context
+ *
+ * Synchronizes with a concurrent poll. Not to be used in normal
+ * drivers, mostly useful if you end up with multiple interfaces
+ * on one NAPI instance.
+ */
+static inline void __napi_synchronize(struct napi_struct *n)
+{
+	smp_mb();
+	while (test_bit(NAPI_STATE_SCHED, &n->state))
+		msleep_interruptible(1);
+}
+
+/**
  *	napi_enable - enable NAPI scheduling
  *	@n: napi context
  *

^ permalink raw reply	[flat|nested] 21+ messages in thread
* [PATCH/RFC] net: Add __napi_sycnhronize() to sync with napi poll
@ 2007-10-16  5:40 Benjamin Herrenschmidt
  0 siblings, 0 replies; 21+ messages in thread
From: Benjamin Herrenschmidt @ 2007-10-16  5:40 UTC (permalink / raw)
  To: shemminger; +Cc: netdev, Roland Dreier, David S. Miller, linuxppc-dev list

net: Add __napi_sycnhronize() to sync with napi poll

The EMAC driver which needs to handle multiple devices with one
NAPI instance implements its own per-channel disable bit. However,
when setting such a bit, it needs to synchronize with the poller
(that is make sure that any pending poller instance has completed,
or is started late enough to see that disable bit).

This implements a low level __napi_synchronize() function to acheive
that. The underscores are to emphasis the low level aspect of it and
to discourage driver writers who don't know what they are doing to
use it (to please DaveM :-)

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---

If the approach is accepted, I would like to have this merged now
so the EMAC patch to make it work again can follow :-)

Note: I use msleep_interruptible(1); just like napi_disable(). However
I'm not too happy that the "hot" loop that results of a pending signal
here will spin without even a cpu_relax ... what do you guys think would
be the best way to handle this ?



Index: linux-work/include/linux/netdevice.h
===================================================================
--- linux-work.orig/include/linux/netdevice.h	2007-10-16 15:27:27.000000000 +1000
+++ linux-work/include/linux/netdevice.h	2007-10-16 15:27:38.000000000 +1000
@@ -394,6 +394,21 @@ static inline void napi_disable(struct n
 }
 
 /**
+ *	__napi_synchronize - synchronize with a concurrent poll
+ *	@n: napi context
+ *
+ * Synchronizes with a concurrent poll. Not to be used in normal
+ * drivers, mostly useful if you end up with multiple interfaces
+ * on one NAPI instance.
+ */
+static inline void __napi_synchronize(struct napi_struct *n)
+{
+	smp_mb();
+	while (test_bit(NAPI_STATE_SCHED, &n->state))
+		msleep_interruptible(1);
+}
+
+/**
  *	napi_enable - enable NAPI scheduling
  *	@n: napi context
  *

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

end of thread, other threads:[~2007-10-18  1:27 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-16  5:49 [PATCH/RFC] net: Add __napi_sycnhronize() to sync with napi poll Benjamin Herrenschmidt
2007-10-16  6:06 ` Herbert Xu
2007-10-16  7:37   ` Benjamin Herrenschmidt
2007-10-16  7:44     ` David Miller
2007-10-16 18:53 ` Stephen Hemminger
2007-10-16 21:14   ` Benjamin Herrenschmidt
2007-10-17  2:50   ` Benjamin Herrenschmidt
2007-10-17  2:52   ` Benjamin Herrenschmidt
2007-10-17  3:16     ` Jeff Garzik
2007-10-17  3:24       ` Benjamin Herrenschmidt
2007-10-17 15:31         ` Stephen Hemminger
2007-10-17 21:52           ` Benjamin Herrenschmidt
2007-10-17 22:04           ` [PATCH] net: Add napi_sycnhronize() " Benjamin Herrenschmidt
2007-10-17 23:36             ` Josh Boyer
2007-10-17 23:59               ` Benjamin Herrenschmidt
2007-10-18  1:02             ` Josh Boyer
2007-10-18  1:26               ` Benjamin Herrenschmidt
2007-10-18  1:19             ` Benjamin Herrenschmidt
2007-10-17 23:14           ` [PATCH] fix EMAC driver for proper napi_synchronize API Benjamin Herrenschmidt
2007-10-18  0:21             ` Jeff Garzik
  -- strict thread matches above, loose matches on Subject: below --
2007-10-16  5:40 [PATCH/RFC] net: Add __napi_sycnhronize() to sync with napi poll Benjamin Herrenschmidt

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).