rust: zpool: add API for C and Rust
From: | Vitaly Wool <vitaly.wool-AT-konsulko.se> | |
To: | linux-mm-AT-kvack.org, rust-for-linux-AT-vger.kernel.org | |
Subject: | [PATCH v6 0/2] rust: zpool: add API for C and Rust | |
Date: | Tue, 23 Sep 2025 12:25:47 +0200 | |
Message-ID: | <20250923102547.2545992-1-vitaly.wool@konsulko.se> | |
Cc: | Johannes Weiner <hannes-AT-cmpxchg.org>, Yosry Ahmed <yosry.ahmed-AT-linux.dev>, Nhat Pham <nphamcs-AT-gmail.com>, Chengming Zhou <chengming.zhou-AT-linux.dev>, Andrew Morton <akpm-AT-linux-foundation.org>, David Hildenbrand <david-AT-redhat.com>, Lorenzo Stoakes <lorenzo.stoakes-AT-oracle.com>, "Liam R . Howlett" <Liam.Howlett-AT-oracle.com>, Vlastimil Babka <vbabka-AT-suse.cz>, Mike Rapoport <rppt-AT-kernel.org>, Suren Baghdasaryan <surenb-AT-google.com>, Michal Hocko <mhocko-AT-suse.com>, Minchan Kim <minchan-AT-kernel.org>, Sergey Senozhatsky <senozhatsky-AT-chromium.org>, Miguel Ojeda <ojeda-AT-kernel.org>, Alex Gaynor <alex.gaynor-AT-gmail.com>, Boqun Feng <boqun.feng-AT-gmail.com>, Gary Guo <gary-AT-garyguo.net>, Björn Roy Baron <bjorn3_gh-AT-protonmail.com>, Benno Lossin <lossin-AT-kernel.org>, Andreas Hindborg <a.hindborg-AT-kernel.org>, Alice Ryhl <aliceryhl-AT-google.com>, Trevor Gross <tmgross-AT-umich.edu>, Danilo Krummrich <dakr-AT-kernel.org>, Greg Kroah-Hartman <gregkh-AT-linuxfoundation.org>, linux-kernel-AT-vger.kernel.org, Vitaly Wool <vitaly.wool-AT-konsulko.se> | |
Archive-link: | Article |
zpool used to be a common frontend for memory storage pool implementations. With its removal the opportunity to select an allocation backend for zswap has been completely lost. However, with the recent advancements in the vmap/vmalloc field that allow for fast and simple allocation backends, and the initiative to implement one in Rust, the zpool API is still necessary, though it's enough to have it as a thin API for compile time backend selection. This patchset provides such API and implements the interface to use it in Rust kernel code, thus enabling both C and Rust implementations of zpool allocators. zsmalloc and documentation are updated accordingly. Co-developed-by: Alice Ryhl <aliceryhl@google.com> Signed-off-by: Alice Ryhl <aliceryhl@google.com> Signed-off-by: Vitaly Wool <vitaly.wool@konsulko.se> --- Changelog: v1 -> v2: * reworked to stick to the existing Rust driver infrastructure * removed raw pointers from the Rust API v2 -> v3: * detailed safety requirements for unsafe API functions * removed unwrap() * some typo corrections v3 -> v4: * added a working example of zpool Rust API usage in the documentation part * change to Flags arranged as a separate patch * improved safety requirements for ZpoolDriver trait v4 -> v5: * created a new type ZpoolHandle for handle representation on the Rust side * improved description of Flags::from_raw() * pool is no more borrowed as mutable for ZpoolDriver::malloc() * ZpoolDriver::destroy() removed * improved ZpoolDriver implementation example * typos/markup corrections v5 -> v6: * removed zpool API is partially restored (to the minimal required extent) * no Adapter based runtime registration is necessary * a Rust macro for compile time registration is introduced instead --- Documentation/admin-guide/mm/zswap.rst | 14 +- MAINTAINERS | 1 include/linux/zpool.h | 62 ++++++++ mm/Kconfig | 22 ++- mm/zsmalloc.c | 3 mm/zswap.c | 30 ++-- rust/bindings/bindings_helper.h | 1 rust/kernel/lib.rs | 2 rust/kernel/zpool.rs | 366 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 9 files changed, 479 insertions(+), 22 deletions(-)