patch-2.3.5 linux/include/asm-i386/softirq.h
Next file: linux/include/linux/binfmts.h
Previous file: linux/include/asm-i386/locks.h
Back to the patch index
Back to the overall index
- Lines: 84
- Date:
Wed Jun 2 13:54:53 1999
- Orig file:
v2.3.4/linux/include/asm-i386/softirq.h
- Orig date:
Mon May 31 22:28:06 1999
diff -u --recursive --new-file v2.3.4/linux/include/asm-i386/softirq.h linux/include/asm-i386/softirq.h
@@ -6,6 +6,15 @@
extern unsigned int local_bh_count[NR_CPUS];
+#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 cpu_bh_trylock(cpu) (local_bh_count[(cpu)] ? 0 : (local_bh_count[(cpu)] = 1))
+#define cpu_bh_endlock(cpu) (local_bh_count[(cpu)] = 0)
+
+#define local_bh_disable() cpu_bh_disable(smp_processor_id())
+#define local_bh_enable() cpu_bh_enable(smp_processor_id())
+
#define get_active_bhs() (bh_mask & bh_active)
#define clear_active_bhs(x) atomic_clear_mask((x),&bh_active)
@@ -40,13 +49,6 @@
extern void synchronize_bh(void);
-/*
- * This is suboptimal. We only need to disable bh's locally
- * on this CPU...
- */
-#define local_bh_disable() atomic_inc(&global_bh_lock)
-#define local_bh_enable() atomic_dec(&global_bh_lock)
-
static inline void start_bh_atomic(void)
{
atomic_inc(&global_bh_lock);
@@ -61,19 +63,20 @@
/* These are for the IRQs testing the lock */
static inline int softirq_trylock(int cpu)
{
- if (!test_and_set_bit(0,&global_bh_count)) {
- if (atomic_read(&global_bh_lock) == 0) {
- ++local_bh_count[cpu];
- return 1;
+ if (cpu_bh_trylock(cpu)) {
+ if (!test_and_set_bit(0,&global_bh_count)) {
+ if (atomic_read(&global_bh_lock) == 0)
+ return 1;
+ clear_bit(0,&global_bh_count);
}
- clear_bit(0,&global_bh_count);
+ cpu_bh_endlock(cpu);
}
return 0;
}
static inline void softirq_endlock(int cpu)
{
- local_bh_count[cpu]--;
+ cpu_bh_enable(cpu);
clear_bit(0,&global_bh_count);
}
@@ -81,22 +84,19 @@
extern inline void start_bh_atomic(void)
{
- local_bh_count[smp_processor_id()]++;
+ local_bh_disable();
barrier();
}
extern inline void end_bh_atomic(void)
{
barrier();
- local_bh_count[smp_processor_id()]--;
+ local_bh_enable();
}
-#define local_bh_disable() (local_bh_count[smp_processor_id()]++)
-#define local_bh_enable() (local_bh_count[smp_processor_id()]--)
-
/* These are for the irq's testing the lock */
-#define softirq_trylock(cpu) (local_bh_count[cpu] ? 0 : (local_bh_count[cpu]=1))
-#define softirq_endlock(cpu) (local_bh_count[cpu] = 0)
+#define softirq_trylock(cpu) (cpu_bh_trylock(cpu))
+#define softirq_endlock(cpu) (cpu_bh_endlock(cpu))
#define synchronize_bh() barrier()
#endif /* SMP */
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)