Skip to content

Commit 9619d79

Browse files
committed
---
yaml --- r: 23461 b: refs/heads/master c: 5ba7434 h: refs/heads/master i: 23459: 462b804 v: v3
1 parent 08a6bd2 commit 9619d79

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: e55c5ceac239417784f9fe8c37f92e974b9cc06e
2+
refs/heads/master: 5ba7434cb17c19438b00730b37741f2d61449ad8
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be

trunk/src/rt/rust_task.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,13 @@ MUST_CHECK bool rust_task::yield() {
248248

249249
// This check is largely superfluous; it's the one after the context swap
250250
// 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
251258
if (must_fail_from_being_killed()) {
252259
{
253260
scoped_lock with(lifecycle_lock);

trunk/src/rt/rust_task.h

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -431,12 +431,11 @@ rust_task::call_on_rust_stack(void *args, void *fn_ptr) {
431431
assert(get_sp_limit() != 0 && "Stack must be configured");
432432
assert(next_rust_sp);
433433

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;
440439

441440
uintptr_t prev_c_sp = next_c_sp;
442441
next_c_sp = get_sp();
@@ -448,10 +447,7 @@ rust_task::call_on_rust_stack(void *args, void *fn_ptr) {
448447
__morestack(args, fn_ptr, sp);
449448

450449
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;
455451

456452
record_sp_limit(0);
457453
}

0 commit comments

Comments
 (0)