From: Davidlohr Bueso <dave@stgolabs.net>
To: Dave Chinner <david@fromorbit.com>
Cc: viro@zeniv.linux.org.uk, akpm@linux-foundation.org,
peterz@infradead.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org, Davidlohr Bueso <dbueso@suse.de>
Subject: [PATCH v2] fs/dcache: optimize start_dir_add()
Date: Thu, 29 Oct 2020 12:07:48 -0700 [thread overview]
Message-ID: <20201029190748.u5zrnk6rjtc4p43v@linux-p48b> (raw)
In-Reply-To: <20201026215923.GA306023@dread.disaster.area>
Considering both end_dir_add() and d_alloc_parallel(), the
dir->i_dir_seq wants acquire/release semantics, therefore
micro-optimize for ll/sc archs. Also add READ_ONCE around
the variable mostly for documentation purposes - either
the successful cmpxchg or the pause will avoid the tearing).
Signed-off-by: Davidlohr Bueso <dbueso@suse.de>
---
fs/dcache.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/fs/dcache.c b/fs/dcache.c
index ea0485861d93..9177f0d08a5a 100644
--- a/fs/dcache.c
+++ b/fs/dcache.c
@@ -2504,8 +2504,8 @@ static inline unsigned start_dir_add(struct inode *dir)
{
for (;;) {
- unsigned n = dir->i_dir_seq;
- if (!(n & 1) && cmpxchg(&dir->i_dir_seq, n, n + 1) == n)
+ unsigned n = READ_ONCE(dir->i_dir_seq);
+ if (!(n & 1) && cmpxchg_acquire(&dir->i_dir_seq, n, n + 1) == n)
return n;
cpu_relax();
}
--
2.26.2
prev parent reply other threads:[~2020-10-29 19:29 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-22 21:16 [PATCH] " Davidlohr Bueso
2020-10-26 21:59 ` Dave Chinner
2020-10-29 19:07 ` Davidlohr Bueso [this message]
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=20201029190748.u5zrnk6rjtc4p43v@linux-p48b \
--to=dave@stgolabs.net \
--cc=akpm@linux-foundation.org \
--cc=david@fromorbit.com \
--cc=dbueso@suse.de \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.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®