Scalability is a double edged sword...
Posted Jul 18, 2002 17:50 UTC (Thu) by
iabervon (subscriber, #722)
Parent article:
Scalability is a double edged sword...
Most Linux systems are still single-processor, and the whole locking setup handles the UP case nicely, regardless of which lock you use.
When fine-grained locking doesn't mean holding more locks, but rather holding a different lock from what different code might hold (e.g., separate locks for different filesystems, instead of one for all), it's better for small SMP, because it removes cache line contention (as well as a bit of lock contention).
The BKL should be replaced with other locks whenever possible, because its semantics is odd. Of course, few if any people know in a particular case how to replace it with other locks for just that reason.
Holding locks for less time is mixed. If you do two operations while holding the lock, it might not be worth dropping the lock in between them (even if it is safe to do so). But if you're taking a lock, calling a function, and releasing the lock, it might as well be done in the function, since that means that the function can take the lock only if it actually needs it, can take a more specific lock, and doesn't have to be documented as requiring the lock. Due to the way SMP support came to Linux (the BKL dropped in at the top and split from there), this situation exists in a lot of places.
Splitting a lock that is used for a number of related purposes into a group of locks where more than one is needed for some common operation is bad for the low end, and should be avoided in mainline Linux. But there's a lot of other lock refinements that are possible.
Linus, in any case, is focused these days on small SMP, and nothing is going to go into the mainline kernel which hurts small SMP without a major increase in the readability of the code (i.e., it would have to decrease the chance of non-obvious locking-related bugs). People who have large numbers of processors will probably want to maintain a lots-of-little-locks patch, but there's no reason to have it in the mainline, because people wouldn't be able to test whether they were improving performance for the high end anyway.
(
Log in to post comments)