Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use queue-based RwLock on more platforms #123811

Merged
merged 4 commits into from
Apr 16, 2024
Merged

Conversation

joboet
Copy link
Contributor

@joboet joboet commented Apr 11, 2024

This switches over Windows 7, SGX and Xous to the queue-based RwLock implementation added in #110211, thereby fixing #121949 for Windows 7 and partially resolving #114581 on SGX. TEEOS can't currently be switched because it doesn't have a good thread parking implementation.

CC @roblabla @raoulstrackx @xobs Could you help me test this, please?
r? @ChrisDenton the Windows stuff should be familiar to you

@joboet joboet added the A-atomic Area: atomics, barriers, and sync primitives label Apr 11, 2024
@rustbot rustbot added O-SGX Target: SGX S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Apr 11, 2024
@joboet joboet added O-xous OS: A microkernel OS for privacy in computing O-windows-7 OS: Windows 7 or Windows Server 2008 R2 or etc. labels Apr 11, 2024
@ChrisDenton
Copy link
Contributor

ChrisDenton commented Apr 11, 2024

The Windows stuff is fine. I can't easily test on Windows 7 atm (so help is welcome) but testing the Win7 binary on Windows 10 worked..

I'll wait for the SGX and Xous experts to weigh in on their target. And if someone can test on Windows 7 proper that would be great. I don't foresee any issues though so I wouldn't block on it.

@xobs
Copy link
Contributor

xobs commented Apr 12, 2024

Looks good to me:

...
test sync::reentrant_lock::tests::smoke ... ok
test sync::reentrant_lock::tests::trylock_works ... ok
test sync::rwlock::tests::frob ... ok
test sync::rwlock::tests::panic_while_mapping_read_unlocked_no_poison ... ok
test sync::rwlock::tests::panic_while_mapping_write_unlocked_poison ... ok
test sync::rwlock::tests::smoke ... ok
test sync::rwlock::tests::test_get_mut ... ok
test sync::rwlock::tests::test_get_mut_poison ... PANIC in PID 6:
thread '<unnamed>' panicked at library/std/src/sync/rwlock/tests.rs:307:9:
test panic in inner thread to poison RwLock
ok
test sync::rwlock::tests::test_into_inner ... ok
test sync::rwlock::tests::test_into_inner_drop ... ok
test sync::rwlock::tests::test_into_inner_poison ... PANIC in PID 6:
thread '<unnamed>' panicked at library/std/src/sync/rwlock/tests.rs:283:9:
test panic in inner thread to poison RwLock
ok
test sync::rwlock::tests::test_mapped_read_guard_covariance ... ok
test sync::rwlock::tests::test_mapping_mapped_guard ... ok
test sync::rwlock::tests::test_read_guard_covariance ... ok
test sync::rwlock::tests::test_rw_arc ... ok
test sync::rwlock::tests::test_rw_arc_access_in_unwind ... PANIC in PID 6:
thread '<unnamed>' panicked at library/std/src/sync/rwlock/tests.rs:209:9:
explicit panic
ok
test sync::rwlock::tests::test_rw_arc_no_poison_mapped_r_r ... PANIC in PID 6:
thread '<unnamed>' panicked at library/std/src/sync/rwlock/tests.rs:122:9:
explicit panic
ok
test sync::rwlock::tests::test_rw_arc_no_poison_mapped_r_w ... PANIC in PID 6:
thread '<unnamed>' panicked at library/std/src/sync/rwlock/tests.rs:149:9:
explicit panic
ok
test sync::rwlock::tests::test_rw_arc_no_poison_rr ... PANIC in PID 6:
thread '<unnamed>' panicked at library/std/src/sync/rwlock/tests.rs:108:9:
explicit panic
ok
test sync::rwlock::tests::test_rw_arc_no_poison_rw ... PANIC in PID 6:
thread '<unnamed>' panicked at library/std/src/sync/rwlock/tests.rs:135:9:
explicit panic
ok
test sync::rwlock::tests::test_rw_arc_poison_mapped_w_r ... PANIC in PID 6:
thread '<unnamed>' panicked at library/std/src/sync/rwlock/tests.rs:68:9:
explicit panic
ok
test sync::rwlock::tests::test_rw_arc_poison_mapped_w_w ... PANIC in PID 6:
thread '<unnamed>' panicked at library/std/src/sync/rwlock/tests.rs:95:9:
explicit panic
ok
test sync::rwlock::tests::test_rw_arc_poison_wr ... PANIC in PID 6:
thread '<unnamed>' panicked at library/std/src/sync/rwlock/tests.rs:55:9:
explicit panic
ok
test sync::rwlock::tests::test_rw_arc_poison_ww ... PANIC in PID 6:
thread '<unnamed>' panicked at library/std/src/sync/rwlock/tests.rs:81:9:
explicit panic
ok
test sync::rwlock::tests::test_rwlock_try_write ... ok
test sync::rwlock::tests::test_rwlock_unsized ... ok
test sys::os_str::bytes::tests::display ... ok
test sys::os_str::bytes::tests::slice_debug_output ... ok
test sys::pal::common::tests::bench_heap_path_alloc ... ok
...

