Re: [QUESTION] about the maple tree and current status of mmap_lock scalability

From: Matthew Wilcox
Date: Thu Dec 29 2022 - 12:32:17 EST


On Thu, Dec 29, 2022 at 05:10:28PM +0000, Lorenzo Stoakes wrote:
> On Thu, Dec 29, 2022 at 04:51:37PM +0000, Matthew Wilcox wrote:
> > The mmap_lock is taken for many, many things. [snip]
>
> I am currently describing the use of this lock (for 6.0) in the book and it is
> striking just how broadly it's used. I'm diagramming it out for 'core' users,
> i.e. non-driver and non-some other things, but even constraining that leaves a
> HUGE number of users.

I fear this would be overwhelming. I don't think anybody would disagree
that the mmap_lock needs to be split up like the BKL was, but we didn't
do that by diagramming it out. Instead, we introduced new smaller locks
that protected much better-defined things until eventually we were able
to kill the BKL entirely.

That's what I'm trying to do here -- there is one well-defined thing
that the maple tree lock will protect, and that's the structure of the
maple tree. It doesn't protect the data pointed to by the pointers
stored in the tree, just the maple tree itself.

> I've also documented the 'unexpected' uses of the
> page_table_lock, which seems to have been significantly improved over time but
> still a few cases remain!

Now, I think this is useful. There's probably few enough abuses of the
PTL that my brain can wrap itself around which ones are legitimate and
then deal with the inappropriate ones.

> Am happy to give you (+ anybody else on MAINTAINERS list) an early copy of the
> relevant bit (once I've finished the diagrams anyway) if that'd be helpful!

I'm definitely interested in the PTL. Thank you for the offer!

> Now if you guys could stop obsoleting my work that'd be great ;)

Never! How else will you get interest in the Second Edition Covering
Linux 7.0? ;-)