Subject: Re: IPL-lowering functions should return 'void', and now they do.
To: Ben Harris <>
From: Chris G. Demetriou <>
List: tech-kern
Date: 06/08/2000 09:28:10
Ben Harris <> writes:
> The manual page seems to be uncertain about whether splx() is ever used to
> raise priority.  I'd assume that it isn't, but it'd be nice for it to be
> confirmed by Someone Who Knows.

That's different than what you ask later:

> Indeed, but I'd like to know if anything will ever use it, not just if
> it's currently used.  More importantly, I'd like to know if splx() can
> assume that the spl is being lowered, since this saves a comparison (it
> knows it always has to check for soft interrupts).

So, the interesting question here is probably "if splx() is going to
raise the IPL, how would it do that," or, put another way, how would a
caller know what IPL to give splx() in order to raise the IPL.

There are three cases where i can think of this happening:

	* changing IPL to a 'known' value.  This is a very special
	  case.  Take a look at safepri (but note that w.r.t. lowering
	  the IPL in its call to splx(), it should be fine -- assuming
	  it's < splhigh(). 8-)

	* where you're trying to do something wacky, and re-use old
          spl() return values, or something.  This would be insane,
	  and obviously code should never do it.

	* bugs, of the form:

		s1 = spltty()
		s2 = splhigh()

	  (Obviously, "bugs." 8-)

the only input values that can be used to splx() are values returned
by spl*() or provided by MD code... in proper use, splx() will never
be used to raise interrupts except in the case of things like safepri
(and iirc it's the only instance of code like it, and it is safe).

However, that doesn't mean that splx() will necessarily be _lowering_
interrupts.  a simple, safe counterexample is:

	s1 = spltty()
	s2 = spltty()

The IPL should remain the same between the initial spltty() and final
splx() there.

i think i also saw the question asked about whether things can ever
use the return value of splx(): no.  It doesn't make sense (for the
same reason that trying to use the return value of spl0() or
spllowersoftclock() doesn't make sense), and that's why it's been
defined to return `void' for a while now (in NetBSD, at least).

Chris Demetriou - -
Disclaimer: Not speaking for NetBSD, just expressing my own opinion.