On 2/13/25 23:46, Suren Baghdasaryan wrote: > vma_iter_store() functions can be used both when adding a new vma and > when updating an existing one. However for existing ones we do not need > to mark them attached as they are already marked that way. With > vma->detached being a separate flag, double-marking a vmas as attached > or detached is not an issue because the flag will simply be overwritten > with the same value. However once we fold this flag into the refcount > later in this series, re-attaching or re-detaching a vma becomes an > issue since these operations will be incrementing/decrementing a > refcount. > Introduce vma_iter_store_new() and vma_iter_store_overwrite() to replace > vma_iter_store() and avoid re-attaching a vma during vma update. Add > assertions in vma_mark_attached()/vma_mark_detached() to catch invalid > usage. Update vma tests to check for vma detached state correctness. > > Signed-off-by: Suren Baghdasaryan <surenb@xxxxxxxxxx> Reviewed-by: Vlastimil Babka <vbabka@xxxxxxx> > --- > Changes since v9 [1]: > - Change VM_BUG_ON_VMA() to WARN_ON_ONCE() in vma_assert_{attached|detached}, > per Lorenzo Stoakes Maybe later we can reduce the paranoia to VM_WARN_ON_ONCE()?