+ hugetlb-evaluate-subpool-free-state-while-locked.patch added to mm-new branch
Andrew Morton <[email protected]>
| Newsgroups | org.kernel.vger.mm-commits |
|---|---|
| Message-ID | <[email protected]> |
The patch titled
Subject: hugetlb: evaluate subpool free state while locked
has been added to the -mm mm-new branch. Its filename is
hugetlb-evaluate-subpool-free-state-while-locked.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/hugetlb-evaluate-subpool-free-state-while-locked.patch
This patch will later appear in the mm-new branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Note, mm-new is a provisional staging ground for work-in-progress
patches, and acceptance into mm-new is a notification for others take
notice and to finish up reviews. Please do not hesitate to respond to
review feedback and post updated versions to replace or incrementally
fixup patches in mm-new.
The mm-new branch of mm.git is not included in linux-next
If a few days of testing in mm-new is successful, the patch will me moved
into mm.git's mm-unstable branch, which is included in linux-next
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
From: Yichong Chen <[email protected]>
Subject: hugetlb: evaluate subpool free state while locked
Date: Tue, 21 Jul 2026 11:52:07 +0800
unlock_or_release_subpool() drops spool->lock before calling
subpool_is_free(). However, subpool_is_free() reads fields that are
updated under spool->lock, including count, used_hpages and rsv_hpages.
Keep the free-state evaluation under the same lock that protects those
fields. The reservation accounting and kfree() calls still happen after
dropping spool->lock.
Link: https://lore.kernel.org/[email protected]
Signed-off-by: Yichong Chen <[email protected]>
Reviewed-by: Joshua Hahn <[email protected]>
Reviewed-by: Jane Chu <[email protected]>
Cc: David Hildenbrand <[email protected]>
Cc: Muchun Song <[email protected]>
Cc: Oscar Salvador <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
---
mm/hugetlb.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
--- a/mm/hugetlb.c~hugetlb-evaluate-subpool-free-state-while-locked
+++ a/mm/hugetlb.c
@@ -141,12 +141,14 @@ static inline bool subpool_is_free(struc
static inline void unlock_or_release_subpool(struct hugepage_subpool *spool,
unsigned long irq_flags)
{
- spin_unlock_irqrestore(&spool->lock, irq_flags);
+ bool free_subpool = subpool_is_free(spool);
/* If no pages are used, and no other handles to the subpool
* remain, give up any reservations based on minimum size and
* free the subpool */
- if (subpool_is_free(spool)) {
+ spin_unlock_irqrestore(&spool->lock, irq_flags);
+
+ if (free_subpool) {
if (spool->min_hpages != -1)
hugetlb_acct_memory(spool->hstate,
-spool->min_hpages);
_
Patches currently in -mm which might be from [email protected] are
tools-mm-page_owner_sort-return-explicit-filter-results.patch
tools-mm-page_owner_sort-free-per-record-allocations.patch
tools-mm-page_owner_sort-bound-pattern-output-copies.patch
hugetlbfs-release-subpool-on-fill_super-failure.patch
hugetlb-make-hugepage_put_subpool-tolerate-null.patch
hugetlb-evaluate-subpool-free-state-while-locked.patch
fat-release-buffer-head-after-rebuilding-parent.patch