linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: Khalid Aziz <khalid.aziz@oracle.com>,
	Peter Xu <peterx@redhat.com>,
	Vishal Moola <vishal.moola@gmail.com>,
	Jane Chu <jane.chu@oracle.com>,
	Muchun Song <muchun.song@linux.dev>,
	linux-mm@kvack.org
Subject: Re: Unifying page table walkers
Date: Sun, 9 Jun 2024 22:28:30 +0200	[thread overview]
Message-ID: <83de1b25-af25-4a68-8b35-d231338a2035@redhat.com> (raw)
In-Reply-To: <ZmYLwucbNKSqbqo2@casper.infradead.org>

On 09.06.24 22:08, Matthew Wilcox wrote:
> On Fri, Jun 07, 2024 at 08:59:17AM +0200, David Hildenbrand wrote:
>> On 06.06.24 20:29, Matthew Wilcox wrote:
>>> One of the things we discussed at LSFMM was unifying the hugetlb and
>>> THP page table walkers.  I've been looking into it some more recently;
>>> I've found a problem and I think a solution.
>>>
>>> The reason we have a separate hugetlb_entry from pmd_entry and pud_entry
>>> is that it has a different locking context.  It is called with the
>>> hugetlb_vma_lock held for read (nb: this is not the same as the vma
>>> lock; see walk_hugetlb_range()).  Why do we need this?  Because of page
>>> table sharing.
>>>
>>> In a completely separate discussion, I was talking with Khalid about
>>> mshare() support for hugetlbfs, and I suggested that we permit hugetlbfs
>>> pages to be mapped by a VMA which does not have the VM_HUGETLB flag set.
>>> If we do that, the page tables would not be permitted to be shared with
>>> other users of that hugetlbfs file.  But we want to eliminate support
>>> for that anyway, so that's more of a feature than a bug.
>>
>> I am not sure why hugetlb support in mshare would require that (we don't
>> need partial mappings and all of that to support mshare+hugetlb).
> 
> You're absolutely right.  My motivation is the other way around.  A large
> part of "hugetlbfs is special" is tied to the sharing of page tables.
> That's why we have the hugetlb_vma_lock.  If we're already sharing
> page tables with mshare, I assert that it is not necessary to also
> share page tables with other hugetlb users.  So as part of including
> hugetlb support in mshare, we should drop that support, and handle
> hugetlb-mapped-with-mshare similarly to THP. 

Yes, we should absolutely *not* use hugetlb-page table sharing there!

Regarding THP, I'm not sure how far we should go -- we should make our 
lives easier by not allowing partial mappings initially.

> Possibly not the mapcount
> parts so that we preserve the HVO.

The new mapcount scheme I'll be reviving soon will not work easily with 
the existing hugetlb-page table sharing, simply because unrelated MMs 
can map/unmap pages in there, and we effectively transfer ownership of 
page tables between processes.

As soon as we have one "mm" that owns one set of shared page tables 
(i.e., one mshare-mm that owns a set of shared page tables, and to which 
we effectively account the mappings in there), it should all just work.

-- 
Cheers,

David / dhildenb



      reply	other threads:[~2024-06-09 20:28 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-06 18:29 Matthew Wilcox
2024-06-06 19:30 ` James Houghton
2024-06-06 20:04   ` Matthew Wilcox
2024-06-06 20:23     ` James Houghton
2024-06-06 21:21       ` Matthew Wilcox
2024-06-06 23:07         ` James Houghton
2024-06-07  7:15           ` David Hildenbrand
2024-06-06 21:33     ` Peter Xu
2024-06-06 21:49 ` Peter Xu
2024-06-07  5:07   ` Oscar Salvador
2024-06-07  6:59 ` David Hildenbrand
2024-06-09 20:08   ` Matthew Wilcox
2024-06-09 20:28     ` David Hildenbrand [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83de1b25-af25-4a68-8b35-d231338a2035@redhat.com \
    --to=david@redhat.com \
    --cc=jane.chu@oracle.com \
    --cc=khalid.aziz@oracle.com \
    --cc=linux-mm@kvack.org \
    --cc=muchun.song@linux.dev \
    --cc=peterx@redhat.com \
    --cc=vishal.moola@gmail.com \
    --cc=willy@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox