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

Unify id-based thread parking implementations #105903

Merged
merged 4 commits into from
Dec 31, 2022
Merged

Conversation

joboet
Copy link
Member

@joboet joboet commented Dec 19, 2022

Multiple platforms currently use thread-id-based parking implementations (NetBSD and SGX1). Even though the strategy does not differ, these are duplicated for each platform, as the id is encoded into an atomic thread variable in different ways for each platform.

Since park is only called by one thread, it is possible to move the thread id into a separate field. By ensuring that the field is only written to once, before any other threads access it, these accesses can be unsynchronized, removing any restrictions on the size and niches of the thread id.

This PR also renames the internal thread_parker modules to thread_parking, as that name now better reflects their contents. I hope this does not add too much reviewing noise.

r? @m-ou-se

@rustbot label +T-libs

Footnotes

  1. SOLID supports this as well, I will switch it over in a follow-up PR.

@rustbot rustbot added 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 Dec 19, 2022
@rustbot
Copy link
Collaborator

rustbot commented Dec 19, 2022

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@bors
Copy link
Contributor

bors commented Dec 28, 2022

☔ The latest upstream changes (presumably #100539) made this pull request unmergeable. Please resolve the merge conflicts.

@m-ou-se m-ou-se added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 28, 2022
@joboet
Copy link
Member Author

joboet commented Dec 29, 2022

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 29, 2022
library/std/src/sys/unix/thread_parking/netbsd.rs Outdated Show resolved Hide resolved
library/std/src/sys/sgx/thread.rs Outdated Show resolved Hide resolved
@m-ou-se m-ou-se added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 30, 2022
@joboet
Copy link
Member Author

joboet commented Dec 30, 2022

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Dec 30, 2022
@m-ou-se
Copy link
Member

m-ou-se commented Dec 30, 2022

Thanks!

@bors r+

@bors
Copy link
Contributor

bors commented Dec 30, 2022

📌 Commit 898302e has been approved by m-ou-se

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 Dec 30, 2022
@bors
Copy link
Contributor

bors commented Dec 31, 2022

⌛ Testing commit 898302e with merge 3183781d4ab598fabeca6e7bf03ccf4bd5d0e9d2...

@bors
Copy link
Contributor

bors commented Dec 31, 2022

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Dec 31, 2022
@ehuss
Copy link
Contributor

ehuss commented Dec 31, 2022

@bors retry #106320

@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 Dec 31, 2022
@rust-log-analyzer
Copy link
Collaborator

The job x86_64-gnu-stable failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)
tidy: Skipping binary file check, read-only filesystem
Checking which error codes lack tests...
* 633 error codes
* highest error code: E0791
thread '<unnamed>' panicked at 'Encountered error while testing Git status: "failed to execute git log command: fatal: ambiguous argument ':!src/tools/miri': unknown revision or path not in the working tree.\nUse '--' to separate paths from revisions, like this:\n'git <command> [<revision>...] -- [<file>...]'\n"', src/tools/tidy/src/no_merge.rs:23:25
Found 507 error codes
Found 0 error(s) in error codes
Done!
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Any { .. }', src/tools/tidy/src/main.rs:42:61

@bors
Copy link
Contributor

bors commented Dec 31, 2022

⌛ Testing commit 898302e with merge e119b8e065f0f3f34090daa1c27db2d2793cde8a...

@compiler-errors
Copy link
Member

Yield to rollup

@bors retry

bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 31, 2022
…mpiler-errors

Rollup of 9 pull requests

Successful merges:

 - rust-lang#105903 (Unify id-based thread parking implementations)
 - rust-lang#106232 (CFI: Monomorphize transparent ADTs before typeid)
 - rust-lang#106248 (Revert "Implement allow-by-default `multiple_supertrait_upcastable` lint")
 - rust-lang#106286 (Make tidy errors red)
 - rust-lang#106295 (Extend scraped examples layout GUI test for position of buttons)
 - rust-lang#106305 ( bootstrap: Get rid of tail_args in stream_cargo)
 - rust-lang#106310 (Dont use `--merge-base` during bootstrap formatting subcommand)
 - rust-lang#106314 (Fix panic on `x build --help`)
 - rust-lang#106317 (Only deduplicate stack traces for good path bugs)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors
Copy link
Contributor

bors commented Dec 31, 2022

⌛ Testing commit 898302e with merge 247e44e...

@bors bors merged commit ff3326d into rust-lang:master Dec 31, 2022
@rustbot rustbot added this to the 1.68.0 milestone Dec 31, 2022
@rust-log-analyzer
Copy link
Collaborator

A job failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

@joboet joboet deleted the unify_parking branch January 10, 2023 17:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

7 participants