Skip to contentSkip to conversation

2.4.2 softirq cleanup

PATCH New Keith Owens 1 participant 1 message Feb 26, 2001

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 2.4.2 softirq cleanup

This patch hits all architectures, please trim replies.

Patch against 2.4.2 to remove cpu_bh_enable/disable, now it is only called from the same include file.

Define *_current versions of softirq_active, softirq_mask, local_irq_count, local_bh_count, syscall_count, nmi_count. Some architectures can access the current cpu's data without doing an array lookup, they will be able to use the *_current form for speed after this patch is in.

include/asm-alpha/softirq.h +2 -16
diff -ur 2.4.2-pristine/include/asm-alpha/softirq.h 2.4.2-softirq/include/asm-alpha/softirq.h
@@ -5,21 +5,7 @@
 #include <asm/atomic.h>
 #include <asm/hardirq.h>
 
-extern inline void cpu_bh_disable(int cpu)
-{
-	local_bh_count(cpu)++;
-	mb();
-}
-
-extern inline void cpu_bh_enable(int cpu)
-{
-	mb();
-	local_bh_count(cpu)--;
-}
-
-#define local_bh_enable()	cpu_bh_enable(smp_processor_id())
-#define local_bh_disable()	cpu_bh_disable(smp_processor_id())
-
-#define in_softirq() (local_bh_count(smp_processor_id()) != 0)
+#define local_bh_enable()	{ local_bh_count_current()++; mb(); }
+#define local_bh_disable()	{ mb(); local_bh_count_current()--; }
 
 #endif /* _ALPHA_SOFTIRQ_H */
include/asm-arm/softirq.h +2 -7
diff -ur 2.4.2-pristine/include/asm-arm/softirq.h 2.4.2-softirq/include/asm-arm/softirq.h
@@ -4,12 +4,7 @@
 #include <asm/atomic.h>
 #include <asm/hardirq.h>
 
-#define cpu_bh_disable(cpu)	do { local_bh_count(cpu)++; barrier(); } while (0)
-#define cpu_bh_enable(cpu)	do { barrier(); local_bh_count(cpu)--; } while (0)
-
-#define local_bh_disable()	cpu_bh_disable(smp_processor_id())
-#define local_bh_enable()	cpu_bh_enable(smp_processor_id())
-
-#define in_softirq()		(local_bh_count(smp_processor_id()) != 0)
+#define local_bh_disable()	do { local_bh_count_current()++; barrier(); } while (0)
+#define local_bh_enable()	do { barrier(); local_bh_count_current()--; } while (0)
 
 #endif	/* __ASM_SOFTIRQ_H */
include/asm-cris/softirq.h +2 -4
diff -ur 2.4.2-pristine/include/asm-cris/softirq.h 2.4.2-softirq/include/asm-cris/softirq.h
@@ -4,9 +4,7 @@
 #include <asm/atomic.h>
 #include <asm/hardirq.h>
 
-#define local_bh_disable()      (local_bh_count(smp_processor_id())++)
-#define local_bh_enable()       (local_bh_count(smp_processor_id())--)
-
-#define in_softirq() (local_bh_count(smp_processor_id()) != 0)
+#define local_bh_disable()      (local_bh_count_current()++)
+#define local_bh_enable()       (local_bh_count_current()--)
 
 #endif	/* __ASM_SOFTIRQ_H */
include/asm-i386/softirq.h +2 -7
diff -ur 2.4.2-pristine/include/asm-i386/softirq.h 2.4.2-softirq/include/asm-i386/softirq.h
@@ -4,12 +4,7 @@
 #include <asm/atomic.h>
 #include <asm/hardirq.h>
 
-#define cpu_bh_disable(cpu)	do { local_bh_count(cpu)++; barrier(); } while (0)
-#define cpu_bh_enable(cpu)	do { barrier(); local_bh_count(cpu)--; } while (0)
-
-#define local_bh_disable()	cpu_bh_disable(smp_processor_id())
-#define local_bh_enable()	cpu_bh_enable(smp_processor_id())
-
-#define in_softirq() (local_bh_count(smp_processor_id()) != 0)
+#define local_bh_disable()	do { local_bh_count_current()++; barrier(); } while (0)
+#define local_bh_enable()	do { barrier(); local_bh_count_current()--; } while (0)
 
 #endif	/* __ASM_SOFTIRQ_H */
