* Re: [PATCH] btrfs: add __GFP_NOFAIL to the kvmalloc in split_item
[not found] <d70e510bb641c14e48c55a48cf4df518818bd03a.1796340717.git.boris@bur.io>
@ 2026-12-04 11:33 ` Harry Yoo
0 siblings, 0 replies; only message in thread
From: Harry Yoo @ 2026-12-04 11:33 UTC (permalink / raw)
To: Boris Burkov
Cc: linux-btrfs, kernel-team, Shakeel Butt, Kiryl Shutsemau, linux-mm
On Thu, Dec 03, 2026 at 03:36:53PM -0800, Boris Burkov wrote:
> The recent patch
> b2ba99cf6f7b ("btrfs: use kvmalloc() for b-tree split_item()")
>
> improved the behavior of the split_item() allocation for allocations of
> order >= 4. However, we have observed that it seems to regress the
> allocations of order 2 that are more typical for btrfs with 4k page
> size, 16k nodesize and crc32c checksums (split_item gets called from
> btrfs_del_csums only currently)
>
> I believe that this is caused by kvmalloc having a path for failing
> allocations (regardless of order) when fatal_signal_pending() is true on
> the task as checked by vm_area_alloc_pages():
>
> if (!(gfp & __GFP_NOFAIL) && fatal_signal_pending(current))
> break;
Right.
> reached by the following callchain:
> kvmalloc(item_size, GFP_NOFS)
> __kvmalloc_node_noprof()
> __do_kmalloc_node()
> __vmalloc_node_range_noprof()
> __vmalloc_area_node()
> vm_area_alloc_pages()
>
> This results in the same signature of an ENOMEM abort observed in the
> original patch:
>
> BTRFS: error (device dm-3 state A) in btrfs_del_csums:1053: errno=-12 Out of memory
> Link: https://lore.kernel.org/linux-btrfs/2ab022c5c7e07345a9fc91915836cbd4ab2d25ef.1788819456.git.wqu@suse.com/
In this case I think it's fair to specify __GFP_NOFAIL as failing to
allocate it leads to a disruption and there's no reasonable fallback.
https://lore.kernel.org/linux-mm/20211122153233.9924-3-mhocko@kernel.org
> I believe we could attempt to also fix this by having a mempool for this
> csum deletion temporary item buffer, but save that for a follow-up since
> this is a narrow fix for an immediate problem.
>
> Fixes: b2ba99cf6f7b ("btrfs: use kvmalloc() for b-tree split_item()")
> Signed-off-by: Boris Burkov <boris@bur.io>
> ---
For the kvmalloc() part, looks good to me, so:
Reviewed-by: Harry Yoo (Meta) <harry@kernel.org>
--
Cheers,
Harry / Hyeonggon
^ permalink raw reply [flat|nested] only message in thread