Changes from RFC to v2: - Dropped the DRM buddy allocator patches from this series. This series now focuses solely on the C linked list interfacing infrastructure (clist module). The DRM buddy allocator bindings will be sent separately once we agree on the clist abstraction. - Dropped samples and added doctests. - Added proper lifetime management similar to scatterlist.
The git tree with all patches can be found at the tag: git://git.kernel.org/pub/scm/linux/kernel/git/jfern/linux.git (tag: clist-v2-checkpoint-6) Introduction ============ This patchset introduces an interface to iterate over doubly circular linked lists used in the kernel (allocated by C kernel code). The main usecase is iterating over the list of blocks provided by the DRM buddy allocator but there will certainly be others in the future. This series introduces a new rust module called clist with the necessary helpers and abstractions for safe iteration over C-allocated linked lists. Notes from earlier series: A question may arise: Why not use rust list.rs for this? ========================================================= Rust's list.rs is used to provide safe intrusive lists for Rust-allocated items. In doing so, it takes ownership of the items in the list and the links between list items. However, the usecase for DRM buddy allocator bindings, the C side allocates the items in the list, and also links the list together. Due to this, there is an ownership conflict making list.rs not the best abstraction for this usecase. What we need is a view of the list, not ownership of it. Further, the list links in a bindings usecase may come from C allocated objects, not from the Rust side. Other comments ============== I already presented the idea in Zulip and it seemed it mostly got agreements there. I rebased the patches on linux-next. I can also add MAINTAINER entries in a future version, if folks agree this should have its own MAINTAINER record. Link to RFC: https://lore.kernel.org/all/[email protected]/ Joel Fernandes (3): rust: helpers: Add list helpers for C linked list operations rust: clist: Add basic list infrastructure and head iterator rust: clist: Add typed iteration with FromListHead trait rust/helpers/helpers.c | 1 + rust/helpers/list.c | 32 ++++ rust/kernel/clist.rs | 394 +++++++++++++++++++++++++++++++++++++++++ rust/kernel/lib.rs | 1 + 4 files changed, 428 insertions(+) create mode 100644 rust/helpers/list.c create mode 100644 rust/kernel/clist.rs -- 2.34.1
