From: Alice Ryhl <aliceryhl@google.com>
To: 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>,
"Benno Lossin" <benno.lossin@proton.me>,
"Andreas Hindborg" <a.hindborg@samsung.com>,
"Marco Elver" <elver@google.com>,
"Kees Cook" <keescook@chromium.org>, "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,
"Alice Ryhl" <aliceryhl@google.com>
Subject: [PATCH 0/9] Add Rust linked list for reference counted values
Date: Tue, 02 Apr 2024 12:16:57 +0000 [thread overview]
Message-ID: <20240402-linked-list-v1-0-b1c59ba7ae3b@google.com> (raw)
This patchset contains a Rust implementation of a doubly-linked list for
use with reference counted values. Linked lists are famously hard to
implement in Rust [1] given the cyclic nature of the pointers, and
indeed, this implementation uses unsafe to get around that.
Linked lists aren't great for cache locality reasons, but it can be hard
to avoid them for cases where you need data structures that don't
allocate. Most linked lists in Binder are for collections where order
matters (usually stacks or queues). There are also a few lists that are
just collections, but linked lists are only used for this purpose in
cases where the linked list is cold and performance isn't that
important. The linked list is chosen over Vec in this case so that I
don't have to worry about reducing the capacity of the vector. (Our
red/black trees are a much better place to look for improving cache
locality of collections in Rust Binder, and the upcoming xarray bindings
would help with that.)
Please see the Rust Binder RFC [2] for usage examples.
The linked lists are used all over Rust Binder, but some pointers for
where to look for examples:
[PATCH RFC 04/20] rust_binder: add work lists
Implements the work lists that store heterogeneous items. Uses the
various macros a bunch.
[PATCH RFC 10/20] rust_binder: add death notifications
Uses the cursor. Also has objects with multiple prev/next pointer pairs.
[PATCH RFC 15/20] rust_binder: add process freezing
Uses the iterator with for loops.
This patchset depends on [3].
Link: https://rust-unofficial.github.io/too-many-lists/ [1]
Link: https://lore.kernel.org/rust-for-linux/20231101-rust-binder-v1-0-08ba9197f637@google.com/ [2]
Link: https://lore.kernel.org/rust-for-linux/20240311-arc-for-list-v3-0-cba1883c62eb@google.com/ [3]
Signed-off-by: Alice Ryhl <aliceryhl@google.com>
---
Alice Ryhl (9):
rust: list: add ListArc
rust: list: add tracking for ListArc
rust: list: add struct with prev/next pointers
rust: list: add macro for implementing ListItem
rust: list: add List
rust: list: add iterators
rust: list: add cursor
rust: list: support heterogeneous lists
rust: list: add ListArcField
rust/kernel/lib.rs | 1 +
rust/kernel/list.rs | 637 +++++++++++++++++++++++++++++++++
rust/kernel/list/arc.rs | 431 ++++++++++++++++++++++
rust/kernel/list/arc_field.rs | 94 +++++
rust/kernel/list/impl_list_item_mod.rs | 181 ++++++++++
5 files changed, 1344 insertions(+)
---
base-commit: 98ebc2e1c5bd188fd3140a0f812b302bb9c3ad26
change-id: 20240221-linked-list-25169a90a4de
Best regards,
--
Alice Ryhl <aliceryhl@google.com>
next reply other threads:[~2024-04-02 12:17 UTC|newest]
Thread overview: 40+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-02 12:16 Alice Ryhl [this message]
2024-04-02 12:16 ` [PATCH 1/9] rust: list: add ListArc Alice Ryhl
2024-04-03 15:51 ` Benno Lossin
2024-04-04 14:00 ` Alice Ryhl
2024-05-03 14:36 ` Alice Ryhl
2024-05-04 15:50 ` Benno Lossin
2024-04-03 17:18 ` Kane York
2024-04-02 12:16 ` [PATCH 2/9] rust: list: add tracking for ListArc Alice Ryhl
2024-04-03 15:52 ` Benno Lossin
2024-04-04 14:14 ` Alice Ryhl
2024-04-04 14:41 ` Benno Lossin
2024-04-02 12:17 ` [PATCH 3/9] rust: list: add struct with prev/next pointers Alice Ryhl
2024-04-03 15:57 ` Benno Lossin
2024-04-04 14:03 ` Alice Ryhl
2024-04-04 14:05 ` Benno Lossin
2024-04-05 9:47 ` Benno Lossin
2024-04-08 7:57 ` Alice Ryhl
2024-04-02 12:17 ` [PATCH 4/9] rust: list: add macro for implementing ListItem Alice Ryhl
2024-04-03 10:42 ` Benno Lossin
2024-04-02 12:17 ` [PATCH 5/9] rust: list: add List Alice Ryhl
2024-04-04 14:03 ` Benno Lossin
2024-04-04 14:12 ` Alice Ryhl
2024-04-04 14:51 ` Benno Lossin
2024-04-08 8:04 ` Alice Ryhl
2024-04-08 8:51 ` Benno Lossin
2024-04-02 12:17 ` [PATCH 6/9] rust: list: add iterators Alice Ryhl
2024-04-04 14:36 ` Benno Lossin
2024-04-04 14:41 ` Alice Ryhl
2024-04-04 14:52 ` Benno Lossin
2024-04-08 8:00 ` Alice Ryhl
2024-04-02 12:17 ` [PATCH 7/9] rust: list: add cursor Alice Ryhl
2024-04-03 12:19 ` Benno Lossin
2024-04-03 12:49 ` Alice Ryhl
2024-04-04 13:28 ` Benno Lossin
2024-04-04 13:40 ` Alice Ryhl
2024-04-02 12:17 ` [PATCH 8/9] rust: list: support heterogeneous lists Alice Ryhl
2024-04-04 15:35 ` Benno Lossin
2024-04-08 7:59 ` Alice Ryhl
2024-04-02 12:17 ` [PATCH 9/9] rust: list: add ListArcField Alice Ryhl
2024-04-04 15:47 ` 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=20240402-linked-list-v1-0-b1c59ba7ae3b@google.com \
--to=aliceryhl@google.com \
--cc=a.hindborg@samsung.com \
--cc=akpm@linux-foundation.org \
--cc=alex.gaynor@gmail.com \
--cc=benno.lossin@proton.me \
--cc=bjorn3_gh@protonmail.com \
--cc=boqun.feng@gmail.com \
--cc=colyli@suse.de \
--cc=elver@google.com \
--cc=gary@garyguo.net \
--cc=keescook@chromium.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).