Re: [PATCH v4 25/25] mm: simplify VMA flag tests of excluded flags
"Vlastimil Babka (SUSE)" <[email protected]>
| Newsgroups | gmane.linux.ports.riscv,gmane.linux.kernel.mm,gmane.linux.kernel,gmane.linux.kernel.arc,gmane.linux.ports.arm.kernel,gmane.linux.ports.hexagon,gmane.linux.ports.mips,gmane.linux.ports.ppc64.devel,gmane.linux.uml.devel,gmane.linux.file-systems |
|---|---|
| Message-ID | <[email protected]> |
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) <[email protected]>
> Signed-off-by: Lorenzo Stoakes (Oracle) <[email protected]>
Acked-by: Vlastimil Babka (SUSE) <[email protected]>