Re: [PATCH WIP v1 00/20] mm: precise "mapped shared" vs. "mapped exclusively" detection for PTE-mapped THP / partially-mappable folios

From: Linus Torvalds
Date: Fri Nov 24 2023 - 15:59:46 EST


On Fri, 24 Nov 2023 at 05:26, David Hildenbrand <david@xxxxxxxxxx> wrote:
>
> Are you interested in some made-up math, new locking primitives and
> slightly unpleasant performance numbers on first sight? :)

Ugh. I'm not loving the "I have a proof, but it's too big to fit in
the margin" model of VM development.

This does seem to be very subtle.

Also, please benchmark what your rmap changes do to just plain regular
pages - it *looks* like maybe all you did was to add some
VM_WARN_ON_FOLIO() for those cases, but I have this strong memory of
that

if (likely(!compound)) {

case being very critical on all the usual cases (and the cleanups by
Hugh last year were nice).

I get the feeling that you are trying to optimize a particular case
that is special enough that some less complicated model might work.

Just by looking at your benchmarks, I *think* the case you actually
want to optimize is "THP -> fork -> child exit/execve -> parent write
COW reuse" where the THP page was really never in more than two VM's,
and the second VM was an almost accidental temporary thing that is
just about the whole "fork->exec/exit" model.

Which makes me really feel like your rmap_id is very over-engineered.
It seems to be designed to handle all the generic cases, but it seems
like the main cause for it is a very specific case that I _feel_
should be something that could be tracked with *way* less information
(eg just have a "pointer to owner vma, and a simple counter of
non-owners").

I dunno. I was cc'd, I looked at the patches, but I suspect I'm not
really the target audience. If Hugh is ok with this kind of
complexity, I bow to a higher authority. This *does* seem to add a lot
of conceptual complexity to something that is already complicated.

Linus