rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Benno Lossin <benno.lossin@proton.me>
To: Alice Ryhl <aliceryhl@google.com>,
	Miguel Ojeda <ojeda@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: "Alex Gaynor" <alex.gaynor@gmail.com>,
	"Wedson Almeida Filho" <wedsonaf@gmail.com>,
	"Boqun Feng" <boqun.feng@gmail.com>,
	"Gary Guo" <gary@garyguo.net>,
	"Björn Roy Baron" <bjorn3_gh@protonmail.com>,
	"Andreas Hindborg" <a.hindborg@samsung.com>,
	"Marco Elver" <elver@google.com>, "Coly Li" <colyli@suse.de>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Pierre Gondois" <pierre.gondois@arm.com>,
	"Ingo Molnar" <mingo@kernel.org>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Wei Yang" <richard.weiyang@gmail.com>,
	"Matthew Wilcox" <willy@infradead.org>,
	linux-kernel@vger.kernel.org, rust-for-linux@vger.kernel.org,
	"Kees Cook" <kees@kernel.org>
Subject: Re: [PATCH v4 03/10] rust: list: add tracking for ListArc
Date: Tue, 06 Aug 2024 14:30:22 +0000	[thread overview]
Message-ID: <99a469db-da0a-47fe-a69e-38aafebb6d24@proton.me> (raw)
In-Reply-To: <20240806-linked-list-v4-3-23efc510ec92@google.com>

On 06.08.24 15:58, Alice Ryhl wrote:
> Add the ability to track whether a ListArc exists for a given value,
> allowing for the creation of ListArcs without going through UniqueArc.
> 
> The `impl_list_arc_safe!` macro is extended with a `tracked_by` strategy
> that defers the tracking of ListArcs to a field of the struct.
> Additionally, the AtomicListArcTracker type is introduced, which can
> track whether a ListArc exists using an atomic. By deferring the
> tracking to a field of type AtomicListArcTracker, structs gain the
> ability to create ListArcs without going through a UniqueArc.
> 
> Rust Binder uses this for some objects where we want to be able to
> insert them into a linked list at any time. Using the
> AtomicListArcTracker, we are able to check whether an item is already in
> the list, and if not, we can create a `ListArc` and push it.
> 
> The macro has the ability to defer the tracking of ListArcs to a field,
> using whatever strategy that field has. Since we don't add any
> strategies other than AtomicListArcTracker, another similar option would
> be to hard-code that the field should be an AtomicListArcTracker.
> However, Rust Binder has a case where the AtomicListArcTracker is not
> stored directly in the struct, but in a sub-struct. Furthermore, the
> outer struct is generic:
> 
> struct Wrapper<T: ?Sized> {
>     links: ListLinks,
>     inner: T,
> }
> 
> Here, the Wrapper struct implements ListArcSafe with `tracked_by inner`,
> and then the various types used with `inner` also uses the macro to
> implement ListArcSafe. Some of them use the untracked strategy, and some
> of them use tracked_by with an AtomicListArcTracker. This way, Wrapper
> just inherits whichever choice `inner` has made.
> 
> Signed-off-by: Alice Ryhl <aliceryhl@google.com>
> ---
>  rust/kernel/list.rs     |   2 +-
>  rust/kernel/list/arc.rs | 171 +++++++++++++++++++++++++++++++++++++++++++++++-
>  2 files changed, 170 insertions(+), 3 deletions(-)

Reviewed-by: Benno Lossin <benno.lossin@proton.me>

---
Cheers,
Benno


  reply	other threads:[~2024-08-06 15:30 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-06 13:58 [PATCH v4 00/10] Add Rust linked list for reference counted values Alice Ryhl
2024-08-06 13:58 ` [PATCH v4 01/10] rust: init: add `assert_pinned` macro Alice Ryhl
2024-08-06 13:58 ` [PATCH v4 02/10] rust: list: add ListArc Alice Ryhl
2024-08-06 13:58 ` [PATCH v4 03/10] rust: list: add tracking for ListArc Alice Ryhl
2024-08-06 14:30   ` Benno Lossin [this message]
2024-08-06 13:58 ` [PATCH v4 04/10] rust: list: add struct with prev/next pointers Alice Ryhl
2024-08-06 14:32   ` Benno Lossin
2024-08-06 13:58 ` [PATCH v4 05/10] rust: list: add macro for implementing ListItem Alice Ryhl
2024-08-06 14:47   ` Benno Lossin
2024-08-06 13:58 ` [PATCH v4 06/10] rust: list: add List Alice Ryhl
2024-08-06 14:44   ` Benno Lossin
2024-08-06 13:58 ` [PATCH v4 07/10] rust: list: add iterators Alice Ryhl
2024-08-06 13:59 ` [PATCH v4 08/10] rust: list: add cursor Alice Ryhl
2024-08-06 13:59 ` [PATCH v4 09/10] rust: list: support heterogeneous lists Alice Ryhl
2024-08-06 14:47   ` Benno Lossin
2024-08-06 13:59 ` [PATCH v4 10/10] rust: list: add ListArcField Alice Ryhl
2024-08-06 14:00 ` [PATCH v4 00/10] Add Rust linked list for reference counted values Alice Ryhl

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=99a469db-da0a-47fe-a69e-38aafebb6d24@proton.me \
    --to=benno.lossin@proton.me \
    --cc=a.hindborg@samsung.com \
    --cc=akpm@linux-foundation.org \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=colyli@suse.de \
    --cc=elver@google.com \
    --cc=gary@garyguo.net \
    --cc=kees@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pierre.gondois@arm.com \
    --cc=richard.weiyang@gmail.com \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=wedsonaf@gmail.com \
    --cc=willy@infradead.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;
as well as URLs for NNTP newsgroup(s).