Re: [PATCH] rust: sync: completion: document Send and Sync safety

"Gary Guo" <[email protected]>
Newsgroups org.kernel.vger.rust-for-linux,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On Tue Aug 11, 2026 at 7:35 PM BST, Younes Akhouayri via B4 Relay wrote:
> From: Younes Akhouayri <[email protected]>
>
> The existing safety comments only restate the guarantees provided by
> Send and Sync. Document that completions have no task affinity, that
> moving an owning pointer preserves pinning, and that the C API serializes
> access to the completion state with wait.lock.
>
> Signed-off-by: Younes Akhouayri <[email protected]>
> ---
>  rust/kernel/sync/completion.rs | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/rust/kernel/sync/completion.rs b/rust/kernel/sync/completion.rs
> index 35ff049ff078..b5842f04887b 100644
> --- a/rust/kernel/sync/completion.rs
> +++ b/rust/kernel/sync/completion.rs
> @@ -69,10 +69,12 @@ pub struct Completion {
>      inner: Opaque<bindings::completion>,
>  }
>  
> -// SAFETY: `Completion` is safe to be send to any task.
> +// SAFETY: `Completion` has no task affinity,

This is just a different way of stating "safe to send to any task"

> and moving an owning pointer to another task preserves
> +// the pinning of the underlying `struct completion`.

I don't parse the sentence at all.

>  unsafe impl Send for Completion {}
>  
> -// SAFETY: `Completion` is safe to be accessed concurrently.
> +// SAFETY: The C completion API protects accesses to `done` and the wait queue with `wait.lock`, so
> +// the operations exposed through shared references may be called concurrently.
>  unsafe impl Sync for Completion {}

These are internal details of `bindings::completion` and completely opaque to
Rust abstractions. They are not referenced in Rust code at all.

I am not seeing any value of adding this.

Best,
Gary

>  
>  impl Completion {
>
> ---
> base-commit: 8fe5e5f62bdb9660999449a4b5eaebcc37d7f842
> change-id: 20260811-docs-completion-send-sync-safety-296f16d6135c
>
> Best regards,
> --  
> Younes Akhouayri <[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.