Re: [PATCH] reiserfs: kill-the-BKL

From: Linus Torvalds
Date: Thu Apr 09 2009 - 11:41:33 EST




On Thu, 9 Apr 2009, Andi Kleen wrote:
>
> You have to be very careful with this. Mutexes can be slower than
> spinlocks (and the new BKL is a spinlock) in some situations, they
> typically schedule much more etc., which can be costly.

Actually, with the new adaptive spinning, that basically shouldn't be true
any more. Or rather, you should need some really bad/unlucky situation for
it to scheduler more than necessary, and if the locker _acts_ like a
spinlock (ie it doesn't block while holding the lock), performance should
approach a spinlock.

That said, there are definitely reasons why a mutex can be slower than the
BKL, and the whole "BKL gets implicitly dropped at sleep time" is very
high on that list of reasons. The sleeping patterns can be _very_
different with a mutex than with a BKL.

> Better would be to use spinlocks if possible. I guess you just would
> need to find all sleep points and wrap them with lock dropping?

I do agree that a filesystem should try to avoid sleeping locks if at all
possible, especially on the paths that the VM uses for writeback. But on
the other hand, I think the issue with reiserfs is just the bad latencies
that the BKL can cause, and then it doesn't matter.

Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/