From: Karl Mehltretter <kmehltretter@gmail.com>
To: Ackerley Tng <ackerleytng@google.com>
Cc: Zhao Li <enderaoelyther@gmail.com>,
Jinmeng Zhou <zhoujinmeng@bytedance.com>,
Alex Shi <alexs@kernel.org>,
David Hildenbrand <david@kernel.org>,
Dongliang Mu <dzm91@hust.edu.cn>,
Hongxiang Lou <louhongxiang@huawei.com>,
Johannes Weiner <hannes@cmpxchg.org>,
Jonathan Corbet <corbet@lwn.net>,
Joshua Hahn <joshua.hahnjy@gmail.com>,
"Liam R. Howlett" <liam@infradead.org>,
Lorenzo Stoakes <ljs@kernel.org>,
Miaohe Lin <linmiaohe@huawei.com>,
Michal Hocko <mhocko@kernel.org>,
Mike Rapoport <rppt@kernel.org>,
Muchun Song <muchun.song@linux.dev>,
Nhat Pham <nphamcs@gmail.com>,
Oscar Salvador <osalvador@suse.de>, Peter Xu <peterx@redhat.com>,
Randy Dunlap <rdunlap@infradead.org>,
Roman Gushchin <roman.gushchin@linux.dev>,
Shakeel Butt <shakeel.butt@linux.dev>,
Shuah Khan <skhan@linuxfoundation.org>,
Suren Baghdasaryan <surenb@google.com>,
Usama Arif <usama.arif@linux.dev>,
Vlastimil Babka <vbabka@kernel.org>,
Wupeng Ma <mawupeng1@huawei.com>,
Yanteng Si <si.yanteng@linux.dev>,
Naoya Horiguchi <nao.horiguchi@gmail.com>,
fvdl@google.com, jthoughton@google.com, rientjes@google.com,
vannapurve@google.com, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
stable@vger.kernel.org
Subject: Re: [PATCH v3 3/4] mm: hugetlb: Fix subpool usage leak on allocation failure
Date: Mon, 28 Sep 2026 08:28:43 +0200 [thread overview]
Message-ID: <aroH94a5F4Mzuqgd@gmail.com> (raw)
In-Reply-To: <CAEvNRgHQLifmcD1NO6cd7EVcCiQb6gJgNUo4HkFhZAvzuwMq0w@mail.gmail.com>
On Sun, Sep 27, 2026 at 10:19:08PM +0100, Ackerley Tng wrote:
> == Questions for Karl
>
> (Independent of the "Path forward for 7.3/7.4")
>
> 1. Does squashing patch [4/4] of this series into [2/4] [3/4] resolve
> any of what you found?
> 2. Does patch [1/4] introduce new issues, or does it just not fully fix
> all the issues? At this point I think we have so many bugs, it's more
> about fixing bugs progressively (not regressing) than finding a
> complete fix.
> 3. Would it be ok if you integrate your findings across your two replies
> on [2/4] and [3/4]? They're similar yet slightly different so it's
> kind of confusing. If you have reproducers, it would help to share
> them! :)
>
1. Squashing the unchanged patches does not fix it. Full v3 already includes
4/4, and both controlled tests still fail:
Path Cleanup After files / after unmount
----------------------- ------------ ---------------------------
hugetlb_reserve_pages() +2, -ENOMEM 2 / ULONG_MAX-1
alloc_hugetlb_folio() +1, -ENOMEM 3 / ULONG_MAX
Both should end at 4 / 0. I got the same result with one and four vCPUs.
Patch 4 fixes the later region_add() failure path, where the global
reservations have already been acquired. These two failures happen earlier,
after global accounting or folio allocation has failed, so 4/4 does not
cover them.
2. The exact v3 patch 1 does introduce regressions as an intermediate
commit. It starts tracking used_hpages on min_size-only mounts, but the old
failure paths do not undo the new charge. In the ordinary tests, with or
without the two queued fixes below it:
- after the SIGBUS test with no files, HugePages_Rsvd is 0 instead of 2;
- after the failed mmap and unmount, it is 3 instead of 0.
This does not mean always tracking used_hpages is wrong, but 1/4 is not safe
on its own. A reworked series on top of Zhao's and Jinmeng's fixes will need
new testing.
3. In both races, hugepage_subpool_get_pages() first changes the local
subpool state. The later global charge or folio allocation fails. Another
operation then releases capacity and a separate mount consumes it before
rollback. Rollback restores the local minimum, but its positive global
correction fails with -ENOMEM and the error is ignored.
I put the exact test hooks, both userspace controllers, QEMU helpers and
validators in this test-only commit:
https://github.com/kmehltretter82/linux/commit/3ed79d756dc3845b9af9dc1dec3daa8cb141a500
I support merging Zhao's max-only fix and Jinmeng's combined min/max fix
now. They are useful, narrower improvements and do not try to cover these
min-only races.
Karl
next prev parent reply other threads:[~2026-09-28 6:28 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 23:39 [PATCH v3 0/4] Fix HugeTLB subpool used_hpages tracking Ackerley Tng via B4 Relay
2026-09-16 23:39 ` [PATCH v3 1/4] mm: hugetlb: Track used_hpages when getting/putting pages from subpool Ackerley Tng via B4 Relay
2026-09-16 23:39 ` [PATCH v3 2/4] mm: hugetlb: Fix out_put_pages subpool reserve calculation Ackerley Tng via B4 Relay
2026-09-27 17:01 ` Karl Mehltretter
2026-09-16 23:39 ` [PATCH v3 3/4] mm: hugetlb: Fix subpool usage leak on allocation failure Ackerley Tng via B4 Relay
2026-09-27 17:04 ` Karl Mehltretter
2026-09-28 5:19 ` Ackerley Tng
2026-09-28 6:28 ` Karl Mehltretter [this message]
2026-09-16 23:39 ` [PATCH v3 4/4] mm: hugetlb: Avoid re-allocating global reservations on region add failure Ackerley Tng via B4 Relay
2026-09-17 19:26 ` Joshua Hahn
2026-09-18 3:13 ` Ackerley Tng
2026-09-17 3:13 ` [PATCH v3 0/4] Fix HugeTLB subpool used_hpages tracking Andrew Morton
2026-09-17 19:29 ` Joshua Hahn
2026-09-18 3:05 ` Ackerley Tng
2026-09-18 3:53 ` Andrew Morton
2026-09-18 3:21 ` Ackerley Tng
2026-09-23 22:09 ` Karl Mehltretter
2026-09-24 0:27 ` Ackerley Tng
2026-09-26 22:42 ` Ackerley Tng
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=aroH94a5F4Mzuqgd@gmail.com \
--to=kmehltretter@gmail.com \
--cc=ackerleytng@google.com \
--cc=alexs@kernel.org \
--cc=corbet@lwn.net \
--cc=david@kernel.org \
--cc=dzm91@hust.edu.cn \
--cc=enderaoelyther@gmail.com \
--cc=fvdl@google.com \
--cc=hannes@cmpxchg.org \
--cc=joshua.hahnjy@gmail.com \
--cc=jthoughton@google.com \
--cc=liam@infradead.org \
--cc=linmiaohe@huawei.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=louhongxiang@huawei.com \
--cc=mawupeng1@huawei.com \
--cc=mhocko@kernel.org \
--cc=muchun.song@linux.dev \
--cc=nao.horiguchi@gmail.com \
--cc=nphamcs@gmail.com \
--cc=osalvador@suse.de \
--cc=peterx@redhat.com \
--cc=rdunlap@infradead.org \
--cc=rientjes@google.com \
--cc=roman.gushchin@linux.dev \
--cc=rppt@kernel.org \
--cc=shakeel.butt@linux.dev \
--cc=si.yanteng@linux.dev \
--cc=skhan@linuxfoundation.org \
--cc=stable@vger.kernel.org \
--cc=surenb@google.com \
--cc=usama.arif@linux.dev \
--cc=vannapurve@google.com \
--cc=vbabka@kernel.org \
--cc=zhoujinmeng@bytedance.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
all inboxes | Powered by JetHome®