diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2007-05-29 18:10:44 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2007-05-29 18:10:44 +0000 |
commit | 2daba14db3ad27d7c4b423645a257e6ef8a252dd (patch) | |
tree | af0a29b6ad292100004cc51768fa2dcbbe4d122f /sys | |
parent | 77cec5547fcb2bb4116363eafb5c8e596af921e9 (diff) |
Use atomic operations to operate on netisr, instead of clearing it at splhigh.
This changes nothing on legacy architectures, but is a bit faster (and simpler)
on the interesting ones.
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/alpha/alpha/interrupt.c | 19 | ||||
-rw-r--r-- | sys/arch/arm/arm/softintr.c | 20 | ||||
-rw-r--r-- | sys/arch/hp300/hp300/intr.c | 23 | ||||
-rw-r--r-- | sys/arch/m88k/m88k/m88k_machdep.c | 35 | ||||
-rw-r--r-- | sys/arch/mac68k/mac68k/intr.c | 24 | ||||
-rw-r--r-- | sys/arch/macppc/dev/macintr.c | 12 | ||||
-rw-r--r-- | sys/arch/macppc/dev/openpic.c | 12 | ||||
-rw-r--r-- | sys/arch/mips64/mips64/interrupt.c | 10 | ||||
-rw-r--r-- | sys/arch/mvme68k/mvme68k/machdep.c | 23 | ||||
-rw-r--r-- | sys/arch/mvmeppc/dev/openpic.c | 12 | ||||
-rw-r--r-- | sys/arch/sgi/localbus/macebus.c | 9 | ||||
-rw-r--r-- | sys/arch/sh/sh/interrupt.c | 23 | ||||
-rw-r--r-- | sys/arch/sparc/sparc/intr.c | 25 | ||||
-rw-r--r-- | sys/arch/sparc64/sparc64/intr.c | 23 | ||||
-rw-r--r-- | sys/net/netisr.h | 11 |
15 files changed, 163 insertions, 118 deletions
diff --git a/sys/arch/alpha/alpha/interrupt.c b/sys/arch/alpha/alpha/interrupt.c index 79638e6f096..01901d76a27 100644 --- a/sys/arch/alpha/alpha/interrupt.c +++ b/sys/arch/alpha/alpha/interrupt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: interrupt.c,v 1.22 2007/05/05 20:46:34 miod Exp $ */ +/* $OpenBSD: interrupt.c,v 1.23 2007/05/29 18:10:41 miod Exp $ */ /* $NetBSD: interrupt.c,v 1.46 2000/06/03 20:47:36 thorpej Exp $ */ /*- @@ -492,22 +492,21 @@ int netisr; void netintr() { - int n, s; + int n; - s = splhigh(); - n = netisr; - netisr = 0; - splx(s); + while ((n = netisr) != 0) { + atomic_clearbits_int(&netisr, n); #define DONETISR(bit, fn) \ - do { \ - if (n & (1 << (bit))) \ - fn(); \ - } while (0) + do { \ + if (n & (1 << (bit))) \ + fn(); \ + } while (0) #include <net/netisr_dispatch.h> #undef DONETISR + } } struct alpha_soft_intr alpha_soft_intrs[SI_NSOFT]; diff --git a/sys/arch/arm/arm/softintr.c b/sys/arch/arm/arm/softintr.c index ead314a56ea..bf9e9835ce8 100644 --- a/sys/arch/arm/arm/softintr.c +++ b/sys/arch/arm/arm/softintr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: softintr.c,v 1.3 2007/05/10 17:59:24 deraadt Exp $ */ +/* $OpenBSD: softintr.c,v 1.4 2007/05/29 18:10:42 miod Exp $ */ /* $NetBSD: softintr.c,v 1.2 2003/07/15 00:24:39 lukem Exp $ */ /* @@ -44,6 +44,7 @@ #include <uvm/uvm_extern.h> +#include <machine/atomic.h> #include <machine/intr.h> struct soft_intrq soft_intrq[SI_NQUEUES]; @@ -179,20 +180,19 @@ int netisr; void netintr(void) { - int n, s; + int n; - s = splhigh(); - n = netisr; - netisr = 0; - splx(s); + while ((n = netisr) != 0) { + atomic_clearbits_int(&netisr, n); #define DONETISR(bit, fn) \ - do { \ - if (n & (1 << (bit))) \ - fn(); \ - } while (/*CONSTCOND*/0) + do { \ + if (n & (1 << (bit))) \ + fn(); \ + } while (/*CONSTCOND*/0) #include <net/netisr_dispatch.h> #undef DONETISR + } } diff --git a/sys/arch/hp300/hp300/intr.c b/sys/arch/hp300/hp300/intr.c index a578ee37451..6dbd866ef11 100644 --- a/sys/arch/hp300/hp300/intr.c +++ b/sys/arch/hp300/hp300/intr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.c,v 1.16 2006/03/13 19:39:52 brad Exp $ */ +/* $OpenBSD: intr.c,v 1.17 2007/05/29 18:10:42 miod Exp $ */ /* $NetBSD: intr.c,v 1.5 1998/02/16 20:58:30 thorpej Exp $ */ /*- @@ -54,6 +54,7 @@ void netintr(void); +#include <machine/atomic.h> #include <machine/cpu.h> #include <machine/intr.h> @@ -283,13 +284,19 @@ int netisr; void netintr() { -#define DONETISR(bit, fn) \ - do { \ - if (netisr & (1 << (bit))) { \ - netisr &= ~(1 << (bit)); \ - (fn)(); \ - } \ - } while (0) + int n; + + while ((n = netisr) != 0) { + atomic_clearbits_int(&netisr, n); + +#define DONETISR(bit, fn) \ + do { \ + if (n & (1 << (bit))) \ + (fn)(); \ + } while (0) + #include <net/netisr_dispatch.h> + #undef DONETISR + } } diff --git a/sys/arch/m88k/m88k/m88k_machdep.c b/sys/arch/m88k/m88k/m88k_machdep.c index dc9a0643d9a..e9d7b9838ac 100644 --- a/sys/arch/m88k/m88k/m88k_machdep.c +++ b/sys/arch/m88k/m88k/m88k_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: m88k_machdep.c,v 1.20 2007/05/19 20:34:34 miod Exp $ */ +/* $OpenBSD: m88k_machdep.c,v 1.21 2007/05/29 18:10:42 miod Exp $ */ /* * Copyright (c) 1998, 1999, 2000, 2001 Steve Murphree, Jr. * Copyright (c) 1996 Nivas Madhur @@ -59,6 +59,7 @@ #include <machine/asm.h> #include <machine/asm_macro.h> +#include <machine/atomic.h> #include <machine/cmmu.h> #include <machine/cpu.h> #include <machine/reg.h> @@ -373,27 +374,32 @@ int netisr; void dosoftint() { - int sir = ssir; + int sir, n; + + if ((sir = ssir) == 0) + return; atomic_clearbits_int(&ssir, sir); + uvmexp.softs++; if (ISSET(sir, SIR_NET)) { - uvmexp.softs++; -#define DONETISR(bit, fn) \ - do { \ - if (netisr & (1 << bit)) { \ - netisr &= ~(1 << bit); \ - fn(); \ - } \ - } while (0) + while ((n = netisr) != 0) { + atomic_clearbits_int(&netisr, n); + +#define DONETISR(bit, fn) \ + do { \ + if (n & (1 << bit)) \ + fn(); \ + } while (0) + #include <net/netisr_dispatch.h> + #undef DONETISR + } } - if (ISSET(sir, SIR_CLOCK)) { - uvmexp.softs++; + if (ISSET(sir, SIR_CLOCK)) softclock(); - } } int @@ -403,8 +409,7 @@ spl0() s = setipl(IPL_SOFTCLOCK); - if (ssir) - dosoftint(); + dosoftint(); setipl(IPL_NONE); return (s); diff --git a/sys/arch/mac68k/mac68k/intr.c b/sys/arch/mac68k/mac68k/intr.c index 1df3f21aa9f..de36a10e4e6 100644 --- a/sys/arch/mac68k/mac68k/intr.c +++ b/sys/arch/mac68k/mac68k/intr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.c,v 1.8 2007/05/20 17:22:51 miod Exp $ */ +/* $OpenBSD: intr.c,v 1.9 2007/05/29 18:10:42 miod Exp $ */ /* $NetBSD: intr.c,v 1.2 1998/08/25 04:03:56 scottr Exp $ */ /*- @@ -51,6 +51,7 @@ #include <net/netisr.h> +#include <machine/atomic.h> #include <machine/cpu.h> #include <machine/intr.h> @@ -224,21 +225,16 @@ int netisr; void netintr() { - int s, isr; + int isr; - for (;;) { - s = splhigh(); - isr = netisr; - netisr = 0; - splx(s); + while ((isr = netisr) != 0) { + atomic_clearbits_int(&netisr, isr); - if (isr == 0) - return; - -#define DONETISR(bit, fn) do { \ - if (isr & (1 << bit)) \ - (fn)(); \ -} while (0) +#define DONETISR(bit, fn) \ + do { \ + if (isr & (1 << bit)) \ + (fn)(); \ + } while (0) #include <net/netisr_dispatch.h> diff --git a/sys/arch/macppc/dev/macintr.c b/sys/arch/macppc/dev/macintr.c index 1f0c819281b..c0ca3e684f4 100644 --- a/sys/arch/macppc/dev/macintr.c +++ b/sys/arch/macppc/dev/macintr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: macintr.c,v 1.32 2007/03/20 20:59:53 kettenis Exp $ */ +/* $OpenBSD: macintr.c,v 1.33 2007/05/29 18:10:42 miod Exp $ */ /*- * Copyright (c) 1995 Per Fogelstrom @@ -46,6 +46,7 @@ #include <uvm/uvm.h> #include <ddb/db_var.h> +#include <machine/atomic.h> #include <machine/autoconf.h> #include <machine/intr.h> #include <machine/psl.h> @@ -582,10 +583,13 @@ mac_intr_do_pending_int() } if((ci->ci_ipending & SINT_NET) & ~pcpl) { extern int netisr; - int pisr = netisr; - netisr = 0; + int pisr; + ci->ci_ipending &= ~SINT_NET; - softnet(pisr); + while ((pisr = netisr) != 0) { + atomic_clearbits_int(&netisr, pisr); + softnet(pisr); + } } if((ci->ci_ipending & SINT_TTY) & ~pcpl) { ci->ci_ipending &= ~SINT_TTY; diff --git a/sys/arch/macppc/dev/openpic.c b/sys/arch/macppc/dev/openpic.c index bf0d02ac1ef..7a93112979e 100644 --- a/sys/arch/macppc/dev/openpic.c +++ b/sys/arch/macppc/dev/openpic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: openpic.c,v 1.39 2007/05/10 15:28:09 drahn Exp $ */ +/* $OpenBSD: openpic.c,v 1.40 2007/05/29 18:10:43 miod Exp $ */ /*- * Copyright (c) 1995 Per Fogelstrom @@ -46,6 +46,7 @@ #include <uvm/uvm.h> #include <ddb/db_var.h> +#include <machine/atomic.h> #include <machine/autoconf.h> #include <machine/intr.h> #include <machine/psl.h> @@ -501,10 +502,13 @@ openpic_do_pending_int() } if((ci->ci_ipending & SINT_NET) & ~pcpl) { extern int netisr; - int pisr = netisr; - netisr = 0; + int pisr; + ci->ci_ipending &= ~SINT_NET; - softnet(pisr); + while ((pisr = netisr) != 0) { + atomic_clearbits_int(&netisr, pisr); + softnet(pisr); + } } if((ci->ci_ipending & SINT_TTY) & ~pcpl) { ci->ci_ipending &= ~SINT_TTY; diff --git a/sys/arch/mips64/mips64/interrupt.c b/sys/arch/mips64/mips64/interrupt.c index d7246e09c90..5aaaaedd63b 100644 --- a/sys/arch/mips64/mips64/interrupt.c +++ b/sys/arch/mips64/mips64/interrupt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: interrupt.c,v 1.26 2007/05/09 19:20:09 miod Exp $ */ +/* $OpenBSD: interrupt.c,v 1.27 2007/05/29 18:10:43 miod Exp $ */ /* * Copyright (c) 2001-2004 Opsycon AB (www.opsycon.se / www.opsycon.com) @@ -199,11 +199,15 @@ interrupt(struct trap_frame *trapframe) } if ((ipending & SINT_NETMASK) & ~xcpl) { extern int netisr; - int isr = netisr; - netisr = 0; + int isr; + atomic_clearbits_int(&ipending, SINT_NETMASK); + while ((isr = netisr) != 0) { + atomic_clearbits_int(&netisr, isr); + #define DONETISR(b,f) if (isr & (1 << (b))) f(); #include <net/netisr_dispatch.h> + } } #ifdef notyet diff --git a/sys/arch/mvme68k/mvme68k/machdep.c b/sys/arch/mvme68k/mvme68k/machdep.c index 26e2beb0b2f..9e3f237df0c 100644 --- a/sys/arch/mvme68k/mvme68k/machdep.c +++ b/sys/arch/mvme68k/mvme68k/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.103 2007/05/27 17:31:56 miod Exp $ */ +/* $OpenBSD: machdep.c,v 1.104 2007/05/29 18:10:43 miod Exp $ */ /* * Copyright (c) 1995 Theo de Raadt @@ -90,6 +90,7 @@ #endif #include <sys/evcount.h> +#include <machine/atomic.h> #include <machine/autoconf.h> #include <machine/cpu.h> #include <machine/kcore.h> @@ -848,15 +849,21 @@ void netintr(arg) void *arg; { -#define DONETISR(bit, fn) \ - do { \ - if (netisr & (1 << (bit))) { \ - netisr &= ~(1 << (bit)); \ - (fn)(); \ - } \ - } while (0) + int n; + + while ((n = netisr) != 0) { + atomic_clearbits_int(&netisr, n); + +#define DONETISR(bit, fn) \ + do { \ + if (n & (1 << (bit))) \ + (fn)(); \ + } while (0) + #include <net/netisr_dispatch.h> + #undef DONETISR + } } /* diff --git a/sys/arch/mvmeppc/dev/openpic.c b/sys/arch/mvmeppc/dev/openpic.c index f2574be64a5..df7d85f3f83 100644 --- a/sys/arch/mvmeppc/dev/openpic.c +++ b/sys/arch/mvmeppc/dev/openpic.c @@ -1,4 +1,4 @@ -/* $OpenBSD: openpic.c,v 1.21 2006/03/12 02:49:49 brad Exp $ */ +/* $OpenBSD: openpic.c,v 1.22 2007/05/29 18:10:43 miod Exp $ */ /*- * Copyright (c) 1995 Per Fogelstrom @@ -47,6 +47,7 @@ #include <ddb/db_var.h> +#include <machine/atomic.h> #include <machine/autoconf.h> #include <machine/intr.h> #include <machine/psl.h> @@ -639,10 +640,13 @@ openpic_do_pending_int() } if ((ipending & SINT_NET) & ~pcpl) { extern int netisr; - int pisr = netisr; - netisr = 0; + int pisr; + ipending &= ~SINT_NET; - softnet(pisr); + while ((pisr = netisr) != 0) { + atomic_clearbits_int(&netisr, pisr); + softnet(pisr); + } } #if 0 if ((ipending & SINT_TTY) & ~pcpl) { diff --git a/sys/arch/sgi/localbus/macebus.c b/sys/arch/sgi/localbus/macebus.c index f13b0caf8b4..16543214a86 100644 --- a/sys/arch/sgi/localbus/macebus.c +++ b/sys/arch/sgi/localbus/macebus.c @@ -1,4 +1,4 @@ -/* $OpenBSD: macebus.c,v 1.20 2007/05/03 19:34:01 miod Exp $ */ +/* $OpenBSD: macebus.c,v 1.21 2007/05/29 18:10:43 miod Exp $ */ /* * Copyright (c) 2000-2004 Opsycon AB (www.opsycon.se) @@ -653,11 +653,14 @@ macebus_do_pending_int(int newcpl) } if ((ipending & SINT_NETMASK) & ~newcpl) { extern int netisr; - int isr = netisr; - netisr = 0; + int isr; + atomic_clearbits_int(&ipending, SINT_NETMASK); + while ((isr = netisr) != 0) { + atomic_clearbits_int(&netisr, isr); #define DONETISR(b,f) if (isr & (1 << (b))) f(); #include <net/netisr_dispatch.h> + } } #ifdef NOTYET diff --git a/sys/arch/sh/sh/interrupt.c b/sys/arch/sh/sh/interrupt.c index bd6dc40a4d7..fb09a5dee27 100644 --- a/sys/arch/sh/sh/interrupt.c +++ b/sys/arch/sh/sh/interrupt.c @@ -1,4 +1,4 @@ -/* $OpenBSD: interrupt.c,v 1.5 2007/05/10 17:59:26 deraadt Exp $ */ +/* $OpenBSD: interrupt.c,v 1.6 2007/05/29 18:10:43 miod Exp $ */ /* $NetBSD: interrupt.c,v 1.18 2006/01/25 00:02:57 uwe Exp $ */ /*- @@ -48,6 +48,7 @@ #include <sh/trap.h> #include <sh/intcreg.h> #include <sh/tmureg.h> +#include <machine/atomic.h> #include <machine/intr.h> void intc_intr_priority(int, int); @@ -685,21 +686,21 @@ softintr_disestablish(void *arg) void netintr(void) { -#define DONETISR(bit, fn) \ - do { \ - if (n & (1 << bit)) \ - fn(); \ - } while (/*CONSTCOND*/0) + int n; - int s, n; + while ((n = netisr) != 0) { + atomic_clearbits_int(&netisr, n); + +#define DONETISR(bit, fn) \ + do { \ + if (n & (1 << bit)) \ + fn(); \ + } while (/*CONSTCOND*/0) - s = splnet(); - n = netisr; - netisr = 0; - splx(s); #include <net/netisr_dispatch.h> #undef DONETISR + } } /* diff --git a/sys/arch/sparc/sparc/intr.c b/sys/arch/sparc/sparc/intr.c index 0906c999d96..917f71766e0 100644 --- a/sys/arch/sparc/sparc/intr.c +++ b/sys/arch/sparc/sparc/intr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.c,v 1.30 2007/05/29 09:53:57 sobrado Exp $ */ +/* $OpenBSD: intr.c,v 1.31 2007/05/29 18:10:43 miod Exp $ */ /* $NetBSD: intr.c,v 1.20 1997/07/29 09:42:03 fair Exp $ */ /* @@ -53,6 +53,7 @@ #include <net/netisr.h> #include <net/if.h> +#include <machine/atomic.h> #include <machine/cpu.h> #include <machine/ctlreg.h> #include <machine/instr.h> @@ -118,20 +119,22 @@ soft01intr(fp) { if (sir.sir_any) { if (sir.sir_which[SIR_NET]) { - int n, s; + int n; - s = splhigh(); - n = netisr; - netisr = 0; - splx(s); sir.sir_which[SIR_NET] = 0; -#define DONETISR(bit, fn) \ - do { \ - if (n & (1 << bit)) \ - fn(); \ - } while (0) + while ((n = netisr) != 0) { + atomic_clearbits_int(&netisr, n); + +#define DONETISR(bit, fn) \ + do { \ + if (n & (1 << bit)) \ + fn(); \ + } while (0) + #include <net/netisr_dispatch.h> + #undef DONETISR + } } if (sir.sir_which[SIR_CLOCK]) { sir.sir_which[SIR_CLOCK] = 0; diff --git a/sys/arch/sparc64/sparc64/intr.c b/sys/arch/sparc64/sparc64/intr.c index 07b15268e87..9ca99eb7cd1 100644 --- a/sys/arch/sparc64/sparc64/intr.c +++ b/sys/arch/sparc64/sparc64/intr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.c,v 1.25 2007/05/29 09:53:57 sobrado Exp $ */ +/* $OpenBSD: intr.c,v 1.26 2007/05/29 18:10:43 miod Exp $ */ /* $NetBSD: intr.c,v 1.39 2001/07/19 23:38:11 eeh Exp $ */ /* @@ -50,6 +50,7 @@ #include <net/netisr.h> +#include <machine/atomic.h> #include <machine/cpu.h> #include <machine/ctlreg.h> #include <machine/instr.h> @@ -131,19 +132,21 @@ int softnet(fp) void *fp; { - int n, s; + int n; - s = splhigh(); - n = netisr; - netisr = 0; - splx(s); + while ((n = netisr) != 0) { + atomic_clearbits_int(&netisr, n); -#define DONETISR(bit, fn) do { \ - if (n & (1 << bit)) \ - fn(); \ -} while (0) +#define DONETISR(bit, fn) \ + do { \ + if (n & (1 << bit)) \ + fn(); \ + } while (0) + #include <net/netisr_dispatch.h> + #undef DONETISR + } return (1); } diff --git a/sys/net/netisr.h b/sys/net/netisr.h index 856d9ebb7d7..530e419155c 100644 --- a/sys/net/netisr.h +++ b/sys/net/netisr.h @@ -1,4 +1,4 @@ -/* $OpenBSD: netisr.h,v 1.25 2007/05/29 05:43:22 claudio Exp $ */ +/* $OpenBSD: netisr.h,v 1.26 2007/05/29 18:10:43 miod Exp $ */ /* $NetBSD: netisr.h,v 1.12 1995/08/12 23:59:24 mycroft Exp $ */ /* @@ -82,8 +82,13 @@ void bridgeintr(void); void pppoeintr(void); void btintr(void); -#define schednetisr(anisr) \ - { netisr |= (1<<(anisr) | NETISR_RND); setsoftnet(); } +#include <machine/atomic.h> +#include <dev/rndvar.h> +#define schednetisr(anisr) \ +do { \ + atomic_setbits_int(&netisr, (1 << (anisr)) | NETISR_RND); \ + setsoftnet(); \ +} while (0) #endif #endif |