tech-kern archive

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

Re: mutexes, IPL, tty locking



David Holland <dholland-tech%netbsd.org@localhost> wrote:
>  > It would probably be better to use bitmask and ffs() right here, to avoid
>  > looping through priorities.
> 
> Yes, except that you need the counts. Maintaining a mask as well as
> the counts is probably more expensive than executing this loop once in
> a while.

I doubt it would be more expensive, especially if you have more priorities.
It's something one would benchmark, but see below..

> I'm not sure it's as rare as all that; it just mostly doesn't overtly
> fail. Instead you end up silently running at a higher IPL than
> necessary, and that buys you longer interrupt latencies and more
> dropped packets and all that.

Locks and especially spin-locks should be held for shortest possible time.
If your code blocks interrupts too long, then perhaps it's time to make it
more fine-grained.

And again - looking at our tree, it is optimisation for some tiny percent.
One needs to acquire two (or more) spin-locks with different IPL, release
higher first, and have some significant workload before releasing second.
This is more than rare, rather something what needs improvement. :)

-- 
Mindaugas


Home | Main Index | Thread Index | Old Index