Re: [PATCH 1/3] slab, block: generalize bvec_alloc_gfp

Christoph Hellwig
2025-10-27T13:14:46Z

On Mon, Oct 27, 2025 at 01:09:06PM +0000, Matthew Wilcox wrote:
> > > Is there a reason _not_ to use the kvmalloc code for bvec allocations?
> >
> > It's using a dedicated slab cache, which makes sense for such a frequent
> > and usually short-lived allocation. We also don't use vmalloc backing
> > ever at the moment.
>
> That's not what I meant.

Oh, not the entirely kvmalloc code, but the helper. Ok.

> What I was proposing was:
>
> +static inline gfp_t try_alloc_gfp(gfp_t gfp)
> +{
> + gfp |= __GFP_NOWARN;
> + if (!(gfp & __GFP_RETRY_MAYFAIL))
> + gfp &= ~__GFP_DIRECT_RECLAIM;
> + gfp &= ~__GFP_NOFAIL;

That's missing the __GFP_NOMEMALLOC from the original one, and also
__GFP_NORETRY. So it'll be pretty different.

For now I think I'll just either duplicate the logic or keep it in
block code to get the deadlock fix in, and then we can spend more
time analyzing all the flags and documenting the ones needed in
various places.