[PATCH] rust: sync: completion: document Send and Sync safety
Younes Akhouayri via B4 Relay <[email protected]>
| Newsgroups | org.kernel.vger.rust-for-linux,org.kernel.feeds.b4-sent,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <20260811-docs-completion-send-sync-safety-v1-1-0bc663ae967f@younes.io> |
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, and moving an owning pointer to another task preserves +// the pinning of the underlying `struct completion`. 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 {} impl Completion { --- base-commit: 8fe5e5f62bdb9660999449a4b5eaebcc37d7f842 change-id: 20260811-docs-completion-send-sync-safety-296f16d6135c Best regards, -- Younes Akhouayri <[email protected]>