Re: [RESEND v2] irq: Refactor irq_wait_for_interrupt info to simplify the code
From: Thomas Gleixner
Date: Wed Jan 15 2020 - 08:43:29 EST
chengkaitao <pilgrimtao@xxxxxxxxx> writes:
> From: Kaitao Cheng <pilgrimtao@xxxxxxxxx>
>
> Cleanup extra if(test_and_clear_bit), and put the other one in front.
That simplifies the code but opens a race window:
CPU 0 CPU 1
irq_wait_for_interrupt()
has not yet reached schedule()
free_irq()
remove_action();
synchronize_irq();
#ifdef CONFIG_DEBUG_SHIRQ
action->handler() if (test_and_clear_bit())
---> bit is not set yet
--> SET thread running
#endif
kthread_stop() if (kthread_stop())
---> Leave with bit set and thread active count != 0
That's just the most obvious example...
Thanks,
tglx