From: Matthew Wilcox <willy@infradead.org>
To: Filipe Manana <fdmanana@kernel.org>
Cc: dai.ngo@oracle.com, linux-btrfs <linux-btrfs@vger.kernel.org>,
gniebler@suse.com,
"linux-nfs@vger.kernel.org" <linux-nfs@vger.kernel.org>
Subject: Re: bug in btrfs during low memory testing.
Date: Tue, 5 Jul 2022 21:29:50 +0100 [thread overview]
Message-ID: <YsSfPl6IvqrM5OPU@casper.infradead.org> (raw)
In-Reply-To: <CAL3q7H7Jm034yfVYJDzugWHPamvnKU=7XSb=38ey+-L_qdd=OA@mail.gmail.com>
On Tue, Jul 05, 2022 at 09:26:47PM +0100, Filipe Manana wrote:
> In this case we can actually call xa_insert() without holding that
> spinlock, it's safe against other concurrent calls to
> btrfs_get_or_create_delayed_node(), btrfs_get_delayed_node(),
> btrfs_kill_delayed_inode_items(), etc.
>
> However, looking at xa_insert() we have:
>
> xa_lock(xa);
> err = __xa_insert(xa, index, entry, gfp);
> xa_unlock(xa);
>
> And xa_lock() is defined as:
>
> #define xa_lock(xa) spin_lock(&(xa)->xa_lock)
>
> So we'll always be under a spinlock even if we change btrfs to not
> take the root->inode_lock spinlock.
>
> This seems more like a general problem outside btrfs' control.
> So CC'ing Willy to double check.
No, the XArray knows about its own spinlock. It'll drop it if it needs
to allocate memory and the GFP flags indicate that the caller can sleep.
It doesn't know about your spinlock, so it can't do the same thing for
you ;-)
next prev parent reply other threads:[~2022-07-05 20:30 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-05 19:37 bug in btrfs during low memory testing dai.ngo
2022-07-05 20:26 ` Filipe Manana
2022-07-05 20:29 ` Matthew Wilcox [this message]
2022-07-05 20:33 ` Filipe Manana
2022-07-06 6:36 ` Nikolay Borisov
2022-07-06 12:09 ` Matthew Wilcox
2022-07-06 12:13 ` Nikolay Borisov
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=YsSfPl6IvqrM5OPU@casper.infradead.org \
--to=willy@infradead.org \
--cc=dai.ngo@oracle.com \
--cc=fdmanana@kernel.org \
--cc=gniebler@suse.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
/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