summaryrefslogtreecommitdiff
path: root/samples/configfs
diff options
context:
space:
mode:
authorAlice Ryhl <aliceryhl@google.com>2024-08-14 11:05:22 +0300
committerMiguel Ojeda <ojeda@kernel.org>2024-08-23 07:26:57 +0300
commita48026315cd7b6018bd74831a6dc0586adbba1b9 (patch)
treec515cc5449a5891d6014b6eaeddd497b8d8388cb /samples/configfs
parent6cd341715558b8422f33509d9b99a1a0a5b4b29c (diff)
downloadlinux-a48026315cd7b6018bd74831a6dc0586adbba1b9.tar.xz
rust: list: add tracking for ListArc
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. Reviewed-by: Benno Lossin <benno.lossin@proton.me> Signed-off-by: Alice Ryhl <aliceryhl@google.com> Link: https://lore.kernel.org/r/20240814-linked-list-v5-3-f5f5e8075da0@google.com Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Diffstat (limited to 'samples/configfs')
0 files changed, 0 insertions, 0 deletions