| Seq | Timestamp | Type | Name | Duration |
|---|---|---|---|---|
| 0/0 | 2026/09/03 23:58 | flow | patch-triage |
1mArgs:null Results: {
"EnableConfigs": [
"HUGETLBFS"
],
"FocusSymbols": [
"hugetlb_reserve_pages",
"alloc_hugetlb_folio",
"hugepage_subpool_get_pages",
"hugepage_subpool_put_pages",
"hugetlbfs_statfs"
],
"KMSANReasoning": "The patch refactors hugetlb subpool accounting and reservation tracking (in `fs/hugetlbfs/inode.c`, `include/linux/hugetlb.h`, and `mm/hugetlb.c`). Specifically, it tracks `used_hpages` consistently when `max_hpages` is unbounded (-1), fixes reporting in `hugetlbfs_statfs`, and simplifies the error rollback arithmetic when obtaining/releasing subpool reservations in `alloc_hugetlb_folio()` and `hugetlb_reserve_pages()`.\n\nAll modified variables (`free_pages`, `gbl_resv_get`, `gbl_resv_put`) are explicitly initialized before use across all control flow paths, and no uninitialized stack/heap memory or uninitialized struct padding is exposed or copied to userspace. Any potential regressions in this patch would involve accounting discrepancies, memory leaks, or concurrency issues, which are covered by standard kernel diagnostics, assertions, and KASAN/LOCKDEP. Therefore, dedicated KMSAN fuzzing is not required.",
"NeedsKMSAN": false,
"Reasoning": "The patch modifies subpool page accounting, reservation calculation, and error recovery logic in hugetlbfs and core hugetlb memory management routines (hugepage_subpool_get_pages, hugepage_subpool_put_pages, hugetlb_reserve_pages, alloc_hugetlb_folio, hugetlbfs_statfs). These functions are directly reachable from userspace via syscalls such as mmap, open, fallocate, and statfs on hugetlbfs, making this code well-suited for fuzzing.",
"WorthFuzzing": true
} |
| 1/1 | 2026/09/03 23:58 | action | read-patch-diff |
0mArgs:null Results: {
"PatchDiff": "commit 9c3c451828cc8581dcf14d3058a3b74f5624b627\nAuthor: syz-cluster \u003ctriage@syzkaller.com\u003e\nDate: Thu Sep 3 23:58:32 2026 +0000\n\n syz-cluster: applied patch under review\n\ndiff --git a/Documentation/mm/hugetlbfs_reserv.rst b/Documentation/mm/hugetlbfs_reserv.rst\nindex a49115db18c76..d244583fdcbc3 100644\n--- a/Documentation/mm/hugetlbfs_reserv.rst\n+++ b/Documentation/mm/hugetlbfs_reserv.rst\n@@ -314,21 +314,8 @@ huge pages. If they can not be reserved, the mount fails.\n The routines hugepage_subpool_get/put_pages() are called when pages are\n obtained from or released back to a subpool. They perform all subpool\n accounting, and track any reservations associated with the subpool.\n-hugepage_subpool_get/put_pages are passed the number of huge pages by which\n-to adjust the subpool 'used page' count (down for get, up for put). Normally,\n-they return the same value that was passed or an error if not enough pages\n-exist in the subpool.\n-\n-However, if reserves are associated with the subpool a return value less\n-than the passed value may be returned. This return value indicates the\n-number of additional global pool adjustments which must be made. For example,\n-suppose a subpool contains 3 reserved huge pages and someone asks for 5.\n-The 3 reserved pages associated with the subpool can be used to satisfy part\n-of the request. But, 2 pages must be obtained from the global pools. To\n-relay this information to the caller, the value 2 is returned. The caller\n-is then responsible for attempting to obtain the additional two pages from\n-the global pools.\n-\n+hugepage_subpool_get/put_pages() use the number of huge pages passed to adjust\n+the subpool 'used page' count.\n \n COW and Reservations\n ====================\ndiff --git a/Documentation/translations/zh_CN/mm/hugetlbfs_reserv.rst b/Documentation/translations/zh_CN/mm/hugetlbfs_reserv.rst\nindex 20947f8bd0654..ae1f1f31477fc 100644\n--- a/Documentation/translations/zh_CN/mm/hugetlbfs_reserv.rst\n+++ b/Documentation/translations/zh_CN/mm/hugetlbfs_reserv.rst\n@@ -246,15 +246,8 @@ hugepage_subpool的min_hpages字段中被跟踪。在挂载时,hugetlb_acct_me\n 被调用以预留指定数量的巨页。如果它们不能被预留,挂载就会失败。\n \n 当从子池中获取或释放页面时,会调用hugepage_subpool_get/put_pages()函数。\n-hugepage_subpool_get/put_pages被传递给巨页数量,以此来调整子池的 “已用页面” 计数\n-(get为下降,put为上升)。通常情况下,如果子池中没有足够的页面,它们会返回与传递的相同的值或\n-一个错误。\n-\n-然而,如果预留与子池相关联,可能会返回一个小于传递值的返回值。这个返回值表示必须进行的额外全局\n-池调整的数量。例如,假设一个子池包含3个预留的巨页,有人要求5个。与子池相关的3个预留页可以用来\n-满足部分请求。但是,必须从全局池中获得2个页面。为了向调用者转达这一信息,将返回值2。然后,调用\n-者要负责从全局池中获取另外两个页面。\n-\n+它们负责所有子池的统计核算,并跟踪与子池相关联的预留。\n+hugepage_subpool_get/put_pages()函数使用传入的巨页数量来调整子池的“已用页面”计数。\n \n COW和预留\n ==========\ndiff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c\nindex 7611a8470ea26..5113f743f6fc7 100644\n--- a/fs/hugetlbfs/inode.c\n+++ b/fs/hugetlbfs/inode.c\n@@ -1109,8 +1109,12 @@ static int hugetlbfs_statfs(struct dentry *dentry, struct kstatfs *buf)\n \n \t\t\tspin_lock_irq(\u0026sbinfo-\u003espool-\u003elock);\n \t\t\tbuf-\u003ef_blocks = sbinfo-\u003espool-\u003emax_hpages;\n-\t\t\tfree_pages = sbinfo-\u003espool-\u003emax_hpages\n-\t\t\t\t- sbinfo-\u003espool-\u003eused_hpages;\n+\t\t\tif (sbinfo-\u003espool-\u003emax_hpages == -1) {\n+\t\t\t\tfree_pages = -1;\n+\t\t\t} else {\n+\t\t\t\tfree_pages = sbinfo-\u003espool-\u003emax_hpages -\n+\t\t\t\t\t sbinfo-\u003espool-\u003eused_hpages;\n+\t\t\t}\n \t\t\tbuf-\u003ef_bavail = buf-\u003ef_bfree = free_pages;\n \t\t\tspin_unlock_irq(\u0026sbinfo-\u003espool-\u003elock);\n \t\t\tbuf-\u003ef_files = sbinfo-\u003emax_inodes;\ndiff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h\nindex 16c4c4caa126c..4551ff3023640 100644\n--- a/include/linux/hugetlb.h\n+++ b/include/linux/hugetlb.h\n@@ -39,8 +39,8 @@ struct hugepage_subpool {\n \tspinlock_t lock;\n \tlong count;\n \tlong max_hpages;\t/* Maximum huge pages or -1 if no maximum. */\n-\tlong used_hpages;\t/* Used count against maximum, includes */\n-\t\t\t\t/* both allocated and reserved pages. */\n+\tlong used_hpages;\t/* Used page count, includes both */\n+\t\t\t\t/* allocated and reserved pages. */\n \tstruct hstate *hstate;\n \tlong min_hpages;\t/* Minimum huge pages or -1 if no minimum. */\n \tlong rsv_hpages;\t/* Pages reserved against global pool to */\ndiff --git a/mm/hugetlb.c b/mm/hugetlb.c\nindex 7857728457952..e24f856c949c3 100644\n--- a/mm/hugetlb.c\n+++ b/mm/hugetlb.c\n@@ -130,12 +130,8 @@ static inline bool subpool_is_free(struct hugepage_subpool *spool)\n {\n \tif (spool-\u003ecount)\n \t\treturn false;\n-\tif (spool-\u003emax_hpages != -1)\n-\t\treturn spool-\u003eused_hpages == 0;\n-\tif (spool-\u003emin_hpages != -1)\n-\t\treturn spool-\u003ersv_hpages == spool-\u003emin_hpages;\n \n-\treturn true;\n+\treturn spool-\u003eused_hpages == 0;\n }\n \n static inline void unlock_or_release_subpool(struct hugepage_subpool *spool,\n@@ -193,13 +189,18 @@ void hugepage_put_subpool(struct hugepage_subpool *spool)\n \tunlock_or_release_subpool(spool, flags);\n }\n \n-/*\n- * Subpool accounting for allocating and reserving pages.\n- * Return -ENOMEM if there are not enough resources to satisfy the\n- * request. Otherwise, return the number of pages by which the\n- * global pools must be adjusted (upward). The returned value may\n- * only be different than the passed value (delta) in the case where\n- * a subpool minimum size must be maintained.\n+/**\n+ * hugepage_subpool_get_pages - Get pages from a subpool\n+ * @spool: pointer to subpool structure (may be NULL)\n+ * @delta: number of pages to allocate or reserve\n+ *\n+ * Check and update subpool page usage counts when allocating or\n+ * reserving @delta hugepages.\n+ *\n+ * Context: Takes spool-\u003elock using spin_lock_irq().\n+ * Return: Non-negative number of reservations that cannot be\n+ * satisfied by the subpool, or -ENOMEM if the subpool maximum\n+ * limit would be exceeded.\n */\n static long hugepage_subpool_get_pages(struct hugepage_subpool *spool,\n \t\t\t\t long delta)\n@@ -211,15 +212,14 @@ static long hugepage_subpool_get_pages(struct hugepage_subpool *spool,\n \n \tspin_lock_irq(\u0026spool-\u003elock);\n \n-\tif (spool-\u003emax_hpages != -1) {\t\t/* maximum size accounting */\n-\t\tif ((spool-\u003eused_hpages + delta) \u003c= spool-\u003emax_hpages)\n-\t\t\tspool-\u003eused_hpages += delta;\n-\t\telse {\n-\t\t\tret = -ENOMEM;\n-\t\t\tgoto unlock_ret;\n-\t\t}\n+\tif (spool-\u003emax_hpages != -1 \u0026\u0026\n+\t spool-\u003eused_hpages + delta \u003e spool-\u003emax_hpages) {\n+\t\tret = -ENOMEM;\n+\t\tgoto unlock_ret;\n \t}\n \n+\tspool-\u003eused_hpages += delta;\n+\n \t/* minimum size accounting */\n \tif (spool-\u003emin_hpages != -1 \u0026\u0026 spool-\u003ersv_hpages) {\n \t\tif (delta \u003e spool-\u003ersv_hpages) {\n@@ -240,11 +240,19 @@ static long hugepage_subpool_get_pages(struct hugepage_subpool *spool,\n \treturn ret;\n }\n \n-/*\n- * Subpool accounting for freeing and unreserving pages.\n- * Return the number of global page reservations that must be dropped.\n- * The return value may only be different than the passed value (delta)\n- * in the case where a subpool minimum size must be maintained.\n+/**\n+ * hugepage_subpool_put_pages - Release pages back to a subpool\n+ * @spool: pointer to subpool structure (may be NULL)\n+ * @delta: number of pages to free or unreserve\n+ *\n+ * Check and update subpool page usage counts when freeing or\n+ * unreserving @delta hugepages.\n+ *\n+ * Context: Takes spool-\u003elock using spin_lock_irqsave(). May release\n+ * and free @spool if its usage count and references reach\n+ * zero.\n+ * Return: Non-negative number of reservations that the subpool cannot\n+ * absorb.\n */\n static long hugepage_subpool_put_pages(struct hugepage_subpool *spool,\n \t\t\t\t long delta)\n@@ -257,19 +265,24 @@ static long hugepage_subpool_put_pages(struct hugepage_subpool *spool,\n \n \tspin_lock_irqsave(\u0026spool-\u003elock, flags);\n \n-\tif (spool-\u003emax_hpages != -1)\t\t/* maximum size accounting */\n-\t\tspool-\u003eused_hpages -= delta;\n+\tspool-\u003eused_hpages -= delta;\n \n \t /* minimum size accounting */\n \tif (spool-\u003emin_hpages != -1 \u0026\u0026 spool-\u003eused_hpages \u003c spool-\u003emin_hpages) {\n-\t\tif (spool-\u003ersv_hpages + delta \u003c= spool-\u003emin_hpages)\n+\t\t/*\n+\t\t * limit is the maximum number of reservations that\n+\t\t * can be restored to this subpool.\n+\t\t */\n+\t\tlong limit = spool-\u003emin_hpages - spool-\u003eused_hpages;\n+\n+\t\tif (spool-\u003ersv_hpages + delta \u003c= limit)\n \t\t\tret = 0;\n \t\telse\n-\t\t\tret = spool-\u003ersv_hpages + delta - spool-\u003emin_hpages;\n+\t\t\tret = spool-\u003ersv_hpages + delta - limit;\n \n \t\tspool-\u003ersv_hpages += delta;\n-\t\tif (spool-\u003ersv_hpages \u003e spool-\u003emin_hpages)\n-\t\t\tspool-\u003ersv_hpages = spool-\u003emin_hpages;\n+\t\tif (spool-\u003ersv_hpages \u003e limit)\n+\t\t\tspool-\u003ersv_hpages = limit;\n \t}\n \n \t/*\n@@ -2942,7 +2955,7 @@ struct folio *alloc_hugetlb_folio(struct vm_area_struct *vma,\n \tstruct hugepage_subpool *spool = subpool_vma(vma);\n \tstruct hstate *h = hstate_vma(vma);\n \tstruct folio *folio;\n-\tlong retval, gbl_chg, gbl_reserve;\n+\tlong retval, gbl_resv_get;\n \tmap_chg_state map_chg;\n \tstruct mempolicy_interpreted mpoli;\n \tgfp_t gfp = htlb_alloc_mask(h);\n@@ -2981,8 +2994,8 @@ struct folio *alloc_hugetlb_folio(struct vm_area_struct *vma,\n \t * Or if it can get one from the pool reservation directly.\n \t */\n \tif (map_chg) {\n-\t\tgbl_chg = hugepage_subpool_get_pages(spool, 1);\n-\t\tif (gbl_chg \u003c 0) {\n+\t\tgbl_resv_get = hugepage_subpool_get_pages(spool, 1);\n+\t\tif (gbl_resv_get \u003c 0) {\n \t\t\tret = -ENOSPC;\n \t\t\tgoto out_end_reservation;\n \t\t}\n@@ -2991,7 +3004,7 @@ struct folio *alloc_hugetlb_folio(struct vm_area_struct *vma,\n \t\t * If we have the vma reservation ready, no need for extra\n \t\t * global reservation.\n \t\t */\n-\t\tgbl_chg = 0;\n+\t\tgbl_resv_get = 0;\n \t}\n \n \t/*\n@@ -3002,10 +3015,10 @@ struct folio *alloc_hugetlb_folio(struct vm_area_struct *vma,\n \t\talloc_flags |= HUGETLB_ALLOC_CHARG_CGROUP_RSVD;\n \n \t/*\n-\t * gbl_chg == 0 indicates a reservation exists for this\n+\t * gbl_resv_get == 0 indicates a reservation exists for this\n \t * allocation, so try to use it.\n \t */\n-\tif (gbl_chg == 0)\n+\tif (gbl_resv_get == 0)\n \t\talloc_flags |= HUGETLB_ALLOC_USE_GLOBAL_RESERVATIONS;\n \n \t/* Takes reference on mpol. */\n@@ -3059,13 +3072,10 @@ struct folio *alloc_hugetlb_folio(struct vm_area_struct *vma,\n \treturn folio;\n \n out_subpool_put:\n-\t/*\n-\t * put page to subpool iff the quota of subpool's rsv_hpages is used\n-\t * during hugepage_subpool_get_pages.\n-\t */\n-\tif (map_chg \u0026\u0026 !gbl_chg) {\n-\t\tgbl_reserve = hugepage_subpool_put_pages(spool, 1);\n-\t\thugetlb_acct_memory(h, -gbl_reserve);\n+\tif (map_chg) {\n+\t\tlong gbl_resv_put = hugepage_subpool_put_pages(spool, 1);\n+\n+\t\thugetlb_acct_memory(h, gbl_resv_get - gbl_resv_put);\n \t}\n \n out_end_reservation:\n@@ -6661,12 +6671,14 @@ long hugetlb_reserve_pages(struct inode *inode,\n \t\tstruct vm_area_struct *vma,\n \t\tvma_flags_t vma_flags)\n {\n-\tlong chg = -1, add = -1, spool_resv, gbl_resv;\n+\tlong chg = -1, add = -1;\n \tstruct hstate *h = hstate_inode(inode);\n \tstruct hugepage_subpool *spool = subpool_inode(inode);\n \tstruct resv_map *resv_map;\n \tstruct hugetlb_cgroup *h_cg = NULL;\n-\tlong gbl_reserve, regions_needed = 0;\n+\tlong regions_needed = 0;\n+\tlong gbl_resv_get;\n+\tlong gbl_resv_put;\n \tint err;\n \n \t/* This should never happen */\n@@ -6741,9 +6753,9 @@ long hugetlb_reserve_pages(struct inode *inode,\n \t * the subpool has a minimum size, there may be some global\n \t * reservations already in place (gbl_reserve).\n \t */\n-\tgbl_reserve = hugepage_subpool_get_pages(spool, chg);\n-\tif (gbl_reserve \u003c 0) {\n-\t\terr = gbl_reserve;\n+\tgbl_resv_get = hugepage_subpool_get_pages(spool, chg);\n+\tif (gbl_resv_get \u003c 0) {\n+\t\terr = gbl_resv_get;\n \t\tgoto out_uncharge_cgroup;\n \t}\n \n@@ -6751,7 +6763,7 @@ long hugetlb_reserve_pages(struct inode *inode,\n \t * Check enough hugepages are available for the reservation.\n \t * Hand the pages back to the subpool if there are not\n \t */\n-\terr = hugetlb_acct_memory(h, gbl_reserve);\n+\terr = hugetlb_acct_memory(h, gbl_resv_get);\n \tif (err \u003c 0)\n \t\tgoto out_put_pages;\n \n@@ -6770,7 +6782,7 @@ long hugetlb_reserve_pages(struct inode *inode,\n \t\tadd = region_add(resv_map, from, to, regions_needed, h, h_cg);\n \n \t\tif (unlikely(add \u003c 0)) {\n-\t\t\thugetlb_acct_memory(h, -gbl_reserve);\n+\t\t\thugetlb_acct_memory(h, -gbl_resv_get);\n \t\t\terr = add;\n \t\t\tgoto out_put_pages;\n \t\t} else if (unlikely(chg \u003e add)) {\n@@ -6806,26 +6818,21 @@ long hugetlb_reserve_pages(struct inode *inode,\n \t}\n \treturn chg;\n \n-out_put_pages:\n-\tspool_resv = chg - gbl_reserve;\n-\tif (spool_resv) {\n-\t\t/* put sub pool's reservation back, chg - gbl_reserve */\n-\t\tgbl_resv = hugepage_subpool_put_pages(spool, spool_resv);\n-\t\t/*\n-\t\t * subpool's reserved pages can not be put back due to race,\n-\t\t * return to hstate.\n-\t\t */\n-\t\thugetlb_acct_memory(h, -gbl_resv);\n-\t}\n-\t/* Restore used_hpages for pages that failed global reservation */\n-\tif (gbl_reserve \u0026\u0026 spool) {\n-\t\tunsigned long flags;\n+ out_put_pages:\n+\t/*\n+\t * Return all that was requested from the subpool, let subpool\n+\t * tell us the new number of reservations that need to be\n+\t * returned to the global pool.\n+\t */\n+\tgbl_resv_put = hugepage_subpool_put_pages(spool, chg);\n+\t/*\n+\t * There may be a difference between the number of\n+\t * reservations to consume and the number to restore now if\n+\t * there are multiple threads interacting with the subpool -\n+\t * restore the difference.\n+\t */\n+\thugetlb_acct_memory(h, gbl_resv_get - gbl_resv_put);\n \n-\t\tspin_lock_irqsave(\u0026spool-\u003elock, flags);\n-\t\tif (spool-\u003emax_hpages != -1)\n-\t\t\tspool-\u003eused_hpages -= gbl_reserve;\n-\t\tunlock_or_release_subpool(spool, flags);\n-\t}\n out_uncharge_cgroup:\n \thugetlb_cgroup_uncharge_cgroup_rsvd(hstate_index(h),\n \t\t\t\t\t chg * pages_per_huge_page(h), h_cg);\n"
} |
| 2/1 | 2026/09/03 23:58 | agent | patch-evaluator |
0mModel:core Args: null Results: {
"EnableConfigs": [
"HUGETLBFS"
],
"FocusSymbols": [
"hugetlb_reserve_pages",
"alloc_hugetlb_folio",
"hugepage_subpool_get_pages",
"hugepage_subpool_put_pages",
"hugetlbfs_statfs"
],
"Reasoning": "The patch modifies subpool page accounting, reservation calculation, and error recovery logic in hugetlbfs and core hugetlb memory management routines (hugepage_subpool_get_pages, hugepage_subpool_put_pages, hugetlb_reserve_pages, alloc_hugetlb_folio, hugetlbfs_statfs). These functions are directly reachable from userspace via syscalls such as mmap, open, fallocate, and statfs on hugetlbfs, making this code well-suited for fuzzing.",
"WorthFuzzing": true
}Instruction: You are an expert Linux kernel maintainer and security engineer.
Your job is to review a provided patch series and evaluate whether it warrants fuzzing with syzkaller.
IMPORTANT: The changes have ALREADY been applied and committed as the HEAD commit in
your workspace. Do NOT rely on internal assumptions. You must actively use your code access
tools to inspect the actual source code, callers, and surrounding context.
================================================================================
1. CORE TRIAGE PHILOSOPHY
================================================================================
The goal of patch fuzzing is to discover crashes, regressions, exposed latent bugs,
and newly triggered assertions introduced by the patch series.
- REACHABILITY IS THE PRIMARY GATE:
Fuzzing can only discover bugs in code that can actually execute in standard virtualized
environments (GCE or QEMU, utilizing software-emulated devices like USB gadgets, netdev, tun/tap).
If the modified code is structurally unreachable (see Section 2), it MUST NOT be fuzzed,
regardless of whether it adds assertions or complex logic.
- DO NOT BLINDLY TRUST "NO FUNCTIONAL CHANGE" (NFCI) OR "REFACTORING" CLAIMS:
Patch authors routinely label changes as "cleanups", "refactorings", or state
"No functional change intended". Do NOT take these claims at face value.
Code refactorings that rearrange logic, introduce helper functions, or alter state management
in core subsystems frequently introduce subtle semantic shifts or uncover latent kernel bugs.
If reachable executable code is modified or refactored, it MUST be fuzzed.
- NEW OR MODIFIED ASSERTIONS IN REACHABLE CODE MUST BE FUZZED:
When a patch introduces or modifies runtime checks or assertions (e.g., WARN_ON*, VM_WARN_ON*,
BUG_ON*, lockdep_assert*) in reachable code paths, it enforces new or stricter invariants.
Even if the author believes the invariant always holds, fuzzing is essential to verify whether
an unusual sequence of operations can violate it.
================================================================================
2. WHEN TO RETURN WorthFuzzing=false (NEGATIVE CRITERIA)
================================================================================
Return WorthFuzzing=false ONLY IF all modified code falls strictly into one or more of these categories:
- Non-kernel and non-executable changes:
* Modifications to Documentation/, comments, or spelling fixes.
* User-space directories, self-tests, samples, or scripts (e.g., tools/, samples/, scripts/, usr/)
that do not affect the compiled kernel image (vmlinux) or kernel modules.
* Purely decorative logging (e.g., message strings in pr_err, printk, dev_info) or tracepoints
that do not alter control flow or data structures.
* Build system or Kconfig changes that do not alter compiled C logic.
- Structurally unreachable hardware:
* Vendor-specific PCIe switches, SmartNICs, or GPU drivers (e.g., mlxsw, pds_core, qed,
ionic, amdgpu) requiring physical ASIC/PCIe cards not emulated in standard QEMU.
- Unreachable execution paths:
* Driver teardown callbacks (.remove, .shutdown, pci_unregister_driver) executed only during
physical PCI hot-unplug or manual sysfs driver unbinding.
* Code paths exclusive to architectures other than the target architecture.
================================================================================
3. WHEN TO RETURN WorthFuzzing=true (POSITIVE CRITERIA)
================================================================================
Return WorthFuzzing=true whenever the patch touches reachable executable code, including:
- Core Subsystems:
* Any logic modifications in memory management (mm/), synchronization/locking (kernel/locking/),
BPF, scheduler, core networking, VFS, or syscall handling.
- Refactorings and Code Cleanups:
* Any restructuring of reachable data structures, helper abstractions, or algorithm flows.
- Runtime Assertions and Defensive Checks:
* Any introduction or alteration of assertions (WARN_ON*, VM_WARN_ON*, BUG_ON*, etc.) in reachable paths.
- Reachable Drivers and Protocols:
* Drivers accessible via virtual buses (virtio, USB gadget, loopback, netlink, binder, sockets, etc.).
================================================================================
4. EXTRACTING FocusSymbols (PREVENTING DILUTION)
================================================================================
When WorthFuzzing=true, you must extract specific kernel functions into FocusSymbols to guide the fuzzer:
- AVOID UBIQUITOUS LIFECYCLE HOT-PATHS:
Do NOT list generic, ubiquitous functions called by almost every program in the corpus
(including, but not limited to: general memory allocators and deallocators, page fault
and trap handlers, or core synchronization primitives; this is not an exhaustive list).
Listing ubiquitous functions causes the fuzzer to classify thousands of unrelated tests as "focused",
which severely dilutes fuzzing effort away from the actual changes.
- TARGET SPECIFIC FEATURE LOGIC AND ENTRYPOINTS:
List functions that specifically implement the logic being added or altered, or direct API entrypoints
for the subsystem feature under review.
- HANDLING STATIC INLINE FUNCTIONS IN HEADERS (.h):
Compiler-inlined static functions (such as static inlines in mm/*.h or include/linux/*.h) lack
distinct symbol addresses in vmlinux and cannot be targeted directly by symbol coverage filters.
If the changes are primarily in static inline helpers, identify non-static, feature-specific caller
functions in .c files that exercise them (avoiding ubiquitous lifecycle wrappers).
================================================================================
5. IDENTIFYING EnableConfigs
================================================================================
Identify any specific CONFIG_ options required to properly compile and reach the modified code:
- Inspect Kconfig files and #ifdef guards; do not make assumptions.
- Check "depends on" lines in Kconfig to include any non-standard parent subsystem configs needed.
- Strip any 'CONFIG_' prefix (e.g., return "NET_IPV4" instead of "CONFIG_NET_IPV4").
Prefer calling several tools at the same time to save round-trips.
Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.
Prompt: Target architecture: amd64
For your convenience, here is the diff of the changes:
commit 9c3c451828cc8581dcf14d3058a3b74f5624b627
Author: syz-cluster <triage@syzkaller.com>
Date: Thu Sep 3 23:58:32 2026 +0000
syz-cluster: applied patch under review
diff --git a/Documentation/mm/hugetlbfs_reserv.rst b/Documentation/mm/hugetlbfs_reserv.rst
index a49115db18c76..d244583fdcbc3 100644
--- a/Documentation/mm/hugetlbfs_reserv.rst
+++ b/Documentation/mm/hugetlbfs_reserv.rst
@@ -314,21 +314,8 @@ huge pages. If they can not be reserved, the mount fails.
The routines hugepage_subpool_get/put_pages() are called when pages are
obtained from or released back to a subpool. They perform all subpool
accounting, and track any reservations associated with the subpool.
-hugepage_subpool_get/put_pages are passed the number of huge pages by which
-to adjust the subpool 'used page' count (down for get, up for put). Normally,
-they return the same value that was passed or an error if not enough pages
-exist in the subpool.
-
-However, if reserves are associated with the subpool a return value less
-than the passed value may be returned. This return value indicates the
-number of additional global pool adjustments which must be made. For example,
-suppose a subpool contains 3 reserved huge pages and someone asks for 5.
-The 3 reserved pages associated with the subpool can be used to satisfy part
-of the request. But, 2 pages must be obtained from the global pools. To
-relay this information to the caller, the value 2 is returned. The caller
-is then responsible for attempting to obtain the additional two pages from
-the global pools.
-
+hugepage_subpool_get/put_pages() use the number of huge pages passed to adjust
+the subpool 'used page' count.
COW and Reservations
====================
diff --git a/Documentation/translations/zh_CN/mm/hugetlbfs_reserv.rst b/Documentation/translations/zh_CN/mm/hugetlbfs_reserv.rst
index 20947f8bd0654..ae1f1f31477fc 100644
--- a/Documentation/translations/zh_CN/mm/hugetlbfs_reserv.rst
+++ b/Documentation/translations/zh_CN/mm/hugetlbfs_reserv.rst
@@ -246,15 +246,8 @@ hugepage_subpool的min_hpages字段中被跟踪。在挂载时,hugetlb_acct_me
被调用以预留指定数量的巨页。如果它们不能被预留,挂载就会失败。
当从子池中获取或释放页面时,会调用hugepage_subpool_get/put_pages()函数。
-hugepage_subpool_get/put_pages被传递给巨页数量,以此来调整子池的 “已用页面” 计数
-(get为下降,put为上升)。通常情况下,如果子池中没有足够的页面,它们会返回与传递的相同的值或
-一个错误。
-
-然而,如果预留与子池相关联,可能会返回一个小于传递值的返回值。这个返回值表示必须进行的额外全局
-池调整的数量。例如,假设一个子池包含3个预留的巨页,有人要求5个。与子池相关的3个预留页可以用来
-满足部分请求。但是,必须从全局池中获得2个页面。为了向调用者转达这一信息,将返回值2。然后,调用
-者要负责从全局池中获取另外两个页面。
-
+它们负责所有子池的统计核算,并跟踪与子池相关联的预留。
+hugepage_subpool_get/put_pages()函数使用传入的巨页数量来调整子池的“已用页面”计数。
COW和预留
==========
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 7611a8470ea26..5113f743f6fc7 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -1109,8 +1109,12 @@ static int hugetlbfs_statfs(struct dentry *dentry, struct kstatfs *buf)
spin_lock_irq(&sbinfo->spool->lock);
buf->f_blocks = sbinfo->spool->max_hpages;
- free_pages = sbinfo->spool->max_hpages
- - sbinfo->spool->used_hpages;
+ if (sbinfo->spool->max_hpages == -1) {
+ free_pages = -1;
+ } else {
+ free_pages = sbinfo->spool->max_hpages -
+ sbinfo->spool->used_hpages;
+ }
buf->f_bavail = buf->f_bfree = free_pages;
spin_unlock_irq(&sbinfo->spool->lock);
buf->f_files = sbinfo->max_inodes;
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 16c4c4caa126c..4551ff3023640 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -39,8 +39,8 @@ struct hugepage_subpool {
spinlock_t lock;
long count;
long max_hpages; /* Maximum huge pages or -1 if no maximum. */
- long used_hpages; /* Used count against maximum, includes */
- /* both allocated and reserved pages. */
+ long used_hpages; /* Used page count, includes both */
+ /* allocated and reserved pages. */
struct hstate *hstate;
long min_hpages; /* Minimum huge pages or -1 if no minimum. */
long rsv_hpages; /* Pages reserved against global pool to */
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 7857728457952..e24f856c949c3 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -130,12 +130,8 @@ static inline bool subpool_is_free(struct hugepage_subpool *spool)
{
if (spool->count)
return false;
- if (spool->max_hpages != -1)
- return spool->used_hpages == 0;
- if (spool->min_hpages != -1)
- return spool->rsv_hpages == spool->min_hpages;
- return true;
+ return spool->used_hpages == 0;
}
static inline void unlock_or_release_subpool(struct hugepage_subpool *spool,
@@ -193,13 +189,18 @@ void hugepage_put_subpool(struct hugepage_subpool *spool)
unlock_or_release_subpool(spool, flags);
}
-/*
- * Subpool accounting for allocating and reserving pages.
- * Return -ENOMEM if there are not enough resources to satisfy the
- * request. Otherwise, return the number of pages by which the
- * global pools must be adjusted (upward). The returned value may
- * only be different than the passed value (delta) in the case where
- * a subpool minimum size must be maintained.
+/**
+ * hugepage_subpool_get_pages - Get pages from a subpool
+ * @spool: pointer to subpool structure (may be NULL)
+ * @delta: number of pages to allocate or reserve
+ *
+ * Check and update subpool page usage counts when allocating or
+ * reserving @delta hugepages.
+ *
+ * Context: Takes spool->lock using spin_lock_irq().
+ * Return: Non-negative number of reservations that cannot be
+ * satisfied by the subpool, or -ENOMEM if the subpool maximum
+ * limit would be exceeded.
*/
static long hugepage_subpool_get_pages(struct hugepage_subpool *spool,
long delta)
@@ -211,15 +212,14 @@ static long hugepage_subpool_get_pages(struct hugepage_subpool *spool,
spin_lock_irq(&spool->lock);
- if (spool->max_hpages != -1) { /* maximum size accounting */
- if ((spool->used_hpages + delta) <= spool->max_hpages)
- spool->used_hpages += delta;
- else {
- ret = -ENOMEM;
- goto unlock_ret;
- }
+ if (spool->max_hpages != -1 &&
+ spool->used_hpages + delta > spool->max_hpages) {
+ ret = -ENOMEM;
+ goto unlock_ret;
}
+ spool->used_hpages += delta;
+
/* minimum size accounting */
if (spool->min_hpages != -1 && spool->rsv_hpages) {
if (delta > spool->rsv_hpages) {
@@ -240,11 +240,19 @@ static long hugepage_subpool_get_pages(struct hugepage_subpool *spool,
return ret;
}
-/*
- * Subpool accounting for freeing and unreserving pages.
- * Return the number of global page reservations that must be dropped.
- * The return value may only be different than the passed value (delta)
- * in the case where a subpool minimum size must be maintained.
+/**
+ * hugepage_subpool_put_pages - Release pages back to a subpool
+ * @spool: pointer to subpool structure (may be NULL)
+ * @delta: number of pages to free or unreserve
+ *
+ * Check and update subpool page usage counts when freeing or
+ * unreserving @delta hugepages.
+ *
+ * Context: Takes spool->lock using spin_lock_irqsave(). May release
+ * and free @spool if its usage count and references reach
+ * zero.
+ * Return: Non-negative number of reservations that the subpool cannot
+ * absorb.
*/
static long hugepage_subpool_put_pages(struct hugepage_subpool *spool,
long delta)
@@ -257,19 +265,24 @@ static long hugepage_subpool_put_pages(struct hugepage_subpool *spool,
spin_lock_irqsave(&spool->lock, flags);
- if (spool->max_hpages != -1) /* maximum size accounting */
- spool->used_hpages -= delta;
+ spool->used_hpages -= delta;
/* minimum size accounting */
if (spool->min_hpages != -1 && spool->used_hpages < spool->min_hpages) {
- if (spool->rsv_hpages + delta <= spool->min_hpages)
+ /*
+ * limit is the maximum number of reservations that
+ * can be restored to this subpool.
+ */
+ long limit = spool->min_hpages - spool->used_hpages;
+
+ if (spool->rsv_hpages + delta <= limit)
ret = 0;
else
- ret = spool->rsv_hpages + delta - spool->min_hpages;
+ ret = spool->rsv_hpages + delta - limit;
spool->rsv_hpages += delta;
- if (spool->rsv_hpages > spool->min_hpages)
- spool->rsv_hpages = spool->min_hpages;
+ if (spool->rsv_hpages > limit)
+ spool->rsv_hpages = limit;
}
/*
@@ -2942,7 +2955,7 @@ struct folio *alloc_hugetlb_folio(struct vm_area_struct *vma,
struct hugepage_subpool *spool = subpool_vma(vma);
struct hstate *h = hstate_vma(vma);
struct folio *folio;
- long retval, gbl_chg, gbl_reserve;
+ long retval, gbl_resv_get;
map_chg_state map_chg;
struct mempolicy_interpreted mpoli;
gfp_t gfp = htlb_alloc_mask(h);
@@ -2981,8 +2994,8 @@ struct folio *alloc_hugetlb_folio(struct vm_area_struct *vma,
* Or if it can get one from the pool reservation directly.
*/
if (map_chg) {
- gbl_chg = hugepage_subpool_get_pages(spool, 1);
- if (gbl_chg < 0) {
+ gbl_resv_get = hugepage_subpool_get_pages(spool, 1);
+ if (gbl_resv_get < 0) {
ret = -ENOSPC;
goto out_end_reservation;
}
@@ -2991,7 +3004,7 @@ struct folio *alloc_hugetlb_folio(struct vm_area_struct *vma,
* If we have the vma reservation ready, no need for extra
* global reservation.
*/
- gbl_chg = 0;
+ gbl_resv_get = 0;
}
/*
@@ -3002,10 +3015,10 @@ struct folio *alloc_hugetlb_folio(struct vm_area_struct *vma,
alloc_flags |= HUGETLB_ALLOC_CHARG_CGROUP_RSVD;
/*
- * gbl_chg == 0 indicates a reservation exists for this
+ * gbl_resv_get == 0 indicates a reservation exists for this
* allocation, so try to use it.
*/
- if (gbl_chg == 0)
+ if (gbl_resv_get == 0)
alloc_flags |= HUGETLB_ALLOC_USE_GLOBAL_RESERVATIONS;
/* Takes reference on mpol. */
@@ -3059,13 +3072,10 @@ struct folio *alloc_hugetlb_folio(struct vm_area_struct *vma,
return folio;
out_subpool_put:
- /*
- * put page to subpool iff the quota of subpool's rsv_hpages is used
- * during hugepage_subpool_get_pages.
- */
- if (map_chg && !gbl_chg) {
- gbl_reserve = hugepage_subpool_put_pages(spool, 1);
- hugetlb_acct_memory(h, -gbl_reserve);
+ if (map_chg) {
+ long gbl_resv_put = hugepage_subpool_put_pages(spool, 1);
+
+ hugetlb_acct_memory(h, gbl_resv_get - gbl_resv_put);
}
out_end_reservation:
@@ -6661,12 +6671,14 @@ long hugetlb_reserve_pages(struct inode *inode,
struct vm_area_struct *vma,
vma_flags_t vma_flags)
{
- long chg = -1, add = -1, spool_resv, gbl_resv;
+ long chg = -1, add = -1;
struct hstate *h = hstate_inode(inode);
struct hugepage_subpool *spool = subpool_inode(inode);
struct resv_map *resv_map;
struct hugetlb_cgroup *h_cg = NULL;
- long gbl_reserve, regions_needed = 0;
+ long regions_needed = 0;
+ long gbl_resv_get;
+ long gbl_resv_put;
int err;
/* This should never happen */
@@ -6741,9 +6753,9 @@ long hugetlb_reserve_pages(struct inode *inode,
* the subpool has a minimum size, there may be some global
* reservations already in place (gbl_reserve).
*/
- gbl_reserve = hugepage_subpool_get_pages(spool, chg);
- if (gbl_reserve < 0) {
- err = gbl_reserve;
+ gbl_resv_get = hugepage_subpool_get_pages(spool, chg);
+ if (gbl_resv_get < 0) {
+ err = gbl_resv_get;
goto out_uncharge_cgroup;
}
@@ -6751,7 +6763,7 @@ long hugetlb_reserve_pages(struct inode *inode,
* Check enough hugepages are available for the reservation.
* Hand the pages back to the subpool if there are not
*/
- err = hugetlb_acct_memory(h, gbl_reserve);
+ err = hugetlb_acct_memory(h, gbl_resv_get);
if (err < 0)
goto out_put_pages;
@@ -6770,7 +6782,7 @@ long hugetlb_reserve_pages(struct inode *inode,
add = region_add(resv_map, from, to, regions_needed, h, h_cg);
if (unlikely(add < 0)) {
- hugetlb_acct_memory(h, -gbl_reserve);
+ hugetlb_acct_memory(h, -gbl_resv_get);
err = add;
goto out_put_pages;
} else if (unlikely(chg > add)) {
@@ -6806,26 +6818,21 @@ long hugetlb_reserve_pages(struct inode *inode,
}
return chg;
-out_put_pages:
- spool_resv = chg - gbl_reserve;
- if (spool_resv) {
- /* put sub pool's reservation back, chg - gbl_reserve */
- gbl_resv = hugepage_subpool_put_pages(spool, spool_resv);
- /*
- * subpool's reserved pages can not be put back due to race,
- * return to hstate.
- */
- hugetlb_acct_memory(h, -gbl_resv);
- }
- /* Restore used_hpages for pages that failed global reservation */
- if (gbl_reserve && spool) {
- unsigned long flags;
+ out_put_pages:
+ /*
+ * Return all that was requested from the subpool, let subpool
+ * tell us the new number of reservations that need to be
+ * returned to the global pool.
+ */
+ gbl_resv_put = hugepage_subpool_put_pages(spool, chg);
+ /*
+ * There may be a difference between the number of
+ * reservations to consume and the number to restore now if
+ * there are multiple threads interacting with the subpool -
+ * restore the difference.
+ */
+ hugetlb_acct_memory(h, gbl_resv_get - gbl_resv_put);
- spin_lock_irqsave(&spool->lock, flags);
- if (spool->max_hpages != -1)
- spool->used_hpages -= gbl_reserve;
- unlock_or_release_subpool(spool, flags);
- }
out_uncharge_cgroup:
hugetlb_cgroup_uncharge_cgroup_rsvd(hstate_index(h),
chg * pages_per_huge_page(h), h_cg);
|
| 3/2 | 2026/09/03 23:58 | llm | patch-evaluator |
0mModel:gemini-3.7-flash Args: null Results: null Tokens: input: 7809 output: 31 thoughts: 651 Thoughts: **Analyzing the Hugetlbfs Subpool Accounting Patch** Okay, let's dive into this patch. My immediate goal is to understand the implications of these changes within the hugetlbfs/hugetlb memory management subsystem. I'm seeing changes across a few key areas: the documentation, the inode implementation, and the core include and mm files. That makes me take it seriously. First, I'll zero in on the modified files. I'm focusing on `mm/hugetlb.c`, `fs/hugetlbfs/inode.c`, and `include/linux/hugetlb.h` as they are the meat of this. The documentation updates are important, but understanding the *functionality* change is critical. Right away, I see this revolves around subpool accounting. That's a critical piece of the puzzle for hugetlbfs. It seems the patch is altering the logic for how we track and manage hugepages within these subpools. Specifically, here's what's jumping out at me: * **`subpool_is_free`**: This is interesting. The check is now just `used_hpages == 0`, a simplification. This makes me consider if there is a use case that causes this change, and what the effect will be. * **`hugepage_subpool_get_pages`**: It looks like the patch is always incrementing `used_hpages` now, even when `max_hpages` is -1. That suggests a possible change in how we handle unbounded subpools. * **`hugepage_subpool_put_pages`**: The decrement is always happening, and the minimum size accounting logic appears to be reworked. This is critical for resource management and could introduce subtle behavioral changes that must be carefully scrutinized. * **`alloc_hugetlb_folio` & `hugetlb_reserve_pages`**: Error handling and resource accounting are modified. I need to understand how the changes to `hugetlb_acct_memory` affect overall memory usage tracking and potential resource leaks. I also need to verify that we are handling errors correctly here and are not introducing new race conditions or memory corruption possibilities. * **`hugetlbfs_statfs`**: The check for `max_hpages == -1` and setting `free_pages = -1` makes sense for an unbounded pool. My next step is to determine if this code is in a hot path. And from my experience, the answer is *yes*. These functions are directly involved in user-space interactions through syscalls like `mmap` with `MAP_HUGETLB`, managing hugetlbfs mounts, file operations, madvise, fallocate, and `statfs`. Any subtle change in this area can have widespread consequences and needs thorough review. I need to confirm the required Kconfig options are enabled (e.g., `CONFIG_HUGETLBFS`, `CONFIG_HUGETLB_PAGE`, etc.) to understand the context of the change. Time to `grepper` or check the Kconfig files. This is going to be my immediate next step. |
| 4/2 | 2026/09/03 23:58 | tool | grepper |
0mError:no matches Args: {
"Expression": "config HUGETLB",
"PathPrefix": "fs/hugetlbfs/"
}Results: {
"error": "no matches"
} |
| 5/2 | 2026/09/03 23:58 | llm | patch-evaluator |
0mModel:gemini-3.7-flash Args: null Results: null Tokens: input: 9174 output: 32 thoughts: 22 Thoughts: Here's my take on those thoughts, tailored for an expert audience: **Examining Kconfig Files for HugeTLB Configuration** Okay, so I need to get a handle on the HugeTLB configuration options. The first places I'm going to look are, naturally, `fs/hugetlbfs/Kconfig` and `mm/Kconfig`. It’s a pretty standard approach, really, but it's the right starting point. `fs/hugetlbfs` *should* contain the options specific to the filesystem itself, probably related to its mount options, quota support, and maybe some page allocation details tied to the VFS layer. I'm expecting to find settings like the default hugepage size, whether hugetlbfs is enabled by default, and perhaps some fine-grained controls over features. On the other hand, `mm/Kconfig` is where I'd anticipate the more fundamental memory management configurations. I'm thinking settings dealing with the NUMA affinity of hugepages, the overall allocation policies, and the maximum sizes available. It's almost certain there’ll be options related to the core kernel infrastructure for managing huge pages and whether hugepage support is even compiled into the kernel. It’s also possible that there are some cross-references between the two Kconfig files; the filesystem-specific options might depend on or interact with the memory management options defined in `mm/Kconfig`. Time to dive in and see exactly how these options are structured and what dependencies exist. I'm hoping to quickly identify the key parameters that control HugeTLB behavior, particularly those impacting performance and resource utilization. |
| 6/2 | 2026/09/03 23:58 | tool | grepper |
0mError:no matches Args: {
"Expression": "HUGETLB",
"PathPrefix": "fs/hugetlbfs/Kconfig"
}Results: {
"error": "no matches"
} |
| 7/2 | 2026/09/03 23:58 | llm | patch-evaluator |
0mModel:gemini-3.7-flash Args: null Results: null Tokens: input: 9583 output: 26 thoughts: 14 Thoughts: Okay, here's my attempt at summarizing those thoughts from an expert's perspective, using the first person: **Navigating the Kernel's Configuration Landscape** Alright, so I'm looking to tweak something, and I need to figure out where the relevant configuration options live. First things first, the logical starting point is the `Kconfig` files. That's where all the configuration knobs are defined, right? Given the general area I'm working in, my instinct is to narrow the search. I'm thinking either the `fs/` directory, which covers all the filesystems, or the `mm/` directory, which encompasses all the memory management aspects. Those are the two most likely places to find the configuration options I'm interested in, based on the problem I am working on. Now, let's see which is the correct one. |
| 8/2 | 2026/09/03 23:58 | tool | grepper |
0mArgs:{
"Expression": "hugetlbfs",
"PathPrefix": "fs/"
}Results: {
"Output": "fs/Kconfig=250=menuconfig HUGETLBFS\n--\nfs/Kconfig-255-\thelp\nfs/Kconfig:256:\t hugetlbfs is a filesystem backing for HugeTLB pages, based on\nfs/Kconfig-257-\t ramfs. For architectures that support it, say Y here and read\n--\nfs/Makefile=73=obj-y\t\t\t\t+= ramfs/\nfs/Makefile:74:obj-$(CONFIG_HUGETLBFS)\t\t+= hugetlbfs/\nfs/Makefile-75-obj-$(CONFIG_CODA_FS)\t\t+= coda/\n--\nfs/hugetlbfs/Makefile-5-\nfs/hugetlbfs/Makefile:6:obj-$(CONFIG_HUGETLBFS) += hugetlbfs.o\nfs/hugetlbfs/Makefile-7-\nfs/hugetlbfs/Makefile:8:hugetlbfs-objs := inode.o\n--\nfs/hugetlbfs/inode.c-42-#define CREATE_TRACE_POINTS\nfs/hugetlbfs/inode.c:43:#include \u003ctrace/events/hugetlbfs.h\u003e\nfs/hugetlbfs/inode.c-44-\nfs/hugetlbfs/inode.c:45:static const struct address_space_operations hugetlbfs_aops;\nfs/hugetlbfs/inode.c:46:static const struct file_operations hugetlbfs_file_operations;\nfs/hugetlbfs/inode.c:47:static const struct inode_operations hugetlbfs_dir_inode_operations;\nfs/hugetlbfs/inode.c:48:static const struct inode_operations hugetlbfs_inode_operations;\nfs/hugetlbfs/inode.c-49-\nfs/hugetlbfs/inode.c:50:enum hugetlbfs_size_type { NO_SIZE, SIZE_STD, SIZE_PERCENT };\nfs/hugetlbfs/inode.c-51-\nfs/hugetlbfs/inode.c:52:struct hugetlbfs_fs_context {\nfs/hugetlbfs/inode.c-53-\tstruct hstate\t\t*hstate;\n--\nfs/hugetlbfs/inode.c-58-\tlong\t\t\tmin_hpages;\nfs/hugetlbfs/inode.c:59:\tenum hugetlbfs_size_type max_val_type;\nfs/hugetlbfs/inode.c:60:\tenum hugetlbfs_size_type min_val_type;\nfs/hugetlbfs/inode.c-61-\tkuid_t\t\t\tuid;\n--\nfs/hugetlbfs/inode.c=78=static const struct fs_parameter_spec hugetlb_fs_parameters[] = {\n--\nfs/hugetlbfs/inode.c-98-\nfs/hugetlbfs/inode.c:99:static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma)\nfs/hugetlbfs/inode.c-100-{\n--\nfs/hugetlbfs/inode.c-146-\t * for SHM_HUGETLB, the pages are reserved in the shmget() call so skip\nfs/hugetlbfs/inode.c:147:\t * reserving here. Note: only for SHM hugetlbfs file, the inode\nfs/hugetlbfs/inode.c-148-\t * flag S_PRIVATE is set.\n--\nfs/hugetlbfs/inode.c=196=static size_t adjust_range_hwpoison(struct folio *folio, size_t offset,\n--\nfs/hugetlbfs/inode.c-219- */\nfs/hugetlbfs/inode.c:220:static ssize_t hugetlbfs_read_iter(struct kiocb *iocb, struct iov_iter *to)\nfs/hugetlbfs/inode.c-221-{\n--\nfs/hugetlbfs/inode.c-297-\nfs/hugetlbfs/inode.c:298:static int hugetlbfs_write_begin(const struct kiocb *iocb,\nfs/hugetlbfs/inode.c-299-\t\t\tstruct address_space *mapping,\n--\nfs/hugetlbfs/inode.c-305-\nfs/hugetlbfs/inode.c:306:static int hugetlbfs_write_end(const struct kiocb *iocb,\nfs/hugetlbfs/inode.c-307-\t\t\t struct address_space *mapping,\n--\nfs/hugetlbfs/inode.c=552=static void remove_inode_hugepages(struct inode *inode, loff_t lstart,\n--\nfs/hugetlbfs/inode.c-592-\nfs/hugetlbfs/inode.c:593:static void hugetlbfs_evict_inode(struct inode *inode)\nfs/hugetlbfs/inode.c-594-{\n--\nfs/hugetlbfs/inode.c-596-\nfs/hugetlbfs/inode.c:597:\ttrace_hugetlbfs_evict_inode(inode);\nfs/hugetlbfs/inode.c-598-\tremove_inode_hugepages(inode, 0, LLONG_MAX);\n--\nfs/hugetlbfs/inode.c=607=static void hugetlb_vmtruncate(struct inode *inode, loff_t offset)\n--\nfs/hugetlbfs/inode.c-623-\nfs/hugetlbfs/inode.c:624:static void hugetlbfs_zero_partial_page(struct hstate *h,\nfs/hugetlbfs/inode.c-625-\t\t\t\t\tstruct address_space *mapping,\n--\nfs/hugetlbfs/inode.c-646-\nfs/hugetlbfs/inode.c:647:static long hugetlbfs_punch_hole(struct inode *inode, loff_t offset, loff_t len)\nfs/hugetlbfs/inode.c-648-{\nfs/hugetlbfs/inode.c:649:\tstruct hugetlbfs_inode_info *info = HUGETLBFS_I(inode);\nfs/hugetlbfs/inode.c-650-\tstruct address_space *mapping = inode-\u003ei_mapping;\n--\nfs/hugetlbfs/inode.c-672-\tif (offset \u003c hole_start)\nfs/hugetlbfs/inode.c:673:\t\thugetlbfs_zero_partial_page(h, mapping,\nfs/hugetlbfs/inode.c-674-\t\t\t\toffset, min(offset + len, hole_start));\n--\nfs/hugetlbfs/inode.c-685-\tif ((offset + len) \u003e hole_end \u0026\u0026 (offset + len) \u003e hole_start)\nfs/hugetlbfs/inode.c:686:\t\thugetlbfs_zero_partial_page(h, mapping,\nfs/hugetlbfs/inode.c-687-\t\t\t\thole_end, offset + len);\n--\nfs/hugetlbfs/inode.c-699-\nfs/hugetlbfs/inode.c:700:static long hugetlbfs_fallocate(struct file *file, int mode, loff_t offset,\nfs/hugetlbfs/inode.c-701-\t\t\t\tloff_t len)\n--\nfs/hugetlbfs/inode.c-703-\tstruct inode *inode = file_inode(file);\nfs/hugetlbfs/inode.c:704:\tstruct hugetlbfs_inode_info *info = HUGETLBFS_I(inode);\nfs/hugetlbfs/inode.c-705-\tstruct address_space *mapping = inode-\u003ei_mapping;\n--\nfs/hugetlbfs/inode.c-718-\tif (mode \u0026 FALLOC_FL_PUNCH_HOLE) {\nfs/hugetlbfs/inode.c:719:\t\terror = hugetlbfs_punch_hole(inode, offset, len);\nfs/hugetlbfs/inode.c-720-\t\tgoto out_nolock;\n--\nfs/hugetlbfs/inode.c-826-out_nolock:\nfs/hugetlbfs/inode.c:827:\ttrace_hugetlbfs_fallocate(inode, mode, offset, len, error);\nfs/hugetlbfs/inode.c-828-\treturn error;\n--\nfs/hugetlbfs/inode.c-830-\nfs/hugetlbfs/inode.c:831:static int hugetlbfs_setattr(struct mnt_idmap *idmap,\nfs/hugetlbfs/inode.c-832-\t\t\t struct dentry *dentry, struct iattr *attr)\n--\nfs/hugetlbfs/inode.c-837-\tunsigned int ia_valid = attr-\u003eia_valid;\nfs/hugetlbfs/inode.c:838:\tstruct hugetlbfs_inode_info *info = HUGETLBFS_I(inode);\nfs/hugetlbfs/inode.c-839-\n--\nfs/hugetlbfs/inode.c-843-\nfs/hugetlbfs/inode.c:844:\ttrace_hugetlbfs_setattr(inode, dentry, attr);\nfs/hugetlbfs/inode.c-845-\n--\nfs/hugetlbfs/inode.c-863-\nfs/hugetlbfs/inode.c:864:static struct inode *hugetlbfs_get_root(struct super_block *sb,\nfs/hugetlbfs/inode.c:865:\t\t\t\t\tstruct hugetlbfs_fs_context *ctx)\nfs/hugetlbfs/inode.c-866-{\n--\nfs/hugetlbfs/inode.c-875-\t\tsimple_inode_init_ts(inode);\nfs/hugetlbfs/inode.c:876:\t\tinode-\u003ei_op = \u0026hugetlbfs_dir_inode_operations;\nfs/hugetlbfs/inode.c-877-\t\tinode-\u003ei_fop = \u0026simple_dir_operations;\n--\nfs/hugetlbfs/inode.c-891- */\nfs/hugetlbfs/inode.c:892:static struct lock_class_key hugetlbfs_i_mmap_rwsem_key;\nfs/hugetlbfs/inode.c-893-\nfs/hugetlbfs/inode.c:894:static struct inode *hugetlbfs_get_inode(struct super_block *sb,\nfs/hugetlbfs/inode.c-895-\t\t\t\t\tstruct mnt_idmap *idmap,\n--\nfs/hugetlbfs/inode.c-913-\tif (inode) {\nfs/hugetlbfs/inode.c:914:\t\tstruct hugetlbfs_inode_info *info = HUGETLBFS_I(inode);\nfs/hugetlbfs/inode.c-915-\n--\nfs/hugetlbfs/inode.c-918-\t\tlockdep_set_class(\u0026inode-\u003ei_mapping-\u003ei_mmap_rwsem,\nfs/hugetlbfs/inode.c:919:\t\t\t\t\u0026hugetlbfs_i_mmap_rwsem_key);\nfs/hugetlbfs/inode.c:920:\t\tinode-\u003ei_mapping-\u003ea_ops = \u0026hugetlbfs_aops;\nfs/hugetlbfs/inode.c-921-\t\tsimple_inode_init_ts(inode);\n--\nfs/hugetlbfs/inode.c-928-\t\tcase S_IFREG:\nfs/hugetlbfs/inode.c:929:\t\t\tinode-\u003ei_op = \u0026hugetlbfs_inode_operations;\nfs/hugetlbfs/inode.c:930:\t\t\tinode-\u003ei_fop = \u0026hugetlbfs_file_operations;\nfs/hugetlbfs/inode.c-931-\t\t\tbreak;\nfs/hugetlbfs/inode.c-932-\t\tcase S_IFDIR:\nfs/hugetlbfs/inode.c:933:\t\t\tinode-\u003ei_op = \u0026hugetlbfs_dir_inode_operations;\nfs/hugetlbfs/inode.c-934-\t\t\tinode-\u003ei_fop = \u0026simple_dir_operations;\n--\nfs/hugetlbfs/inode.c-944-\t\tlockdep_annotate_inode_mutex_key(inode);\nfs/hugetlbfs/inode.c:945:\t\ttrace_hugetlbfs_alloc_inode(inode, dir, mode);\nfs/hugetlbfs/inode.c-946-\t} else {\n--\nfs/hugetlbfs/inode.c-956- */\nfs/hugetlbfs/inode.c:957:static int hugetlbfs_mknod(struct mnt_idmap *idmap, struct inode *dir,\nfs/hugetlbfs/inode.c-958-\t\t\t struct dentry *dentry, umode_t mode, dev_t dev)\n--\nfs/hugetlbfs/inode.c-961-\nfs/hugetlbfs/inode.c:962:\tinode = hugetlbfs_get_inode(dir-\u003ei_sb, idmap, dir, mode, dev);\nfs/hugetlbfs/inode.c-963-\tif (!inode)\n--\nfs/hugetlbfs/inode.c-969-\nfs/hugetlbfs/inode.c:970:static struct dentry *hugetlbfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,\nfs/hugetlbfs/inode.c-971-\t\t\t\t struct dentry *dentry, umode_t mode)\nfs/hugetlbfs/inode.c-972-{\nfs/hugetlbfs/inode.c:973:\tint retval = hugetlbfs_mknod(idmap, dir, dentry,\nfs/hugetlbfs/inode.c-974-\t\t\t\t mode, 0);\n--\nfs/hugetlbfs/inode.c-979-\nfs/hugetlbfs/inode.c:980:static int hugetlbfs_create(struct mnt_idmap *idmap,\nfs/hugetlbfs/inode.c-981-\t\t\t struct inode *dir, struct dentry *dentry,\n--\nfs/hugetlbfs/inode.c-983-{\nfs/hugetlbfs/inode.c:984:\treturn hugetlbfs_mknod(idmap, dir, dentry, mode | S_IFREG, 0);\nfs/hugetlbfs/inode.c-985-}\nfs/hugetlbfs/inode.c-986-\nfs/hugetlbfs/inode.c:987:static int hugetlbfs_tmpfile(struct mnt_idmap *idmap,\nfs/hugetlbfs/inode.c-988-\t\t\t struct inode *dir, struct file *file,\n--\nfs/hugetlbfs/inode.c-992-\nfs/hugetlbfs/inode.c:993:\tinode = hugetlbfs_get_inode(dir-\u003ei_sb, idmap, dir, mode | S_IFREG, 0);\nfs/hugetlbfs/inode.c-994-\tif (!inode)\n--\nfs/hugetlbfs/inode.c-1000-\nfs/hugetlbfs/inode.c:1001:static int hugetlbfs_symlink(struct mnt_idmap *idmap,\nfs/hugetlbfs/inode.c-1002-\t\t\t struct inode *dir, struct dentry *dentry,\n--\nfs/hugetlbfs/inode.c-1008-\nfs/hugetlbfs/inode.c:1009:\tinode = hugetlbfs_get_inode(dir-\u003ei_sb, idmap, dir, mode, 0);\nfs/hugetlbfs/inode.c-1010-\tif (inode) {\n--\nfs/hugetlbfs/inode.c-1023-#ifdef CONFIG_MIGRATION\nfs/hugetlbfs/inode.c:1024:static int hugetlbfs_migrate_folio(struct address_space *mapping,\nfs/hugetlbfs/inode.c-1025-\t\t\t\tstruct folio *dst, struct folio *src,\n--\nfs/hugetlbfs/inode.c-1044-#else\nfs/hugetlbfs/inode.c:1045:#define hugetlbfs_migrate_folio NULL\nfs/hugetlbfs/inode.c-1046-#endif\nfs/hugetlbfs/inode.c-1047-\nfs/hugetlbfs/inode.c:1048:static int hugetlbfs_error_remove_folio(struct address_space *mapping,\nfs/hugetlbfs/inode.c-1049-\t\t\t\tstruct folio *folio)\n--\nfs/hugetlbfs/inode.c-1056- */\nfs/hugetlbfs/inode.c:1057:static int hugetlbfs_show_options(struct seq_file *m, struct dentry *root)\nfs/hugetlbfs/inode.c-1058-{\nfs/hugetlbfs/inode.c:1059:\tstruct hugetlbfs_sb_info *sbinfo = HUGETLBFS_SB(root-\u003ed_sb);\nfs/hugetlbfs/inode.c-1060-\tstruct hugepage_subpool *spool = sbinfo-\u003espool;\n--\nfs/hugetlbfs/inode.c-1093-\nfs/hugetlbfs/inode.c:1094:static int hugetlbfs_statfs(struct dentry *dentry, struct kstatfs *buf)\nfs/hugetlbfs/inode.c-1095-{\nfs/hugetlbfs/inode.c:1096:\tstruct hugetlbfs_sb_info *sbinfo = HUGETLBFS_SB(dentry-\u003ed_sb);\nfs/hugetlbfs/inode.c-1097-\tstruct hstate *h = hstate_inode(d_inode(dentry));\n--\nfs/hugetlbfs/inode.c-1128-\nfs/hugetlbfs/inode.c:1129:static void hugetlbfs_put_super(struct super_block *sb)\nfs/hugetlbfs/inode.c-1130-{\nfs/hugetlbfs/inode.c:1131:\tstruct hugetlbfs_sb_info *sbi = HUGETLBFS_SB(sb);\nfs/hugetlbfs/inode.c-1132-\n--\nfs/hugetlbfs/inode.c-1141-\nfs/hugetlbfs/inode.c:1142:static inline int hugetlbfs_dec_free_inodes(struct hugetlbfs_sb_info *sbinfo)\nfs/hugetlbfs/inode.c-1143-{\n--\nfs/hugetlbfs/inode.c-1156-\nfs/hugetlbfs/inode.c:1157:static void hugetlbfs_inc_free_inodes(struct hugetlbfs_sb_info *sbinfo)\nfs/hugetlbfs/inode.c-1158-{\n--\nfs/hugetlbfs/inode.c-1166-\nfs/hugetlbfs/inode.c:1167:static struct kmem_cache *hugetlbfs_inode_cachep;\nfs/hugetlbfs/inode.c-1168-\nfs/hugetlbfs/inode.c:1169:static struct inode *hugetlbfs_alloc_inode(struct super_block *sb)\nfs/hugetlbfs/inode.c-1170-{\nfs/hugetlbfs/inode.c:1171:\tstruct hugetlbfs_sb_info *sbinfo = HUGETLBFS_SB(sb);\nfs/hugetlbfs/inode.c:1172:\tstruct hugetlbfs_inode_info *p;\nfs/hugetlbfs/inode.c-1173-\nfs/hugetlbfs/inode.c:1174:\tif (unlikely(!hugetlbfs_dec_free_inodes(sbinfo)))\nfs/hugetlbfs/inode.c-1175-\t\treturn NULL;\nfs/hugetlbfs/inode.c:1176:\tp = alloc_inode_sb(sb, hugetlbfs_inode_cachep, GFP_KERNEL);\nfs/hugetlbfs/inode.c-1177-\tif (unlikely(!p)) {\nfs/hugetlbfs/inode.c:1178:\t\thugetlbfs_inc_free_inodes(sbinfo);\nfs/hugetlbfs/inode.c-1179-\t\treturn NULL;\n--\nfs/hugetlbfs/inode.c-1183-\nfs/hugetlbfs/inode.c:1184:static void hugetlbfs_free_inode(struct inode *inode)\nfs/hugetlbfs/inode.c-1185-{\nfs/hugetlbfs/inode.c:1186:\ttrace_hugetlbfs_free_inode(inode);\nfs/hugetlbfs/inode.c:1187:\tkmem_cache_free(hugetlbfs_inode_cachep, HUGETLBFS_I(inode));\nfs/hugetlbfs/inode.c-1188-}\nfs/hugetlbfs/inode.c-1189-\nfs/hugetlbfs/inode.c:1190:static void hugetlbfs_destroy_inode(struct inode *inode)\nfs/hugetlbfs/inode.c-1191-{\nfs/hugetlbfs/inode.c:1192:\thugetlbfs_inc_free_inodes(HUGETLBFS_SB(inode-\u003ei_sb));\nfs/hugetlbfs/inode.c-1193-}\nfs/hugetlbfs/inode.c-1194-\nfs/hugetlbfs/inode.c:1195:static const struct address_space_operations hugetlbfs_aops = {\nfs/hugetlbfs/inode.c:1196:\t.write_begin\t= hugetlbfs_write_begin,\nfs/hugetlbfs/inode.c:1197:\t.write_end\t= hugetlbfs_write_end,\nfs/hugetlbfs/inode.c-1198-\t.dirty_folio\t= noop_dirty_folio,\nfs/hugetlbfs/inode.c:1199:\t.migrate_folio = hugetlbfs_migrate_folio,\nfs/hugetlbfs/inode.c:1200:\t.error_remove_folio\t= hugetlbfs_error_remove_folio,\nfs/hugetlbfs/inode.c-1201-};\n--\nfs/hugetlbfs/inode.c=1204=static void init_once(void *foo)\nfs/hugetlbfs/inode.c-1205-{\nfs/hugetlbfs/inode.c:1206:\tstruct hugetlbfs_inode_info *ei = foo;\nfs/hugetlbfs/inode.c-1207-\n--\nfs/hugetlbfs/inode.c-1210-\nfs/hugetlbfs/inode.c:1211:static const struct file_operations hugetlbfs_file_operations = {\nfs/hugetlbfs/inode.c:1212:\t.read_iter\t\t= hugetlbfs_read_iter,\nfs/hugetlbfs/inode.c:1213:\t.mmap\t\t\t= hugetlbfs_file_mmap,\nfs/hugetlbfs/inode.c-1214-\t.fsync\t\t\t= noop_fsync,\n--\nfs/hugetlbfs/inode.c-1216-\t.llseek\t\t\t= default_llseek,\nfs/hugetlbfs/inode.c:1217:\t.fallocate\t\t= hugetlbfs_fallocate,\nfs/hugetlbfs/inode.c-1218-\t.fop_flags\t\t= FOP_HUGE_PAGES,\n--\nfs/hugetlbfs/inode.c-1220-\nfs/hugetlbfs/inode.c:1221:static const struct inode_operations hugetlbfs_dir_inode_operations = {\nfs/hugetlbfs/inode.c:1222:\t.create\t\t= hugetlbfs_create,\nfs/hugetlbfs/inode.c-1223-\t.lookup\t\t= simple_lookup,\n--\nfs/hugetlbfs/inode.c-1225-\t.unlink\t\t= simple_unlink,\nfs/hugetlbfs/inode.c:1226:\t.symlink\t= hugetlbfs_symlink,\nfs/hugetlbfs/inode.c:1227:\t.mkdir\t\t= hugetlbfs_mkdir,\nfs/hugetlbfs/inode.c-1228-\t.rmdir\t\t= simple_rmdir,\nfs/hugetlbfs/inode.c:1229:\t.mknod\t\t= hugetlbfs_mknod,\nfs/hugetlbfs/inode.c-1230-\t.rename\t\t= simple_rename,\nfs/hugetlbfs/inode.c:1231:\t.setattr\t= hugetlbfs_setattr,\nfs/hugetlbfs/inode.c:1232:\t.tmpfile\t= hugetlbfs_tmpfile,\nfs/hugetlbfs/inode.c-1233-};\nfs/hugetlbfs/inode.c-1234-\nfs/hugetlbfs/inode.c:1235:static const struct inode_operations hugetlbfs_inode_operations = {\nfs/hugetlbfs/inode.c:1236:\t.setattr\t= hugetlbfs_setattr,\nfs/hugetlbfs/inode.c-1237-};\nfs/hugetlbfs/inode.c-1238-\nfs/hugetlbfs/inode.c:1239:static const struct super_operations hugetlbfs_ops = {\nfs/hugetlbfs/inode.c:1240:\t.alloc_inode = hugetlbfs_alloc_inode,\nfs/hugetlbfs/inode.c:1241:\t.free_inode = hugetlbfs_free_inode,\nfs/hugetlbfs/inode.c:1242:\t.destroy_inode = hugetlbfs_destroy_inode,\nfs/hugetlbfs/inode.c:1243:\t.evict_inode\t= hugetlbfs_evict_inode,\nfs/hugetlbfs/inode.c:1244:\t.statfs\t\t= hugetlbfs_statfs,\nfs/hugetlbfs/inode.c:1245:\t.put_super\t= hugetlbfs_put_super,\nfs/hugetlbfs/inode.c:1246:\t.show_options\t= hugetlbfs_show_options,\nfs/hugetlbfs/inode.c-1247-};\n--\nfs/hugetlbfs/inode.c=1254=static long\nfs/hugetlbfs/inode.c:1255:hugetlbfs_size_to_hpages(struct hstate *h, unsigned long long size_opt,\nfs/hugetlbfs/inode.c:1256:\t\t\t enum hugetlbfs_size_type val_type)\nfs/hugetlbfs/inode.c-1257-{\n--\nfs/hugetlbfs/inode.c-1273- */\nfs/hugetlbfs/inode.c:1274:static int hugetlbfs_parse_param(struct fs_context *fc, struct fs_parameter *param)\nfs/hugetlbfs/inode.c-1275-{\nfs/hugetlbfs/inode.c:1276:\tstruct hugetlbfs_fs_context *ctx = fc-\u003efs_private;\nfs/hugetlbfs/inode.c-1277-\tstruct fs_parse_result result;\n--\nfs/hugetlbfs/inode.c-1348- */\nfs/hugetlbfs/inode.c:1349:static int hugetlbfs_validate(struct fs_context *fc)\nfs/hugetlbfs/inode.c-1350-{\nfs/hugetlbfs/inode.c:1351:\tstruct hugetlbfs_fs_context *ctx = fc-\u003efs_private;\nfs/hugetlbfs/inode.c-1352-\n--\nfs/hugetlbfs/inode.c-1356-\t */\nfs/hugetlbfs/inode.c:1357:\tctx-\u003emax_hpages = hugetlbfs_size_to_hpages(ctx-\u003ehstate,\nfs/hugetlbfs/inode.c-1358-\t\t\t\t\t\t ctx-\u003emax_size_opt,\nfs/hugetlbfs/inode.c-1359-\t\t\t\t\t\t ctx-\u003emax_val_type);\nfs/hugetlbfs/inode.c:1360:\tctx-\u003emin_hpages = hugetlbfs_size_to_hpages(ctx-\u003ehstate,\nfs/hugetlbfs/inode.c-1361-\t\t\t\t\t\t ctx-\u003emin_size_opt,\n--\nfs/hugetlbfs/inode.c=1376=static int\nfs/hugetlbfs/inode.c:1377:hugetlbfs_fill_super(struct super_block *sb, struct fs_context *fc)\nfs/hugetlbfs/inode.c-1378-{\nfs/hugetlbfs/inode.c:1379:\tstruct hugetlbfs_fs_context *ctx = fc-\u003efs_private;\nfs/hugetlbfs/inode.c:1380:\tstruct hugetlbfs_sb_info *sbinfo;\nfs/hugetlbfs/inode.c-1381-\nfs/hugetlbfs/inode.c:1382:\tsbinfo = kmalloc_obj(struct hugetlbfs_sb_info);\nfs/hugetlbfs/inode.c-1383-\tif (!sbinfo)\n--\nfs/hugetlbfs/inode.c-1410-\tsb-\u003es_magic = HUGETLBFS_MAGIC;\nfs/hugetlbfs/inode.c:1411:\tsb-\u003es_op = \u0026hugetlbfs_ops;\nfs/hugetlbfs/inode.c-1412-\tsb-\u003es_d_flags = DCACHE_DONTCACHE;\n--\nfs/hugetlbfs/inode.c-1415-\t/*\nfs/hugetlbfs/inode.c:1416:\t * Due to the special and limited functionality of hugetlbfs, it does\nfs/hugetlbfs/inode.c-1417-\t * not work well as a stacking filesystem.\n--\nfs/hugetlbfs/inode.c-1419-\tsb-\u003es_stack_depth = FILESYSTEM_MAX_STACK_DEPTH;\nfs/hugetlbfs/inode.c:1420:\tsb-\u003es_root = d_make_root(hugetlbfs_get_root(sb, ctx));\nfs/hugetlbfs/inode.c-1421-\tif (!sb-\u003es_root)\n--\nfs/hugetlbfs/inode.c-1429-\nfs/hugetlbfs/inode.c:1430:static int hugetlbfs_get_tree(struct fs_context *fc)\nfs/hugetlbfs/inode.c-1431-{\nfs/hugetlbfs/inode.c:1432:\tint err = hugetlbfs_validate(fc);\nfs/hugetlbfs/inode.c-1433-\tif (err)\nfs/hugetlbfs/inode.c-1434-\t\treturn err;\nfs/hugetlbfs/inode.c:1435:\treturn get_tree_nodev(fc, hugetlbfs_fill_super);\nfs/hugetlbfs/inode.c-1436-}\nfs/hugetlbfs/inode.c-1437-\nfs/hugetlbfs/inode.c:1438:static void hugetlbfs_fs_context_free(struct fs_context *fc)\nfs/hugetlbfs/inode.c-1439-{\n--\nfs/hugetlbfs/inode.c-1442-\nfs/hugetlbfs/inode.c:1443:static const struct fs_context_operations hugetlbfs_fs_context_ops = {\nfs/hugetlbfs/inode.c:1444:\t.free\t\t= hugetlbfs_fs_context_free,\nfs/hugetlbfs/inode.c:1445:\t.parse_param\t= hugetlbfs_parse_param,\nfs/hugetlbfs/inode.c:1446:\t.get_tree\t= hugetlbfs_get_tree,\nfs/hugetlbfs/inode.c-1447-};\nfs/hugetlbfs/inode.c-1448-\nfs/hugetlbfs/inode.c:1449:static int hugetlbfs_init_fs_context(struct fs_context *fc)\nfs/hugetlbfs/inode.c-1450-{\nfs/hugetlbfs/inode.c:1451:\tstruct hugetlbfs_fs_context *ctx;\nfs/hugetlbfs/inode.c-1452-\nfs/hugetlbfs/inode.c:1453:\tctx = kzalloc_obj(struct hugetlbfs_fs_context);\nfs/hugetlbfs/inode.c-1454-\tif (!ctx)\n--\nfs/hugetlbfs/inode.c-1466-\tfc-\u003efs_private = ctx;\nfs/hugetlbfs/inode.c:1467:\tfc-\u003eops\t= \u0026hugetlbfs_fs_context_ops;\nfs/hugetlbfs/inode.c-1468-\treturn 0;\n--\nfs/hugetlbfs/inode.c-1470-\nfs/hugetlbfs/inode.c:1471:static struct file_system_type hugetlbfs_fs_type = {\nfs/hugetlbfs/inode.c:1472:\t.name\t\t\t= \"hugetlbfs\",\nfs/hugetlbfs/inode.c:1473:\t.init_fs_context\t= hugetlbfs_init_fs_context,\nfs/hugetlbfs/inode.c-1474-\t.parameters\t\t= hugetlb_fs_parameters,\n--\nfs/hugetlbfs/inode.c-1478-\nfs/hugetlbfs/inode.c:1479:static struct vfsmount *hugetlbfs_vfsmount[HUGE_MAX_HSTATE];\nfs/hugetlbfs/inode.c-1480-\n--\nfs/hugetlbfs/inode.c=1501=struct file *hugetlb_file_setup(const char *name, size_t size,\n--\nfs/hugetlbfs/inode.c-1513-\nfs/hugetlbfs/inode.c:1514:\tmnt = hugetlbfs_vfsmount[hstate_idx];\nfs/hugetlbfs/inode.c-1515-\tif (!mnt)\n--\nfs/hugetlbfs/inode.c-1529-\tfile = ERR_PTR(-ENOSPC);\nfs/hugetlbfs/inode.c:1530:\t/* hugetlbfs_vfsmount[] mounts do not use idmapped mounts. */\nfs/hugetlbfs/inode.c:1531:\tinode = hugetlbfs_get_inode(mnt-\u003emnt_sb, \u0026nop_mnt_idmap, NULL,\nfs/hugetlbfs/inode.c-1532-\t\t\t\t S_IFREG | S_IRWXUGO, 0);\n--\nfs/hugetlbfs/inode.c-1546-\t\tfile = alloc_file_pseudo(inode, mnt, name, O_RDWR,\nfs/hugetlbfs/inode.c:1547:\t\t\t\t\t\u0026hugetlbfs_file_operations);\nfs/hugetlbfs/inode.c-1548-\tif (!IS_ERR(file))\n--\nfs/hugetlbfs/inode.c-1555-\nfs/hugetlbfs/inode.c:1556:static struct vfsmount *__init mount_one_hugetlbfs(struct hstate *h)\nfs/hugetlbfs/inode.c-1557-{\n--\nfs/hugetlbfs/inode.c-1560-\nfs/hugetlbfs/inode.c:1561:\tfc = fs_context_for_mount(\u0026hugetlbfs_fs_type, SB_KERNMOUNT);\nfs/hugetlbfs/inode.c-1562-\tif (IS_ERR(fc)) {\n--\nfs/hugetlbfs/inode.c-1564-\t} else {\nfs/hugetlbfs/inode.c:1565:\t\tstruct hugetlbfs_fs_context *ctx = fc-\u003efs_private;\nfs/hugetlbfs/inode.c-1566-\t\tctx-\u003ehstate = h;\n--\nfs/hugetlbfs/inode.c-1570-\tif (IS_ERR(mnt))\nfs/hugetlbfs/inode.c:1571:\t\tpr_err(\"Cannot mount internal hugetlbfs for page size %luK\",\nfs/hugetlbfs/inode.c-1572-\t\t huge_page_size(h) / SZ_1K);\n--\nfs/hugetlbfs/inode.c-1575-\nfs/hugetlbfs/inode.c:1576:static int __init init_hugetlbfs_fs(void)\nfs/hugetlbfs/inode.c-1577-{\n--\nfs/hugetlbfs/inode.c-1588-\terror = -ENOMEM;\nfs/hugetlbfs/inode.c:1589:\thugetlbfs_inode_cachep = kmem_cache_create(\"hugetlbfs_inode_cache\",\nfs/hugetlbfs/inode.c:1590:\t\t\t\t\tsizeof(struct hugetlbfs_inode_info),\nfs/hugetlbfs/inode.c-1591-\t\t\t\t\t0, SLAB_ACCOUNT, init_once);\nfs/hugetlbfs/inode.c:1592:\tif (hugetlbfs_inode_cachep == NULL)\nfs/hugetlbfs/inode.c-1593-\t\tgoto out;\nfs/hugetlbfs/inode.c-1594-\nfs/hugetlbfs/inode.c:1595:\terror = register_filesystem(\u0026hugetlbfs_fs_type);\nfs/hugetlbfs/inode.c-1596-\tif (error)\n--\nfs/hugetlbfs/inode.c-1599-\t/* default hstate mount is required */\nfs/hugetlbfs/inode.c:1600:\tmnt = mount_one_hugetlbfs(\u0026default_hstate);\nfs/hugetlbfs/inode.c-1601-\tif (IS_ERR(mnt)) {\n--\nfs/hugetlbfs/inode.c-1604-\t}\nfs/hugetlbfs/inode.c:1605:\thugetlbfs_vfsmount[default_hstate_idx] = mnt;\nfs/hugetlbfs/inode.c-1606-\n--\nfs/hugetlbfs/inode.c-1614-\nfs/hugetlbfs/inode.c:1615:\t\tmnt = mount_one_hugetlbfs(h);\nfs/hugetlbfs/inode.c-1616-\t\tif (IS_ERR(mnt))\nfs/hugetlbfs/inode.c:1617:\t\t\thugetlbfs_vfsmount[i] = NULL;\nfs/hugetlbfs/inode.c-1618-\t\telse\nfs/hugetlbfs/inode.c:1619:\t\t\thugetlbfs_vfsmount[i] = mnt;\nfs/hugetlbfs/inode.c-1620-\t\ti++;\n--\nfs/hugetlbfs/inode.c-1625- out_unreg:\nfs/hugetlbfs/inode.c:1626:\t(void)unregister_filesystem(\u0026hugetlbfs_fs_type);\nfs/hugetlbfs/inode.c-1627- out_free:\nfs/hugetlbfs/inode.c:1628:\tkmem_cache_destroy(hugetlbfs_inode_cachep);\nfs/hugetlbfs/inode.c-1629- out:\n--\nfs/hugetlbfs/inode.c-1631-}\nfs/hugetlbfs/inode.c:1632:fs_initcall(init_hugetlbfs_fs)\n"
} |
| 9/2 | 2026/09/03 23:58 | llm | patch-evaluator |
0mModel:gemini-3.7-flash Args: null Results: null Tokens: input: 20236 output: 32 thoughts: 33 Thoughts: Okay, here's my take on those thoughts, tailored for an expert audience: **Investigating Hugetlbfs Configuration** Right, let's dive straight in. My immediate thought is to zero in on `fs/Kconfig`. That's where all the interesting kernel configuration options are defined, and specifically, I'm betting the crucial ones for Hugetlbfs and huge pages will be in there. I'm thinking around line 250, give or take a few lines – that's often where related options tend to cluster. I need to refresh my memory on the precise config symbols, so I want to pinpoint the definitions of `HUGETLBFS` and `HUGETLB_PAGE`. Knowing the exact options is key. I need to quickly identify their dependencies, defaults, and any associated help text. I want to understand what's required for them to be enabled or disabled, and how they relate to each other. This should clarify the overall configuration landscape for Hugetlbfs within the kernel. |
| 10/2 | 2026/09/03 23:58 | tool | read-file |
0mArgs:{
"File": "fs/Kconfig",
"FirstLine": 245,
"LineCount": 30
}Results: {
"Contents": " 245:\t\t If unsure, say N.\n 246:\t\n 247:\tconfig ARCH_SUPPORTS_HUGETLBFS\n 248:\t\tdef_bool n\n 249:\t\n 250:\tmenuconfig HUGETLBFS\n 251:\t\tbool \"HugeTLB file system support\"\n 252:\t\tdepends on ARCH_SUPPORTS_HUGETLBFS\n 253:\t\tselect MEMFD_CREATE\n 254:\t\tselect PADATA if SMP\n 255:\t\thelp\n 256:\t\t hugetlbfs is a filesystem backing for HugeTLB pages, based on\n 257:\t\t ramfs. For architectures that support it, say Y here and read\n 258:\t\t \u003cfile:Documentation/admin-guide/mm/hugetlbpage.rst\u003e for details.\n 259:\t\n 260:\t\t If unsure, say N.\n 261:\t\n 262:\tif HUGETLBFS\n 263:\tconfig HUGETLB_PAGE_OPTIMIZE_VMEMMAP_DEFAULT_ON\n 264:\t\tbool \"HugeTLB Vmemmap Optimization (HVO) defaults to on\"\n 265:\t\tdefault n\n 266:\t\tdepends on HUGETLB_PAGE_OPTIMIZE_VMEMMAP\n 267:\t\thelp\n 268:\t\t The HugeTLB Vmemmap Optimization (HVO) defaults to off. Say Y here to\n 269:\t\t enable HVO by default. It can be disabled via hugetlb_free_vmemmap=off\n 270:\t\t (boot command line) or hugetlb_optimize_vmemmap (sysctl).\n 271:\tendif # HUGETLBFS\n 272:\t\n 273:\tconfig HUGETLB_PAGE\n 274:\t\tdef_bool HUGETLBFS\n"
} |
| 11/2 | 2026/09/03 23:58 | llm | patch-evaluator |
0mModel:gemini-3.7-flash Args: null Results: null Tokens: input: 20996 output: 38 thoughts: 226 Thoughts: **Analyzing the Implications of CONFIG_HUGETLBFS** Okay, so `CONFIG_HUGETLBFS` is enabled, which, as I know, automatically means `HUGETLB_PAGE` is also enabled. Let's dig into the details of this patch. I need to understand the impact of these changes. First, I need to see which symbols are being touched. I see changes to `hugetlbfs_statfs` in `fs/hugetlbfs/inode.c`. That's important for understanding file system statistics with hugetlb pages. Then there are some static functions in `mm/hugetlb.c`: `hugepage_subpool_get_pages`, `hugepage_subpool_put_pages`, and `subpool_is_free`. The use of static is significant, as it limits their visibility and usage. Lastly, I notice two non-static functions, `alloc_hugetlb_folio` and `hugetlb_reserve_pages`, also in `mm/hugetlb.c`. Now, I'm particularly interested in those subpool functions. I need to confirm that `hugepage_subpool_get_pages` and `hugepage_subpool_put_pages` are indeed static, and, more importantly, I need to trace their callers. Understanding where these subpool functions are used is critical for grasping the scope and potential implications of these changes in the memory management of hugetlb pages. This analysis will help me assess the patch's potential impact. |
| 12/2 | 2026/09/03 23:58 | tool | grepper |
0mArgs:{
"Expression": "hugepage_subpool_(get|put)_pages",
"PathPrefix": "mm/hugetlb.c"
}Results: {
"Output": "mm/hugetlb.c=179=void hugepage_put_subpool(struct hugepage_subpool *spool)\n--\nmm/hugetlb.c-192-/**\nmm/hugetlb.c:193: * hugepage_subpool_get_pages - Get pages from a subpool\nmm/hugetlb.c-194- * @spool: pointer to subpool structure (may be NULL)\n--\nmm/hugetlb.c-204- */\nmm/hugetlb.c:205:static long hugepage_subpool_get_pages(struct hugepage_subpool *spool,\nmm/hugetlb.c-206-\t\t\t\t long delta)\n--\nmm/hugetlb.c-243-/**\nmm/hugetlb.c:244: * hugepage_subpool_put_pages - Release pages back to a subpool\nmm/hugetlb.c-245- * @spool: pointer to subpool structure (may be NULL)\n--\nmm/hugetlb.c-256- */\nmm/hugetlb.c:257:static long hugepage_subpool_put_pages(struct hugepage_subpool *spool,\nmm/hugetlb.c-258-\t\t\t\t long delta)\n--\nmm/hugetlb.c=975=void hugetlb_fix_reserve_counts(struct inode *inode)\n--\nmm/hugetlb.c-980-\nmm/hugetlb.c:981:\trsv_adjust = hugepage_subpool_get_pages(spool, 1);\nmm/hugetlb.c-982-\tif (rsv_adjust \u003e 0) {\n--\nmm/hugetlb.c=1686=void free_huge_folio(struct folio *folio)\n--\nmm/hugetlb.c-1711-\t * would have been a page reserved in the subpool before allocation\nmm/hugetlb.c:1712:\t * via hugepage_subpool_get_pages(). Since we are 'restoring' the\nmm/hugetlb.c:1713:\t * reservation, do not call hugepage_subpool_put_pages() as this will\nmm/hugetlb.c-1714-\t * remove the reserved page from the subpool.\n--\nmm/hugetlb.c-1722-\t\t */\nmm/hugetlb.c:1723:\t\tif (hugepage_subpool_put_pages(spool, 1) == 0)\nmm/hugetlb.c-1724-\t\t\trestore_reserve = true;\n--\nmm/hugetlb.c=2952=struct folio *alloc_hugetlb_folio(struct vm_area_struct *vma,\n--\nmm/hugetlb.c-2996-\tif (map_chg) {\nmm/hugetlb.c:2997:\t\tgbl_resv_get = hugepage_subpool_get_pages(spool, 1);\nmm/hugetlb.c-2998-\t\tif (gbl_resv_get \u003c 0) {\n--\nmm/hugetlb.c-3062-\nmm/hugetlb.c:3063:\t\t\trsv_adjust = hugepage_subpool_put_pages(spool, 1);\nmm/hugetlb.c-3064-\t\t\thugetlb_acct_memory(h, -rsv_adjust);\n--\nmm/hugetlb.c-3075-\tif (map_chg) {\nmm/hugetlb.c:3076:\t\tlong gbl_resv_put = hugepage_subpool_put_pages(spool, 1);\nmm/hugetlb.c-3077-\n--\nmm/hugetlb.c=4719=static void hugetlb_vm_op_close(struct vm_area_struct *vma)\n--\nmm/hugetlb.c-4742-\t\t */\nmm/hugetlb.c:4743:\t\tgbl_reserve = hugepage_subpool_put_pages(spool, reserve);\nmm/hugetlb.c-4744-\t\thugetlb_acct_memory(h, -gbl_reserve);\n--\nmm/hugetlb.c=6669=long hugetlb_reserve_pages(struct inode *inode,\n--\nmm/hugetlb.c-6755-\t */\nmm/hugetlb.c:6756:\tgbl_resv_get = hugepage_subpool_get_pages(spool, chg);\nmm/hugetlb.c-6757-\tif (gbl_resv_get \u003c 0) {\n--\nmm/hugetlb.c-6805-\nmm/hugetlb.c:6806:\t\t\trsv_adjust = hugepage_subpool_put_pages(spool,\nmm/hugetlb.c-6807-\t\t\t\t\t\t\t\tchg - add);\n--\nmm/hugetlb.c-6826-\t */\nmm/hugetlb.c:6827:\tgbl_resv_put = hugepage_subpool_put_pages(spool, chg);\nmm/hugetlb.c-6828-\t/*\n--\nmm/hugetlb.c=6854=long hugetlb_unreserve_pages(struct inode *inode, long start, long end,\n--\nmm/hugetlb.c-6888-\t */\nmm/hugetlb.c:6889:\tgbl_reserve = hugepage_subpool_put_pages(spool, (chg - freed));\nmm/hugetlb.c-6890-\thugetlb_acct_memory(h, -gbl_reserve);\n"
} |
| 13/2 | 2026/09/03 23:58 | llm | patch-evaluator |
0mModel:gemini-3.7-flash Args: null Results: null Tokens: input: 23051 output: 33 thoughts: 354 Thoughts: **Analyzing Huge Page Subpool Functionality** Okay, let's dive into this. My initial instinct is to focus on `hugepage_subpool_get_pages` and `hugepage_subpool_put_pages`. Even though they're static within `mm/hugetlb.c`, and I'm aware static functions that aren't inlined *do* have symbols in vmlinux, I need to make sure I'm following best practices. Time to refresh on the guidelines... right, the relevant section is: "TARGET SPECIFIC FEATURE LOGIC AND ENTRYPOINTS" and "HANDLING STATIC INLINE FUNCTIONS IN HEADERS". So, I'm noting that `hugepage_subpool_get_pages` and `hugepage_subpool_put_pages` are static *non-inline* functions located in a `.c` file, specifically `mm/hugetlb.c`. That's important. It means they'll show up as symbols. Now, to satisfy the guidelines, I need to identify the non-static, exported, or caller functions. Ah, here we go: I've identified the functions that are either the entry points to the subsystem or are modified due to the change in the static functions. The functions are: `hugetlb_reserve_pages`, `alloc_hugetlb_folio`, `hugetlbfs_statfs`, `hugepage_subpool_get_pages`, `hugepage_subpool_put_pages`, `hugepage_put_subpool`, `hugetlb_unreserve_pages`. I'm now ready to look for the other functions involved in this area, specifically the ones that call `unlock_or_release_subpool` / `subpool_is_free`, which will give me a more complete picture of the interactions in this area. |
| 14/2 | 2026/09/03 23:58 | tool | grepper |
0mArgs:{
"Expression": "subpool_is_free",
"PathPrefix": "mm/hugetlb.c"
}Results: {
"Output": "mm/hugetlb.c=127=static struct resv_map *vma_resv_map(struct vm_area_struct *vma);\nmm/hugetlb.c-128-\nmm/hugetlb.c:129:static inline bool subpool_is_free(struct hugepage_subpool *spool)\nmm/hugetlb.c-130-{\n--\nmm/hugetlb.c=137=static inline void unlock_or_release_subpool(struct hugepage_subpool *spool,\n--\nmm/hugetlb.c-139-{\nmm/hugetlb.c:140:\tbool free_subpool = subpool_is_free(spool);\nmm/hugetlb.c-141-\n"
} |
| 15/2 | 2026/09/03 23:58 | llm | patch-evaluator |
0mModel:gemini-3.7-flash Args: null Results: null Tokens: input: 24037 output: 35 thoughts: 16 Thoughts: Here's my analysis of the situation: **Investigating the Callers of `unlock_or_release_subpool`** Okay, so the task at hand is to understand the context surrounding the `unlock_or_release_subpool` function. My immediate thought is to trace its usage. I need to figure out which other parts of the system are actually *calling* this particular function. It's crucial because the function's name suggests it has something to do with either unlocking or releasing a subpool, which is a very specific type of data structure, presumably, related to resource management or concurrency control. Understanding where it's being invoked will reveal its purpose and, perhaps more importantly, the critical paths of execution that depend on its correct operation. I need to be able to determine the potential side effects associated with the call, and whether the function is used in several different places or only a handful. This will inform my investigation significantly. |
| 16/2 | 2026/09/03 23:58 | tool | grepper |
0mArgs:{
"Expression": "unlock_or_release_subpool",
"PathPrefix": "mm/hugetlb.c"
}Results: {
"Output": "mm/hugetlb.c=129=static inline bool subpool_is_free(struct hugepage_subpool *spool)\n--\nmm/hugetlb.c-136-\nmm/hugetlb.c:137:static inline void unlock_or_release_subpool(struct hugepage_subpool *spool,\nmm/hugetlb.c-138-\t\t\t\t\t\tunsigned long irq_flags)\n--\nmm/hugetlb.c=179=void hugepage_put_subpool(struct hugepage_subpool *spool)\n--\nmm/hugetlb.c-188-\tspool-\u003ecount--;\nmm/hugetlb.c:189:\tunlock_or_release_subpool(spool, flags);\nmm/hugetlb.c-190-}\n--\nmm/hugetlb.c=257=static long hugepage_subpool_put_pages(struct hugepage_subpool *spool,\n--\nmm/hugetlb.c-291-\t */\nmm/hugetlb.c:292:\tunlock_or_release_subpool(spool, flags);\nmm/hugetlb.c-293-\n"
} |
| 17/2 | 2026/09/03 23:58 | llm | patch-evaluator |
0mModel:gemini-3.7-flash Args: null Results: null Tokens: input: 24592 output: 29 thoughts: 35 Thoughts: **Investigating HugeTLB Page Reservations** Okay, time to dig into this `hugetlb` situation. My immediate focus is on understanding how `hugetlb_reserve_pages` is being used. I need to get a clear picture of the call stack; essentially, where are the points in the code that actually invoke this function? That's the critical first step. Next, I'll need to correlate that information with the broader use cases of the hugetlbfs subsystem in general. Let's see what the code reveals. This will likely involve some grep work and following call graphs. Knowing this, I can begin to grasp what the kernel is doing with these pages, understand any possible contention issues and address the root of any related performance problems. |
| 18/2 | 2026/09/03 23:59 | tool | grepper |
0mArgs:{
"Expression": "hugetlb_reserve_pages",
"PathPrefix": "fs/"
}Results: {
"Output": "fs/hugetlbfs/inode.c=99=static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma)\n--\nfs/hugetlbfs/inode.c-152-\nfs/hugetlbfs/inode.c:153:\tif (hugetlb_reserve_pages(inode,\nfs/hugetlbfs/inode.c-154-\t\t\t\tvma-\u003evm_pgoff \u003e\u003e huge_page_order(h),\n--\nfs/hugetlbfs/inode.c=1488=static int get_hstate_idx(int page_size_log)\n--\nfs/hugetlbfs/inode.c-1498- * Note that size should be aligned to proper hugepage size in caller side,\nfs/hugetlbfs/inode.c:1499: * otherwise hugetlb_reserve_pages reserves one less hugepages than intended.\nfs/hugetlbfs/inode.c-1500- */\nfs/hugetlbfs/inode.c=1501=struct file *hugetlb_file_setup(const char *name, size_t size,\n--\nfs/hugetlbfs/inode.c-1540-\nfs/hugetlbfs/inode.c:1541:\tif (hugetlb_reserve_pages(inode, 0,\nfs/hugetlbfs/inode.c-1542-\t\t\tsize \u003e\u003e huge_page_shift(hstate_inode(inode)), NULL,\n"
} |
| 19/2 | 2026/09/03 23:59 | llm | patch-evaluator |
0mModel:gemini-3.7-flash Args: null Results: null Tokens: input: 25196 output: 29 thoughts: 18 Thoughts: Here's my take on those thoughts, tailored for an expert audience: **Diving into HugeTLB Reservation** Alright, let's get down to brass tacks. My initial thought process is squarely focused on `hugetlb_reserve_pages` within the `mm/` directory. That function is the linchpin for understanding how we carve out and manage those precious HugeTLB pages, and it's where I need to start. I want to quickly evaluate how the reservation logic is implemented here. I'm thinking about the allocation policy it employs, potential edge cases around fragmentation, and especially how it interacts with NUMA node constraints (if it does). Any obvious flaws or areas that could benefit from performance tuning come to mind. I'm digging deeper into how it interacts with the rest of the HugeTLB infrastructure—the mapping, the fault handling, and, of course, deallocation. Essentially, I'm trying to get a quick mental map of the reservation process to evaluate it. |
| 20/2 | 2026/09/03 23:59 | tool | grepper |
0mArgs:{
"Expression": "hugetlb_reserve_pages",
"PathPrefix": "mm/"
}Results: {
"Output": "mm/hugetlb.c=2952=struct folio *alloc_hugetlb_folio(struct vm_area_struct *vma,\n--\nmm/hugetlb.c-3053-\t\t * vma_needs_reservation and vma_commit_reservation.\nmm/hugetlb.c:3054:\t\t * This indicates a race with hugetlb_reserve_pages.\nmm/hugetlb.c-3055-\t\t * Adjust for the subpool count incremented above AND\nmm/hugetlb.c:3056:\t\t * in hugetlb_reserve_pages for the same page.\tAlso,\nmm/hugetlb.c:3057:\t\t * the reservation count added in hugetlb_reserve_pages\nmm/hugetlb.c-3058-\t\t * no longer applies.\n--\nmm/hugetlb.c=6493=long hugetlb_change_protection(struct vm_area_struct *vma,\n--\nmm/hugetlb.c-6668-\nmm/hugetlb.c:6669:long hugetlb_reserve_pages(struct inode *inode,\nmm/hugetlb.c-6670-\t\tlong from, long to,\n--\nmm/hugetlb.c-6711-\t\t/*\nmm/hugetlb.c:6712:\t\t * resv_map can not be NULL as hugetlb_reserve_pages is only\nmm/hugetlb.c-6713-\t\t * called for inodes for which resv_maps were created (see\n--\nmm/memfd.c=68=struct folio *memfd_alloc_folio(struct file *memfd, pgoff_t idx)\n--\nmm/memfd.c-89-\nmm/memfd.c:90:\t\tnr_resv = hugetlb_reserve_pages(inode, idx, idx + 1, NULL, EMPTY_VMA_FLAGS);\nmm/memfd.c-91-\t\tif (nr_resv \u003c 0)\n"
} |
| 21/2 | 2026/09/03 23:59 | llm | patch-evaluator |
0mModel:gemini-3.7-flash Args: null Results: null Tokens: input: 25962 output: 29 thoughts: 13 Thoughts: Here's a summary of my thought process, as if I were analyzing `alloc_hugetlb_folio`: **Deconstructing `alloc_hugetlb_folio`** Alright, let's dive into `alloc_hugetlb_folio`. Given my understanding of the memory management landscape, this function is obviously a critical piece. It's the gatekeeper for HugeTLB folio allocation, and therefore directly impacts the performance of applications that leverage huge pages. I need to understand this on an intimate level to optimize the code I work with. My immediate thought is to trace its origin and usage. What calls this function? What are the calling contexts? Is it called from a critical path? Does it handle any locking, or assume it's protected at a higher level? These are the first questions I would have to answer to figure out where and how to tweak it. I'd also need to scrutinize its internal logic. How does it interact with the underlying HugeTLB infrastructure? Does it utilize any internal data structures? Are there any potential bottlenecks, like contention on particular resources or overly complex algorithms? I'd look for areas where optimization might be possible, like pre-calculating values, or using more efficient allocation strategies. Also, I'd want to examine the error handling and recovery mechanisms. What happens if the allocation fails? Does it degrade gracefully? Are there retry mechanisms? How are errors reported, and how are they propagated up the call stack? This part is crucial for reliability. I'll need to know whether any failure modes could become an issue later on. Finally, I'd check for any potential memory leaks or memory fragmentation issues. Are resources properly released, especially in error paths? Does the function contribute to memory fragmentation over time? These are long-term considerations that are incredibly important for overall system stability. If there are any, they need to be addressed early! |
| 22/2 | 2026/09/03 23:59 | tool | grepper |
0mArgs:{
"Expression": "alloc_hugetlb_folio",
"PathPrefix": "mm/"
}Results: {
"Output": "mm/hugetlb.c=2155=struct folio *alloc_buddy_hugetlb_folio(struct hstate *h,\n--\nmm/hugetlb.c-2178-\nmm/hugetlb.c:2179:struct folio *alloc_hugetlb_folio_reserve(struct hstate *h, int preferred_nid,\nmm/hugetlb.c-2180-\t\tnodemask_t *nmask, gfp_t gfp_mask)\n--\nmm/hugetlb.c-2199-/* folio migration callback function */\nmm/hugetlb.c:2200:struct folio *alloc_hugetlb_folio_nodemask(struct hstate *h, int preferred_nid,\nmm/hugetlb.c-2201-\t\tnodemask_t *nmask, gfp_t gfp_mask, bool allow_alloc_fallback)\n--\nmm/hugetlb.c=2533=static long vma_del_reservation(struct hstate *h,\n--\nmm/hugetlb.c-2540- * This routine is called to restore reservation information on error paths.\nmm/hugetlb.c:2541: * It should ONLY be called for folios allocated via alloc_hugetlb_folio(),\nmm/hugetlb.c-2542- * and the hugetlb mutex should remain held when calling this routine.\n--\nmm/hugetlb.c-2547- * 2) No reservation was in place for the page, so hugetlb_restore_reserve is\nmm/hugetlb.c:2548: * not set. However, alloc_hugetlb_folio always updates the reserve map.\nmm/hugetlb.c-2549- *\n--\nmm/hugetlb.c-2556- *\nmm/hugetlb.c:2557: * In case 2, simply undo reserve map modifications done by alloc_hugetlb_folio.\nmm/hugetlb.c-2558- */\nmm/hugetlb.c=2559=void restore_reserve_on_error(struct hstate *h, struct vm_area_struct *vma,\n--\nmm/hugetlb.c-2585-\t\t\t * This indicates there is an entry in the reserve map\nmm/hugetlb.c:2586:\t\t\t * not added by alloc_hugetlb_folio. We know it was added\nmm/hugetlb.c:2587:\t\t\t * before the alloc_hugetlb_folio call, otherwise\nmm/hugetlb.c-2588-\t\t\t * hugetlb_restore_reserve would be set on the folio.\n--\nmm/hugetlb.c=2926=typedef enum {\n--\nmm/hugetlb.c-2951- */\nmm/hugetlb.c:2952:struct folio *alloc_hugetlb_folio(struct vm_area_struct *vma,\nmm/hugetlb.c-2953-\t\t\t\t unsigned long addr, bool cow_from_owner)\n--\nmm/hugetlb.c=4894=int copy_hugetlb_page_range(struct mm_struct *dst, struct mm_struct *src,\n--\nmm/hugetlb.c-5015-\t\t\t\t/* Do not use reserve as it's private owned */\nmm/hugetlb.c:5016:\t\t\t\tnew_folio = alloc_hugetlb_folio(dst_vma, addr, false);\nmm/hugetlb.c-5017-\t\t\t\tif (IS_ERR(new_folio)) {\n--\nmm/hugetlb.c=5487=static vm_fault_t hugetlb_wp(struct vm_fault *vmf)\n--\nmm/hugetlb.c-5568-\tspin_unlock(vmf-\u003eptl);\nmm/hugetlb.c:5569:\tnew_folio = alloc_hugetlb_folio(vma, vmf-\u003eaddress, cow_from_owner);\nmm/hugetlb.c-5570-\n--\nmm/hugetlb.c=5759=static vm_fault_t hugetlb_no_page(struct address_space *mapping,\n--\nmm/hugetlb.c-5828-\nmm/hugetlb.c:5829:\t\tfolio = alloc_hugetlb_folio(vma, vmf-\u003eaddress, false);\nmm/hugetlb.c-5830-\t\tif (IS_ERR(folio)) {\n--\nmm/hugetlb.c=6009=vm_fault_t hugetlb_fault(struct mm_struct *mm, struct vm_area_struct *vma,\n--\nmm/hugetlb.c-6244- */\nmm/hugetlb.c:6245:static struct folio *alloc_hugetlb_folio_vma(struct hstate *h,\nmm/hugetlb.c-6246-\t\tstruct vm_area_struct *vma, unsigned long address)\n--\nmm/hugetlb.c-6261-\t */\nmm/hugetlb.c:6262:\tfolio = alloc_hugetlb_folio_nodemask(h, node, nodemask, gfp_mask, false);\nmm/hugetlb.c-6263-\tmpol_cond_put(mpol);\n--\nmm/hugetlb.c=6272=int hugetlb_mfill_atomic_pte(pte_t *dst_pte,\n--\nmm/hugetlb.c-6328-\nmm/hugetlb.c:6329:\t\tfolio = alloc_hugetlb_folio(dst_vma, dst_addr, false);\nmm/hugetlb.c-6330-\t\tif (IS_ERR(folio)) {\n--\nmm/hugetlb.c-6354-\t\t\t */\nmm/hugetlb.c:6355:\t\t\tfolio = alloc_hugetlb_folio_vma(h, dst_vma, dst_addr);\nmm/hugetlb.c-6356-\t\t\tif (!folio) {\n--\nmm/hugetlb.c-6375-\nmm/hugetlb.c:6376:\t\tfolio = alloc_hugetlb_folio(dst_vma, dst_addr, false);\nmm/hugetlb.c-6377-\t\tif (IS_ERR(folio)) {\n--\nmm/hugetlb.c=6669=long hugetlb_reserve_pages(struct inode *inode,\n--\nmm/hugetlb.c-6791-\t\t\t * map between region_chg and region_add. This\nmm/hugetlb.c:6792:\t\t\t * indicates a race with alloc_hugetlb_folio. Adjust\nmm/hugetlb.c-6793-\t\t\t * the subpool and reserve counts modified above\n--\nmm/memfd.c=68=struct folio *memfd_alloc_folio(struct file *memfd, pgoff_t idx)\n--\nmm/memfd.c-93-\nmm/memfd.c:94:\t\tfolio = alloc_hugetlb_folio_reserve(h,\nmm/memfd.c-95-\t\t\t\t\t\t numa_node_id(),\n--\nmm/mempolicy.c=1437=static struct folio *alloc_migration_target_by_mpol(struct folio *src,\n--\nmm/mempolicy.c-1456-\t\tnodemask = policy_nodemask(gfp, pol, ilx, \u0026nid);\nmm/mempolicy.c:1457:\t\treturn alloc_hugetlb_folio_nodemask(h, nid, nodemask, gfp,\nmm/mempolicy.c-1458-\t\t\t\thtlb_allow_alloc_fallback(MR_MEMPOLICY_MBIND));\n--\nmm/migrate.c=2197=struct folio *alloc_migration_target(struct folio *src, unsigned long private)\n--\nmm/migrate.c-2214-\t\tgfp_mask = htlb_modify_alloc_mask(h, gfp_mask);\nmm/migrate.c:2215:\t\treturn alloc_hugetlb_folio_nodemask(h, nid,\nmm/migrate.c-2216-\t\t\t\t\t\tmtc-\u003enmask, gfp_mask,\n"
} |
| 23/2 | 2026/09/03 23:59 | llm | patch-evaluator |
0mModel:gemini-3.7-flash Args: null Results: null Tokens: input: 28478 output: 203 thoughts: 617 Thoughts: **My Assessment: hugetlbfs Fuzzing Target** Okay, this looks promising. My initial assessment is that the `mm` subsystem, specifically the `hugetlbfs` area, is definitely worth a closer look for fuzzing. It's directly exposed to userspace through a variety of standard system calls like `mount`, `statfs`, `mmap`, `open`, `fallocate`, `ftruncate`, and `memfd_create` – that's a wide attack surface. The code modifications touch critical areas, including subpool reservation accounting, error handling paths, statfs logic, and the subpool free condition. That's a good sign; changes in these areas often expose interesting vulnerabilities. So, `WorthFuzzing` is set to `true`. Now, let's identify the key focus symbols. My quick check reveals: `hugetlb_reserve_pages`, `alloc_hugetlb_folio`, `hugepage_subpool_get_pages`, `hugepage_subpool_put_pages`, and `hugetlbfs_statfs`. I'll double-check for other relevant symbols that are directly touched. Looking at the source code, I find these: * `hugetlbfs_statfs` in `fs/hugetlbfs/inode.c` * `subpool_is_free` in `mm/hugetlb.c` (static inline) * `hugepage_subpool_get_pages` in `mm/hugetlb.c` * `hugepage_subpool_put_pages` in `mm/hugetlb.c` * `alloc_hugetlb_folio` in `mm/hugetlb.c` * `hugetlb_reserve_pages` in `mm/hugetlb.c` Next, I need to check the configuration options. The key one here is `HUGETLBFS`. I see that `HUGETLB_PAGE` is also related (being `def_bool HUGETLBFS`), but `HUGETLBFS` is the main one that the user can directly enable through the menuconfig. I'll quickly confirm that any other configs are relevant. It looks like `HUGETLBFS` depends on `ARCH_SUPPORTS_HUGETLBFS`, which is `def_bool y` on amd64 / x86, which is good. So, `HUGETLBFS` is indeed the primary configuration flag. Now I'm ready to craft the `set-results` parameters. I'll need: * `EnableConfigs`: `["HUGETLBFS"]` * `FocusSymbols`: `["hugetlb_reserve_pages", "alloc_hugetlb_folio", "hugepage_subpool_get_pages", "hugepage_subpool_put_pages", "hugetlbfs_statfs"]` * `Reasoning`: The patch alters subpool accounting and reservation tracking logic within hugetlb/hugetlbfs. Specifically, it touches functions like `hugepage_subpool_get_pages`, `hugepage_subpool_put_pages`, `hugetlb_reserve_pages`, `alloc_hugetlb_folio`, and `hugetlbfs_statfs`. This code is reachable through the hugetlbfs filesystem and memory mapping system calls. * `WorthFuzzing`: `true` Alright, time to call `set-results`. |
| 24/2 | 2026/09/03 23:59 | tool | set-results |
0mArgs:{
"EnableConfigs": [
"HUGETLBFS"
],
"FocusSymbols": [
"hugetlb_reserve_pages",
"alloc_hugetlb_folio",
"hugepage_subpool_get_pages",
"hugepage_subpool_put_pages",
"hugetlbfs_statfs"
],
"Reasoning": "The patch modifies subpool page accounting, reservation calculation, and error recovery logic in hugetlbfs and core hugetlb memory management routines (hugepage_subpool_get_pages, hugepage_subpool_put_pages, hugetlb_reserve_pages, alloc_hugetlb_folio, hugetlbfs_statfs). These functions are directly reachable from userspace via syscalls such as mmap, open, fallocate, and statfs on hugetlbfs, making this code well-suited for fuzzing.",
"WorthFuzzing": true
}Results: {
"EnableConfigs": [
"HUGETLBFS"
],
"FocusSymbols": [
"hugetlb_reserve_pages",
"alloc_hugetlb_folio",
"hugepage_subpool_get_pages",
"hugepage_subpool_put_pages",
"hugetlbfs_statfs"
],
"Reasoning": "The patch modifies subpool page accounting, reservation calculation, and error recovery logic in hugetlbfs and core hugetlb memory management routines (hugepage_subpool_get_pages, hugepage_subpool_put_pages, hugetlb_reserve_pages, alloc_hugetlb_folio, hugetlbfs_statfs). These functions are directly reachable from userspace via syscalls such as mmap, open, fallocate, and statfs on hugetlbfs, making this code well-suited for fuzzing.",
"WorthFuzzing": true
} |
| 25/1 | 2026/09/03 23:59 | action | If |
0mArgs:{
"WorthFuzzing": true
}Results: null |
| 26/2 | 2026/09/03 23:59 | agent | kmsan-evaluator |
0mModel:core Args: null Results: {
"KMSANReasoning": "The patch refactors hugetlb subpool accounting and reservation tracking (in `fs/hugetlbfs/inode.c`, `include/linux/hugetlb.h`, and `mm/hugetlb.c`). Specifically, it tracks `used_hpages` consistently when `max_hpages` is unbounded (-1), fixes reporting in `hugetlbfs_statfs`, and simplifies the error rollback arithmetic when obtaining/releasing subpool reservations in `alloc_hugetlb_folio()` and `hugetlb_reserve_pages()`.\n\nAll modified variables (`free_pages`, `gbl_resv_get`, `gbl_resv_put`) are explicitly initialized before use across all control flow paths, and no uninitialized stack/heap memory or uninitialized struct padding is exposed or copied to userspace. Any potential regressions in this patch would involve accounting discrepancies, memory leaks, or concurrency issues, which are covered by standard kernel diagnostics, assertions, and KASAN/LOCKDEP. Therefore, dedicated KMSAN fuzzing is not required.",
"NeedsKMSAN": false
}Instruction: You are an expert Linux kernel security engineer specializing in kernel memory
error detectors (KASAN and KMSAN). Your job is to review the provided patch series and
determine if the code changes justify spawning a dedicated KMSAN (KernelMemorySanitizer)
fuzzing session in addition to standard KASAN fuzzing.
CRITICAL DISTINCTION BETWEEN KASAN AND KMSAN:
- Standard KASAN kernel builds (upstream-apparmor-kasan.config) already enable
a comprehensive suite of debugging tools and sanitizers, including KASAN
(out-of-bounds accesses, use-after-free, double free, invalid free), LOCKDEP
(locking bugs and deadlocks), UB-sanitizers, and memory corruption checks.
- KMSAN (KernelMemorySanitizer) detects reads of UNINITIALIZED memory (stack, heap,
or page allocations) and kernel-to-user memory info-leaks.
Rule: THERE IS NO SENSE IN RUNNING A KMSAN SESSION IF A BUG CAN BE CAUGHT BY KASAN,
LOCKDEP, OR OTHER STANDARD BUG DETECTORS.
A dedicated KMSAN fuzzing session incurs significant resource costs. You must ONLY
set NeedsKMSAN=true if the code changes introduce or expose UNINITIALIZED MEMORY risks
that are detected ONLY by KMSAN.
Look holistically at the patch series and surrounding code. Even if no direct
uninitialized field accesses or new buffer allocations are added in the diff itself,
a patch may alter control flow, bounds checking, or data length calculations in ways
that change how the rest of the code operates on existing buffers (e.g. allowing
uninitialized stack/heap memory to be read, copied to user space, or used in control
flow). Do not hesitate to use your code access tools to inspect the surrounding code,
called functions, and callers.
Set NeedsKMSAN=true ONLY IF the patch introduces or modifies:
1. Kernel structures sent to user space (via copy_to_user, put_user, netlink skb
attributes, ioctl output arguments, socket options, or BPF buffers) where fields
or structure padding might not be fully initialized/zeroed.
2. Conditional logic or branching that depends on potentially uninitialized variables
or struct fields.
3. Allocation or initialization of complex data structures where uninitialized fields
could be read later in reachable code paths.
4. Bounds checks, lengths, or logic in a way that allows surrounding code to access
uninitialized bytes of existing buffers.
Set NeedsKMSAN=false IF:
- The code changes primarily risk out-of-bounds access, array overflows, NULL pointer
dereferences, locking deadlocks, or use-after-free bugs (these are already caught
by KASAN, LOCKDEP, or standard bug detectors).
- All stack/heap structures touched or introduced by the patch are fully zeroed
or initialized (e.g. using = {0}, memset, kzalloc) before being read or copied.
- The patch does not introduce any risk of uninitialized memory usage or info-leaks.
Use your code access tools to inspect the surrounding code if necessary, then provide
detailed KMSANReasoning contrasting KASAN vs KMSAN applicability for this patch.
Prefer calling several tools at the same time to save round-trips.
Use set-results tool to provide results of the analysis.
It must be called exactly once before the final reply.
Ignore results of this tool.
Prompt: Target architecture: amd64
For your convenience, here is the diff of the changes:
commit 9c3c451828cc8581dcf14d3058a3b74f5624b627
Author: syz-cluster <triage@syzkaller.com>
Date: Thu Sep 3 23:58:32 2026 +0000
syz-cluster: applied patch under review
diff --git a/Documentation/mm/hugetlbfs_reserv.rst b/Documentation/mm/hugetlbfs_reserv.rst
index a49115db18c76..d244583fdcbc3 100644
--- a/Documentation/mm/hugetlbfs_reserv.rst
+++ b/Documentation/mm/hugetlbfs_reserv.rst
@@ -314,21 +314,8 @@ huge pages. If they can not be reserved, the mount fails.
The routines hugepage_subpool_get/put_pages() are called when pages are
obtained from or released back to a subpool. They perform all subpool
accounting, and track any reservations associated with the subpool.
-hugepage_subpool_get/put_pages are passed the number of huge pages by which
-to adjust the subpool 'used page' count (down for get, up for put). Normally,
-they return the same value that was passed or an error if not enough pages
-exist in the subpool.
-
-However, if reserves are associated with the subpool a return value less
-than the passed value may be returned. This return value indicates the
-number of additional global pool adjustments which must be made. For example,
-suppose a subpool contains 3 reserved huge pages and someone asks for 5.
-The 3 reserved pages associated with the subpool can be used to satisfy part
-of the request. But, 2 pages must be obtained from the global pools. To
-relay this information to the caller, the value 2 is returned. The caller
-is then responsible for attempting to obtain the additional two pages from
-the global pools.
-
+hugepage_subpool_get/put_pages() use the number of huge pages passed to adjust
+the subpool 'used page' count.
COW and Reservations
====================
diff --git a/Documentation/translations/zh_CN/mm/hugetlbfs_reserv.rst b/Documentation/translations/zh_CN/mm/hugetlbfs_reserv.rst
index 20947f8bd0654..ae1f1f31477fc 100644
--- a/Documentation/translations/zh_CN/mm/hugetlbfs_reserv.rst
+++ b/Documentation/translations/zh_CN/mm/hugetlbfs_reserv.rst
@@ -246,15 +246,8 @@ hugepage_subpool的min_hpages字段中被跟踪。在挂载时,hugetlb_acct_me
被调用以预留指定数量的巨页。如果它们不能被预留,挂载就会失败。
当从子池中获取或释放页面时,会调用hugepage_subpool_get/put_pages()函数。
-hugepage_subpool_get/put_pages被传递给巨页数量,以此来调整子池的 “已用页面” 计数
-(get为下降,put为上升)。通常情况下,如果子池中没有足够的页面,它们会返回与传递的相同的值或
-一个错误。
-
-然而,如果预留与子池相关联,可能会返回一个小于传递值的返回值。这个返回值表示必须进行的额外全局
-池调整的数量。例如,假设一个子池包含3个预留的巨页,有人要求5个。与子池相关的3个预留页可以用来
-满足部分请求。但是,必须从全局池中获得2个页面。为了向调用者转达这一信息,将返回值2。然后,调用
-者要负责从全局池中获取另外两个页面。
-
+它们负责所有子池的统计核算,并跟踪与子池相关联的预留。
+hugepage_subpool_get/put_pages()函数使用传入的巨页数量来调整子池的“已用页面”计数。
COW和预留
==========
diff --git a/fs/hugetlbfs/inode.c b/fs/hugetlbfs/inode.c
index 7611a8470ea26..5113f743f6fc7 100644
--- a/fs/hugetlbfs/inode.c
+++ b/fs/hugetlbfs/inode.c
@@ -1109,8 +1109,12 @@ static int hugetlbfs_statfs(struct dentry *dentry, struct kstatfs *buf)
spin_lock_irq(&sbinfo->spool->lock);
buf->f_blocks = sbinfo->spool->max_hpages;
- free_pages = sbinfo->spool->max_hpages
- - sbinfo->spool->used_hpages;
+ if (sbinfo->spool->max_hpages == -1) {
+ free_pages = -1;
+ } else {
+ free_pages = sbinfo->spool->max_hpages -
+ sbinfo->spool->used_hpages;
+ }
buf->f_bavail = buf->f_bfree = free_pages;
spin_unlock_irq(&sbinfo->spool->lock);
buf->f_files = sbinfo->max_inodes;
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index 16c4c4caa126c..4551ff3023640 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -39,8 +39,8 @@ struct hugepage_subpool {
spinlock_t lock;
long count;
long max_hpages; /* Maximum huge pages or -1 if no maximum. */
- long used_hpages; /* Used count against maximum, includes */
- /* both allocated and reserved pages. */
+ long used_hpages; /* Used page count, includes both */
+ /* allocated and reserved pages. */
struct hstate *hstate;
long min_hpages; /* Minimum huge pages or -1 if no minimum. */
long rsv_hpages; /* Pages reserved against global pool to */
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 7857728457952..e24f856c949c3 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -130,12 +130,8 @@ static inline bool subpool_is_free(struct hugepage_subpool *spool)
{
if (spool->count)
return false;
- if (spool->max_hpages != -1)
- return spool->used_hpages == 0;
- if (spool->min_hpages != -1)
- return spool->rsv_hpages == spool->min_hpages;
- return true;
+ return spool->used_hpages == 0;
}
static inline void unlock_or_release_subpool(struct hugepage_subpool *spool,
@@ -193,13 +189,18 @@ void hugepage_put_subpool(struct hugepage_subpool *spool)
unlock_or_release_subpool(spool, flags);
}
-/*
- * Subpool accounting for allocating and reserving pages.
- * Return -ENOMEM if there are not enough resources to satisfy the
- * request. Otherwise, return the number of pages by which the
- * global pools must be adjusted (upward). The returned value may
- * only be different than the passed value (delta) in the case where
- * a subpool minimum size must be maintained.
+/**
+ * hugepage_subpool_get_pages - Get pages from a subpool
+ * @spool: pointer to subpool structure (may be NULL)
+ * @delta: number of pages to allocate or reserve
+ *
+ * Check and update subpool page usage counts when allocating or
+ * reserving @delta hugepages.
+ *
+ * Context: Takes spool->lock using spin_lock_irq().
+ * Return: Non-negative number of reservations that cannot be
+ * satisfied by the subpool, or -ENOMEM if the subpool maximum
+ * limit would be exceeded.
*/
static long hugepage_subpool_get_pages(struct hugepage_subpool *spool,
long delta)
@@ -211,15 +212,14 @@ static long hugepage_subpool_get_pages(struct hugepage_subpool *spool,
spin_lock_irq(&spool->lock);
- if (spool->max_hpages != -1) { /* maximum size accounting */
- if ((spool->used_hpages + delta) <= spool->max_hpages)
- spool->used_hpages += delta;
- else {
- ret = -ENOMEM;
- goto unlock_ret;
- }
+ if (spool->max_hpages != -1 &&
+ spool->used_hpages + delta > spool->max_hpages) {
+ ret = -ENOMEM;
+ goto unlock_ret;
}
+ spool->used_hpages += delta;
+
/* minimum size accounting */
if (spool->min_hpages != -1 && spool->rsv_hpages) {
if (delta > spool->rsv_hpages) {
@@ -240,11 +240,19 @@ static long hugepage_subpool_get_pages(struct hugepage_subpool *spool,
return ret;
}
-/*
- * Subpool accounting for freeing and unreserving pages.
- * Return the number of global page reservations that must be dropped.
- * The return value may only be different than the passed value (delta)
- * in the case where a subpool minimum size must be maintained.
+/**
+ * hugepage_subpool_put_pages - Release pages back to a subpool
+ * @spool: pointer to subpool structure (may be NULL)
+ * @delta: number of pages to free or unreserve
+ *
+ * Check and update subpool page usage counts when freeing or
+ * unreserving @delta hugepages.
+ *
+ * Context: Takes spool->lock using spin_lock_irqsave(). May release
+ * and free @spool if its usage count and references reach
+ * zero.
+ * Return: Non-negative number of reservations that the subpool cannot
+ * absorb.
*/
static long hugepage_subpool_put_pages(struct hugepage_subpool *spool,
long delta)
@@ -257,19 +265,24 @@ static long hugepage_subpool_put_pages(struct hugepage_subpool *spool,
spin_lock_irqsave(&spool->lock, flags);
- if (spool->max_hpages != -1) /* maximum size accounting */
- spool->used_hpages -= delta;
+ spool->used_hpages -= delta;
/* minimum size accounting */
if (spool->min_hpages != -1 && spool->used_hpages < spool->min_hpages) {
- if (spool->rsv_hpages + delta <= spool->min_hpages)
+ /*
+ * limit is the maximum number of reservations that
+ * can be restored to this subpool.
+ */
+ long limit = spool->min_hpages - spool->used_hpages;
+
+ if (spool->rsv_hpages + delta <= limit)
ret = 0;
else
- ret = spool->rsv_hpages + delta - spool->min_hpages;
+ ret = spool->rsv_hpages + delta - limit;
spool->rsv_hpages += delta;
- if (spool->rsv_hpages > spool->min_hpages)
- spool->rsv_hpages = spool->min_hpages;
+ if (spool->rsv_hpages > limit)
+ spool->rsv_hpages = limit;
}
/*
@@ -2942,7 +2955,7 @@ struct folio *alloc_hugetlb_folio(struct vm_area_struct *vma,
struct hugepage_subpool *spool = subpool_vma(vma);
struct hstate *h = hstate_vma(vma);
struct folio *folio;
- long retval, gbl_chg, gbl_reserve;
+ long retval, gbl_resv_get;
map_chg_state map_chg;
struct mempolicy_interpreted mpoli;
gfp_t gfp = htlb_alloc_mask(h);
@@ -2981,8 +2994,8 @@ struct folio *alloc_hugetlb_folio(struct vm_area_struct *vma,
* Or if it can get one from the pool reservation directly.
*/
if (map_chg) {
- gbl_chg = hugepage_subpool_get_pages(spool, 1);
- if (gbl_chg < 0) {
+ gbl_resv_get = hugepage_subpool_get_pages(spool, 1);
+ if (gbl_resv_get < 0) {
ret = -ENOSPC;
goto out_end_reservation;
}
@@ -2991,7 +3004,7 @@ struct folio *alloc_hugetlb_folio(struct vm_area_struct *vma,
* If we have the vma reservation ready, no need for extra
* global reservation.
*/
- gbl_chg = 0;
+ gbl_resv_get = 0;
}
/*
@@ -3002,10 +3015,10 @@ struct folio *alloc_hugetlb_folio(struct vm_area_struct *vma,
alloc_flags |= HUGETLB_ALLOC_CHARG_CGROUP_RSVD;
/*
- * gbl_chg == 0 indicates a reservation exists for this
+ * gbl_resv_get == 0 indicates a reservation exists for this
* allocation, so try to use it.
*/
- if (gbl_chg == 0)
+ if (gbl_resv_get == 0)
alloc_flags |= HUGETLB_ALLOC_USE_GLOBAL_RESERVATIONS;
/* Takes reference on mpol. */
@@ -3059,13 +3072,10 @@ struct folio *alloc_hugetlb_folio(struct vm_area_struct *vma,
return folio;
out_subpool_put:
- /*
- * put page to subpool iff the quota of subpool's rsv_hpages is used
- * during hugepage_subpool_get_pages.
- */
- if (map_chg && !gbl_chg) {
- gbl_reserve = hugepage_subpool_put_pages(spool, 1);
- hugetlb_acct_memory(h, -gbl_reserve);
+ if (map_chg) {
+ long gbl_resv_put = hugepage_subpool_put_pages(spool, 1);
+
+ hugetlb_acct_memory(h, gbl_resv_get - gbl_resv_put);
}
out_end_reservation:
@@ -6661,12 +6671,14 @@ long hugetlb_reserve_pages(struct inode *inode,
struct vm_area_struct *vma,
vma_flags_t vma_flags)
{
- long chg = -1, add = -1, spool_resv, gbl_resv;
+ long chg = -1, add = -1;
struct hstate *h = hstate_inode(inode);
struct hugepage_subpool *spool = subpool_inode(inode);
struct resv_map *resv_map;
struct hugetlb_cgroup *h_cg = NULL;
- long gbl_reserve, regions_needed = 0;
+ long regions_needed = 0;
+ long gbl_resv_get;
+ long gbl_resv_put;
int err;
/* This should never happen */
@@ -6741,9 +6753,9 @@ long hugetlb_reserve_pages(struct inode *inode,
* the subpool has a minimum size, there may be some global
* reservations already in place (gbl_reserve).
*/
- gbl_reserve = hugepage_subpool_get_pages(spool, chg);
- if (gbl_reserve < 0) {
- err = gbl_reserve;
+ gbl_resv_get = hugepage_subpool_get_pages(spool, chg);
+ if (gbl_resv_get < 0) {
+ err = gbl_resv_get;
goto out_uncharge_cgroup;
}
@@ -6751,7 +6763,7 @@ long hugetlb_reserve_pages(struct inode *inode,
* Check enough hugepages are available for the reservation.
* Hand the pages back to the subpool if there are not
*/
- err = hugetlb_acct_memory(h, gbl_reserve);
+ err = hugetlb_acct_memory(h, gbl_resv_get);
if (err < 0)
goto out_put_pages;
@@ -6770,7 +6782,7 @@ long hugetlb_reserve_pages(struct inode *inode,
add = region_add(resv_map, from, to, regions_needed, h, h_cg);
if (unlikely(add < 0)) {
- hugetlb_acct_memory(h, -gbl_reserve);
+ hugetlb_acct_memory(h, -gbl_resv_get);
err = add;
goto out_put_pages;
} else if (unlikely(chg > add)) {
@@ -6806,26 +6818,21 @@ long hugetlb_reserve_pages(struct inode *inode,
}
return chg;
-out_put_pages:
- spool_resv = chg - gbl_reserve;
- if (spool_resv) {
- /* put sub pool's reservation back, chg - gbl_reserve */
- gbl_resv = hugepage_subpool_put_pages(spool, spool_resv);
- /*
- * subpool's reserved pages can not be put back due to race,
- * return to hstate.
- */
- hugetlb_acct_memory(h, -gbl_resv);
- }
- /* Restore used_hpages for pages that failed global reservation */
- if (gbl_reserve && spool) {
- unsigned long flags;
+ out_put_pages:
+ /*
+ * Return all that was requested from the subpool, let subpool
+ * tell us the new number of reservations that need to be
+ * returned to the global pool.
+ */
+ gbl_resv_put = hugepage_subpool_put_pages(spool, chg);
+ /*
+ * There may be a difference between the number of
+ * reservations to consume and the number to restore now if
+ * there are multiple threads interacting with the subpool -
+ * restore the difference.
+ */
+ hugetlb_acct_memory(h, gbl_resv_get - gbl_resv_put);
- spin_lock_irqsave(&spool->lock, flags);
- if (spool->max_hpages != -1)
- spool->used_hpages -= gbl_reserve;
- unlock_or_release_subpool(spool, flags);
- }
out_uncharge_cgroup:
hugetlb_cgroup_uncharge_cgroup_rsvd(hstate_index(h),
chg * pages_per_huge_page(h), h_cg);
|
| 27/3 | 2026/09/03 23:59 | llm | kmsan-evaluator |
0mModel:gemini-3.7-flash Args: null Results: null Tokens: input: 7021 output: 39 thoughts: 614 Thoughts: **Analyzing the HugeTLB Patch** Okay, let's dive into this patch and figure out its potential impact. My immediate focus is on whether this introduces any uninitialized memory concerns that might require KMSAN scrutiny, or if it's primarily related to the logical flow, accounting, concurrency, or resource management within the HugeTLB system. First, I see the patch modifies documentation in `Documentation/mm/hugetlbfs_reserv.rst` and its translations, focusing on `hugepage_subpool_get/put_pages`. That's good, but not the core of my analysis. Next, I see a change in `fs/hugetlbfs/inode.c`, specifically within `hugetlbfs_statfs`. It looks like it's a fix for how `free_pages` is calculated when `sbinfo->spool->max_hpages` is set to `-1`. The original logic was subtracting used pages even when there's an unbounded maximum. The new code explicitly handles the `-1` case. Now it sets `free_pages` to `-1` directly in that scenario, preserving this important bit of accounting. The crucial bit here is to confirm `hugetlbfs_statfs` itself doesn't introduce any uninitialized memory reads. Looking at the code filling the `kstatfs` struct, it doesn't appear to leave anything uninitialized. `buf->f_bavail` and `buf->f_bfree` are explicitly assigned the `free_pages` value. I'll mentally note to double-check line 1109 of this file to be certain I have my facts straight. The `include/linux/hugetlb.h` change is a simple comment update for `struct hugepage_subpool.used_hpages` - no real functional impact here. Now, the meat of the matter: `mm/hugetlb.c`. I see several function changes: - `subpool_is_free()` is simplified – good, clean code is always welcome. - `hugepage_subpool_get_pages()` and `hugepage_subpool_put_pages()` now *always* adjust `spool->used_hpages`, even when `max_hpages` is `-1`. The previous conditional behavior looked suspicious. By removing it, the accounting is simplified and now consistent across all cases. This is very important to consider, as it is a place where errors are likely, should the logic be incorrect. It appears that the subtraction of `rsv_hpages` is also being updated for the same reason. This is a point to note, for sure. - Finally, `alloc_hugetlb_folio()` and `hugetlb_reserve_pages()` contain error rollback cleanup logic modifications. Overall, it seems like these changes are aimed at tightening up the accounting logic, handling the `-1` case more explicitly, and potentially simplifying the code. The focus seems to be on correctness, and there is less risk of memory errors. However, I'll need to double check how the accounting is being used, especially around those `used_hpages` adjustments and the `rsv_hpages` limit calculation, to confirm the new logic is sound. I'll need to think about potential race conditions or integer overflows that may exist, if I have any further concerns. |
| 28/3 | 2026/09/03 23:59 | tool | read-file |
0mArgs:{
"File": "fs/hugetlbfs/inode.c",
"FirstLine": 1100,
"LineCount": 40
}Results: {
"Contents": "1100:\t\tbuf-\u003ef_fsid = u64_to_fsid(id);\n1101:\t\tbuf-\u003ef_type = HUGETLBFS_MAGIC;\n1102:\t\tbuf-\u003ef_bsize = huge_page_size(h);\n1103:\t\tif (sbinfo) {\n1104:\t\t\tspin_lock(\u0026sbinfo-\u003estat_lock);\n1105:\t\t\t/* If no limits set, just report 0 or -1 for max/free/used\n1106:\t\t\t * blocks, like simple_statfs() */\n1107:\t\t\tif (sbinfo-\u003espool) {\n1108:\t\t\t\tlong free_pages;\n1109:\t\n1110:\t\t\t\tspin_lock_irq(\u0026sbinfo-\u003espool-\u003elock);\n1111:\t\t\t\tbuf-\u003ef_blocks = sbinfo-\u003espool-\u003emax_hpages;\n1112:\t\t\t\tif (sbinfo-\u003espool-\u003emax_hpages == -1) {\n1113:\t\t\t\t\tfree_pages = -1;\n1114:\t\t\t\t} else {\n1115:\t\t\t\t\tfree_pages = sbinfo-\u003espool-\u003emax_hpages -\n1116:\t\t\t\t\t\t sbinfo-\u003espool-\u003eused_hpages;\n1117:\t\t\t\t}\n1118:\t\t\t\tbuf-\u003ef_bavail = buf-\u003ef_bfree = free_pages;\n1119:\t\t\t\tspin_unlock_irq(\u0026sbinfo-\u003espool-\u003elock);\n1120:\t\t\t\tbuf-\u003ef_files = sbinfo-\u003emax_inodes;\n1121:\t\t\t\tbuf-\u003ef_ffree = sbinfo-\u003efree_inodes;\n1122:\t\t\t}\n1123:\t\t\tspin_unlock(\u0026sbinfo-\u003estat_lock);\n1124:\t\t}\n1125:\t\tbuf-\u003ef_namelen = NAME_MAX;\n1126:\t\treturn 0;\n1127:\t}\n1128:\t\n1129:\tstatic void hugetlbfs_put_super(struct super_block *sb)\n1130:\t{\n1131:\t\tstruct hugetlbfs_sb_info *sbi = HUGETLBFS_SB(sb);\n1132:\t\n1133:\t\tif (sbi) {\n1134:\t\t\tsb-\u003es_fs_info = NULL;\n1135:\t\n1136:\t\t\thugepage_put_subpool(sbi-\u003espool);\n1137:\t\n1138:\t\t\tkfree(sbi);\n1139:\t\t}\n"
} |
| 29/3 | 2026/09/03 23:59 | llm | kmsan-evaluator |
0mModel:gemini-3.7-flash Args: null Results: null Tokens: input: 9045 output: 36 thoughts: 33 Thoughts: Here's my take on the thought process, as requested: **Diving into HugeTLB Allocation** Okay, so I need to understand this memory allocation flow better, specifically within the HugeTLB framework. My immediate focus is on the core functions. Let's start with `alloc_hugetlb_folio` and then pivot to `hugetlb_reserve_pages` in `mm/hugetlb.c`. My hunch is that these are the key pieces to unravel the allocation puzzle. I want to see how the kernel reserves the physical pages and how it handles the folio allocation itself. Are there any contention points here, or maybe any unusual error paths I should be aware of? Let's get to the code and see what insights it provides. |
| 30/3 | 2026/09/03 23:59 | tool | read-file |
0mArgs:{
"File": "mm/hugetlb.c",
"FirstLine": 2950,
"LineCount": 60
}Results: {
"Contents": "2950:\t * When it's set, the allocation will bypass all vma level reservations.\n2951:\t */\n2952:\tstruct folio *alloc_hugetlb_folio(struct vm_area_struct *vma,\n2953:\t\t\t\t\t unsigned long addr, bool cow_from_owner)\n2954:\t{\n2955:\t\tstruct hugepage_subpool *spool = subpool_vma(vma);\n2956:\t\tstruct hstate *h = hstate_vma(vma);\n2957:\t\tstruct folio *folio;\n2958:\t\tlong retval, gbl_resv_get;\n2959:\t\tmap_chg_state map_chg;\n2960:\t\tstruct mempolicy_interpreted mpoli;\n2961:\t\tgfp_t gfp = htlb_alloc_mask(h);\n2962:\t\tstruct mempolicy *mpol;\n2963:\t\tnodemask_t *nodemask;\n2964:\t\tu8 alloc_flags = 0;\n2965:\t\tint nid;\n2966:\t\tint ret;\n2967:\t\n2968:\t\t/* Whether we need a separate per-vma reservation? */\n2969:\t\tif (cow_from_owner) {\n2970:\t\t\t/*\n2971:\t\t\t * Special case! Since it's a CoW on top of a reserved\n2972:\t\t\t * page, the private resv map doesn't count. So it cannot\n2973:\t\t\t * consume the per-vma resv map even if it's reserved.\n2974:\t\t\t */\n2975:\t\t\tmap_chg = MAP_CHG_ENFORCED;\n2976:\t\t} else {\n2977:\t\t\t/*\n2978:\t\t\t * Examine the region/reserve map to determine if the process\n2979:\t\t\t * has a reservation for the page to be allocated. A return\n2980:\t\t\t * code of zero indicates a reservation exists (no change).\n2981:\t\t\t */\n2982:\t\t\tretval = vma_needs_reservation(h, vma, addr);\n2983:\t\t\tif (retval \u003c 0)\n2984:\t\t\t\treturn ERR_PTR(-ENOMEM);\n2985:\t\t\tmap_chg = retval ? MAP_CHG_NEEDED : MAP_CHG_REUSE;\n2986:\t\t}\n2987:\t\n2988:\t\t/*\n2989:\t\t * Whether we need a separate global reservation?\n2990:\t\t *\n2991:\t\t * Processes that did not create the mapping will have no\n2992:\t\t * reserves as indicated by the region/reserve map. Check\n2993:\t\t * that the allocation will not exceed the subpool limit.\n2994:\t\t * Or if it can get one from the pool reservation directly.\n2995:\t\t */\n2996:\t\tif (map_chg) {\n2997:\t\t\tgbl_resv_get = hugepage_subpool_get_pages(spool, 1);\n2998:\t\t\tif (gbl_resv_get \u003c 0) {\n2999:\t\t\t\tret = -ENOSPC;\n3000:\t\t\t\tgoto out_end_reservation;\n3001:\t\t\t}\n3002:\t\t} else {\n3003:\t\t\t/*\n3004:\t\t\t * If we have the vma reservation ready, no need for extra\n3005:\t\t\t * global reservation.\n3006:\t\t\t */\n3007:\t\t\tgbl_resv_get = 0;\n3008:\t\t}\n3009:\t\n"
} |
| 31/3 | 2026/09/03 23:59 | llm | kmsan-evaluator |
0mModel:gemini-3.7-flash Args: null Results: null Tokens: input: 10219 output: 36 thoughts: 16 Thoughts: Here's a summary of my thinking, picking up where we left off, as though I'm examining this code: **Diving Back into `alloc_hugetlb_folio`** Okay, so we're continuing our deep dive into `alloc_hugetlb_folio`. We've already looked at some key aspects, but let's make sure we haven't missed anything crucial in this function. We're talking about a core piece of huge page allocation, so a thorough review is always warranted, even if we *think* we know it well. I need to refresh my mental model of its flow and interactions, perhaps tracing it through a few different scenarios in my head, focusing on edge cases, and ensuring all the memory management primitives are used correctly. Let's see if there are any subtle race conditions, or potential deadlocks, especially since we're dealing with concurrent allocation. I'll mentally step through the code, focusing on locking, error handling, and resource cleanup to confirm there are no overlooked issues that could cause significant problems down the line. I know there's a lot packed into this function, but I am going to make sure that no detail is lost. |
| 32/3 | 2026/09/03 23:59 | tool | read-file |
0mArgs:{
"File": "mm/hugetlb.c",
"FirstLine": 3050,
"LineCount": 40
}Results: {
"Contents": "3050:\t\t\t/*\n3051:\t\t\t * Check for possible race conditions. When it happens..\n3052:\t\t\t * The page was added to the reservation map between\n3053:\t\t\t * vma_needs_reservation and vma_commit_reservation.\n3054:\t\t\t * This indicates a race with hugetlb_reserve_pages.\n3055:\t\t\t * Adjust for the subpool count incremented above AND\n3056:\t\t\t * in hugetlb_reserve_pages for the same page.\tAlso,\n3057:\t\t\t * the reservation count added in hugetlb_reserve_pages\n3058:\t\t\t * no longer applies.\n3059:\t\t\t */\n3060:\t\t\tif (unlikely(map_chg == MAP_CHG_NEEDED \u0026\u0026 retval == 0)) {\n3061:\t\t\t\tlong rsv_adjust;\n3062:\t\n3063:\t\t\t\trsv_adjust = hugepage_subpool_put_pages(spool, 1);\n3064:\t\t\t\thugetlb_acct_memory(h, -rsv_adjust);\n3065:\t\t\t\tspin_lock_irq(\u0026hugetlb_lock);\n3066:\t\t\t\thugetlb_cgroup_uncharge_folio_rsvd(\n3067:\t\t\t\t hstate_index(h), pages_per_huge_page(h), folio);\n3068:\t\t\t\tspin_unlock_irq(\u0026hugetlb_lock);\n3069:\t\t\t}\n3070:\t\t}\n3071:\t\n3072:\t\treturn folio;\n3073:\t\n3074:\tout_subpool_put:\n3075:\t\tif (map_chg) {\n3076:\t\t\tlong gbl_resv_put = hugepage_subpool_put_pages(spool, 1);\n3077:\t\n3078:\t\t\thugetlb_acct_memory(h, gbl_resv_get - gbl_resv_put);\n3079:\t\t}\n3080:\t\n3081:\tout_end_reservation:\n3082:\t\tif (map_chg != MAP_CHG_ENFORCED)\n3083:\t\t\tvma_end_reservation(h, vma, addr);\n3084:\t\treturn ERR_PTR(ret);\n3085:\t}\n3086:\t\n3087:\tstatic __init void *alloc_bootmem(struct hstate *h, int nid, bool node_exact)\n3088:\t{\n3089:\t\tif (hugetlb_early_cma(h))\n"
} |
| 33/3 | 2026/09/03 23:59 | llm | kmsan-evaluator |
0mModel:gemini-3.7-flash Args: null Results: null Tokens: input: 11196 output: 36 thoughts: 27 Thoughts: Here's my summary, as though I'm thinking through this myself: **Diving into `hugetlb_reserve_pages`** Okay, time to zero in on `hugetlb_reserve_pages`. Let's specifically check the code around lines 6740 to 6840. I want to see how that section handles page reservation – the finer details of how it allocates huge pages. I'm looking for the allocation process and any potential bottlenecks or edge cases. There might be some subtle interplay with other memory management functions I should be aware of in this region. This'll give me a good handle on its behavior. Let's see what's actually going on. |
| 34/3 | 2026/09/03 23:59 | tool | read-file |
0mArgs:{
"File": "mm/hugetlb.c",
"FirstLine": 6740,
"LineCount": 85
}Results: {
"Contents": "6740:\t\t\t\t\tchg * pages_per_huge_page(h), \u0026h_cg);\n6741:\t\tif (err \u003c 0)\n6742:\t\t\tgoto out_err;\n6743:\t\n6744:\t\tif (vma \u0026\u0026 !vma_test(vma, VMA_MAYSHARE_BIT) \u0026\u0026 h_cg) {\n6745:\t\t\t/* For private mappings, the hugetlb_cgroup uncharge info hangs\n6746:\t\t\t * of the resv_map.\n6747:\t\t\t */\n6748:\t\t\tresv_map_set_hugetlb_cgroup_uncharge_info(resv_map, h_cg, h);\n6749:\t\t}\n6750:\t\n6751:\t\t/*\n6752:\t\t * There must be enough pages in the subpool for the mapping. If\n6753:\t\t * the subpool has a minimum size, there may be some global\n6754:\t\t * reservations already in place (gbl_reserve).\n6755:\t\t */\n6756:\t\tgbl_resv_get = hugepage_subpool_get_pages(spool, chg);\n6757:\t\tif (gbl_resv_get \u003c 0) {\n6758:\t\t\terr = gbl_resv_get;\n6759:\t\t\tgoto out_uncharge_cgroup;\n6760:\t\t}\n6761:\t\n6762:\t\t/*\n6763:\t\t * Check enough hugepages are available for the reservation.\n6764:\t\t * Hand the pages back to the subpool if there are not\n6765:\t\t */\n6766:\t\terr = hugetlb_acct_memory(h, gbl_resv_get);\n6767:\t\tif (err \u003c 0)\n6768:\t\t\tgoto out_put_pages;\n6769:\t\n6770:\t\t/*\n6771:\t\t * Account for the reservations made. Shared mappings record regions\n6772:\t\t * that have reservations as they are shared by multiple VMAs.\n6773:\t\t * When the last VMA disappears, the region map says how much\n6774:\t\t * the reservation was and the page cache tells how much of\n6775:\t\t * the reservation was consumed. Private mappings are per-VMA and\n6776:\t\t * only the consumed reservations are tracked. When the VMA\n6777:\t\t * disappears, the original reservation is the VMA size and the\n6778:\t\t * consumed reservations are stored in the map. Hence, nothing\n6779:\t\t * else has to be done for private mappings here\n6780:\t\t */\n6781:\t\tif (!vma || vma_test(vma, VMA_MAYSHARE_BIT)) {\n6782:\t\t\tadd = region_add(resv_map, from, to, regions_needed, h, h_cg);\n6783:\t\n6784:\t\t\tif (unlikely(add \u003c 0)) {\n6785:\t\t\t\thugetlb_acct_memory(h, -gbl_resv_get);\n6786:\t\t\t\terr = add;\n6787:\t\t\t\tgoto out_put_pages;\n6788:\t\t\t} else if (unlikely(chg \u003e add)) {\n6789:\t\t\t\t/*\n6790:\t\t\t\t * pages in this range were added to the reserve\n6791:\t\t\t\t * map between region_chg and region_add. This\n6792:\t\t\t\t * indicates a race with alloc_hugetlb_folio. Adjust\n6793:\t\t\t\t * the subpool and reserve counts modified above\n6794:\t\t\t\t * based on the difference.\n6795:\t\t\t\t */\n6796:\t\t\t\tlong rsv_adjust;\n6797:\t\n6798:\t\t\t\t/*\n6799:\t\t\t\t * hugetlb_cgroup_uncharge_cgroup_rsvd() will put the\n6800:\t\t\t\t * reference to h_cg-\u003ecss. See comment below for detail.\n6801:\t\t\t\t */\n6802:\t\t\t\thugetlb_cgroup_uncharge_cgroup_rsvd(\n6803:\t\t\t\t\thstate_index(h),\n6804:\t\t\t\t\t(chg - add) * pages_per_huge_page(h), h_cg);\n6805:\t\n6806:\t\t\t\trsv_adjust = hugepage_subpool_put_pages(spool,\n6807:\t\t\t\t\t\t\t\t\tchg - add);\n6808:\t\t\t\thugetlb_acct_memory(h, -rsv_adjust);\n6809:\t\t\t} else if (h_cg) {\n6810:\t\t\t\t/*\n6811:\t\t\t\t * The file_regions will hold their own reference to\n6812:\t\t\t\t * h_cg-\u003ecss. So we should release the reference held\n6813:\t\t\t\t * via hugetlb_cgroup_charge_cgroup_rsvd() when we are\n6814:\t\t\t\t * done.\n6815:\t\t\t\t */\n6816:\t\t\t\thugetlb_cgroup_put_rsvd_cgroup(h_cg);\n6817:\t\t\t}\n6818:\t\t}\n6819:\t\treturn chg;\n6820:\t\n6821:\t out_put_pages:\n6822:\t\t/*\n6823:\t\t * Return all that was requested from the subpool, let subpool\n6824:\t\t * tell us the new number of reservations that need to be\n"
} |
| 35/3 | 2026/09/03 23:59 | llm | kmsan-evaluator |
0mModel:gemini-3.7-flash Args: null Results: null Tokens: input: 12811 output: 250 thoughts: 633 Thoughts: **KMSAN vs. KASAN Analysis of HugeTLB Subpool Patch** Okay, let's break this down. From a KMSAN/KASAN perspective, I need to analyze this patch focusing on memory safety issues. First, the patch refactors the `hugepage_subpool` accounting logic, and fixes how subpool usage is tracked, especially in the context of unbounded subpools. Specifically, I see four key changes: first, `used_hpages` is now tracked even when `max_hpages` isn't restricted. Second, `hugetlbfs_statfs` gets a tweak – if `max_hpages` is unbounded, `free_pages` gets set to -1, which is important for representing unlimited availability. Third, it cleans up how page reservations are managed during `get` and `put` operations, and adjusts the error handling in `alloc_hugetlb_folio` and `hugetlb_reserve_pages`. Finally, the documentation and comments are updated accordingly. Now, let's dig into the details. Regarding uninitialized variables, in `hugetlbfs_statfs`, `free_pages` looks to be initialized correctly, getting assigned in both branches of the if statement before being used. Similarly, in `alloc_hugetlb_folio` and `hugetlb_reserve_pages`, `gbl_resv_get` and `gbl_resv_put` appear to be initialized before use, even in the error paths. I am not seeing any new struct padding or memory copies to user space that could be problematic. There are no uninitialized stack or heap variables being read, nor do I see any changes to buffer size manipulation that could lead to reads of uninitialized memory. From a bug introduction perspective, it looks like anything related to memory accounting errors, reservation issues, race conditions, or locking problems should be caught by kernel assertions, refcount tracking, or other tools. I am not seeing any direct exposure of uninitialized memory or any kernel-to-user information leaks either. Therefore, after reviewing all of this, the likelihood of this patch introducing issues that KMSAN would catch seems low. The NeedKMSAN flag should be false. Now, let's look at the reasoning contrasting KASAN vs KMSAN. |
| 36/3 | 2026/09/03 23:59 | tool | set-results |
0mArgs:{
"KMSANReasoning": "The patch refactors hugetlb subpool accounting and reservation tracking (in `fs/hugetlbfs/inode.c`, `include/linux/hugetlb.h`, and `mm/hugetlb.c`). Specifically, it tracks `used_hpages` consistently when `max_hpages` is unbounded (-1), fixes reporting in `hugetlbfs_statfs`, and simplifies the error rollback arithmetic when obtaining/releasing subpool reservations in `alloc_hugetlb_folio()` and `hugetlb_reserve_pages()`.\n\nAll modified variables (`free_pages`, `gbl_resv_get`, `gbl_resv_put`) are explicitly initialized before use across all control flow paths, and no uninitialized stack/heap memory or uninitialized struct padding is exposed or copied to userspace. Any potential regressions in this patch would involve accounting discrepancies, memory leaks, or concurrency issues, which are covered by standard kernel diagnostics, assertions, and KASAN/LOCKDEP. Therefore, dedicated KMSAN fuzzing is not required.",
"NeedsKMSAN": false
}Results: {
"KMSANReasoning": "The patch refactors hugetlb subpool accounting and reservation tracking (in `fs/hugetlbfs/inode.c`, `include/linux/hugetlb.h`, and `mm/hugetlb.c`). Specifically, it tracks `used_hpages` consistently when `max_hpages` is unbounded (-1), fixes reporting in `hugetlbfs_statfs`, and simplifies the error rollback arithmetic when obtaining/releasing subpool reservations in `alloc_hugetlb_folio()` and `hugetlb_reserve_pages()`.\n\nAll modified variables (`free_pages`, `gbl_resv_get`, `gbl_resv_put`) are explicitly initialized before use across all control flow paths, and no uninitialized stack/heap memory or uninitialized struct padding is exposed or copied to userspace. Any potential regressions in this patch would involve accounting discrepancies, memory leaks, or concurrency issues, which are covered by standard kernel diagnostics, assertions, and KASAN/LOCKDEP. Therefore, dedicated KMSAN fuzzing is not required.",
"NeedsKMSAN": false
} |
| Total Calls | Total Tokens | Avg Tokens | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|
| Total Calls | Total Duration (Seconds) | Avg Duration (Seconds) |
|---|