Re: [RFC PATCH 1/3] lockdep/irq: Be more strict about IRQ-threadable code end

From: Peter Zijlstra
Date: Mon Mar 23 2020 - 09:53:27 EST


On Mon, Mar 23, 2020 at 04:32:05AM +0100, Frederic Weisbecker wrote:
> --- a/kernel/irq/handle.c
> +++ b/kernel/irq/handle.c
> @@ -144,18 +144,24 @@ irqreturn_t __handle_irq_event_percpu(struct irq_desc *desc, unsigned int *flags
>
> for_each_action_of_desc(desc, action) {
> irqreturn_t res;
> + bool threadable;
>
> /*
> * If this IRQ would be threaded under force_irqthreads, mark it so.
> */
> - if (irq_settings_can_thread(desc) &&
> - !(action->flags & (IRQF_NO_THREAD | IRQF_PERCPU | IRQF_ONESHOT)))
> + threadable = (irq_settings_can_thread(desc) &&
> + !(action->flags & (IRQF_NO_THREAD | IRQF_PERCPU | IRQF_ONESHOT)));
> +
> + if (threadable)
> trace_hardirq_threaded();
>
> trace_irq_handler_entry(irq, action);
> res = action->handler(irq, action->dev_id);
> trace_irq_handler_exit(irq, action, res);
>
> + if (threadable)
> + trace_hardirq_unthreaded();

AFAICT this doesn't work for nested IRQ handlers.

> if (WARN_ONCE(!irqs_disabled(),"irq %u handler %pS enabled interrupts\n",
> irq, action->handler))
> local_irq_disable();
> --
> 2.25.0
>