Repository navigation
test(libkernel): give the positioned close test a real 300 us head start - #7669
Merged
oneandonlydean merged 1 commit intoOct 19, 2026
Merged
Conversation
With WinLibs, std::this_thread::sleep_for under 1 ms returns at once, so close raced the reader in every round and a run where all 60 rounds lost the race aborted. The test now waits with PreciseSleepUs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Oct 19, 2026
karimibrahim07
left a comment
Contributor
There was a problem hiding this comment.
Windows check of head 2c75b6c5b, merged onto main ccbd40240 together with #7670, #7709, #7717 and #7680 (each merge clean, built once). Windows 11 Pro (26300), Ryzen 5 3600, WinLibs GCC 15.2.0 r7, Ninja Release, BUILD_TESTING=ON.
- The wait, same toolchain (a standalone probe, not part of the PR, 100 calls each):
std::this_thread::sleep_forof 50, 300 and 999 us took a median of 0.1 us (max 2.2 us), and 1000 us took 15.6 ms. That matches your numbers, so onmainthe test's 300 us head start isn't there.PreciseSleepUs(300)fromPreciseWait.hpp, 200 calls on a loaded machine: 368 to 634 us, median 500 us. It always waits at least what was asked, so the head start is real now. guest_positioned_closepasses,--repeat until-fail:3.- Under load (8 copies at once plus 12 busy processes, 80 runs each),
main's test and this one both passed. Like you, I didn't reproduce the #7532 abort on this machine. There was one abort, in this PR's binary, at line 35 (create_directory). That one comes from my harness: 8 copies in the same working directory, two of which picked the samesteady_clockdirectory name. It isn't the overlap check, and ctest never runs two copies at once.
Code: PreciseSleepUs is what production code uses for sub-millisecond waits since #1551, and on Windows it takes the PreciseSleepHundredNanos path, not winpthreads' nanosleep. The include is the only other change. I have no requests.
AI-assisted: yes. I ran the build, the probe and the runs above.
12 tasks done
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.
What
guest_positioned_close(from #5938) gives the reader thread a 300 us head start beforesceKernelClose, so that close lands while the 32 MiBsceKernelPreadholds the positioned-transfer lock, and it requires at least one of its 60 rounds to overlap that way. On Windows the head start is not there: with the WinLibs toolchain,std::this_thread::sleep_forof anything below 1 ms returns at once. libstdc++ calls winpthreads'nanosleep, which converts the request to whole milliseconds, so 300 us becomes 0 and no wait happens (#1471 tracks the same thing for production code). Close then races the reader's first instructions in every round, and a run where all 60 rounds lose the race aborts withPositioned close check failed at line 69. That is the intermittent failure onmainreported in #7532 (5 of 30 runs on a VM) and #6972.The test now waits with
PreciseSleepUs(300), the sub-millisecond wait production code uses since #1551.Tested
Windows 11 26200, Ryzen 5 5600X, WinLibs GCC 15.2.0 r7, Release,
BUILD_TESTING=ON, onmain48d61f53b.sleep_forof 50, 300 and 999 us took 0.0 us (median of 200 calls each); 1000 us took 15.6 ms.overlapped(not part of this PR), 30 runs each on an idle machine:main56 to 60 of 60 per run (median 59), this change 60 of 60 in every run. With 24 busy threads both overlapped 60 of 60 in 10 runs each: on this machine a loaded main thread is slow to close, so the reader wins. The failing runs in fix(linux): enter the guest entry on a main stack at the console's address #7532 come from a host where close wins every round, which the real 300 us head start rules out.guest_positioned_closepasses with the change. I did not reproduce the abort on this machine: 45 runs ofmainunder load passed.python tools/check_conventions.py --base origin/mainwith this title and body passes.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code