From: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
To: Alice Ryhl <aliceryhl@google.com>,
Miguel Ojeda <ojeda@kernel.org>,
Wedson Almeida Filho <wedsonaf@gmail.com>,
Alex Gaynor <alex.gaynor@gmail.com>
Cc: "Boqun Feng" <boqun.feng@gmail.com>,
"Gary Guo" <gary@garyguo.net>,
"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
"Benno Lossin" <benno.lossin@proton.me>,
"Ingo Molnar" <mingo@redhat.com>,
"Peter Zijlstra" <peterz@infradead.org>,
"Will Deacon" <will@kernel.org>,
"Mark Rutland" <mark.rutland@arm.com>,
rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org,
patches@lists.linux.dev,
"Andreas Hindborg" <a.hindborg@samsung.com>
Subject: Re: [PATCH v2 4/4] rust: task: add `Send` marker to `Task`
Date: Tue, 23 May 2023 13:41:35 -0300 [thread overview]
Message-ID: <83f2822e-f36c-0dbf-8226-cef3dc2ba072@gmail.com> (raw)
In-Reply-To: <20230523144418.1250547-5-aliceryhl@google.com>
On 5/23/23 11:44, Alice Ryhl wrote:
> When a type also implements `Sync`, the meaning of `Send` is just "this
> type may be accessed mutably from threads other than the one it is
> created on". That's ok for this type.
>
> Signed-off-by: Alice Ryhl <aliceryhl@google.com>
> Reviewed-by: Andreas Hindborg <a.hindborg@samsung.com>
> ---
> [...]
>
> -// SAFETY: It's OK to access `Task` through references from other threads because we're either
> -// accessing properties that don't change (e.g., `pid`, `group_leader`) or that are properly
> +// SAFETY: By design, the only way to access a `Task` is via the `current` function or via an
> +// `ARef<Task>` obtained through the `AlwaysRefCounted` impl. This means that the only situation in
> +// which a `Task` can be accessed mutably is when the refcount drops to zero and the destructor
> +// runs. It is safe for that to happen on any thread, so it is ok for this type to be `Send`.
> +unsafe impl Send for Task {}
> +
> +// SAFETY: It's OK to access `Task` through shared references from other threads because we're
> +// either accessing properties that don't change (e.g., `pid`, `group_leader`) or that are properly
> // synchronised by C code (e.g., `signal_pending`).
> unsafe impl Sync for Task {}
>
Reviewed-by: Martin Rodriguez Reboredo <yakoyoku@gmail.com>
next prev parent reply other threads:[~2023-05-23 16:42 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-23 14:44 [PATCH v2 0/4] Update thread safety markers Alice Ryhl
2023-05-23 14:44 ` [PATCH v2 1/4] rust: sync: reword the `Arc` safety comment for `Send` Alice Ryhl
2023-05-23 15:49 ` Gary Guo
2023-05-23 16:27 ` Martin Rodriguez Reboredo
2023-05-25 13:35 ` Benno Lossin
2023-05-23 14:44 ` [PATCH v2 2/4] rust: sync: reword the `Arc` safety comment for `Sync` Alice Ryhl
2023-05-23 15:50 ` Gary Guo
2023-05-23 17:08 ` Alice Ryhl
2023-05-23 16:29 ` Martin Rodriguez Reboredo
2023-05-25 13:43 ` Benno Lossin
2023-05-23 14:44 ` [PATCH v2 3/4] rust: specify when `ARef` is thread safe Alice Ryhl
2023-05-23 16:31 ` Martin Rodriguez Reboredo
2023-05-25 13:45 ` Benno Lossin
2023-05-23 14:44 ` [PATCH v2 4/4] rust: task: add `Send` marker to `Task` Alice Ryhl
2023-05-23 15:56 ` Gary Guo
2023-05-23 16:41 ` Martin Rodriguez Reboredo [this message]
2023-05-25 13:46 ` Benno Lossin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=83f2822e-f36c-0dbf-8226-cef3dc2ba072@gmail.com \
--to=yakoyoku@gmail.com \
--cc=a.hindborg@samsung.com \
--cc=alex.gaynor@gmail.com \
--cc=aliceryhl@google.com \
--cc=benno.lossin@proton.me \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=gary@garyguo.net \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=ojeda@kernel.org \
--cc=patches@lists.linux.dev \
--cc=peterz@infradead.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=wedsonaf@gmail.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox