File tree 2 files changed +13
-10
lines changed
2 files changed +13
-10
lines changed Original file line number Diff line number Diff line change @@ -248,6 +248,13 @@ MUST_CHECK bool rust_task::yield() {
248
248
249
249
// This check is largely superfluous; it's the one after the context swap
250
250
// that really matters. This one allows us to assert a useful invariant.
251
+
252
+ // NB: This takes lifecycle_lock three times, and I believe that none of
253
+ // them are actually necessary, as per #3213. Removing the locks here may
254
+ // cause *harmless* races with a killer... but I didn't observe any
255
+ // substantial performance improvement from removing them, even with
256
+ // msgsend-ring-pipes, and also it's my last day, so I'm not about to
257
+ // remove them. -- bblum
251
258
if (must_fail_from_being_killed ()) {
252
259
{
253
260
scoped_lock with (lifecycle_lock);
Original file line number Diff line number Diff line change @@ -431,12 +431,11 @@ rust_task::call_on_rust_stack(void *args, void *fn_ptr) {
431
431
assert (get_sp_limit () != 0 && " Stack must be configured" );
432
432
assert (next_rust_sp);
433
433
434
- bool had_reentered_rust_stack;
435
- {
436
- scoped_lock with (lifecycle_lock);
437
- had_reentered_rust_stack = reentered_rust_stack;
438
- reentered_rust_stack = true ;
439
- }
434
+ // Unlocked access. Might "race" a killer, but harmlessly. This code is
435
+ // only run by the task itself, so cannot race itself. See the comment
436
+ // above inhibit_kill (or #3213) in rust_task.cpp for justification.
437
+ bool had_reentered_rust_stack = reentered_rust_stack;
438
+ reentered_rust_stack = true ;
440
439
441
440
uintptr_t prev_c_sp = next_c_sp;
442
441
next_c_sp = get_sp ();
@@ -448,10 +447,7 @@ rust_task::call_on_rust_stack(void *args, void *fn_ptr) {
448
447
__morestack (args, fn_ptr, sp);
449
448
450
449
next_c_sp = prev_c_sp;
451
- {
452
- scoped_lock with (lifecycle_lock);
453
- reentered_rust_stack = had_reentered_rust_stack;
454
- }
450
+ reentered_rust_stack = had_reentered_rust_stack;
455
451
456
452
record_sp_limit (0 );
457
453
}
You can’t perform that action at this time.
0 commit comments