linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Hildenbrand <david@redhat.com>
To: Ryan Roberts <ryan.roberts@arm.com>,
	John Hubbard <jhubbard@nvidia.com>,
	Matthew Wilcox <willy@infradead.org>,
	Yang Shi <shy828301@gmail.com>,
	"Yin, Fengwei" <fengwei.yin@intel.com>,
	Yu Zhao <yuzhao@google.com>, Zi Yan <ziy@nvidia.com>,
	David Rientjes <rientjes@google.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Vlastimil Babka <vbabka@suse.cz>,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	Hugh Dickins <hughd@google.com>
Cc: Linux-MM <linux-mm@kvack.org>
Subject: Re: ANON_LARGE_FOLIOS meeting follow-up & refined proposal
Date: Mon, 2 Oct 2023 14:58:58 +0200	[thread overview]
Message-ID: <caa738eb-bbb3-870e-9fc4-a7a27a1d8e3b@redhat.com> (raw)
In-Reply-To: <1b03f4d6-634d-4786-81a0-5a104799b125@arm.com>

>> Not only that. It was also because we didn't want to confuse users/devs that
>> assume that THP == PMD-sized.
>>
>> I'll CC Hugh, I recall he had an opinion on that (I recall some comments about
>> cleanly separating both features towards the user).
> 
> Were those comments made during the first meeting? I don't recall them, but will
> go back and watch the video.

Unless I am daydreaming, Willy made such comments during a THP cabal 
meeting, and Hugh somewhere on the list in other context. Maybe they 
changed their mind or I am making things up (after 4 days of fever 
dreams I don't know what's real anymore :D ).

The biggest concern was that huge really implies PMD (and maybe later 
PUD) -- and could end up confusing users, stats etc. Maybe it can be 
handled, I'll have to take a look at your proposal.

I was advocating just calling these things THP right from the start (and 
was using the arguments you are using in this mail :) ), but understood 
the concerns.

Apparently, freebsd wants to call these things "Medium-sized superpages" 
[1]. Of course, superpages are just huge pages, but everybody has to 
invent a new term for the same thing [I did not check who had it first 
;) ]. Of course, under Windows static (like hugetlb) huge pages are 
called large-pages.

[1] https://www.freebsd.org/status/report-2022-04-2022-06/superpages/

> 
>>
>>> Personally I think my latest proposal is a way to solve that problem, and in
>>> that case, I personally think exposing it as an extension to THP is neater:
>>>
>>>    - all existing THP controls work as they did before
>>>    - new anon_orders and anon_always_mask files allow opt-in to
>>>      smaller-than-PMD-orders
>>
>> As "enable" controls anon only (that's correct, right?), maybe these should also
>> simply be called "orders" and "always_mask". shmem could get their own set, like
>> "shmem_enable".
> 
> Yes, could do it that way. I thought that since "shmem_" was used when shmem was
> introduced, it would be clearer to prefix the new anon controls too. Happy to
> remove though.
> 
>>
>>>    - All exisitng counters remain unchanged, and continue to count PMD-mapped THP
>>>      only:
>>>         - /proc/meminfo:AnonHugePages
>>>         - /sys/devices/system/node/nodeX/meminfo:AnonHugePages
>>>         - /proc/vmstat:nr_anon_transparent_hugepages
>>>         - /proc/<pid>/smaps[_roolup]:AnonHugePages
>>>         - memory.stat(v1):rss_huge
>>>         - memory.stat(v2):anon_thp
>>>    - New counters introduced to count PTE-mapped THP/large folios:
>>>         - /proc/meminfo:AnonHugePteMap
>>>         - /sys/devices/system/node/nodeX/meminfo:AnonHugePteMap
>>>         - /proc/vmstat:nr_anon_thp_pte
>>>         - /proc/<pid>/smaps[_roolup]:AnonHugePteMap
>>>         - memory.stat(v1):anon_thp_pte
>>>         - memory.stat(v2):anon_thp_pte
>>>    - It's a lot less code (I have an implementation for both approaches)
>>>
>>> Admittedly, I haven't spent too much time thinking about the other thp counters
>>> in vmstat yet (e.g. thp_fault_alloc, thp_fault_fallback, etc). Proposal is that
>>> for now, they would continue to be PMD-order only. But I think you could
>>> probably hook those upto the PTE-mapped ones as well, instead of duplicating all
>>> the counters.
>>>
>>> As Kiril mentioned, PTE-mapped THP is already a thing, so this approach just
>>> formalises it.
>>
>> Not quite. PTE-mapped THP were just a side-effect of the transparency handling.
>> We never allocated and populated PTE-mapped PMD-sized THP on allocation. So I
>> don't immediately see the connection between both for this case.
> 
> I'm just making the point that when they become PTE-mapped, we don't stop
> calling them THP. I accept that its not exactly the same though.

... PTE-mappin them does not change their size ;) But I get what you mean.

