All of lore.kernel.org
 help / color / mirror / Atom feed
From: cbouatmailru@gmail.com (Anton Vorontsov)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH RFC 3/4] net: Implement napi_try_disable()
Date: Wed, 7 Jul 2010 21:13:29 +0400	[thread overview]
Message-ID: <20100707171329.GC20015@oksana.dev.rtsoft.ru> (raw)
In-Reply-To: <20100707171222.GA16448@oksana.dev.rtsoft.ru>

For KGDBoE we'll need to disable NAPI, so that we don't randomly
interrupt secondary CPUs while they process networking stuff.

We need to wait for NAPI to become disabled from an atomic context,
thus we can't use napi_disable() as it calls msleep().

Plus, in KGDB we have to always poll for IPIs during busy-waiting,
which means that we must implement the function in a such way that
we can do some caller specific work during the time we wait for
NAPI disable, so just changing msleep() to mdelay() won't work.

Signed-off-by: Anton Vorontsov <avorontsov@mvista.com>
---
 include/linux/netdevice.h |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 08a1dd8..4fc24eb 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -414,6 +414,27 @@ extern void __napi_complete(struct napi_struct *n);
 extern void napi_complete(struct napi_struct *n);
 
 /**
+ *	napi_try_disable - try to prevent NAPI from scheduling
+ *	@n: napi context
+ *
+ * This call is similar to napi_disable(), except that it doesn't
+ * wait till any outstanding processing completes, but returns
+ * whether napi was successfuly disabled.
+ *
+ * Note that you still must wait till napi is actually disabled,
+ * so the only benefit from using this call is that you can do
+ * some useful work while you wait.
+ */
+static inline int napi_try_disable(struct napi_struct *n)
+{
+	set_bit(NAPI_STATE_DISABLE, &n->state);
+	if (test_and_set_bit(NAPI_STATE_SCHED, &n->state))
+		return 0;
+	clear_bit(NAPI_STATE_DISABLE, &n->state);
+	return 1;
+}
+
+/**
  *	napi_disable - prevent NAPI from scheduling
  *	@n: napi context
  *
-- 
1.7.0.5

WARNING: multiple messages have this Message-ID (diff)
From: Anton Vorontsov <cbouatmailru@gmail.com>
To: kgdb-bugreport@lists.sourceforge.net
Cc: Russell King <linux@arm.linux.org.uk>,
	"David S. Miller" <davem@davemloft.net>,
	Jason Wessel <jason.wessel@windriver.com>,
	netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Subject: [PATCH RFC 3/4] net: Implement napi_try_disable()
Date: Wed, 7 Jul 2010 21:13:29 +0400	[thread overview]
Message-ID: <20100707171329.GC20015@oksana.dev.rtsoft.ru> (raw)
In-Reply-To: <20100707171222.GA16448@oksana.dev.rtsoft.ru>

For KGDBoE we'll need to disable NAPI, so that we don't randomly
interrupt secondary CPUs while they process networking stuff.

We need to wait for NAPI to become disabled from an atomic context,
thus we can't use napi_disable() as it calls msleep().

Plus, in KGDB we have to always poll for IPIs during busy-waiting,
which means that we must implement the function in a such way that
we can do some caller specific work during the time we wait for
NAPI disable, so just changing msleep() to mdelay() won't work.

Signed-off-by: Anton Vorontsov <avorontsov@mvista.com>
---
 include/linux/netdevice.h |   21 +++++++++++++++++++++
 1 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/include/linux/netdevice.h b/include/linux/netdevice.h
index 08a1dd8..4fc24eb 100644
--- a/include/linux/netdevice.h
+++ b/include/linux/netdevice.h
@@ -414,6 +414,27 @@ extern void __napi_complete(struct napi_struct *n);
 extern void napi_complete(struct napi_struct *n);
 
 /**
+ *	napi_try_disable - try to prevent NAPI from scheduling
+ *	@n: napi context
+ *
+ * This call is similar to napi_disable(), except that it doesn't
+ * wait till any outstanding processing completes, but returns
+ * whether napi was successfuly disabled.
+ *
+ * Note that you still must wait till napi is actually disabled,
+ * so the only benefit from using this call is that you can do
+ * some useful work while you wait.
+ */
+static inline int napi_try_disable(struct napi_struct *n)
+{
+	set_bit(NAPI_STATE_DISABLE, &n->state);
+	if (test_and_set_bit(NAPI_STATE_SCHED, &n->state))
+		return 0;
+	clear_bit(NAPI_STATE_DISABLE, &n->state);
+	return 1;
+}
+
+/**
  *	napi_disable - prevent NAPI from scheduling
  *	@n: napi context
  *
-- 
1.7.0.5


  parent reply	other threads:[~2010-07-07 17:13 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-07 17:12 [PATCH RFC 0/4] ARM/KGDB: Some fixes for SMP machines Anton Vorontsov
2010-07-07 17:12 ` Anton Vorontsov
2010-07-07 17:13 ` [PATCH RFC 1/4] ARM: kgdb: Must poll for IPIs during busy-waiting Anton Vorontsov
2010-07-07 17:13   ` Anton Vorontsov
2010-07-07 17:13 ` [PATCH RFC 2/4] ARM: kgdb: Disable preemption before re-enabling interrupts Anton Vorontsov
2010-07-07 17:13   ` Anton Vorontsov
2010-07-07 17:13 ` Anton Vorontsov [this message]
2010-07-07 17:13   ` [PATCH RFC 3/4] net: Implement napi_try_disable() Anton Vorontsov
2010-07-07 17:13 ` [PATCH RFC 4/4] kgdb: Quiesce IO back-end before rounding up secondary CPUs Anton Vorontsov
2010-07-07 17:13   ` Anton Vorontsov
2010-07-07 17:54 ` [PATCH RFC 0/4] ARM/KGDB: Some fixes for SMP machines Anton Vorontsov
2010-07-07 17:54   ` Anton Vorontsov
2010-07-08  8:48 ` Will Deacon
2010-07-08  8:48 ` Will Deacon
2010-07-08  8:48 ` Will Deacon

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=20100707171329.GC20015@oksana.dev.rtsoft.ru \
    --to=cbouatmailru@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.