From: Robert Olsson <Robert.Olsson@data.slu.se>
To: dipankar@in.ibm.com
Cc: Andrea Arcangeli <andrea@suse.de>,
"David S. Miller" <davem@redhat.com>,
kuznet@ms2.inr.ac.ru, linux-kernel@vger.kernel.org,
netdev@oss.sgi.com, Robert.Olsson@data.slu.se,
paulmck@us.ibm.com, akpm@osdl.org
Subject: Re: route cache DoS testing and softirqs
Date: Wed, 31 Mar 2004 20:46:09 +0200 [thread overview]
Message-ID: <16491.4593.718724.277551@robur.slu.se> (raw)
In-Reply-To: <20040331171023.GA4543@in.ibm.com>
[-- Attachment #1: message body text --]
[-- Type: text/plain, Size: 2007 bytes --]
Dipankar Sarma writes:
> And I am not. I am still on 2.6.0 and there seems to be no NAPI support
> for the e100 there. Should I try 2.6.4 where e100 has NAPI support ?
>
> Anyway, even without softirqs on the back of hardirqs, there are
> other ways of softirq overload as seen in Robert's setup.
Well I see some hardirq's most from TX and timer interrups and HZ=1000 can
can change the way softirq's are run a bit.
I hacked do_softirq() sources so we can understand how things work a bit
better. (Use fastroute stats from /proc/net/softnet_stat).
ksoftird == softirq's sourced from ksofttirq
irqexit == softirq's sourced from interrupt exit
bh_enbl == softirq's sourced local_bh_enable
Before run
total droppped tsquz throttl bh_enbl ksoftird irqexit other
00000000 00000000 00000000 00000000 000000e8 0000017e 00030411 00000000
00000000 00000000 00000000 00000000 000000ae 00000277 00030349 00000000
After DoS (See description from previous mail)
total droppped tsquz throttl bh_enbl ksoftird irqexit other
00164c55 00000000 000021de 00000000 000000fc 0000229f 0003443c 00000000
001695e7 00000000 0000224d 00000000 00000162 0000236f 000342f7 00000000
So the major part of softirq's are run from irqexit and therefor out of
scheduler control. This even with RX polling (eth0, eth2) We still have
some TX interrupts plus timer interrupts now at 1000Hz. Which probably
reduces the number of softirq's that ksoftirqd runs.
CPU0 CPU1
0: 297156 0 IO-APIC-edge timer
1: 431 0 IO-APIC-edge i8042
2: 0 0 XT-PIC cascade
8: 0 0 IO-APIC-edge rtc
14: 34527 0 IO-APIC-edge ide0
26: 131 0 IO-APIC-level eth0
27: 22910 0 IO-APIC-level eth1
28: 8 124 IO-APIC-level eth2
29: 9 23197 IO-APIC-level eth3
NMI: 0 0
LOC: 297060 297059
[-- Attachment #2: softirq_monitor.pat --]
[-- Type: application/octet-stream, Size: 3973 bytes --]
--- kernel/softirq.c.orig 2004-03-11 03:55:24.000000000 +0100
+++ kernel/softirq.c 2004-03-31 18:15:26.000000000 +0200
@@ -69,7 +69,13 @@
*/
#define MAX_SOFTIRQ_RESTART 10
-asmlinkage void do_softirq(void)
+
+/* Use the fastroute stats. */
+
+#include <linux/netdevice.h>
+DECLARE_PER_CPU(struct netif_rx_stats, netdev_rx_stat);
+
+asmlinkage void do_softirq(int from)
{
int max_restart = MAX_SOFTIRQ_RESTART;
__u32 pending;
@@ -84,9 +90,44 @@
if (pending) {
struct softirq_action *h;
+ struct task_struct *tsk = __get_cpu_var(ksoftirqd);
local_bh_disable();
+#if 0
+ /* Avoid softirq's from DoS'ing user apps incl. RCU's etc */
+
+ if (unlikely(from != SIRQ_FROM_KSOFTIRQD &&
+ tsk &&
+ sched_clock() - tsk->timestamp >
+ (unsigned long long) 2*1000000000 &&
+ !(current->state & (TASK_DEAD | TASK_ZOMBIE)))) {
+
+ set_tsk_need_resched(current);
+ local_irq_disable();
+ goto done;
+ }
+#endif
+
restart:
+ switch (from) {
+
+ case SIRQ_FROM_BH:
+ __get_cpu_var(netdev_rx_stat).fastroute_hit++;
+ break;
+
+ case SIRQ_FROM_KSOFTIRQD:
+ __get_cpu_var(netdev_rx_stat).fastroute_success++;
+ break;
+
+ case SIRQ_FROM_IRQEXIT:
+ __get_cpu_var(netdev_rx_stat).fastroute_defer++;
+ break;
+
+
+ default:
+ __get_cpu_var(netdev_rx_stat).fastroute_deferred_out++;
+
+ }
/* Reset the pending bitmask before enabling irqs */
local_softirq_pending() = 0;
@@ -106,6 +147,7 @@
pending = local_softirq_pending();
if (pending && --max_restart)
goto restart;
+ done:
if (pending)
wakeup_softirqd();
__local_bh_enable();
@@ -122,7 +164,7 @@
WARN_ON(irqs_disabled());
if (unlikely(!in_interrupt() &&
local_softirq_pending()))
- invoke_softirq();
+ invoke_softirq(SIRQ_FROM_BH);
preempt_check_resched();
}
EXPORT_SYMBOL(local_bh_enable);
@@ -324,7 +366,7 @@
__set_current_state(TASK_RUNNING);
while (local_softirq_pending()) {
- do_softirq();
+ do_softirq(SIRQ_FROM_KSOFTIRQD);
cond_resched();
}
--- include/linux/netdevice.h~ 2004-03-11 03:55:44.000000000 +0100
+++ include/linux/netdevice.h 2004-03-31 12:24:57.000000000 +0200
@@ -669,7 +669,7 @@
{
int err = netif_rx(skb);
if (softirq_pending(smp_processor_id()))
- do_softirq();
+ do_softirq(SIRQ_FROM_NETIF_RX_NI);
return err;
}
--- include/linux/interrupt.h.orig 2004-03-31 18:24:03.000000000 +0200
+++ include/linux/interrupt.h 2004-03-31 18:19:28.000000000 +0200
@@ -92,7 +92,17 @@
void *data;
};
-asmlinkage void do_softirq(void);
+/* Softirq originator */
+enum
+{
+ SIRQ_FROM_KSOFTIRQD=0,
+ SIRQ_FROM_IRQEXIT,
+ SIRQ_FROM_BH,
+ SIRQ_FROM_NETIF_RX_NI,
+ SIRQ_FROM_PKTGEN
+};
+
+asmlinkage void do_softirq(int from);
extern void open_softirq(int nr, void (*action)(struct softirq_action*), void *data);
extern void softirq_init(void);
#define __raise_softirq_irqoff(nr) do { local_softirq_pending() |= 1UL << (nr); } while (0)
@@ -100,7 +110,7 @@
extern void FASTCALL(raise_softirq(unsigned int nr));
#ifndef invoke_softirq
-#define invoke_softirq() do_softirq()
+#define invoke_softirq(from) do_softirq(from)
#endif
--- include/asm-i386/hardirq.h.orig 2004-03-11 03:55:37.000000000 +0100
+++ include/asm-i386/hardirq.h 2004-03-31 18:27:17.000000000 +0200
@@ -88,7 +88,7 @@
do { \
preempt_count() -= IRQ_EXIT_OFFSET; \
if (!in_interrupt() && softirq_pending(smp_processor_id())) \
- do_softirq(); \
+ do_softirq(SIRQ_FROM_IRQEXIT); \
preempt_enable_no_resched(); \
} while (0)
--- net/core/pktgen.c~ 2004-03-11 03:55:36.000000000 +0100
+++ net/core/pktgen.c 2004-03-31 12:24:57.000000000 +0200
@@ -710,7 +710,7 @@
if (need_resched())
schedule();
else
- do_softirq();
+ do_softirq(SIRQ_FROM_PKTGEN);
} while (netif_queue_stopped(odev));
idle = cycles() - idle_start;
info->idle_acc += idle;
[-- Attachment #3: message body text --]
[-- Type: text/plain, Size: 21 bytes --]
Cheers.
--ro
next prev parent reply other threads:[~2004-03-31 18:46 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-03-29 18:45 Dipankar Sarma
2004-03-29 22:29 ` Andrea Arcangeli
2004-03-30 5:06 ` Srivatsa Vaddagiri
2004-03-30 5:35 ` Srivatsa Vaddagiri
2004-03-30 15:11 ` Andrea Arcangeli
2004-03-31 2:36 ` Rusty Russell
2004-03-30 14:43 ` Dipankar Sarma
2004-03-30 19:53 ` Dipankar Sarma
2004-03-30 20:47 ` Andrea Arcangeli
2004-03-30 21:06 ` Dipankar Sarma
2004-03-30 21:27 ` Andrea Arcangeli
2004-03-30 21:29 ` Robert Olsson
2004-03-31 7:36 ` Dipankar Sarma
2004-03-30 20:05 ` kuznet
2004-03-30 20:28 ` Dipankar Sarma
2004-04-01 6:00 ` kuznet
2004-03-30 21:14 ` Andrea Arcangeli
2004-03-30 21:30 ` David S. Miller
2004-03-30 21:37 ` Andrea Arcangeli
2004-03-30 22:22 ` David S. Miller
2004-03-30 22:49 ` Andrea Arcangeli
2004-03-31 20:46 ` Dipankar Sarma
2004-03-31 21:31 ` Andrea Arcangeli
2004-03-31 21:52 ` Dipankar Sarma
2004-03-30 22:33 ` Robert Olsson
2004-03-31 17:10 ` Dipankar Sarma
2004-03-31 18:46 ` Robert Olsson [this message]
2004-03-31 20:37 ` Dipankar Sarma
2004-03-31 21:28 ` Andrea Arcangeli
2004-03-31 21:43 ` Dipankar Sarma
2004-04-05 17:11 ` Robert Olsson
2004-04-05 21:22 ` Dipankar Sarma
2004-04-06 12:55 ` Robert Olsson
2004-04-06 19:52 ` Dipankar Sarma
2004-04-07 15:23 ` Robert Olsson
2004-04-07 19:48 ` Dipankar Sarma
2004-04-08 13:29 ` kuznet
2004-04-08 14:07 ` Robert Olsson
2004-03-31 22:36 ` Robert Olsson
2004-03-31 22:52 ` Andrea Arcangeli
2004-04-01 6:43 ` kuznet
2004-04-01 13:16 ` Andrea Arcangeli
2004-04-08 13:38 ` kuznet
2004-04-01 13:44 ` Robert Olsson
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=16491.4593.718724.277551@robur.slu.se \
--to=robert.olsson@data.slu.se \
--cc=akpm@osdl.org \
--cc=andrea@suse.de \
--cc=davem@redhat.com \
--cc=dipankar@in.ibm.com \
--cc=kuznet@ms2.inr.ac.ru \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@oss.sgi.com \
--cc=paulmck@us.ibm.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
all inboxes | Powered by JetHome®