> 
>>
>> Would you account a PTE-mapped (PMD-sized) THP as anon_thp or anon_thp_pte? What
>> if it's mapped via PTEs and PMDs? I don't see how that formalises that case for
>> the existing PMD-szed THP.
> 
> I account PTE-mapped THP as anon_thp_pte. And if the same folio is mapped both
> ways, I account it in both counters. I'm not claiming that anon_thp +
> anon_thp_pte = amount of allocated thp in total. anon_thp_pte is intended to
> help debug; you can use it to see what percentage of pte-mapped memory is THP.
> 
>>
>>>
>>> I also think the "huge" means PMD-size argument is a bit weak, given that THP
>>> supports PUD-size today for file mappings, and in the context of hugetlb, huge
>>> can mean contpte, pmd, contpmd, pud, etc.
>>
>> I made similar statements in the past but was convinced otherwise :)
>>
>>>
>>> I'll have the patch set ready to post by Friday. How about I post it, then we
>>> can continue the conversation in the context of the actual code? If the
>>> concensus is that this is not the way to do it, then I'll post the large_folio
>>> version instead?
>>
>> No strong opinion from my side, I considered a "fresh start" without the THP
>> implication/thermonology after all the previous discussions cleaner [which I
>> think was one of the outcomes of the previous discussions].
>>
> 
> My concern is that the "fresh start" is not as simple as it appears. I've come
> to the conclusion that if we have a new interface, then it should really be a
> strict superset of THP to make it extensible in future. But that opens questions

^ +1

> about how you configure PMD-sized allocations when both interfaces disagree. For
> "enabled" its fairly straightforward; you can do a logical OR. But its less
> clear how to handle disagreement over defrag. And then you have huge_zero_page
> and khugepaged etc, which might just stay with THP. But eventually we will

Probably we want everything that THP had (khugepaged, zeropage, ...) 
also on some (selected?) smaller orders.

> probably want to do async collapse for smaller order folios too, and at that
> point you have to duplicate all those controls... So I concluded that actually
> it is cleaner to just bolt on a small-order extension to THP. I've updated all
> the docs, and that was pretty simple to do, which usually suggests that the
> extension is purely additive and shouldn't be confusing.

Fine with me. I don't quite like bitmaps exposed to user space, though. 
Just having a user-readable list or a "directory" with various options 
as files might be cleaner ...

> 
> Take a look at the patches, then make a judgement ;-)
> 

... but we'll discuss it there :)

-- 
Cheers,

David / dhildenb



  reply	other threads:[~2023-10-02 12:59 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-14  8:16 Ryan Roberts
2023-09-22 15:48 ` Ryan Roberts
2023-09-23  0:33   ` John Hubbard
2023-09-25  8:51     ` Ryan Roberts
2023-09-26 18:31       ` David Hildenbrand
2023-09-27  7:23         ` Ryan Roberts
2023-09-27 15:32           ` David Hildenbrand
2023-09-27 19:04             ` Ryan Roberts
2023-10-02 12:58               ` David Hildenbrand [this message]
2023-10-05  7:37                 ` Ryan Roberts
     [not found]                   ` <c60321ef-8596-8fa0-7367-f43e69e1d894@redhat.com>
2023-10-05  9:46                     ` Ryan Roberts
2023-10-06 11:53                       ` David Hildenbrand
2023-09-26 18:34       ` David Hildenbrand
2023-09-26  8:13   ` Kirill A. Shutemov
2023-09-26 18:29   ` David Hildenbrand
2023-09-26 18:26 ` David Hildenbrand

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=caa738eb-bbb3-870e-9fc4-a7a27a1d8e3b@redhat.com \
    --to=david@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=fengwei.yin@intel.com \
    --cc=hughd@google.com \
    --cc=jhubbard@nvidia.com \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-mm@kvack.org \
    --cc=rientjes@google.com \
    --cc=ryan.roberts@arm.com \
    --cc=shy828301@gmail.com \
    --cc=vbabka@suse.cz \
    --cc=willy@infradead.org \
    --cc=yuzhao@google.com \
    --cc=ziy@nvidia.com \
    /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