public inbox for linux-kernel-mentees@lists.linux-foundation.org
 help / color / mirror / Atom feed
From: "Benno Lossin" <lossin@kernel.org>
To: "Marcelo Moreira" <marcelomoreira1905@gmail.com>
Cc: <aliceryhl@google.com>, <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 v6 3/3] rust: revocable: Document RevocableGuard invariants and refine Deref safety
Date: Wed, 09 Jul 2025 10:04:58 +0200	[thread overview]
Message-ID: <DB7DACSKLCI6.1YONOEGQZ08T7@kernel.org> (raw)
In-Reply-To: <CAPZ3m_hArv5MA7H4RYRj1FHUaaFF9+2QAuo03xhUKGQ-YZ8uFg@mail.gmail.com>

On Wed Jul 9, 2025 at 12:24 AM CEST, Marcelo Moreira wrote:
> Em ter., 8 de jul. de 2025 às 12:04, Benno Lossin <lossin@kernel.org> escreveu:
>> On Tue Jul 8, 2025 at 2:33 AM CEST, Marcelo Moreira wrote:
>> >  pub struct RevocableGuard<'a, T> {
>> >      // This can't use the `&'a T` type because references that appear in function arguments must
>> >      // not become dangling during the execution of the function, which can happen if the
>> > @@ -258,8 +259,8 @@ impl<T> Deref for RevocableGuard<'_, T> {
>> >      type Target = T;
>> >
>> >      fn deref(&self) -> &Self::Target {
>> > -        // SAFETY: By the type invariants, we hold the rcu read-side lock, so the object is
>> > -        // guaranteed to remain valid.
>> > +        // SAFETY: `self.data_ref` is valid for writes because of `Self`'s type invariants,
>> > +        // and `_rcu_guard` ensures the data's accessibility for the lifetime of this guard.
>>
>> This also needs to be adjusted.
>
> oh, of course, &T is an immutable reference, mb.
>
> What about:
> // SAFETY: `self.data_ref` is valid because of `Self`'s type invariants
> // and the active RCU read-side lock held via `_rcu_guard`, ensuring
> the data's accessibility.

Sounds good.

---
Cheers,
Benno

  reply	other threads:[~2025-07-09  8:05 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-08  0:33 [PATCH v6 0/3] rust: revocable: Documentation and refactorings for Revocable type Marcelo Moreira
2025-07-08  0:33 ` [PATCH v6 1/3] rust: revocable: Clarify write invariant and update safety comments Marcelo Moreira
2025-07-08  0:33 ` [PATCH v6 2/3] rust: revocable: Refactor revocation mechanism to remove generic revoke_internal Marcelo Moreira
2025-07-08  0:33 ` [PATCH v6 3/3] rust: revocable: Document RevocableGuard invariants and refine Deref safety Marcelo Moreira
2025-07-08 15:04   ` Benno Lossin
2025-07-08 22:24     ` Marcelo Moreira
2025-07-09  8:04       ` Benno Lossin [this message]
2025-07-11 23:06     ` Marcelo Moreira
2025-07-12  8:26       ` Benno Lossin
2025-07-12 18:49         ` Marcelo Moreira
2025-07-12 19:56           ` Benno Lossin
2025-07-16 20:11             ` Marcelo Moreira

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=DB7DACSKLCI6.1YONOEGQZ08T7@kernel.org \
    --to=lossin@kernel.org \
    --cc=aliceryhl@google.com \
    --cc=dakr@kernel.org \
    --cc=linux-kernel-mentees@lists.linuxfoundation.org \
    --cc=marcelomoreira1905@gmail.com \
    --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