From: Steven Rostedt <rostedt@goodmis.org>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: alison@peloton-tech.com, LKML <linux-kernel@vger.kernel.org>,
linux-rt-users <linux-rt-users@vger.kernel.org>,
netdev <netdev@vger.kernel.org>,
Thomas Gleixner <tglx@linutronix.de>,
Peter Zijlstra <peterz@infradead.org>,
Clark Williams <williams@redhat.com>,
Eric Dumazet <eric.dumazet@gmail.com>,
David Miller <davem@davemloft.net>
Subject: Re: [PATCH][RT] netpoll: Always take poll_lock when doing polling
Date: Sat, 4 Jun 2016 07:11:31 -0400 [thread overview]
Message-ID: <20160604071131.08d449db@grimm.local.home> (raw)
In-Reply-To: <20160602161235.GA12971@linutronix.de>
On Thu, 2 Jun 2016 18:12:35 +0200
Sebastian Andrzej Siewior <bigeasy@linutronix.de> wrote:
> * Steven Rostedt | 2016-05-26 19:56:41 [-0400]:
>
> >[ Alison, can you try this patch ]
>
> Alison, did you try it?
>
> Sebastian
This patch may help too...
-- Steve
>From 729e35706b8352d83692764adbeca429bb26ba7f Mon Sep 17 00:00:00 2001
From: Steven Rostedt <srostedt@redhat.com>
Date: Tue, 5 Jan 2016 14:53:09 -0500
Subject: [PATCH] softirq: Perform softirqs in local_bh_enable() for a limited
amount of time
To prevent starvation of tasks like ksoftirqd, if the task that is
processing its softirqs takes more than 2 jiffies to do so, and the
softirqs are constantly being re-added, then defer the processing to
ksoftirqd.
Signed-off-by: Steven Rostedt <rosted@goodmis.org>
Signed-off-by: Luis Claudio R. Goncalves <lgoncalv@redhat.com>
---
kernel/softirq.c | 53 ++++++++++++++++++++++++++++++++++-------------------
1 file changed, 34 insertions(+), 19 deletions(-)
Index: linux-rt.git/kernel/softirq.c
===================================================================
--- linux-rt.git.orig/kernel/softirq.c 2016-06-04 07:01:54.584296827 -0400
+++ linux-rt.git/kernel/softirq.c 2016-06-04 07:06:35.449913451 -0400
@@ -206,6 +206,22 @@ static void handle_softirq(unsigned int
}
}
+/*
+ * We restart softirq processing for at most MAX_SOFTIRQ_RESTART times,
+ * but break the loop if need_resched() is set or after 2 ms.
+ * The MAX_SOFTIRQ_TIME provides a nice upper bound in most cases, but in
+ * certain cases, such as stop_machine(), jiffies may cease to
+ * increment and so we need the MAX_SOFTIRQ_RESTART limit as
+ * well to make sure we eventually return from this method.
+ *
+ * These limits have been established via experimentation.
+ * The two things to balance is latency against fairness -
+ * we want to handle softirqs as soon as possible, but they
+ * should not be able to lock up the box.
+ */
+#define MAX_SOFTIRQ_TIME msecs_to_jiffies(2)
+#define MAX_SOFTIRQ_RESTART 10
+
#ifndef CONFIG_PREEMPT_RT_FULL
static inline int ksoftirqd_softirq_pending(void)
{
@@ -349,22 +365,6 @@ void __local_bh_enable_ip(unsigned long
}
EXPORT_SYMBOL(__local_bh_enable_ip);
-/*
- * We restart softirq processing for at most MAX_SOFTIRQ_RESTART times,
- * but break the loop if need_resched() is set or after 2 ms.
- * The MAX_SOFTIRQ_TIME provides a nice upper bound in most cases, but in
- * certain cases, such as stop_machine(), jiffies may cease to
- * increment and so we need the MAX_SOFTIRQ_RESTART limit as
- * well to make sure we eventually return from this method.
- *
- * These limits have been established via experimentation.
- * The two things to balance is latency against fairness -
- * we want to handle softirqs as soon as possible, but they
- * should not be able to lock up the box.
- */
-#define MAX_SOFTIRQ_TIME msecs_to_jiffies(2)
-#define MAX_SOFTIRQ_RESTART 10
-
#ifdef CONFIG_TRACE_IRQFLAGS
/*
* When we run softirqs from irq_exit() and thus on the hardirq stack we need
@@ -537,11 +537,17 @@ static void do_single_softirq(int which)
*/
static void do_current_softirqs(void)
{
- while (current->softirqs_raised) {
- int i = __ffs(current->softirqs_raised);
+ unsigned long end = jiffies + MAX_SOFTIRQ_TIME;
+ unsigned int softirqs_raised = current->softirqs_raised;
+
+restart:
+ current->softirqs_raised &= ~softirqs_raised;
+
+ while (softirqs_raised) {
+ int i = __ffs(softirqs_raised);
unsigned int pending, mask = (1U << i);
- current->softirqs_raised &= ~mask;
+ softirqs_raised &= ~mask;
local_irq_enable();
/*
@@ -568,6 +574,15 @@ static void do_current_softirqs(void)
unlock_softirq(i);
local_irq_disable();
}
+
+ softirqs_raised = current->softirqs_raised;
+ if (softirqs_raised) {
+ if (time_before(jiffies, end))
+ goto restart;
+
+ __this_cpu_read(ksoftirqd)->softirqs_raised |= softirqs_raised;
+ wakeup_softirqd();
+ }
}
void __local_bh_disable(void)
next prev parent reply other threads:[~2016-06-04 11:11 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-26 23:56 [PATCH][RT] netpoll: Always take poll_lock when doing polling Steven Rostedt
2016-06-02 16:12 ` Sebastian Andrzej Siewior
2016-06-04 11:11 ` Steven Rostedt [this message]
2016-06-05 15:16 ` Alison Chaiken
2016-06-06 12:03 ` Clark Williams
2016-06-06 23:25 ` Alison Chaiken
2016-06-07 9:46 ` Sebastian Andrzej Siewior
2016-06-08 0:19 ` Alison Chaiken
2016-06-09 12:37 ` Sebastian Andrzej Siewior
2016-09-03 23:40 ` Alison Chaiken
2016-06-10 15:57 ` Sebastian Andrzej Siewior
2016-06-10 16:11 ` Steven Rostedt
2016-06-10 16:20 ` Sebastian Andrzej Siewior
2016-06-10 16:45 ` Steven Rostedt
2016-06-10 15:30 ` Sebastian Andrzej Siewior
2016-06-10 16:28 ` Eric Dumazet
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=20160604071131.08d449db@grimm.local.home \
--to=rostedt@goodmis.org \
--cc=alison@peloton-tech.com \
--cc=bigeasy@linutronix.de \
--cc=davem@davemloft.net \
--cc=eric.dumazet@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rt-users@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
--cc=williams@redhat.com \
/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).