Re: Calling current() from interrupt context

From: Linus Torvalds (torvalds@transmeta.com)
Date: Mon Oct 09 2000 - 13:08:36 EST


In article <20001008212709.D14137@excalibur.research.wombat.ie>,
Kenn Humborg <kenn@linux.ie> wrote:
>
>I'd just like to confirm that it's illegal to call current()
>from interrupt-handling code.

It's not categorically forbidden.

It does indeed happen, think about things like cross-CPU interrupts for
TLB invalidations etc.

At the very least such interrupts are interested in the "current CPU" -
which on most architectures is defined to "current->processor".

Also, there's been some work on recursive spinlocks, which also used
"current" as the test for recursion.

You might be able to avoid it by using other approaches (most of this
code tends to be architecture-specific anyway).

I think you are right in general, but there are certainly things to look
out for, just in case.

(And taking a trap in an interrupt handler prints out an oops message:
you can expect no end of confusion and debugging problems if "current"
is not valid at that point - lots of small details that probably make
this fairly painful).

Note that there are alternative approaches. For example, you could make
the interrupt stack be in the same multi-page as the regular stack, and
switch them both at task-switch time - just allocate four pages instead
of two, and use "current = esp & ~16383" instead or something like that.

                Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Sun Oct 15 2000 - 21:00:12 EST