From: Stephen Hemminger <shemminger@linux-foundation.org>
To: "David S. Miller" <davem@davemloft.net>,
"Jeff Garzik" <jgarzik@pobox.com>
Cc: netdev@vger.kernel.org
Subject: [PATCH 1/2] napi_synchronize: waiting for NAPI
Date: Wed, 17 Oct 2007 13:26:41 -0700 [thread overview]
Message-ID: <20071017202653.266566036@linux-foundation.org> (raw)
In-Reply-To: 20071017202640.171902388@linux-foundation.org
[-- Attachment #1: napi-synchronize.patch --]
[-- Type: text/plain, Size: 1039 bytes --]
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>
next parent reply other threads:[~2007-10-17 20:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20071017202640.171902388@linux-foundation.org>
2007-10-17 20:26 ` Stephen Hemminger [this message]
2007-10-18 0:21 ` [PATCH 1/2] napi_synchronize: waiting for NAPI Jeff Garzik
2007-10-18 0:28 ` Benjamin Herrenschmidt
2007-10-18 1:26 ` Stephen Hemminger
2007-10-18 1:33 ` Benjamin Herrenschmidt
2007-10-17 20:26 ` [PATCH 2/2] sky2: shutdown cleanup Stephen Hemminger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20071017202653.266566036@linux-foundation.org \
--to=shemminger@linux-foundation.org \
--cc=davem@davemloft.net \
--cc=jgarzik@pobox.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).