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

Matthew Wilcox
2025-10-27T13:09:19Z

On Mon, Oct 27, 2025 at 07:47:28AM +0100, Christoph Hellwig wrote:
> On Sun, Oct 26, 2025 at 09:19:27PM +0000, Matthew Wilcox wrote:
> > it's quite different. I am by no stretch of the imagination a GFP
> > flags expert, but it seems to me that we should make the two the same
> > since they're both "try to allocate and we have a fallback if
> > necessary". I suspect kvmalloc() is called with a wider range of
> > GFP flags than bvec allocation is, so it's probably better tested.
> >
> > 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.

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;
+
+ return gfp;
+}