include/asm-ia64/softirq.h +2 -7
diff -ur 2.4.2-pristine/include/asm-ia64/softirq.h 2.4.2-softirq/include/asm-ia64/softirq.h
@@ -7,12 +7,7 @@
  */
 #include <asm/hardirq.h>
 
-#define cpu_bh_disable(cpu)	do { local_bh_count(cpu)++; barrier(); } while (0)
-#define cpu_bh_enable(cpu)	do { barrier(); local_bh_count(cpu)--; } while (0)
-
-#define local_bh_disable()	cpu_bh_disable(smp_processor_id())
-#define local_bh_enable()	cpu_bh_enable(smp_processor_id())
-
-#define in_softirq()		(local_bh_count(smp_processor_id()) != 0)
+#define local_bh_disable()	do { local_bh_count_current()++; barrier(); } while (0)
+#define local_bh_enable()	do { barrier(); local_bh_count_current()--; } while (0)
 
 #endif /* _ASM_IA64_SOFTIRQ_H */
include/asm-m68k/softirq.h +2 -7
diff -ur 2.4.2-pristine/include/asm-m68k/softirq.h 2.4.2-softirq/include/asm-m68k/softirq.h
@@ -7,12 +7,7 @@
 
 #include <asm/atomic.h>
 
-#define cpu_bh_disable(cpu)	do { local_bh_count(cpu)++; barrier(); } while (0)
-#define cpu_bh_enable(cpu)	do { barrier(); local_bh_count(cpu)--; } while (0)
-
-#define local_bh_disable()	cpu_bh_disable(smp_processor_id())
-#define local_bh_enable()	cpu_bh_enable(smp_processor_id())
-
-#define in_softirq() (local_bh_count(smp_processor_id()) != 0)
+#define local_bh_disable()	do { local_bh_count_current()++; barrier(); } while (0)
+#define local_bh_enable()	do { barrier(); local_bh_count_current()--; } while (0)
 
 #endif
include/asm-mips/softirq.h +2 -7
diff -ur 2.4.2-pristine/include/asm-mips/softirq.h 2.4.2-softirq/include/asm-mips/softirq.h
@@ -13,12 +13,7 @@
 #include <asm/atomic.h>
 #include <asm/hardirq.h>
 
-#define cpu_bh_disable(cpu)	do { local_bh_count(cpu)++; barrier(); } while (0)
-#define cpu_bh_enable(cpu)	do { barrier(); local_bh_count(cpu)--; } while (0)
-
-#define local_bh_disable()	cpu_bh_disable(smp_processor_id())
-#define local_bh_enable()	cpu_bh_enable(smp_processor_id())
-
-#define in_softirq() (local_bh_count(smp_processor_id()) != 0)
+#define local_bh_disable()	do { local_bh_count_current()++; barrier(); } while (0)
+#define local_bh_enable()	do { barrier(); local_bh_count_current()--; } while (0)
 
 #endif /* _ASM_SOFTIRQ_H */
include/asm-mips64/softirq.h +2 -7
diff -ur 2.4.2-pristine/include/asm-mips64/softirq.h 2.4.2-softirq/include/asm-mips64/softirq.h
@@ -13,12 +13,7 @@
 #include <asm/atomic.h>
 #include <asm/hardirq.h>
 
-#define cpu_bh_disable(cpu)	do { local_bh_count(cpu)++; barrier(); } while (0)
-#define cpu_bh_enable(cpu)	do { barrier(); local_bh_count(cpu)--; } while (0)
-
-#define local_bh_disable()	cpu_bh_disable(smp_processor_id())
-#define local_bh_enable()	cpu_bh_enable(smp_processor_id())
-
-#define in_softirq() (local_bh_count(smp_processor_id()) != 0)
+#define local_bh_disable()	do { local_bh_count_current()++; barrier(); } while (0)
+#define local_bh_enable()	do { barrier(); local_bh_count_current()--; } while (0)
 
 #endif /* _ASM_SOFTIRQ_H */
include/asm-parisc/softirq.h +2 -7
diff -ur 2.4.2-pristine/include/asm-parisc/softirq.h 2.4.2-softirq/include/asm-parisc/softirq.h
@@ -4,12 +4,7 @@
 #include <asm/atomic.h>
 #include <asm/hardirq.h>
 
