Skip to content

Add splitting caveats to {read,write}_volatile#156931

Open
scottmcm wants to merge 1 commit into
rust-lang:mainfrom
scottmcm:caveat-volatile-loads
Open

Add splitting caveats to {read,write}_volatile#156931
scottmcm wants to merge 1 commit into
rust-lang:mainfrom
scottmcm:caveat-volatile-loads

Conversation

@scottmcm
Copy link
Copy Markdown
Member

It sounds like we don't actually have guarantees right now (#t-opsem > Defining volatile splitting @ 💬) so let's document that. I think this doesn't need an FCP since it's not actually guaranteeing anything.

@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 May 25, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 25, 2026

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: libs
  • libs expanded to 7 candidates

Copy link
Copy Markdown
Member

@RalfJung RalfJung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

r? me
@rustbot author
Cc @rust-lang/opsem

View changes since this review

///
/// # Load splitting
///
/// Exactly which hardware loads are performed by this function are, in general, highly target-dependent.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// Exactly which hardware loads are performed by this function are, in general, highly target-dependent.
/// Exactly which hardware loads are performed by this function is, in general, highly target-dependent.

/// Exactly which hardware loads are performed by this function are, in general, highly target-dependent.
///
/// For a simple scalar, such as when `T` is a thin pointer, this will typically be one load assuming
/// your target supports a load of exactly that size.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// your target supports a load of exactly that size.
/// your target supports a load of exactly that size and alignment.

///
/// For anything else, it will be split into multiple loads in some unspecified way. This can happen
/// even for scalars: notably, on many targets loading a `u128` will still need to be split, despite
/// being "one" scalar. A load over, say, 64 bytes will almost certainly need to be split. Any load
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/// being "one" scalar. A load over, say, 64 bytes will almost certainly need to be split. Any load
/// being "one" scalar. A load larger than, say, 64 bytes will almost certainly need to be split. Any load

@rustbot rustbot assigned RalfJung and unassigned Mark-Simulacrum May 26, 2026
@rustbot rustbot 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 May 26, 2026
///
/// For anything else, it will be split into multiple loads in some unspecified way. This can happen
/// even for scalars: notably, on many targets loading a `u128` will still need to be split, despite
/// being "one" scalar. A load over, say, 64 bytes will almost certainly need to be split. Any load
Copy link
Copy Markdown
Contributor

@asquared31415 asquared31415 May 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this really intended to say 64 bytes (not bits)? as far as i am aware, on most supported platforms, splits tend to happen for anything larger than usize, and as the previous sentence says, even u128 is split on x86_64.

Maybe this should say "larger than size_of::<usize>()" or similar?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. 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.

5 participants