login
Header Space

 
 

Re: Interrupt, interrupt threads, continuations, and kernel lwps

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <jonathan@...>
Cc: Bill Studenmund <wrstuden@...>, Andrew Doran <ad@...>, <tech-kern@...>
Date: Friday, February 23, 2007 - 12:27 am

On Thu, Feb 22, 2007 at 04:49:40PM -0800, jonathan@dsg.stanford.edu wrote:

Well, it is. :-) It is one form of context switch, and all of the=20
context-switchy things it does are a main part of its expense.


True.

For the common case, we will have almost the same behavior as now, except=
=20
that we can take mutexes in an interrupt handler.

As I understand it, the difficulty comes in when the mutex is held by a=20
thread that is not running. In that case, the interrupt handler blocks. In=
=20
that case, the interrupt handler has to be blocked, and the interrupt has=
=20
to be disabled/ignored until serviced. For systems with a PIC, we disable=
=20
the interrupt and cope.

For systems without a PIC, like many m68k systems (and VAX as I understand=
=20
matt), we would need to disable said interrupt in the CPU (set the chip's=
=20
interrupt level) until the service routine completes.

As noted, this will hopefully be a rare occurrence, where a thread that=20
holds an interrupt mutex is no longer on a processor. We can structure our=
=20
code so that this is very unlikely, if not impossible.

Note that in the case of the mutex being locked but the thread being on=20
another processor, we will just spin-wait. That's a feature of the locking=
=20
we copied from Solaris. I expect that this _will_ happen, but we then get=
=20
the exact same behaviors as if we had spinlocks.


Single ande multi-CPU to be sure. But as for the other stuff, it's mostly=
=20
what we have now. So I don't see how we will have radially-different=20
results.

We should test stuff over time to make sure we don't do something stupid,=
=20
to be sure!


I don't think that will mater for interupt handlers. Yes, I think there's=
=20
a lot of work to do for the networking stack. But I think it'll be=20
different work.

As above, trying to get the lock while a thread running on another CPU has=
=20
it turns into a spin wait. That's not the slow case. So as long as we=20
don't hold a mutex we take in interrupt context while we do something else=
=20
that can block, we will NOT trigger the slow path in an interrupt handler.=
=20
We don't sleep while holding SPL now (or we aren't supposed to), so a very=
=20
direct 1:1 translation should be fine.

We can run into issues, of course, and we need to look for them. Like a
case where the process that we interrupted holds a mutex that the thread
that holds the interrupt mutex is waiting for. That's a deadlock if we
don't detect it & trigger slow-path. It can also be argued that that's a
bad design. :-)

While I think we need to think about some architectures more, I believe=20
this is a good direction to go in.

Also, I remember you wanting to work on MP-ing the network stack. newlock2=
=20
+ interrupt handling will be a definite springboard for that!

Take care,

Bill
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: Interrupt, interrupt threads, continuations, and kernel ..., Joerg Sonnenberger, (Thu Feb 22, 5:59 pm)
Re: Interrupt, interrupt threads, continuations, and kernel ..., Bill Studenmund, (Fri Feb 23, 12:27 am)
Re: Interrupt, interrupt threads, continuations, and kernel ..., Steven M. Bellovin, (Wed Feb 21, 10:21 pm)
speck-geostationary