From: Marcelo Moreira <marcelomoreira1905@gmail.com>
To: lossin@kernel.org, dakr@kernel.org, ojeda@kernel.org,
rust-for-linux@vger.kernel.org, skhan@linuxfoundation.org,
linux-kernel-mentees@lists.linuxfoundation.org,
~lkcamp/patches@lists.sr.ht
Subject: Re: [PATCH 1/3] rust: revocable: update write invariant and fix safety comments
Date: Sun, 1 Jun 2025 22:53:03 -0300 [thread overview]
Message-ID: <CAPZ3m_isiaSEH91epnMma-rU6a6gDhwVfL9ejLPx1xPMH0fwzA@mail.gmail.com> (raw)
In-Reply-To: <20250602010701.116503-1-marcelomoreira1905@gmail.com>
[PATCH v4 0/3]
rust: revocable: documentation and refactorings
This series of patches brings documentation and refactorings to the
`Revocable` type.
The main changes include:
- Clarifying the write invariant and updating associated safety
comments for `Revocable<T>`.
- Refactoring `RevocableGuard` to be internally safe by holding a
direct reference (`&'a T`), simplifying its usage and reducing unsafe
code.
- Splitting the internal `revoke_internal` function into two distinct,
explicit functions: `revoke()` (safe, synchronizing with RCU) and
`revoke_nosync()` (unsafe, without RCU synchronization).
This is v4 of the patch series.
Changes since v3:
- Refined the wording of the `Revocable<T>` invariants to be more
precise about read and write validity conditions, specifically
including RCU read-side lock acquisition timing for reads and RCU
grace period for writes. - Simplified the `try_access_with_guard`
safety comment for better conciseness.
- Refactored `RevocableGuard` to use `&'a T` instead of `*const T`,
removing its internal invariants and `unsafe` blocks.
- Simplified `Revocable::try_access` to leverage
`try_access_with_guard` and `map`.
- Split `revoke_internal` into `revoke()` and `revoke_nosync()`
functions, making synchronization behavior explicit.
- Link to v3: https://lore.kernel.org/rust-for-linux/DA6XFLKUTP1P.RR6P5AK9PKIZ@kernel.org/T/#t
Changes in v2:
- Refined the wording of the invariants in `Revocable<T>` to be more
direct and address feedback regarding the phrase 'must occur'.
- Added '// INVARIANT:' comments in `try_access` and
`try_access_with_guard` as suggested by reviewers.
- Added the missing invariant for `RevocableGuard<'_, T>` regarding
the validity of `data_ref`.
- Updated the safety comment in the `Deref` implementation of
`RevocableGuard` to refer to the new invariant.
- Link to v2: https://lore.kernel.org/rust-for-linux/CAPZ3m_jw0LxK1MmseaamNYhj9VY8AXtJ0AOcYd9qcn=5wPE4eA@mail.gmail.com/T/#t
Signed-off-by: Marcelo Moreira <marcelomoreira1905@gmail.com>
---
Marcelo Moreira (3):
rust: revocable: update write invariant and fix safety comments
rust: revocable: simplify RevocableGuard for internal safety
rust: revocable: split revoke_internal into revoke and revoke_nosync
rust/kernel/revocable.rs | 84
++++++++++++++++++++++++++++++++++++------------------------------------------------
1 file changed, 36 insertions(+), 48 deletions(-)
--- base-commit: 7a17bbc1d952057898cb0739e60665908fbb8c72
Cheers,
Marcelo Moreira
prev parent reply other threads:[~2025-06-02 1:53 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-02 1:06 [PATCH 1/3] rust: revocable: update write invariant and fix safety comments Marcelo Moreira
2025-06-02 1:07 ` [PATCH 2/3] rust: revocable: simplify RevocableGuard for internal safety Marcelo Moreira
2025-06-02 1:07 ` [PATCH 3/3] rust: revocable: split revoke_internal into revoke and revoke_nosync Marcelo Moreira
2025-06-02 1:53 ` Marcelo Moreira [this message]
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=CAPZ3m_isiaSEH91epnMma-rU6a6gDhwVfL9ejLPx1xPMH0fwzA@mail.gmail.com \
--to=marcelomoreira1905@gmail.com \
--cc=dakr@kernel.org \
--cc=linux-kernel-mentees@lists.linuxfoundation.org \
--cc=lossin@kernel.org \
--cc=ojeda@kernel.org \
--cc=rust-for-linux@vger.kernel.org \
--cc=skhan@linuxfoundation.org \
--cc=~lkcamp/patches@lists.sr.ht \
/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;
as well as URLs for NNTP newsgroup(s).