-#define cpu_bh_disable(cpu)	do { local_bh_count(cpu)++; barrier(); } while (0)
-#define cpu_bh_enable(cpu)	do { barrier(); local_bh_count(cpu)--; } while (0)
-
-#define local_bh_disable()	cpu_bh_disable(smp_processor_id())
-#define local_bh_enable()	cpu_bh_enable(smp_processor_id())
-
-#define in_softirq() (local_bh_count(smp_processor_id()) != 0)
+#define local_bh_disable()	do { local_bh_count_current()++; barrier(); } while (0)
+#define local_bh_enable()	do { barrier(); local_bh_count_current()--; } while (0)
 
 #endif	/* __ASM_SOFTIRQ_H */
include/asm-ppc/softirq.h +2 -4
diff -ur 2.4.2-pristine/include/asm-ppc/softirq.h 2.4.2-softirq/include/asm-ppc/softirq.h
@@ -5,10 +5,8 @@
 #include <asm/atomic.h>
 #include <asm/hardirq.h>
 
-#define local_bh_disable()	do { local_bh_count(smp_processor_id())++; barrier(); } while (0)
-#define local_bh_enable()	do { barrier(); local_bh_count(smp_processor_id())--; } while (0)
-
-#define in_softirq() (local_bh_count(smp_processor_id()) != 0)
+#define local_bh_disable()	do { local_bh_count_current()++; barrier(); } while (0)
+#define local_bh_enable()	do { barrier(); local_bh_count_current()--; } while (0)
 
 #endif	/* __ASM_SOFTIRQ_H */
 #endif /* __KERNEL__ */
include/asm-s390/softirq.h +4 -6
diff -ur 2.4.2-pristine/include/asm-s390/softirq.h 2.4.2-softirq/include/asm-s390/softirq.h
@@ -17,13 +17,11 @@
 #include <asm/hardirq.h>
 #include <asm/lowcore.h>
 
-#define cpu_bh_disable(cpu)	do { local_bh_count(cpu)++; barrier(); } while (0)
-#define cpu_bh_enable(cpu)	do { barrier(); local_bh_count(cpu)--; } while (0)
+#undef  local_bh_count_current
+#define local_bh_count_current()	(S390_lowcore.__local_bh_count)
 
-#define local_bh_disable()	cpu_bh_disable(smp_processor_id())
-#define local_bh_enable()	cpu_bh_enable(smp_processor_id())
-
-#define in_softirq() (local_bh_count(smp_processor_id()) != 0)
+#define local_bh_disable()	do { local_bh_count_current()++; barrier(); } while (0)
+#define local_bh_enable()	do { barrier(); local_bh_count_current()--; } while (0)
 
 #endif	/* __ASM_SOFTIRQ_H */
 
include/asm-s390x/softirq.h +6 -8
diff -ur 2.4.2-pristine/include/asm-s390x/softirq.h 2.4.2-softirq/include/asm-s390x/softirq.h
@@ -1,7 +1,7 @@
 /*
- *  include/asm-s390/softirq.h
+ *  include/asm-s390x/softirq.h
  *
- *  S390 version
+ *  S390x version
  *
  *  Derived from "include/asm-i386/softirq.h"
  */
@@ -17,13 +17,11 @@
 #include <asm/hardirq.h>
 #include <asm/lowcore.h>
 
-#define cpu_bh_disable(cpu)	do { local_bh_count(cpu)++; barrier(); } while (0)
-#define cpu_bh_enable(cpu)	do { barrier(); local_bh_count(cpu)--; } while (0)
+#undef  local_bh_count_current
+#define local_bh_count_current()	(S390_lowcore.__local_bh_count)
 
-#define local_bh_disable()	cpu_bh_disable(smp_processor_id())
-#define local_bh_enable()	cpu_bh_enable(smp_processor_id())
-
-#define in_softirq() (local_bh_count(smp_processor_id()) != 0)
+#define local_bh_disable()	do { local_bh_count_current()++; barrier(); } while (0)
+#define local_bh_enable()	do { barrier(); local_bh_count_current()--; } while (0)
 
 #endif	/* __ASM_SOFTIRQ_H */
 
include/asm-sh/softirq.h +2 -7
diff -ur 2.4.2-pristine/include/asm-sh/softirq.h 2.4.2-softirq/include/asm-sh/softirq.h
@@ -4,12 +4,7 @@
 #include <asm/atomic.h>
 #include <asm/hardirq.h>
 
