Re: [PATCH v4 25/25] mm: simplify VMA flag tests of excluded flags
From: Vlastimil Babka (SUSE)
Date: Mon Mar 23 2026 - 12:24:40 EST
On 3/20/26 8:38 PM, Lorenzo Stoakes (Oracle) wrote:
> We have implemented flag mask comparisons of the form:
>
> if ((vm_flags & (VM_FOO|VM_BAR|VM_BAZ) == VM_FOO) { ... }
>
> Like-for-like in the code using a bitwise-and mask via vma_flags_and() and
> using vma_flags_same() to ensure the final result equals only the required
> flag value.
>
> This is fine but confusing, make things clearer by instead explicitly
> excluding undesired flags and including the desired one via tests of the
> form:
>
> if (vma_flags_test(&flags, VMA_FOO_BIT) &&
> !vma_flags_test_any(&flags, VMA_BAR_BIT, VMA_BAZ_BIT)) { ... }
>
> Which makes it easier to understand what is going on.
>
> No functional change intended.
>
> Suggested-by: Vlastimil Babka (SUSE) <vbabka@xxxxxxxxxx>
> Signed-off-by: Lorenzo Stoakes (Oracle) <ljs@xxxxxxxxxx>
Acked-by: Vlastimil Babka (SUSE) <vbabka@xxxxxxxxxx>