From: David Sterba <dsterba@suse.cz>
To: David Sterba <dsterba@suse.cz>
Cc: Nikolay Borisov <nborisov@suse.com>,
Josef Bacik <josef@toxicpanda.com>, Qu Wenruo <wqu@suse.com>,
linux-btrfs@vger.kernel.org,
Zygo Blaxell <ce3g8jdj@umail.furryterror.org>,
David Sterba <dsterba@suse.com>
Subject: Re: [PATCH v2] btrfs: relocation: Fix KASAN reports caused by extended reloc tree lifespan
Date: Wed, 8 Jan 2020 16:11:59 +0100 [thread overview]
Message-ID: <20200108151159.GI3929@twin.jikos.cz> (raw)
In-Reply-To: <20200108150841.GH3929@twin.jikos.cz>
On Wed, Jan 08, 2020 at 04:08:41PM +0100, David Sterba wrote:
> > >> +static bool have_reloc_root(struct btrfs_root *root)
> > >> +{
> > >> + if (test_bit(BTRFS_ROOT_DEAD_RELOC_TREE, &root->state))
> > >> + return false;
> > >
> > > You still need a smp_mb__after_atomic() here, test_bit is unordered.
> >
> > Nope, that won't do anything, since smp_mb__(After|before)_atomic only
> > orders RMW operations and test_bit is not an RMW operation. From
> > atomic_bitops.txt:
> >
> >
> > Non-RMW ops:
> >
> >
> >
> > test_bit()
> >
> > Furthermore from atomic_t.txt:
> >
> > The barriers:
> >
> >
> >
> > smp_mb__{before,after}_atomic()
> >
> >
> >
> > only apply to the RMW atomic ops and can be used to augment/upgrade the
> >
> > ordering inherent to the op.
>
> The way I read it is more like smp_rmb/smp_wmb, but for bits in this
> case, so the smp_mb__before/after_atomic was only a syntactic sugar to
> match that it's atomic bitops. I realize this could have caused some
> confusion, however I still think that some sort of barrier is needed.
There's an existing pattern used for serializing set/clear of
BTRFS_ROOT_IN_TRANS_SETUP (record_root_in_trans,
btrfs_record_root_in_trans).
Once upon a time there were barriers like smp_mb__before_clear_bit but
they got unified to just smp_mb__before_atomic for all set/clear
operations, so I believe I was not all wrong with using them.
next prev parent reply other threads:[~2020-01-08 15:12 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-01-08 5:12 [PATCH v2] btrfs: relocation: Fix KASAN reports caused by extended reloc tree lifespan Qu Wenruo
2020-01-08 12:28 ` Nikolay Borisov
2020-01-08 12:36 ` Qu WenRuo
2020-01-08 14:55 ` Josef Bacik
2020-01-08 15:03 ` Nikolay Borisov
2020-01-08 15:08 ` David Sterba
2020-01-08 15:11 ` David Sterba [this message]
2020-01-09 5:54 ` Qu Wenruo
2020-01-09 14:37 ` David Sterba
2020-01-10 0:21 ` Qu Wenruo
2020-01-10 0:58 ` Qu Wenruo
2020-01-13 4:41 ` Qu Wenruo
2020-01-13 17:19 ` David Sterba
2020-01-13 19:15 ` Nikolay Borisov
2020-01-08 15:19 ` Josef Bacik
2020-01-09 0:11 ` Qu Wenruo
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=20200108151159.GI3929@twin.jikos.cz \
--to=dsterba@suse.cz \
--cc=ce3g8jdj@umail.furryterror.org \
--cc=dsterba@suse.com \
--cc=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=nborisov@suse.com \
--cc=wqu@suse.com \
/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