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]
Message-Id: <20150619223223.94775FFA@viggo.jf.intel.com>
Date:	Fri, 19 Jun 2015 15:32:23 -0700
From:	Dave Hansen <dave@...1.net>
To:	dave@...1.net
Cc:	jack@...e.cz, viro@...iv.linux.org.uk,
	linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
	paulmck@...ux.vnet.ibm.com, tim.c.chen@...ux.intel.com,
	ak@...ux.intel.com
Subject: [RFC][PATCH 2/2] fs: conditionally do memory barrier in __sb_end_write()


If I sit in a loop and do write()s to small tmpfs files,
__sb_end_write() is third-hottest kernel function due to its
smp_mb().

The stated purpose for the smp_mb() in __sb_end_write() is to
ensure "s_writers are updated before we wake up waiters".  We
only wake up waiters if waitqueue_active(), but we do the
smp_mb() unconditionally.

It seems like we should be able to avoid it unless we are
actually doing the wake_up().

Cc: Jan Kara <jack@...e.cz>
Cc: Alexander Viro <viro@...iv.linux.org.uk>
Cc: linux-fsdevel@...r.kernel.org
Cc: linux-kernel@...r.kernel.org
Cc: Paul E. McKenney <paulmck@...ux.vnet.ibm.com>
Cc: Tim Chen <tim.c.chen@...ux.intel.com>
Cc: Andi Kleen <ak@...ux.intel.com>

---

 b/fs/super.c |   13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff -puN fs/super.c~selectively-do-barriers-in-__sb_end_write fs/super.c
--- a/fs/super.c~selectively-do-barriers-in-__sb_end_write	2015-06-19 15:20:37.953726659 -0700
+++ b/fs/super.c	2015-06-19 15:20:37.956726794 -0700
@@ -1147,13 +1147,14 @@ out:
 void __sb_end_write(struct super_block *sb, int level)
 {
 	percpu_counter_dec(&sb->s_writers.counter[level-1]);
-	/*
-	 * Make sure s_writers are updated before we wake up waiters in
-	 * freeze_super().
-	 */
-	smp_mb();
-	if (waitqueue_active(&sb->s_writers.wait))
+	if (waitqueue_active(&sb->s_writers.wait)) {
+		/*
+		 * Make sure other CPUs can see our s_writers update
+		 * before we wake up waiters in freeze_super().
+		 */
+		smp_mb();
 		wake_up(&sb->s_writers.wait);
+	}
 	rwsem_release(&sb->s_writers.lock_map[level-1], 1, _RET_IP_);
 }
 EXPORT_SYMBOL(__sb_end_write);
_
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