lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 3 Apr 2008 00:35:39 +0200 (CEST)
From:	Mikulas Patocka <mikulas@...ax.karlin.mff.cuni.cz>
To:	Linus Torvalds <torvalds@...ux-foundation.org>
cc:	viro@...iv.linux.org.uk, linux-kernel@...r.kernel.org
Subject: Re: [PATCH]: Fix SMP-reordering race in mark_buffer_dirty

On Wed, 2 Apr 2008, Linus Torvalds wrote:

> 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.

The cost of doing the buffer lookup and update is much more than the 20 
clocks, so the 20 clocks mfence/lock difference can be forgotten.

> (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.)

That is another good example: when two CPUs are simultaneously updating 
the same buffer (i.e. two inodes in one block or simultaneous writes to a 
bitmap), then test_set_buffer_dirty will do cache ping-pong (that is much 
more expensive than that 20-100 cycles for an interlocked instruction), 
and smp_mb()+test_buffer_dirty will keep cache intact.

So maybe there's still a reason for smb_mb().

Mikulas

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