linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Muchun Song <songmuchun@bytedance.com>
To: David Hildenbrand <david@redhat.com>
Cc: corbet@lwn.net, akpm@linux-foundation.org, paulmck@kernel.org,
	mike.kravetz@oracle.com, osalvador@suse.de,
	linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-mm@kvack.org, duanxiongchun@bytedance.com,
	smuchun@gmail.com
Subject: Re: [PATCH v2 2/2] mm: memory_hotplug: introduce SECTION_CANNOT_OPTIMIZE_VMEMMAP
Date: Thu, 16 Jun 2022 18:16:36 +0800	[thread overview]
Message-ID: <YqsDBPslAQ6IJZ6P@FVFYT0MHHV2J.usts.net> (raw)
In-Reply-To: <abf6bd60-b944-100e-b327-97365d366ed8@redhat.com>

On Thu, Jun 16, 2022 at 09:21:35AM +0200, David Hildenbrand wrote:
> On 16.06.22 04:45, Muchun Song wrote:
> > On Wed, Jun 15, 2022 at 11:51:49AM +0200, David Hildenbrand wrote:
> >> On 20.05.22 04:55, Muchun Song wrote:
> >>> For now, the feature of hugetlb_free_vmemmap is not compatible with the
> >>> feature of memory_hotplug.memmap_on_memory, and hugetlb_free_vmemmap
> >>> takes precedence over memory_hotplug.memmap_on_memory. However, someone
> >>> wants to make memory_hotplug.memmap_on_memory takes precedence over
> >>> hugetlb_free_vmemmap since memmap_on_memory makes it more likely to
> >>> succeed memory hotplug in close-to-OOM situations.  So the decision
> >>> of making hugetlb_free_vmemmap take precedence is not wise and elegant.
> >>> The proper approach is to have hugetlb_vmemmap.c do the check whether
> >>> the section which the HugeTLB pages belong to can be optimized.  If
> >>> the section's vmemmap pages are allocated from the added memory block
> >>> itself, hugetlb_free_vmemmap should refuse to optimize the vmemmap,
> >>> otherwise, do the optimization.  Then both kernel parameters are
> >>> compatible.  So this patch introduces SECTION_CANNOT_OPTIMIZE_VMEMMAP
> >>> to indicate whether the section could be optimized.
> >>>
> >>
> >> In theory, we have that information stored in the relevant memory block,
> >> but I assume that lookup in the xarray + locking is impractical.
> >>
> >> I wonder if we can derive that information simply from the vmemmap pages
> >> themselves, because *drumroll*
> >>
> >> For one vmemmap page (the first one), the vmemmap corresponds to itself
> >> -- what?!
> >>
> >>
> >> [	hotplugged memory	]
> >> [ memmap ][      usable memory	]
> >>       |    |                    |
> >>   ^---     |                    |
> >>    ^-------                     |
> >>          ^----------------------
> >>
> >> The memmap of the first page of hotplugged memory falls onto itself.
> >> We'd have to derive from actual "usable memory" that condition.
> >>
> >>
> >> We currently support memmap_on_memory memory only within fixed-size
> >> memory blocks. So "hotplugged memory" is guaranteed to be aligned to
> >> memory_block_size_bytes() and the size is memory_block_size_bytes().
> >>
> >> If we'd have a page falling into usbale memory, we'd simply lookup the
> >> first page and test if the vmemmap maps to itself.
> >>
> > 
> > I think this can work. Should we use this approach in next version?
> > 
> 
> Either that or more preferable, flagging the vmemmap pages eventually.
> That's might be future proof.
>

All right. I think we can go with the above approach, we can improve it
to flagging-base approach in the future if needed.

> >>
> >> Of course, once we'd support variable-sized memory blocks, it would be
> >> different.
> >>
> >>
> >> An easier/future-proof approach might simply be flagging the vmemmap
> >> pages as being special. We reuse page flags for that, which don't have
> >> semantics yet (i.e., PG_reserved indicates a boot-time allocation via
> >> memblock).
> >>
> > 
> > I think you mean flag vmemmap pages' struct page as PG_reserved if it
> > can be optimized, right? When the vmemmap pages are allocated in
> > hugetlb_vmemmap_alloc(), is it valid to flag them as PG_reserved (they
> > are allocated from buddy allocator not memblock)?
> > 
> 
> Sorry I wasn't clear. I'd flag them with some other
> not-yet-used-for-vmemmap-pages flag. Reusing PG_reserved could result in
> trouble.
>

Sorry. I thought you suggest reusing "PG_reserved". My bad misreading.

Thanks.


  reply	other threads:[~2022-06-16 10:16 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-20  2:55 [PATCH v2 0/2] make hugetlb_optimize_vmemmap compatible with memmap_on_memory Muchun Song
2022-05-20  2:55 ` [PATCH v2 1/2] mm: memory_hotplug: enumerate all supported section flags Muchun Song
2022-06-15  9:35   ` David Hildenbrand
2022-06-15 13:02     ` Muchun Song
2022-05-20  2:55 ` [PATCH v2 2/2] mm: memory_hotplug: introduce SECTION_CANNOT_OPTIMIZE_VMEMMAP Muchun Song
2022-06-15  9:51   ` David Hildenbrand
2022-06-16  2:45     ` Muchun Song
2022-06-16  7:21       ` David Hildenbrand
2022-06-16 10:16         ` Muchun Song [this message]
2022-06-16  3:57     ` Oscar Salvador
2022-06-16  7:30       ` David Hildenbrand
2022-06-17  5:46         ` Oscar Salvador
2022-06-17  7:28           ` Muchun Song
2022-06-17  7:39             ` David Hildenbrand
2022-06-17  9:10               ` Muchun Song
2022-06-17  9:25                 ` David Hildenbrand
2022-06-17  9:40                   ` Muchun Song
2022-06-17  9:48             ` Oscar Salvador
2022-06-17  7:43           ` David Hildenbrand
2022-06-17  9:54             ` Oscar Salvador
2022-06-17 10:14               ` David Hildenbrand
2022-06-17 10:49                 ` Muchun Song
2022-06-17 11:19                   ` Muchun Song
2022-06-18  5:49           ` Muchun Song

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=YqsDBPslAQ6IJZ6P@FVFYT0MHHV2J.usts.net \
    --to=songmuchun@bytedance.com \
    --cc=akpm@linux-foundation.org \
    --cc=corbet@lwn.net \
    --cc=david@redhat.com \
    --cc=duanxiongchun@bytedance.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=mike.kravetz@oracle.com \
    --cc=osalvador@suse.de \
    --cc=paulmck@kernel.org \
    --cc=smuchun@gmail.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