From: Jan Kara <jack@suse.cz>
To: Dave Hansen <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: Re: [RFC][PATCH 1/2] fs: use RCU for free_super() vs. __sb_start_write()
Date: Tue, 23 Jun 2015 13:09:33 +0200 [thread overview]
Message-ID: <20150623110933.GE2427@quack.suse.cz> (raw)
In-Reply-To: <20150619223223.10B658AD@viggo.jf.intel.com>
On Fri 19-06-15 15:32:23, Dave Hansen wrote:
>
> Currently, __sb_start_write() and freeze_super() can race with
> each other. __sb_start_write() uses a smp_mb() to ensure that
> freeze_super() can see its write to sb->s_writers.counter and
> that it can see freeze_super()'s update to sb->s_writers.frozen.
> This all seems to work fine.
>
> But, this smp_mb() makes __sb_start_write() the single hottest
> function in the kernel if I sit in a loop and do tiny write()s to
> tmpfs over and over. This is on a very small 2-core system, so
> it will only get worse on larger systems.
>
> This _seems_ like an ideal case for RCU. __sb_start_write() is
> the RCU read-side and is in a very fast, performance-sensitive
> path. freeze_super() is the RCU writer and is in an extremely
> rare non-performance-sensitive path.
>
> Instead of doing and smp_wmb() in __sb_start_write(), we do
> rcu_read_lock(). This ensures that a CPU doing freeze_super()
> can not proceed past its synchronize_rcu() until the grace
> period has ended and the 's_writers.frozen = SB_FREEZE_WRITE'
> is visible to __sb_start_write().
>
> One question here: Does the work that __sb_start_write() does in
> a previous grace period becomes visible to freeze_super() after
> its call to synchronize_rcu()? It _seems_ like it should, but it
> seems backwards to me since __sb_start_write() is the "reader" in
> this case.
>
> This patch increases the number of writes/second that I can do
> by 10.4%.
>
> Does anybody see any holes with this?
Nice speed up and looks good to me. Just one question below.
> @@ -1340,7 +1344,7 @@ int freeze_super(struct super_block *sb)
> printk(KERN_ERR
> "VFS:Filesystem freeze failed\n");
> sb->s_writers.frozen = SB_UNFROZEN;
> - smp_wmb();
> + synchronize_rcu();
Do we really need synchronize_rcu() here? We just need to make sure write
to sb->s_writers.frozen happens before we start waking processes...
> wake_up(&sb->s_writers.wait_unfrozen);
> deactivate_locked_super(sb);
> return ret;
> @@ -1387,7 +1391,7 @@ int thaw_super(struct super_block *sb)
>
> out:
> sb->s_writers.frozen = SB_UNFROZEN;
> - smp_wmb();
> + synchronize_rcu();
> wake_up(&sb->s_writers.wait_unfrozen);
And here as well...
Honza
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
next prev parent reply other threads:[~2015-06-23 11:09 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 ` [RFC][PATCH 2/2] fs: conditionally do memory barrier in __sb_end_write() Dave Hansen
2015-06-23 12:02 ` Jan Kara
2015-06-23 11:09 ` Jan Kara [this message]
2015-06-24 20:21 ` [RFC][PATCH 1/2] fs: use RCU for free_super() vs. __sb_start_write() 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=20150623110933.GE2427@quack.suse.cz \
--to=jack@suse.cz \
--cc=ak@linux.intel.com \
--cc=dave@sr71.net \
--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).