From: Linus Torvalds <torvalds@linux-foundation.org>
To: Mikulas Patocka <mikulas@artax.karlin.mff.cuni.cz>
Cc: viro@zeniv.linux.org.uk, linux-kernel@vger.kernel.org
Subject: Re: [PATCH]: Fix SMP-reordering race in mark_buffer_dirty
Date: Wed, 2 Apr 2008 14:31:46 -0700 (PDT) [thread overview]
Message-ID: <alpine.LFD.1.00.0804021422570.14670@woody.linux-foundation.org> (raw)
In-Reply-To: <Pine.LNX.4.64.0804022238460.25023@artax.karlin.mff.cuni.cz>
On Wed, 2 Apr 2008, Mikulas Patocka wrote:
>
> So you're right, the gain of mfence is so little that you can remove it
> and use only test_set_buffer_dirty.
Well, I suspect that part of the issue is that quite often you end up
with *both* because the buffer wasn't already dirty from before.
Re-dirtying a dirty buffer is pretty common for things like bitmap blocks
etc, so it's probably a worthy optimization if it has no cost, and on
Core2 I suspect your version is worth it, but it's not like it's going to
be necessarily a 99% kind of case. I suspect quite a lot of the
mark_buffer_dirty() calls are actually on clean buffers.
(Of course, a valid argument is that if it was already dirty, we'll skip
the other expensive parts, so only the "already dirty" case is worth
optimizing for. Maybe true. There might also be cases where it means one
less dirty cacheline in memory.)
> I don't know if there are other architectures where smb_mb() would be
> significantly faster than test_and_set_bit.
Probably none, since it test_and_set_bit() implies a smp_mb(), and
generally the bigger cost is in the barrier than in the bit setting
itself.
Core 2 is the outlier in having a noticeably faster "mfence" than atomic
instructions (and judging by noises Intel makes, Nehalem will undo that
outlier).
Linus
next prev parent reply other threads:[~2008-04-02 21:32 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-04-02 19:20 Mikulas Patocka
2008-04-02 19:44 ` Linus Torvalds
2008-04-02 21:03 ` Mikulas Patocka
2008-04-02 21:31 ` Linus Torvalds [this message]
2008-04-02 21:35 ` Linus Torvalds
2008-04-02 22:39 ` Mikulas Patocka
2008-04-02 22:51 ` Linus Torvalds
2008-04-02 22:35 ` Mikulas Patocka
2008-04-02 22:01 ` Andrew Morton
2008-04-02 22:07 ` Linus Torvalds
2008-04-02 22:53 ` Mikulas Patocka
2008-04-02 23:52 ` Linus Torvalds
2008-04-03 2:12 ` Andrew Morton
2008-04-03 14:34 ` Linus Torvalds
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=alpine.LFD.1.00.0804021422570.14670@woody.linux-foundation.org \
--to=torvalds@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mikulas@artax.karlin.mff.cuni.cz \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®