Re: [PATCH]: Fix SMP-reordering race in mark_buffer_dirty

From: Linus Torvalds
Date: Wed Apr 02 2008 - 19:52:46 EST




On Wed, 2 Apr 2008, Andrew Morton wrote:
>
> But then the test-and-set of an already-set flag would newly cause the
> cacheline to be dirtied, requiring additional bus usage to write it back?

Looking around a bit, I don't see any realistic case where this could
possibly be the case and that is performance-sensitive.

The VFS-level uses of mark_buffer_dirty() seem to all be coupled with
other uses that clear or set other bits in the buffer status word, so the
cacheline will always apparently be dirty.

The low-level filesystems sometimes do it for things like block bitmap
changes, and I could imagine that there it actually (a) is no longer in
the cache and (b) the buffer really was dirty to start with, but in ext3
for example, you'd end up in journal_dirty_metadata which spinlocks on the
BH_State bit first etc etc.

So the cacheline *will* be dirty, and this function doesn't seem like it
could possibly ever show up in a real profile for any real load anyway, so
it seems odd to try to optimize it this way.

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/