Subject: Re: splx() optimization [was Re: SMP re-eetrancy in "bottom half" drivers]
To: Bill Studenmund <wrstuden@netbsd.org>
From: Jonathan Stone <jonathan@dsg.stanford.edu>
List: tech-kern
Date: 06/03/2005 15:39:10
In message <20050603013901.GB4381@netbsd.org>Bill Studenmund writes
[...]
>How certain are we that all our code has been changed to not abuse spl
>ordering? It used to be that some spl levels implied all the lower ones
>too. Translated into locks, that means that if a cpu wants to set a
>certain slp, it would need to implicitly grab a whole lot of locks (the
>one for this spl and all lower ones). I _think_ we cleaned that out, but
>I'm not sure.
Back in the days of 4BSD on a VAX, processor IPLs were effectively a
counter, not bitfields; so _all_ SPLs that mapped to distinct CPU
prioities always implicitly masked all lower SPLs.
>If our code is clean, then I think we're fine, and we can have a given
>spl only grab one level of locks. So you could have different heads in the
>system operating at different spl levels.
That's what I hoped for. OTOH, your wording makes it very clear
(to me, anyway) that *at most* one head can be in the kernel at any
given (SPL,lock) level.
You also remind me that, once upon a time, spl*() raising was idempotent,
and code fragments like the following
void device_fn(...);
void
caller1(...)
{
/* ... */
device_fn();
}
void
caller2(...)
{
int s;
s = splfoo();
device_fn();
splx(s);
}
void
device_fn()
{
int s;
s = splfoo();
/* ... guts of driver function */
splx(s);
}
would work. (caller1 might be also inside the driver, and thus
already called at splfoo().)
Do we have any such code, these days?