netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] softirq: reduce latencies
@ 2013-01-03 12:28 Eric Dumazet
  2013-01-03 20:46 ` Andrew Morton
  2013-01-03 22:08 ` Ben Hutchings
  0 siblings, 2 replies; 22+ messages in thread
From: Eric Dumazet @ 2013-01-03 12:28 UTC (permalink / raw)
  To: David Miller, Andrew Morton
  Cc: netdev, linux-kernel@vger.kernel.org, Tom Herbert

From: Eric Dumazet <edumazet@google.com>

In various network workloads, __do_softirq() latencies can be up
to 20 ms if HZ=1000, and 200 ms if HZ=100.

This is because we iterate 10 times in the softirq dispatcher,
and some actions can consume a lot of cycles.

This patch changes the fallback to ksoftirqd condition to :

- A time limit of 2 ms.
- need_resched() being set on current task

When one of this condition is met, we wakeup ksoftirqd for further
softirq processing if we still have pending softirqs.

I ran several benchmarks and got no significant difference in
throughput, but a very significant reduction of maximum latencies.

Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: David Miller <davem@davemloft.net>
Cc: Tom Herbert <therbert@google.com>
---
 kernel/softirq.c |   17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/kernel/softirq.c b/kernel/softirq.c
index ed567ba..64d61ea 100644
--- a/kernel/softirq.c
+++ b/kernel/softirq.c
@@ -195,21 +195,21 @@ void local_bh_enable_ip(unsigned long ip)
 EXPORT_SYMBOL(local_bh_enable_ip);
 
 /*
- * We restart softirq processing MAX_SOFTIRQ_RESTART times,
- * and we fall back to softirqd after that.
+ * We restart softirq processing for at most 2 ms,
+ * and if need_resched() is not set.
  *
- * This number has been established via experimentation.
+ * 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_RESTART 10
+#define MAX_SOFTIRQ_TIME  min(1, (2*HZ/1000))
 
 asmlinkage void __do_softirq(void)
 {
 	struct softirq_action *h;
 	__u32 pending;
-	int max_restart = MAX_SOFTIRQ_RESTART;
+	unsigned long end = jiffies + MAX_SOFTIRQ_TIME;
 	int cpu;
 	unsigned long old_flags = current->flags;
 
@@ -264,11 +264,12 @@ restart:
 	local_irq_disable();
 
 	pending = local_softirq_pending();
-	if (pending && --max_restart)
-		goto restart;
+	if (pending) {
+		if (time_before(jiffies, end) && !need_resched())
+			goto restart;
 
-	if (pending)
 		wakeup_softirqd();
+	}
 
 	lockdep_softirq_exit();
 

^ permalink raw reply related	[flat|nested] 22+ messages in thread
* Re: [PATCH net-next] softirq: reduce latencies
@ 2013-01-03 13:12 Sedat Dilek
  2013-01-03 13:31 ` Eric Dumazet
  0 siblings, 1 reply; 22+ messages in thread
From: Sedat Dilek @ 2013-01-03 13:12 UTC (permalink / raw)
  To: Eric Dumazet; +Cc: netdev, LKML

Hi Eric,

your patch from [2] applies cleanly on top of Linux v3.8-rc2.
I would like to test it.
In [1] you were talking about benchmarks you did.
Can you describe them or provide a testcase (script etc.)?
You made only network testing?
Thanks in advance.

Regards,
- Sedat -

[1] http://marc.info/?l=linux-kernel&m=135721614718434&w=2
[2] https://patchwork.kernel.org/patch/1927531/

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

end of thread, other threads:[~2013-01-04 21:49 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-03 12:28 [PATCH net-next] softirq: reduce latencies Eric Dumazet
2013-01-03 20:46 ` Andrew Morton
2013-01-03 22:41   ` Eric Dumazet
2013-01-04  5:16     ` Namhyung Kim
2013-01-04  6:53       ` Eric Dumazet
     [not found]     ` <787701357283699@web24e.yandex.ru>
2013-01-04  7:46       ` Eric Dumazet
2013-01-03 22:08 ` Ben Hutchings
2013-01-03 22:40   ` Eric Dumazet
2013-01-04  7:49     ` [PATCH v2 " Eric Dumazet
2013-01-04  8:15       ` Joe Perches
2013-01-04  8:23         ` Eric Dumazet
2013-01-04  9:12           ` Joe Perches
2013-01-04 17:00             ` Eric Dumazet
2013-01-04 21:15               ` [PATCH] jiffies conversions: Use compile time constants when possible Joe Perches
2013-01-04 21:49       ` [PATCH v2 net-next] softirq: reduce latencies David Miller
  -- strict thread matches above, loose matches on Subject: below --
2013-01-03 13:12 [PATCH " Sedat Dilek
2013-01-03 13:31 ` Eric Dumazet
2013-01-03 19:41   ` Rick Jones
2013-01-04  4:41     ` Eric Dumazet
2013-01-04  5:31       ` Sedat Dilek
2013-01-04  6:54         ` Eric Dumazet
2013-01-04 11:57       ` Sedat Dilek

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