From: Dave Hansen <dave@sr71.net>
To: dave@sr71.net
Cc: jack@suse.cz, viro@zeniv.linux.org.uk,
linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
paulmck@linux.vnet.ibm.com, tim.c.chen@linux.intel.com,
ak@linux.intel.com
Subject: [RFC][PATCH 2/2] fs: conditionally do memory barrier in __sb_end_write()
Date: Fri, 19 Jun 2015 15:32:23 -0700 [thread overview]
Message-ID: <20150619223223.94775FFA@viggo.jf.intel.com> (raw)
In-Reply-To: <20150619223223.10B658AD@viggo.jf.intel.com>
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@suse.cz>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: linux-fsdevel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
Cc: Tim Chen <tim.c.chen@linux.intel.com>
Cc: Andi Kleen <ak@linux.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-fsdevel" in
next prev parent reply other threads:[~2015-06-19 22:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-19 22:32 [RFC][PATCH 1/2] fs: use RCU for free_super() vs. __sb_start_write() Dave Hansen
2015-06-19 22:32 ` Dave Hansen [this message]
2015-06-23 12:02 ` [RFC][PATCH 2/2] fs: conditionally do memory barrier in __sb_end_write() Jan Kara
2015-06-23 11:09 ` [RFC][PATCH 1/2] fs: use RCU for free_super() vs. __sb_start_write() Jan Kara
2015-06-24 20:21 ` Dave Hansen
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=20150619223223.94775FFA@viggo.jf.intel.com \
--to=dave@sr71.net \
--cc=ak@linux.intel.com \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=paulmck@linux.vnet.ibm.com \
--cc=tim.c.chen@linux.intel.com \
--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;
as well as URLs for NNTP newsgroup(s).