Re: [PATCH v4 04/10] mm/vma: add+use vma lockdep acquire/release defines

From: Lorenzo Stoakes

Date: Wed Jan 28 2026 - 06:49:23 EST


On Wed, Jan 28, 2026 at 12:37:49PM +0100, Sebastian Andrzej Siewior wrote:
> On 2026-01-23 20:12:14 [+0000], Lorenzo Stoakes wrote:
> > --- a/include/linux/mmap_lock.h
> > +++ b/include/linux/mmap_lock.h
> > @@ -78,6 +78,37 @@ static inline void mmap_assert_write_locked(const struct mm_struct *mm)
>
> > +/* Only meaningful if CONFIG_LOCK_STAT is defined. */
> > +#define __vma_lockdep_stat_mark_acquired(vma) \
> > + lock_acquired(&vma->vmlock_dep_map, _RET_IP_)
> > +
>
> After going through the remaining series, I don't think I found a
> matching lock_contended(). So perf/ tracing just give you a few
> lock-acquired events. Wouldn't it make sense to also some
> lock_contended() events where the caller had to wait before it could
> acquire the lock?

Yeah I did wonder about this actually. The series really just abstracts this
part, so I think doing something with that should be a follow-up.

Suren - what was your intent with this? I did wonder what we actually really
accomplished with this.

VMA locks are always try-locks.

Write locks can't be contended against one another since VMAs are always a
per-process entity and not obtained remotely, so either a VMA is write-locked by
us or not write-locked, never write-locked by anybody else.

Read locks immediately give up if the VMA is write locked.

Would we want to record a lock_contended() event in that case I guess then?

I don't think we'd want to do that if the VMA were detached, only if it were
write-locked?

>
> Sebastian

Cheers, Lorenzo