Thread (32 messages) 32 messages, 3 authors, 2026-03-27

Re: [PATCH v4 25/25] mm: simplify VMA flag tests of excluded flags

From: "Vlastimil Babka (SUSE)" <vbabka@kernel.org>
Date: 2026-03-23 15:51:55
Also in: linux-fsdevel, linux-mips, linux-mm, linux-riscv, linux-s390, linux-um, lkml, loongarch, selinux

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@kernel.org>
Signed-off-by: Lorenzo Stoakes (Oracle) <ljs@kernel.org>
Acked-by: Vlastimil Babka (SUSE) <vbabka@kernel.org>

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help