Re: [PATCH v3 10/10] mmap locking API: rename mmap_sem to mmap_lock

From: Michel Lespinasse
Date: Mon Apr 06 2020 - 11:49:36 EST


On Wed, Apr 1, 2020 at 6:48 AM Peter Zijlstra <peterz@xxxxxxxxxxxxx> wrote:
>
> On Fri, Mar 27, 2020 at 03:51:02PM -0700, Michel Lespinasse wrote:
> > Rename the mmap_sem field to mmap_lock. Any new uses of this lock
> > should now go through the new mmap locking api. The mmap_lock is
> > still implemented as a rwsem, though this could change in the future.
>
> > diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h
> > index c28911c3afa8..a168d13b5c44 100644
> > --- a/include/linux/mm_types.h
> > +++ b/include/linux/mm_types.h
> > @@ -431,7 +431,7 @@ struct mm_struct {
> > spinlock_t page_table_lock; /* Protects page tables and some
> > * counters
> > */
> > - struct rw_semaphore mmap_sem;
> > + struct rw_semaphore mmap_lock;
>
> It would be best if you change the type too.

I suppose you mean wrapping the struct rw_semaphore within a new
struct ? I did not do that in this patchset because there remains some
calls to lockdep_assert_held() on that field, which imply that the
field must have a .dep_map field that's not tucked away behind an
additional struct.

I have another patchset that reimplements the mmap_lock as a different
type (for range locking), with its own dep_map handling, but it's not
ready for pushing to mainline yet...

--
Michel "Walken" Lespinasse
A program is never fully debugged until the last user dies.