mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@linux-foundation.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: mikulas@artax.karlin.mff.cuni.cz, 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 15:01:58 -0700	[thread overview]
Message-ID: <20080402150158.f366370f.akpm@linux-foundation.org> (raw)
In-Reply-To: <alpine.LFD.1.00.0804021237031.14670@woody.linux-foundation.org>

On Wed, 2 Apr 2008 12:44:05 -0700 (PDT)
Linus Torvalds <torvalds@linux-foundation.org> wrote:

> 
> 
> On Wed, 2 Apr 2008, Mikulas Patocka wrote:
> > +	/*
> > +	 * Make sure that the test for buffer_dirty(bh) is not reordered with
> > +	 * previous modifications to the buffer data.
> > +	 * -- mikulas
> > +	 */
> > +	smp_mb();
> >  	WARN_ON_ONCE(!buffer_uptodate(bh));
> >  	if (!buffer_dirty(bh) && !test_set_buffer_dirty(bh))
> 
> At that point, the better patch is to just *remove* the buffer_dirty() 
> test, and rely on the stronger ordering requirements of 
> test_set_buffer_dirty().
> 
> The whole - and only - point of the buffer_dirty() check was to avoid the 
> more expensive test_set_buffer_dirty() call, but it's only more expensive 
> because of the barrier semantics. So if you add a barrier, the point goes 
> away and you should instead remove the optimization.

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?

The CPU's test-and-set-bit operation could of course optimise that away in
this case.  But does it?



  parent reply	other threads:[~2008-04-02 22:03 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
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 [this message]
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=20080402150158.f366370f.akpm@linux-foundation.org \
    --to=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mikulas@artax.karlin.mff.cuni.cz \
    --cc=torvalds@linux-foundation.org \
    --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®