LWN.net Logo

Btrfs aims for the mainline

Btrfs aims for the mainline

Posted Jan 8, 2009 4:16 UTC (Thu) by pr1268 (subscriber, #24648)
In reply to: Btrfs aims for the mainline by jzbiciak
Parent article: Btrfs aims for the mainline

Why not just get rid of the outer (top) if-statement altogether, and move the cpu_relax() statement to after the inner if-statement?


(Log in to post comments)

Btrfs aims for the mainline

Posted Jan 9, 2009 17:57 UTC (Fri) by giraffedata (subscriber, #1954) [Link]

Why not just get rid of the outer (top) if-statement altogether, and move the cpu_relax() statement to after the inner if-statement?

In at least some systems, it is probably an extra instruction or two for the most common case -- that the lock is available immediately. Lock algorithms are usually written this way.

Incidentally, as long as we're counting, it's 514. mutex_lock_nested() will necessarily try to acquire the lock before going to sleep.

Copyright © 2013, Eklektix, Inc.
Comments and public postings are copyrighted by their creators.
Linux is a registered trademark of Linus Torvalds