Skip to content

[LTP] [PATCH v5] Migrating the libhugetlbfs/testcases/alloc-instantia…#1313

Open
SamirMulani wants to merge 1 commit intolinux-test-project:masterfrom
SamirMulani:migration-alloc-instantiate-race
Open

[LTP] [PATCH v5] Migrating the libhugetlbfs/testcases/alloc-instantia…#1313
SamirMulani wants to merge 1 commit intolinux-test-project:masterfrom
SamirMulani:migration-alloc-instantiate-race

Conversation

@SamirMulani
Copy link
Copy Markdown
Contributor

@SamirMulani SamirMulani commented May 4, 2026

…te-race.c test

This test is designed to detect a kernel allocation race introduced with hugepage demand-faulting. The problem is that no lock is held between allocating a hugepage and instantiating it in the pagetables or page cache index. In between the two, the (huge) page is cleared, so there's substantial time. Thus two processes can race instantiating the (same) last available hugepage - one will fail on the allocation, and thus cause an OOM fault even though the page it actually wants is being instantiated by the other racing process.

v3: https://lore.kernel.org/all/20250928030721.3537869-1-samir@linux.ibm.com/
v4: https://lore.kernel.org/ltp/20260317095559.5766-1-samir@linux.ibm.com/

v4
Addressed review comments:

  • Removed unnecessary [Description] tag from comment block
  • Added static keyword to global variables (child1, child2, race_type, fd_sync)
  • Moved totpages and hpage_size to local scope in run_test()
  • Replaced busy loop with TST_CHECKPOINT_WAIT/WAKE mechanism
  • Fixed indentation in thread_racer() function
  • Made check_online_cpus() function static
  • Declared loop variable 'i' inside for loops using C99 style
  • Removed unnecessary 'available' variable, use CPU_COUNT() directly
  • Fixed indentation for tst_res() call
  • Removed q_sync global variable to avoid uninitialized access
  • Removed unused SYSFS_CPU_ONLINE_FMT macro
  • Optimized variable scope throughout the code
  • Implemented proper checkpoint synchronization pattern
  • Added cleanup() function for resource cleanup
  • Updated Makefile, runtest/hugetlb, and .gitignore

v5:

  • Replace empty initializer {} with {NULL, NULL, NULL} to fix -Wmissing-field-initializers warning in the options array terminator. ---

[ type description here; PLEASE REMOVE THIS LINE AND THE LINES BELOW BEFORE SUBMITTING THIS PULL REQUEST ]

…te-race.c test

This test is designed to detect a kernel allocation race introduced
with hugepage demand-faulting.  The problem is that no lock is held
between allocating a hugepage and instantiating it in the
pagetables or page cache index.  In between the two, the (huge)
page is cleared, so there's substantial time.  Thus two processes
can race instantiating the (same) last available hugepage - one
will fail on the allocation, and thus cause an OOM fault even
though the page it actually wants is being instantiated by the
other racing process.

Signed-off-by: Samir <samir@linux.ibm.com>
v3: https://lore.kernel.org/all/20250928030721.3537869-1-samir@linux.ibm.com/
v4: https://lore.kernel.org/ltp/20260317095559.5766-1-samir@linux.ibm.com/
---
v4:
Addressed review comments:
- Removed unnecessary [Description] tag from comment block
- Added static keyword to global variables (child1, child2, race_type, fd_sync)
- Moved totpages and hpage_size to local scope in run_test()
- Replaced busy loop with TST_CHECKPOINT_WAIT/WAKE mechanism
- Fixed indentation in thread_racer() function
- Made check_online_cpus() function static
- Declared loop variable 'i' inside for loops using C99 style
- Removed unnecessary 'available' variable, use CPU_COUNT() directly
- Fixed indentation for tst_res() call
- Removed q_sync global variable to avoid uninitialized access
- Removed unused SYSFS_CPU_ONLINE_FMT macro
- Optimized variable scope throughout the code
- Implemented proper checkpoint synchronization pattern
- Added cleanup() function for resource cleanup
- Updated Makefile, runtest/hugetlb, and .gitignore

v5:
- Replace empty initializer {} with {NULL, NULL, NULL} to fix
-Wmissing-field-initializers warning in the options array terminator.
---

Signed-off-by: Samir <samir@linux.ibm.com>
@SamirMulani SamirMulani force-pushed the migration-alloc-instantiate-race branch from 0b6b593 to dc4004f Compare May 4, 2026 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant