Unreliable Linux kernel hacking guide claims
You can say that you are in a hardware interrupt because in_irq () returns true.
Warning . Remember that this will lead to a false positive if interrupts are disabled (see below).
Is it really that it in_irq()can return a nonzero value not in the hardirq context in Linux kernels 2.6.32 or later on x86?
In my experiments with the kernel 2.6.32 (Debian 6) and 3.4 (OpenSUSE 12.1), I in_irq()always returned 0 when called from a process context, even if it was called between local_irq_disable()and local_irq_enable(). The results were the same when I used spinlock functions that forbid interrupts instead local_irq*.
From the kernel source, I currently do not see how it in_irq()can return a false result. Can anyone clarify this?
EDIT: I also tried using the API *_irqsave()and *_irq()spinlock API, as well as local_irq_save()/ local_irq_restore(), the results were the same, i.e. in_irq()returned 0 when interrupts were disabled. Disabling interrupts explicitly using clithe x86 machine instruction also did not force in_irq () to return a nonzero value.
source
share