Source-Changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: CVS commit: src/sys

On Mon, Dec 08, 2008 at 05:01:04PM +1100, matthew green wrote:

>    On Sun, Dec 07, 2008 at 11:43:54AM +0000, Andrew Doran wrote:
>    > On Sun, Dec 07, 2008 at 11:40:53AM +0000, Andrew Doran wrote:
>    > 
>    > > Module Name:   src
>    > > Committed By:  ad
>    > > Date:          Sun Dec  7 11:40:53 UTC 2008
>    > > 
>    > > Modified Files:
>    > >        src/sys/kern: kern_cpu.c
>    > >        src/sys/sys: cpu.h
>    > 
>    > cvs admin "-m1.27:Add cpu_softintr_p() for assertions" cpu.h
>    > cvs admin "-m1.39:Add cpu_softintr_p() for assertions" kern_cpu.c
>    Cool. Does is means that we can use
>    (!cpu_intr_p() && !cpu_softintr_p())
>    to know if we can tsleep() or not (this would clean up the ATA subsystem)
> it was my understanding that cpu_intr_p() was only to be
> used in diag/debug code.

Yeah. They are reliable and so you can use them for runtime decisions but I
think it's preferable to use them only for assertions, on the principle that
having foreknowledge of what context a routine is called in is likely to
make for more reliable code *. Otherwise we can end up guessing and coding
for situations that do not occur.

With the buffer cache locking I added a conditional based on cpu_intr_p() in
biodone(). In some places we expect completion to be processed immediatley
and elsewhere we just want to note that I/O is complete, and don't care when
that completion is processed. Given how old and well known the routine and
how widespread its use is I couldn't see a another compromise so caved in
(reluctantly) and used cpu_intr_p().


* As a side note, if you're looking at a bit of code and can't tell what
context a particular routine is called in it makes dealing with concurrency
(eg MP or realtime) harder. The uvm code and some of the pmaps are nice in
that many functions have comments about what they expect (e.g. a lock held,
thread context, wired stack, whatever), what their side effects are and it's
well checked with KASSERTs.

Home | Main Index | Thread Index | Old Index