[LTP] [PATCH v5] Migrating the libhugetlbfs/testcases/alloc-instantia…#1313
Open
SamirMulani wants to merge 1 commit intolinux-test-project:masterfrom
Open
[LTP] [PATCH v5] Migrating the libhugetlbfs/testcases/alloc-instantia…#1313SamirMulani wants to merge 1 commit intolinux-test-project:masterfrom
SamirMulani wants to merge 1 commit intolinux-test-project:masterfrom
Conversation
…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>
0b6b593 to
dc4004f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
…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:
v5:
[ type description here; PLEASE REMOVE THIS LINE AND THE LINES BELOW BEFORE SUBMITTING THIS PULL REQUEST ]