Re: [PATCH v2 4/5] proc/task_mmu: read proc/pid/smaps_rollup under per-vma lock
From: David Hildenbrand (Arm)
Date: Wed Sep 09 2026 - 14:56:25 EST
> - vma_start = vma->vm_start;
> - do {
> - smap_gather_stats(priv, vma, &mss, vma->vm_start);
> - last_vma_end = vma->vm_end;
> + if (!IS_ERR(vma) && vma != get_gate_vma(lock_ctx->mm))
> + vma_start = vma->vm_start;
> +
> + while (vma) {
> + if (IS_ERR(vma)) {
> + ret = PTR_ERR(vma);
> + goto out_unlock;
> + }
> +
Can we add a comment whey we break (and not e.g., continue) whenw e hit the gate
VMA?
(I seriously don't kmow ... should I know? :) )
> + if (vma == get_gate_vma(lock_ctx->mm))
> + break;
>
> /*
> - * Release mmap_lock temporarily if someone wants to
> - * access it for write request.
> + * If after retaking the lock, already reported VMA grew or
> + * merged with the next one, smap_gather_stats() will gather
> + * stats for the remaining portion by starting at last_vma_end.
> */
> - if (mmap_lock_is_contended(mm)) {
> - vma_iter_invalidate(&vmi);
> - unlock_ctx_mm(&priv->lock_ctx);
> - ret = lock_ctx_mm(&priv->lock_ctx);
> - if (ret) {
> - release_task_mempolicy(priv);
> - goto out_put_mm;
> - }
> + smap_gather_stats(priv, vma, &mss, last_vma_end);
> + last_vma_end = vma->vm_end;
I skimmed over the remaining bits, hoping the VMA lock experts will review in
detail :)
--
Cheers,
David