Repository navigation
Conversation
… its mutex FreeBSD 11.4's _mutex_cv_lock takes the mutex back through mutex_lock_common, so a woken waiter tries once, spins and yields by the mutex's counts before it blocks. The wait here called the native lock directly; it now goes through the same spin and yield path as scePthreadMutexLock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MarcZX10
left a comment
There was a problem hiding this comment.
Re-checked — new head, test evidence needed
I reviewed head 16375634e31e44e35ff62a7ab513811d5249b292 and found no source-level blocker, but the new condition-wait test has not been verified by the hosted run.
The Windows job passed its build, but its log says No guest core/libs test sources changed; the changed-test runner therefore did not execute guest_pthread_mutex_spin. Linux and specialized jobs were skipped. The PR description reports Linux test results but does not identify the tested commit SHA, so I cannot tie those results to this head.
Please provide the exact tested SHA and output for guest_pthread_mutex_spin and the focused condition/mutex tests, or arrange for CI to select and run the changed test. I will recheck the same evidence on the updated head.
|
Windows run of this head (
AI-assisted: yes (Claude Code). |
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
|
Tested SHA:
Negative control: with only On CI: the PR does change Thanks to @JJenkx for the Windows run (3 of 3 on this head). |
|
@cocoa55 Reviewed at The expanded Please keep the ring coverage and add a test seam or observable callback/count check that distinguishes the relock path without timing assumptions. Show it passing with this change and failing when only |
The mutex yield step counts each yield in a counter that MutexYieldsForTest_nid_no_patch reads. With no spins and a yield count of 5, a waiter woken while another thread holds its mutex must yield exactly 5 times before it blocks, for each mutex type and for the outer level of a recursive mutex held twice. With WakingLock::lock calling the native lock directly the count stays 0 and the test aborts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Added in 8c4cdf8. The mutex yield step now counts each yield in a relaxed atomic that At 8c4cdf8 (Linux, CachyOS kernel 7.3, GCC 16.2.1, Release): |
What
A woken
scePthreadCondWait/scePthreadCondTimedwait(and thepthread_cond_*calls that use them) now takes its mutex back through the same path asscePthreadMutexLock: it tries once, spins and yields by the mutex's spin and yield counts, then blocks. Before this change,WakingLock::lock()inCond.cppcalled the native lock directly. FreeBSD 11.4 re-locks through_mutex_cv_lock, which callsmutex_lock_common, so a woken waiter spins and yields like any other lock. This is a follow-up to #13544.MutexOperations::SpinAcquire(PthreadMutex, std::timed_mutex&)and itsstd::recursive_timed_mutex&overload exposeMutex.cpp's existing spin path. The re-lock of a recursive mutex's outer level spins; the inner levels the owner takes back don't. The condition variable clause is removed from thelibkernel.mddebt entry.This fixes behaviour only and makes no speed claim.
Tested
Linux (CachyOS, kernel 7.3, GCC, Release, i5-9400F).
guest_pthread_mutex_spinadds a token ring: 4 guest threads take 300 turns each through one condition variable, broadcasting after every turn, so every wake re-locks the mutex under contention. It runs for all four mutex types with 2000 spins and 4 yields, and with neither; withscePthreadCondWaitandscePthreadCondTimedwait; and at recursive depth 2 for the recursive type. It checks that no two threads are ever inside together and that the turn and total counts are exact.These pass: all 56
^guest_pthreadtests,guest_cond_timedwait,guest_cond_recursive_mutex,guest_cond_unowned_mutex, bothguest_libc_cnd_*tests and all 29guest_job_manager_*tests.tools/check_conventions.pypasses.tools/pr_overlap.pyfinds no shared lines: #9326 and #12642 change other functions inMutex.cpp. Not run on Windows or with a title.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