@roblabla
Copy link
Contributor

Oh, awesome! I had resigned myself to thinking the win7 target would be stuck with a broken implementation of RwLocks, so this is great news!

I ran the full core/alloc/std test suite on Windows 7 32-bit and 64-bit, both are passing. LGTM!

@raoulstrackx
Copy link
Contributor

The SGX part also looks good, but I had to apply this patch to keep the compiler happy:

diff --git a/library/std/src/sys/pal/sgx/waitqueue/mod.rs b/library/std/src/sys/pal/sgx/waitqueue/mod.rs
index ea49bb28034..9c106e1d960 100644
--- a/library/std/src/sys/pal/sgx/waitqueue/mod.rs
+++ b/library/std/src/sys/pal/sgx/waitqueue/mod.rs
@@ -64,7 +64,7 @@ pub fn lock_var_mut(&mut self) -> &mut T {
 #[derive(Copy, Clone)]
 pub enum NotifiedTcs {
     Single(Tcs),
-    All { count: NonZero<usize> },
+    All { _count: NonZero<usize> },
 }
 
 /// An RAII guard that will notify a set of target threads as well as unlock
@@ -232,7 +232,7 @@ pub fn notify_all<T>(
             }
 
             if let Some(count) = NonZero::new(count) {
-                Ok(WaitGuard { mutex_guard: Some(guard), notified_tcs: NotifiedTcs::All { count } })
+                Ok(WaitGuard { mutex_guard: Some(guard), notified_tcs: NotifiedTcs::All { _count: count } })
             } else {
                 Err(guard)
             }

@ChrisDenton
Copy link
Contributor

Thank you everyone for testing this!

@bors r+

@bors
Copy link
Contributor

bors commented Apr 16, 2024

📌 Commit 10b6ca1 has been approved by ChrisDenton

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Apr 16, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 16, 2024
…llaumeGomez

Rollup of 7 pull requests

Successful merges:

 - rust-lang#122811 (Move `SourceMap` initialization)
 - rust-lang#123512 (Match ergonomics 2024: Implement eat-one-layer)
 - rust-lang#123811 (Use queue-based `RwLock` on more platforms)
 - rust-lang#123859 (Remove uneeded clones now that TrustedStep implies Copy)
 - rust-lang#123979 (Subtype predicates only exist on inference types, so we can allow them to register opaque types within them.)
 - rust-lang#124016 (Outline default query and hook provider function implementations)
 - rust-lang#124023 (Allow workproducts without object files.)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 1176134 into rust-lang:master Apr 16, 2024
12 checks passed
@rustbot rustbot added this to the 1.79.0 milestone Apr 16, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Apr 16, 2024
Rollup merge of rust-lang#123811 - joboet:queue_em_up, r=ChrisDenton

Use queue-based `RwLock` on more platforms

This switches over Windows 7, SGX and Xous to the queue-based `RwLock` implementation added in rust-lang#110211, thereby fixing rust-lang#121949 for Windows 7 and partially resolving rust-lang#114581 on SGX. TEEOS can't currently be switched because it doesn't have a good thread parking implementation.

CC `@roblabla` `@raoulstrackx` `@xobs` Could you help me test this, please?
r? `@ChrisDenton` the Windows stuff should be familiar to you
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-atomic Area: atomics, barriers, and sync primitives O-SGX Target: SGX O-windows-7 OS: Windows 7 or Windows Server 2008 R2 or etc. O-xous OS: A microkernel OS for privacy in computing S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants