Use lockdep to check that IRQs are enabled or disabled as expected. This way the sanity check only shows overhead when concurrency correctness debug code is enabled.
Unified · Split
| @@ -137,7 +137,7 @@ EXPORT_SYMBOL(__local_bh_disable_ip); · 136 unmodified lines | |||
| 137 | 137 | ||
| 138 | static void __local_bh_enable(unsigned int cnt) | 138 | static void __local_bh_enable(unsigned int cnt) |
| 139 | { | 139 | { |
| 140 | WARN_ON_ONCE(!irqs_disabled()); | 140 | lockdep_assert_irqs_disabled(); |
| 141 | 141 | ||
| 142 | if (softirq_count() == (cnt & SOFTIRQ_MASK)) | 142 | if (softirq_count() == (cnt & SOFTIRQ_MASK)) |
| 143 | trace_softirqs_on(_RET_IP_); | 143 | trace_softirqs_on(_RET_IP_); |
| @@ -158,7 +158,8 @@ EXPORT_SYMBOL(_local_bh_enable); · 14 unmodified lines | |||
| 158 | 158 | ||
| 159 | void __local_bh_enable_ip(unsigned long ip, unsigned int cnt) | 159 | void __local_bh_enable_ip(unsigned long ip, unsigned int cnt) |
| 160 | { | 160 | { |
| 161 | WARN_ON_ONCE(in_irq() || irqs_disabled()); | 161 | WARN_ON_ONCE(in_irq()); |
| 162 | lockdep_assert_irqs_enabled(); | ||
| 162 | #ifdef CONFIG_TRACE_IRQFLAGS | 163 | #ifdef CONFIG_TRACE_IRQFLAGS |
| 163 | local_irq_disable(); | 164 | local_irq_disable(); |
| 164 | #endif | 165 | #endif |
| @@ -396,9 +397,8 @@ void irq_exit(void) · 231 unmodified lines | |||
| 396 | #ifndef __ARCH_IRQ_EXIT_IRQS_DISABLED | 397 | #ifndef __ARCH_IRQ_EXIT_IRQS_DISABLED |
| 397 | local_irq_disable(); | 398 | local_irq_disable(); |
| 398 | #else | 399 | #else |
| 399 | WARN_ON_ONCE(!irqs_disabled()); | 400 | lockdep_assert_irqs_disabled(); |
| 400 | #endif | 401 | #endif |
| 401 | |||
| 402 | account_irq_exit_time(current); | 402 | account_irq_exit_time(current); |
| 403 | preempt_count_sub(HARDIRQ_OFFSET); | 403 | preempt_count_sub(HARDIRQ_OFFSET); |
| 404 | if (!in_interrupt() && local_softirq_pending()) | 404 | if (!in_interrupt() && local_softirq_pending()) |
| @@ -488,7 +488,7 @@ EXPORT_SYMBOL(__tasklet_hi_schedule); · 83 unmodified lines | |||
| 488 | 488 | ||
| 489 | void __tasklet_hi_schedule_first(struct tasklet_struct *t) | 489 | void __tasklet_hi_schedule_first(struct tasklet_struct *t) |
| 490 | { | 490 | { |
| 491 | BUG_ON(!irqs_disabled()); | 491 | lockdep_assert_irqs_disabled(); |
| 492 | 492 | ||
| 493 | t->next = __this_cpu_read(tasklet_hi_vec.head); | 493 | t->next = __this_cpu_read(tasklet_hi_vec.head); |
| 494 | __this_cpu_write(tasklet_hi_vec.head, t); | 494 | __this_cpu_write(tasklet_hi_vec.head, t); |