-#define cpu_bh_disable(cpu)	do { local_bh_count(cpu)++; barrier(); } while (0)
-#define cpu_bh_enable(cpu)	do { barrier(); local_bh_count(cpu)--; } while (0)
-
-#define local_bh_disable()	cpu_bh_disable(smp_processor_id())
-#define local_bh_enable()	cpu_bh_enable(smp_processor_id())
-
-#define in_softirq() (local_bh_count(smp_processor_id()) != 0)
+#define local_bh_disable()	do { local_bh_count_current()++; barrier(); } while (0)
+#define local_bh_enable()	do { barrier(); local_bh_count_current()--; } while (0)
 
 #endif /* __ASM_SH_SOFTIRQ_H */
include/asm-sparc/softirq.h +2 -4
diff -ur 2.4.2-pristine/include/asm-sparc/softirq.h 2.4.2-softirq/include/asm-sparc/softirq.h
@@ -13,9 +13,7 @@
 #include <asm/smp.h>
 #include <asm/hardirq.h>
 
-#define local_bh_disable()	(local_bh_count(smp_processor_id())++)
-#define local_bh_enable()	(local_bh_count(smp_processor_id())--)
-
-#define in_softirq() (local_bh_count(smp_processor_id()) != 0)
+#define local_bh_disable()	(local_bh_count_current()++)
+#define local_bh_enable()	(local_bh_count_current()--)
 
 #endif	/* __SPARC_SOFTIRQ_H */
include/asm-sparc64/softirq.h +2 -4
diff -ur 2.4.2-pristine/include/asm-sparc64/softirq.h 2.4.2-softirq/include/asm-sparc64/softirq.h
@@ -10,9 +10,7 @@
 #include <asm/hardirq.h>
 #include <asm/system.h>		/* for membar() */
 
-#define local_bh_disable()	(local_bh_count(smp_processor_id())++)
-#define local_bh_enable()	(local_bh_count(smp_processor_id())--)
-
-#define in_softirq() (local_bh_count(smp_processor_id()) != 0)
+#define local_bh_disable()	(local_bh_count_current()++)
+#define local_bh_enable()	(local_bh_count_current()--)
 
 #endif /* !(__SPARC64_SOFTIRQ_H) */
include/linux/irq_cpustat.h +20 -6
diff -ur 2.4.2-pristine/include/linux/irq_cpustat.h 2.4.2-softirq/include/linux/irq_cpustat.h
@@ -7,6 +7,11 @@
  * they define their own mappings for irq_stat.
  *
  * Keith Owens <[email protected]> July 2000.
+ *
+ * Added _current forms to allow architectures with per cpu pages to take
+ * advantage of the optimizations that allows.
+ *
+ * Keith Owens <[email protected]> February 2001.
  */
 
 #include <linux/config.h>
@@ -26,12 +31,21 @@
 #endif	
 
   /* arch independent irq_stat fields */
-#define softirq_active(cpu)	__IRQ_STAT((cpu), __softirq_active)
-#define softirq_mask(cpu)	__IRQ_STAT((cpu), __softirq_mask)
-#define local_irq_count(cpu)	__IRQ_STAT((cpu), __local_irq_count)
-#define local_bh_count(cpu)	__IRQ_STAT((cpu), __local_bh_count)
-#define syscall_count(cpu)	__IRQ_STAT((cpu), __syscall_count)
+#define softirq_active(cpu)		__IRQ_STAT((cpu), __softirq_active)
+#define softirq_active_current()	softirq_active(smp_processor_id())
+#define softirq_mask(cpu)		__IRQ_STAT((cpu), __softirq_mask)
+#define softirq_mask_current()		softirq_mask(smp_processor_id())
+#define local_irq_count(cpu)		__IRQ_STAT((cpu), __local_irq_count)
+#define local_irq_count_current()	local_irq_count(smp_processor_id())
+#define local_bh_count(cpu)		__IRQ_STAT((cpu), __local_bh_count)
+#define local_bh_count_current()	local_bh_count(smp_processor_id())
+#define syscall_count(cpu)		__IRQ_STAT((cpu), __syscall_count)
+#define syscall_count_current()		syscall_count(smp_processor_id())
   /* arch dependent irq_stat fields */
-#define nmi_count(cpu)		__IRQ_STAT((cpu), __nmi_count)		/* i386, ia64 */
+#define nmi_count(cpu)			__IRQ_STAT((cpu), __nmi_count)		/* i386, ia64 */
+#define nmi_count_current()		nmi_count(smp_processor_id())
+
+/* When this gets expanded, local_bh_count_current() may have been redefined */
+#define in_softirq()			(local_bh_count_current() != 0)
 
 #endif	/* __irq_cpustat_h */