From: David Sterba <dsterba@suse.cz>
To: Qu Wenruo <quwenruo.btrfs@gmx.com>
Cc: ChenXiaoSong <chenxiaosong2@huawei.com>,
clm@fb.com, josef@toxicpanda.com, dsterba@suse.com,
linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org,
zhangxiaoxu5@huawei.com, yanaijie@huawei.com, wqu@suse.com
Subject: Re: [PATCH v4 1/3] btrfs: add might_sleep() to some places in update_qgroup_limit_item()
Date: Wed, 16 Nov 2022 13:24:40 +0100 [thread overview]
Message-ID: <20221116122440.GN5824@suse.cz> (raw)
In-Reply-To: <3918175e-dddd-2a55-32c4-c07de78ff4cb@gmx.com>
On Wed, Nov 16, 2022 at 04:43:50PM +0800, Qu Wenruo wrote:
>
>
> On 2022/11/16 16:09, ChenXiaoSong wrote:
> > 在 2022/11/16 6:48, Qu Wenruo 写道:
> >> Looks good.
> >>
> >> We may want to add more in other locations, but this is really a good
> >> start.
> >>
> >> Reviewed-by: Qu Wenruo <wqu@suse.com>
> >>
> >> Thanks,
> >> Qu
> >
> > If I just add might_sleep() in btrfs_alloc_path() and
> > btrfs_search_slot(), is it reasonable?
>
> Adding it to btrfs_search_slot() is definitely correct.
>
> But why for btrfs_alloc_path()? Wouldn't kmem_cache_zalloc() itself
> already do the might_sleep_if() somewhere?
>
> I just looked the call chain, and indeed it is doing the check already:
>
> btrfs_alloc_path()
> |- kmem_cache_zalloc()
> |- kmem_cache_alloc()
> |- __kmem_cache_alloc_lru()
> |- slab_alloc()
> |- slab_alloc_node()
> |- slab_pre_alloc_hook()
> |- might_alloc()
> |- might_sleep_if()
The call chaing is unconditional so the check will always happen but the
condition itself in might_sleep_if does not recognize GFP_NOFS:
34 static inline bool gfpflags_allow_blocking(const gfp_t gfp_flags)
35 {
36 return !!(gfp_flags & __GFP_DIRECT_RECLAIM);
37 }
#define GFP_NOFS (__GFP_RECLAIM | __GFP_IO)
And I think the qgroup limit was exactly a spin lock over btrfs_path_alloc so
it did not help. An might_sleep() inside btrfs_path_alloc() is a very minimal
but reliable check we could add, the paths are used in many places so it would
increase the coverage.
next prev parent reply other threads:[~2022-11-16 12:28 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-15 17:17 [PATCH v4 0/3] btrfs: fix sleep from invalid context bug in update_qgroup_limit_item() ChenXiaoSong
2022-11-15 17:17 ` [PATCH v4 1/3] btrfs: add might_sleep() to some places " ChenXiaoSong
2022-11-15 17:41 ` David Sterba
2022-11-15 22:48 ` Qu Wenruo
2022-11-16 8:09 ` ChenXiaoSong
2022-11-16 8:43 ` Qu Wenruo
2022-11-16 12:24 ` David Sterba [this message]
2022-11-16 12:26 ` Qu Wenruo
2022-11-15 17:17 ` [PATCH v4 2/3] btrfs: qgroup: introduce btrfs_update_quoto_limit() helper ChenXiaoSong
2022-11-15 17:33 ` David Sterba
2022-11-15 17:17 ` [PATCH v4 3/3] btrfs: qgroup: fix sleep from invalid context bug in update_qgroup_limit_item() ChenXiaoSong
2022-11-15 16:22 ` ChenXiaoSong
2022-11-15 22:50 ` 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=20221116122440.GN5824@suse.cz \
--to=dsterba@suse.cz \
--cc=chenxiaosong2@huawei.com \
--cc=clm@fb.com \
--cc=dsterba@suse.com \
--cc=josef@toxicpanda.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=quwenruo.btrfs@gmx.com \
--cc=wqu@suse.com \
--cc=yanaijie@huawei.com \
--cc=zhangxiaoxu5@huawei.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