From: Andrew Morton <akpm@linux-foundation.org>
To: Jinjiang Tu <tujinjiang@huawei.com>
Cc: <muchun.song@linux.dev>, <david@redhat.com>, <osalvador@suse.de>,
<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: Wed, 2 Apr 2025 20:49:31 -0700 [thread overview]
Message-ID: <20250402204931.78a02332bcd9d9e9db970fd0@linux-foundation.org> (raw)
In-Reply-To: <20250401082339.676723-1-tujinjiang@huawei.com>
On Tue, 1 Apr 2025 16:23:39 +0800 Jinjiang Tu <tujinjiang@huawei.com> wrote:
> In set_max_huge_pages(), min_count should mean the acquired persistent
> huge pages, but it contains surplus huge pages. It will leads to failing
> to freeing free huge pages for a Node.
>
> Steps to reproduce:
> 1) create 5 hugetlb folios in Node0
> 2) run a program to use all the hugetlb folios
> 3) echo 0 > nr_hugepages for Node0 to free the hugetlb folios. Thus the 5
> hugetlb folios in Node0 are accounted as surplus.
> 4) create 5 hugetlb folios in Node1
> 5) echo 0 > nr_hugepages for Node1 to free the hugetlb folios
>
> The result:
> Node0 Node1
> Total 5 5
> Free 0 5
> Surp 5 5
>
> We couldn't subtract surplus_huge_pages from min_mount, since free hugetlb
> folios may be surplus due to HVO. In __update_and_free_hugetlb_folio(),
> hugetlb_vmemmap_restore_folio() may fail, add the folio back to pool and
> treat it as surplus. If we directly subtract surplus_huge_pages from
> min_mount, some free folios will be subtracted twice.
>
> To fix it, check if count is less than the num of free huge pages that
> could be destroyed (i.e., available_huge_pages(h)), and remove hugetlb
> folios if so.
>
> Since there may exist free surplus hugetlb folios, we should remove
> surplus folios first to make surplus count correct.
>
> The result with this patch:
> Node0 Node1
> Total 5 0
> Free 0 0
> Surp 5 0
Thanks.
> Fixes: 9a30523066cd ("hugetlb: add per node hstate attributes")
16 years ago. How do people feel about a -stable backport?
next prev parent reply other threads:[~2025-04-03 3:49 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 [this message]
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
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=20250402204931.78a02332bcd9d9e9db970fd0@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=david@redhat.com \
--cc=linux-mm@kvack.org \
--cc=muchun.song@linux.dev \
--cc=osalvador@suse.de \
--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