Subject: Re: Interrupt, interrupt threads, continuations, and kernel lwps
To: Pavel Cahyna <pavel@netbsd.org>
From: Andrew Doran <ad@netbsd.org>
List: tech-kern
Date: 06/16/2007 14:42:52
On Sat, Jun 16, 2007 at 02:26:48PM +0100, Andrew Doran wrote:
> On Fri, Jun 15, 2007 at 11:20:42PM +0200, Pavel Cahyna wrote:
>
> > What would this mean? Replacing splbio, splnet, etc. by
> > spllow/splmid/splhigh?
>
> That's the plan. It depends on the platform but looks roughly like this:
>
> bio, net, tty, vm -> low
> sched, clock, audio -> mid
> statclock, serial, ipi -> high
>
> Audio will need to start out life at low since it still needs the kernel
> lock. When the audio locking stuff is complete it can move into mid. Some
> of the goals are:
>
> o Define and enforce a hierarchy since there is no such thing now.
>
> o Make the hierarchy simple so that it defeats spinlock ordering problems,
> is easy to understand and easy to implement.
>
> o Provide enough levels that in the common case, we don't screw up things
> like timekeeping or serial comms.
>
> In the long term, the soft levels would stay but only if appropriate for MD
> code. That is, if the soft interrupt dispatch code wants to make use of
> them. In the near term we need them until the end users begin to make use
> of locks or other exclusion mechanisms.
One more thing.. There would still be the concept of soft interrupt levels
but it's more related to scheduler priorities. The threads sit at a higher
priority than everything else in the system, and there's an ordering among
them: serial > net > bio > clock. The number of levels is limited because it
can be tied in fairly closely with the MD interrupt dispatching code. There
would be nothing to stop anyone from creating (for example) a kthread or
workqueue in the same priority space though.
Andrew
/* Public interface. */
void *softint_establish(u_int, void (*)(void *), void *);
void softint_disestablish(void *);
void softint_schedule(void *);
/* Flags for softint_establish(). */
#define SOFTINT_BIO 0x0000
#define SOFTINT_CLOCK 0x0001
#define SOFTINT_SERIAL 0x0002
#define SOFTINT_NET 0x0003
#define SOFTINT_MPSAFE 0x0100
#define SOFTINT_COUNT 0x0004
#define SOFTINT_LVLMASK 0x00ff