Re: [PATCH v2 0/9] Add support for shared PTEs across processes

From: Khalid Aziz
Date: Fri Jul 08 2022 - 15:37:24 EST


On 7/8/22 05:47, David Hildenbrand wrote:
On 02.07.22 06:24, Andrew Morton wrote:
On Wed, 29 Jun 2022 16:53:51 -0600 Khalid Aziz <khalid.aziz@xxxxxxxxxx> wrote:

This patch series implements a mechanism in kernel to allow
userspace processes to opt into sharing PTEs. It adds a new
in-memory filesystem - msharefs.

Dumb question: why do we need a new filesystem for this? Is it not
feasible to permit PTE sharing for mmaps of tmpfs/xfs/ext4/etc files?


IIRC, the general opinion at LSF/MM was that this approach at hand is
makes people nervous and I at least am not convinced that we really want
to have this upstream.

Hi David,

You are right that sharing page tables across processes feels scary, but at the same time threads already share PTEs and this just extends that concept to processes. A number of people have commented on potential usefulness of this concept and implementation. There were concerns raised about being able to make this safe and reliable. I had agreed to send a second version of the patch incorporating feedback from last review and LSF/MM, and that is what v2 patch is about. The suggestion to extend hugetlb PMD sharing was discussed briefly. Conclusion from that discussion and earlier discussion on mailing list was hugetlb PMD sharing is built with special case code in too many places in the kernel and it is better to replace it with something more general purpose than build even more on it. Mike can correct me if I got that wrong.


What's *completely* missing from the cover letter are the dirty details:
"Actual data is mmap'ed using anonymous pages, ext4/xfs/btfrfs/etc
files.". Gah.

Yes, cover letter in v2 patch was a little lacking. I will add more details next time.


As raised already, "anonymous pages" makes me shiver.


(To me, what I read, this looks like an RFC to me, yet I see "v2". But I
am a little confused why most of the feedback at LSF/MM seems to be
ignored and people are moving forward with this approach. But maybe my
memory is wrong.)

Please, let's look into more generic page table sharing just like
hugetlb already provides to some degree. And if we need additional
alignment requirements to share multiple page table levels, then let's
look into that as well for special users.


Thanks,
Khalid