|
@@ -61,6 +61,119 @@ static inline void wakeup_softirqd(void)
|
|
wake_up_process(tsk);
|
|
wake_up_process(tsk);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+/*
|
|
|
|
+ * This one is for softirq.c-internal use,
|
|
|
|
+ * where hardirqs are disabled legitimately:
|
|
|
|
+ */
|
|
|
|
+static void __local_bh_disable(unsigned long ip)
|
|
|
|
+{
|
|
|
|
+ unsigned long flags;
|
|
|
|
+
|
|
|
|
+ WARN_ON_ONCE(in_irq());
|
|
|
|
+
|
|
|
|
+ raw_local_irq_save(flags);
|
|
|
|
+ add_preempt_count(SOFTIRQ_OFFSET);
|
|
|
|
+ /*
|
|
|
|
+ * Were softirqs turned off above:
|
|
|
|
+ */
|
|
|
|
+ if (softirq_count() == SOFTIRQ_OFFSET)
|
|
|
|
+ trace_softirqs_off(ip);
|
|
|
|
+ raw_local_irq_restore(flags);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+void local_bh_disable(void)
|
|
|
|
+{
|
|
|
|
+ __local_bh_disable((unsigned long)__builtin_return_address(0));
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+EXPORT_SYMBOL(local_bh_disable);
|
|
|
|
+
|
|
|
|
+void __local_bh_enable(void)
|
|
|
|
+{
|
|
|
|
+ WARN_ON_ONCE(in_irq());
|
|
|
|
+
|
|
|
|
+ /*
|
|
|
|
+ * softirqs should never be enabled by __local_bh_enable(),
|
|
|
|
+ * it always nests inside local_bh_enable() sections:
|
|
|
|
+ */
|
|
|
|
+ WARN_ON_ONCE(softirq_count() == SOFTIRQ_OFFSET);
|
|
|
|
+
|
|
|
|
+ sub_preempt_count(SOFTIRQ_OFFSET);
|
|
|
|
+}
|
|
|
|
+EXPORT_SYMBOL_GPL(__local_bh_enable);
|
|
|
|
+
|
|
|
|
+/*
|
|
|
|
+ * Special-case - softirqs can safely be enabled in
|
|
|
|
+ * cond_resched_softirq(), or by __do_softirq(),
|
|
|
|
+ * without processing still-pending softirqs:
|
|
|
|
+ */
|
|
|
|
+void _local_bh_enable(void)
|
|
|
|
+{
|
|
|
|
+ WARN_ON_ONCE(in_irq());
|
|
|
|
+ WARN_ON_ONCE(!irqs_disabled());
|
|
|
|
+
|
|
|
|
+ if (softirq_count() == SOFTIRQ_OFFSET)
|
|
|
|
+ trace_softirqs_on((unsigned long)__builtin_return_address(0));
|
|
|
|
+ sub_preempt_count(SOFTIRQ_OFFSET);
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+EXPORT_SYMBOL(_local_bh_enable);
|
|
|
|
+
|
|
|
|
+void local_bh_enable(void)
|
|
|
|
+{
|
|
|
|
+ unsigned long flags;
|
|
|
|
+
|
|
|
|
+ WARN_ON_ONCE(in_irq());
|
|
|
|
+ WARN_ON_ONCE(irqs_disabled());
|
|
|
|
+
|
|
|
|
+ local_irq_save(flags);
|
|
|
|
+ /*
|
|
|
|
+ * Are softirqs going to be turned on now:
|
|
|
|
+ */
|
|
|
|
+ if (softirq_count() == SOFTIRQ_OFFSET)
|
|
|
|
+ trace_softirqs_on((unsigned long)__builtin_return_address(0));
|
|
|
|
+ /*
|
|
|
|
+ * Keep preemption disabled until we are done with
|
|
|
|
+ * softirq processing:
|
|
|
|
+ */
|
|
|
|
+ sub_preempt_count(SOFTIRQ_OFFSET - 1);
|
|
|
|
+
|
|
|
|
+ if (unlikely(!in_interrupt() && local_softirq_pending()))
|
|
|
|
+ do_softirq();
|
|
|
|
+
|
|
|
|
+ dec_preempt_count();
|
|
|
|
+ local_irq_restore(flags);
|
|
|
|
+ preempt_check_resched();
|
|
|
|
+}
|
|
|
|
+EXPORT_SYMBOL(local_bh_enable);
|
|
|
|
+
|
|
|
|
+void local_bh_enable_ip(unsigned long ip)
|
|
|
|
+{
|
|
|
|
+ unsigned long flags;
|
|
|
|
+
|
|
|
|
+ WARN_ON_ONCE(in_irq());
|
|
|
|
+
|
|
|
|
+ local_irq_save(flags);
|
|
|
|
+ /*
|
|
|
|
+ * Are softirqs going to be turned on now:
|
|
|
|
+ */
|
|
|
|
+ if (softirq_count() == SOFTIRQ_OFFSET)
|
|
|
|
+ trace_softirqs_on(ip);
|
|
|
|
+ /*
|
|
|
|
+ * Keep preemption disabled until we are done with
|
|
|
|
+ * softirq processing:
|
|
|
|
+ */
|
|
|
|
+ sub_preempt_count(SOFTIRQ_OFFSET - 1);
|
|
|
|
+
|
|
|
|
+ if (unlikely(!in_interrupt() && local_softirq_pending()))
|
|
|
|
+ do_softirq();
|
|
|
|
+
|
|
|
|
+ dec_preempt_count();
|
|
|
|
+ local_irq_restore(flags);
|
|
|
|
+ preempt_check_resched();
|
|
|
|
+}
|
|
|
|
+EXPORT_SYMBOL(local_bh_enable_ip);
|
|
|
|
+
|
|
/*
|
|
/*
|
|
* We restart softirq processing MAX_SOFTIRQ_RESTART times,
|
|
* We restart softirq processing MAX_SOFTIRQ_RESTART times,
|
|
* and we fall back to softirqd after that.
|
|
* and we fall back to softirqd after that.
|
|
@@ -80,8 +193,9 @@ asmlinkage void __do_softirq(void)
|
|
int cpu;
|
|
int cpu;
|
|
|
|
|
|
pending = local_softirq_pending();
|
|
pending = local_softirq_pending();
|
|
|
|
+ __local_bh_disable((unsigned long)__builtin_return_address(0));
|
|
|
|
+ trace_softirq_enter();
|
|
|
|
|
|
- local_bh_disable();
|
|
|
|
cpu = smp_processor_id();
|
|
cpu = smp_processor_id();
|
|
restart:
|
|
restart:
|
|
/* Reset the pending bitmask before enabling irqs */
|
|
/* Reset the pending bitmask before enabling irqs */
|
|
@@ -109,7 +223,8 @@ restart:
|
|
if (pending)
|
|
if (pending)
|
|
wakeup_softirqd();
|
|
wakeup_softirqd();
|
|
|
|
|
|
- __local_bh_enable();
|
|
|
|
|
|
+ trace_softirq_exit();
|
|
|
|
+ _local_bh_enable();
|
|
}
|
|
}
|
|
|
|
|
|
#ifndef __ARCH_HAS_DO_SOFTIRQ
|
|
#ifndef __ARCH_HAS_DO_SOFTIRQ
|
|
@@ -136,23 +251,6 @@ EXPORT_SYMBOL(do_softirq);
|
|
|
|
|
|
#endif
|
|
#endif
|
|
|
|
|
|
-void local_bh_enable(void)
|
|
|
|
-{
|
|
|
|
- WARN_ON(irqs_disabled());
|
|
|
|
- /*
|
|
|
|
- * Keep preemption disabled until we are done with
|
|
|
|
- * softirq processing:
|
|
|
|
- */
|
|
|
|
- sub_preempt_count(SOFTIRQ_OFFSET - 1);
|
|
|
|
-
|
|
|
|
- if (unlikely(!in_interrupt() && local_softirq_pending()))
|
|
|
|
- do_softirq();
|
|
|
|
-
|
|
|
|
- dec_preempt_count();
|
|
|
|
- preempt_check_resched();
|
|
|
|
-}
|
|
|
|
-EXPORT_SYMBOL(local_bh_enable);
|
|
|
|
-
|
|
|
|
#ifdef __ARCH_IRQ_EXIT_IRQS_DISABLED
|
|
#ifdef __ARCH_IRQ_EXIT_IRQS_DISABLED
|
|
# define invoke_softirq() __do_softirq()
|
|
# define invoke_softirq() __do_softirq()
|
|
#else
|
|
#else
|
|
@@ -165,6 +263,7 @@ EXPORT_SYMBOL(local_bh_enable);
|
|
void irq_exit(void)
|
|
void irq_exit(void)
|
|
{
|
|
{
|
|
account_system_vtime(current);
|
|
account_system_vtime(current);
|
|
|
|
+ trace_hardirq_exit();
|
|
sub_preempt_count(IRQ_EXIT_OFFSET);
|
|
sub_preempt_count(IRQ_EXIT_OFFSET);
|
|
if (!in_interrupt() && local_softirq_pending())
|
|
if (!in_interrupt() && local_softirq_pending())
|
|
invoke_softirq();
|
|
invoke_softirq();
|