From: Oscar Salvador <osalvador@suse.de>
To: Jinjiang Tu <tujinjiang@huawei.com>
Cc: muchun.song@linux.dev, akpm@linux-foundation.org,
david@redhat.com, linux-mm@kvack.org, wangkefeng.wang@huawei.com
Subject: Re: [PATCH v2] mm/hugetlb: fix set_max_huge_pages() when there are surplus pages
Date: Mon, 7 Apr 2025 12:00:26 +0200 [thread overview]
Message-ID: <Z_OiOiG6LC8KZYA9@localhost.localdomain> (raw)
In-Reply-To: <Z_OcXymduxID6M5t@localhost.localdomain>
On Mon, Apr 07, 2025 at 11:35:27AM +0200, Oscar Salvador wrote:
> On Mon, Apr 07, 2025 at 03:23:08PM +0800, Jinjiang Tu wrote:
> > diff --git a/mm/hugetlb.c b/mm/hugetlb.c
> > index 39f92aad7bd1..4afcd5ce417c 100644
> > --- a/mm/hugetlb.c
> > +++ b/mm/hugetlb.c
> > @@ -3826,6 +3826,7 @@ static int set_max_huge_pages(struct hstate *h, unsigned long count, int nid,
> > nodemask_t *nodes_allowed)
> > {
> > unsigned long min_count;
> > + unsigned long persistent_free_count;
> > unsigned long allocated;
> > struct folio *folio;
> > LIST_HEAD(page_list);
> > @@ -3960,7 +3961,14 @@ static int set_max_huge_pages(struct hstate *h, unsigned long count, int nid,
> > * and won't grow the pool anywhere else. Not until one of the
> > * sysctls are changed, or the surplus pages go out of use.
> > */
> > - min_count = h->resv_huge_pages + h->nr_huge_pages - h->free_huge_pages;
> > + persistent_free_count = h->free_huge_pages;
> > + if (h->free_huge_pages > persistent_huge_pages(h)) {
> > + if (h->free_huge_pages > h->surplus_huge_pages)
> > + persistent_free_count -= h->surplus_huge_pages;
> > + else
> > + persistent_free_count = 0;
> > + }
> > + min_count = h->resv_huge_pages + persistent_huge_pages(h) - persistent_free_count;
I forgot to mention that before this chunk, we might still want
something like your remove_surplus_pool_hugetlb_folio(), but that goes
through all nodes, not only through the nodes_allowed nodemask and
checks for free surplus pages due to hvo, and tries to get rid of them.
But on the oher hand, we can leave as is, since "meh, we failed to restore
those pages so though luck", which is the status quo right now, and I
am fine with it.
In the end, the situation can get fixed by itself as those pages might be
reallocated again and then we have a second chance to restore vmemmap when
they get freed again.
--
Oscar Salvador
SUSE Labs
prev parent reply other threads:[~2025-04-07 10:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-01 8:23 Jinjiang Tu
2025-04-03 3:49 ` Andrew Morton
2025-04-03 14:26 ` Oscar Salvador
2025-04-04 13:18 ` Oscar Salvador
2025-04-06 10:30 ` Oscar Salvador
2025-04-06 10:37 ` Oscar Salvador
2025-04-07 7:26 ` Jinjiang Tu
2025-04-07 7:23 ` Jinjiang Tu
2025-04-07 9:35 ` Oscar Salvador
2025-04-07 10:00 ` Oscar Salvador [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=Z_OiOiG6LC8KZYA9@localhost.localdomain \
--to=osalvador@suse.de \
--cc=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=linux-mm@kvack.org \
--cc=muchun.song@linux.dev \
--cc=tujinjiang@huawei.com \
--cc=wangkefeng.wang@huawei.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