12-24-04 11:34 PM
Casper H.S. Dik wrote:
> kamalp@acm.org (Kamal R. Prasad) writes:
>
>
>
>
> Except that it doesn't in a Solaris kernel (there is more than one CPU)
> and you also block progress of all unrelated threads; in that it
> is a very primitive, coarse grained, lock.
> (splnet(), e.g., locks at the network interrupts so you can safely
> do administrative in the network stack)
>
>
>
>
> Why is that primitive? Spinlocks are used a lot in MP systems
> for short term waits (the Solaris kernel spins when it tries to
> grab a lock held by a thread currently running on a CPU); it assumes
> the lock will be short term. (It is an adaptive lock)
Pardon some thread drift here.
You are abosutely correct when you say that the
Solaris kernel assumes the lock will be short term and
that the code is adaptive. As a matter of fact,
there is a comment at the top of the adaptive
mutex code which reinforces this and says
something along the lines of: "if this
is not the case, re-think your algorithm."
(But how many developers read comments anyway?
As I recall, the adaptive mutexes default to
spinlocks.)
[Yes, we have access under NDA to the Solaris
source. I don't think I am violating the NDA
by paraphrasing the comment above.]
A poorly written device driver can eat up gobs
of CPU time if the mutexes are at too great a
granularity or are held too long.
We had an experience a couple of years ago with
some third-party boards. Our performance testing
indicated that the bulk of CPU was spent in
the "care and feeding" of the board (>90%
writes. For the most part, all the interrupts
were doing was setting an IODONE flag.).
In order to get more throughput, we
upgraded the CPU's to double the speed, but,
we got zero increase in throughput!
Now, the vendor recommended that, in order
to increase throughput, we put in more boards.
(Thus increasing the vendor's sales and profits
at 8K USD per board? I wonder?)
However we were out of card-slots in the frame
and this was not an option for us.
Upon further investigation, we found that their
driver code was using adaptive mutexes and that
the granularity of the locking was *per board*
as opposed to per channel (64 channels per board).
What does this have to do with the "splxxx()"
discussion? Not much, other than that any kind
of locking mechanism can be mis-used and abused.
End Thread Drift.
[Rest Snipped ]
NPL
--
"It is impossible to make anything foolproof
because fools are so ingenious"
- A. Bloch
[ Post a follow-up to this message ]
|