Commit Graph
3 Commits
Author SHA1 Message Date
Vitaly Wool 1738796994 rust: support large alignments in allocations
Add support for large (> PAGE_SIZE) alignments in Rust allocators.  All
the preparations on the C side are already done, we just need to add
bindings for <alloc>_node_align() functions and start using those.

Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Vitaly Wool <[email protected]>
Acked-by: Danilo Krummrich <[email protected]>
Acked-by: Alice Ryhl <[email protected]>
Cc: Herbert Xu <[email protected]>
Cc: Jann Horn <[email protected]>
Cc: Kent Overstreet <[email protected]>
Cc: Liam Howlett <[email protected]>
Cc: Lorenzo Stoakes <[email protected]>
Cc: Uladzislau Rezki (Sony) <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
2025-09-13 16:54:46 -07:00
Vitaly Wool 7760b6421b rust: add support for NUMA ids in allocations
Add a new type to support specifying NUMA identifiers in Rust allocators
and extend the allocators to have NUMA id as a parameter.  Thus, modify
ReallocFunc to use the new extended realloc primitives from the C side of
the kernel (i.e.  k[v]realloc_node_align/vrealloc_node_align) and add the
new function alloc_node to the Allocator trait while keeping the existing
one (alloc) for backward compatibility.

This will allow to specify node to use for allocation of e.  g.  {KV}Box,
as well as for future NUMA aware users of the API.

[[email protected]: fix missing import needed for `rusttest`]
  Link: https://lkml.kernel.org/r/[email protected]
Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Vitaly Wool <[email protected]>
Signed-off-by: Miguel Ojeda <[email protected]>
Acked-by: Danilo Krummrich <[email protected]>
Acked-by: Alice Ryhl <[email protected]>
Cc: Herbert Xu <[email protected]>
Cc: Jann Horn <[email protected]>
Cc: Kent Overstreet <[email protected]>
Cc: Liam Howlett <[email protected]>
Cc: Lorenzo Stoakes <[email protected]>
Cc: Uladzislau Rezki (Sony) <[email protected]>
Cc: Vlastimil Babka <[email protected]>
Cc: Miguel Ojeda <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
2025-09-13 16:54:46 -07:00
Danilo Krummrich 61c004781d rust: alloc: implement Vmalloc allocator
Implement `Allocator` for `Vmalloc`, the kernel's virtually contiguous
allocator, typically used for larger objects, (much) larger than page
size.

All memory allocations made with `Vmalloc` end up in `vrealloc()`.

Reviewed-by: Alice Ryhl <[email protected]>
Reviewed-by: Benno Lossin <[email protected]>
Reviewed-by: Gary Guo <[email protected]>
Signed-off-by: Danilo Krummrich <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Miguel Ojeda <[email protected]>
2024-10-15 22:56:59 +02:00