Re: [PATCH 4/4] mm: introduce and use VMA flag test helpers

From: Lorenzo Stoakes

Date: Thu Oct 30 2025 - 15:22:34 EST


On Thu, Oct 30, 2025 at 02:54:21PM -0300, Jason Gunthorpe wrote:
> On Thu, Oct 30, 2025 at 02:03:02PM +0000, Lorenzo Stoakes wrote:
>
> > Yeah, OK well your point has been made here, the compiler _is_ smart enough
> > to save us here :)
> >
> > Let's avoid this first word stuff altogether then.
>
> I suggest to add some helpers to the general include/linux/bitmap.h
> "subsystem" that lets it help do this:
>
> #define BITMAP_OR_BITS(type, member, bit1, bit2, bit3)
>
> returns a type with the bitmap array member initialized to those bits
>
> Then some other bitmap helpers that are doing the specific maths you
> want..
>
> * bitmap_and_eq(src1, src2, src3, nbits) true if *src1 & *src2 == *src3
> * bitmap_and_eq_zero(src1, src2, nbits) true if *src1 & *src1 == 0
> etc
>
> Jason

Yeah makes sense to put it there.

Thanks, Lorenzo