File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -60,6 +60,7 @@ void JL_UV_LOCK(void)
6060 }
6161 else {
6262 jl_atomic_fetch_add_relaxed (& jl_uv_n_waiters , 1 );
63+ jl_fence (); // [^store_buffering_2]
6364 jl_wake_libuv ();
6465 JL_LOCK (& jl_uv_mutex );
6566 jl_atomic_fetch_add_relaxed (& jl_uv_n_waiters , -1 );
Original file line number Diff line number Diff line change @@ -38,7 +38,14 @@ static const int16_t sleeping = 1;
3838// * Enqueuer:
3939// * 2: `jl_atomic_load_relaxed(&ptls->sleep_check_state)` in `jl_wakeup_thread` returns `not_sleeping`
4040// i.e., the dequeuer misses the enqueue and enqueuer misses the sleep state transition.
41-
41+ // [^store_buffering_2]: and also
42+ // * Enqueuer:
43+ // * 1a: `jl_atomic_store_relaxed(jl_uv_n_waiters, 1)` in `JL_UV_LOCK`
44+ // * 1b: "cheap read" of `handle->pending` in `uv_async_send` (via `JL_UV_LOCK`) loads `0`
45+ // * Dequeuer:
46+ // * 2a: store `2` to `handle->pending` in `uv_async_send` (via `JL_UV_LOCK` in `jl_task_get_next`)
47+ // * 2b: `jl_atomic_load_relaxed(jl_uv_n_waiters)` in `jl_task_get_next` returns `0`
48+ // i.e., the dequeuer misses the `n_waiters` is set and enqueuer misses the `uv_stop` flag (in `signal_async`) transition to cleared
4249
4350JULIA_DEBUG_SLEEPWAKE (
4451uint64_t wakeup_enter ;
@@ -276,7 +283,7 @@ static int may_sleep(jl_ptls_t ptls) JL_NOTSAFEPOINT
276283 // by the thread itself. As a result, if this returns false, it will
277284 // continue returning false. If it returns true, we know the total
278285 // modification order of the fences.
279- jl_fence (); // [^store_buffering_1]
286+ jl_fence (); // [^store_buffering_1] [^store_buffering_2]
280287 return jl_atomic_load_relaxed (& ptls -> sleep_check_state ) == sleeping ;
281288}
282289
You can’t perform that action at this time.
0 commit comments