[PATCH v13 0/4] support large align and nid in Rust allocators

Vitaly Wool posted 4 patches 2 months, 3 weeks ago
There is a newer version of this series
fs/bcachefs/darray.c           |    2 -
fs/bcachefs/util.h             |    2 -
include/linux/bpfptr.h         |    2 -
include/linux/slab.h           |   39 ++++++++++++++++++++++---------------
include/linux/vmalloc.h        |   12 ++++++++---
lib/rhashtable.c               |    4 +--
mm/nommu.c                     |    3 +-
mm/slub.c                      |   64 +++++++++++++++++++++++++++++++++++++++++--------------------
mm/vmalloc.c                   |   29 ++++++++++++++++++++++-----
rust/helpers/slab.c            |   10 +++++----
rust/helpers/vmalloc.c         |    5 ++--
rust/kernel/alloc.rs           |   54 ++++++++++++++++++++++++++++++++++++++++++++++-----
rust/kernel/alloc/allocator.rs |   49 +++++++++++++++++++++-------------------------
rust/kernel/alloc/kbox.rs      |    4 +--
rust/kernel/alloc/kvec.rs      |   11 ++++++++--
15 files changed, 200 insertions(+), 90 deletions(-)
[PATCH v13 0/4] support large align and nid in Rust allocators
Posted by Vitaly Wool 2 months, 3 weeks ago
The coming patches provide the ability for Rust allocators to set
NUMA node and large alignment.

Changelog:
v2 -> v3:
* fixed the build breakage for non-MMU configs
v3 -> v4:
* added NUMA node support for k[v]realloc (patch #2)
* removed extra logic in Rust helpers
* patch for Rust allocators split into 2 (align: patch #3 and
  NUMA ids: patch #4)
v4 -> v5:
* reworked NUMA node support for k[v]realloc for all 3 <alloc>_node
  functions to have the same signature
* all 3 <alloc>_node slab/vmalloc functions now support alignment
  specification
* Rust helpers are extended with new functions, the old ones are left
  intact
* Rust support for NUMA nodes comes first now (as patch #3)
v5 -> v6:
* added <alloc>_node_align functions to keep the existing interfaces
  intact
* clearer separation for Rust support of MUNA ids and large alignments
v6 -> v7:
* NUMA identifier as a new Rust type (NumaNode)
* better documentation for changed and new functions and constants
v7 -> v8:
* removed NumaError
* small cleanups per reviewers' comments
v8 -> v9:
* realloc functions can now reallocate memory for a different NUMA
  node
* better comments/explanations in the Rust part
v9 -> v10:
* refined behavior when memory is being reallocated for a different
  NUMA node, comments added
* cleanups in the Rust part, rustfmt ran
* typos corrected
v10 -> v11:
* added documentation for the NO_NODE constant
* added node parameter to Allocator's alloc/realloc instead of adding
  separate alloc_node resp. realloc_node functions, modified users of
  alloc/realloc in accordance with that
v11 -> v12:
* some redundant _noprof functions removed in patch 2/4
* c'n'p error fixed in patch 2/4 (vmalloc_to_page -> virt_to_page)
* some typo corrections and documentation updates, primarily in patch
  3/4
v12 -> v13:
* fixed wording in comments (patches 1, 3)
* fixed bigger alignment handling in krealloc (patch 2)
* removed pr_warn import (patch 4)

Signed-off-by: Vitaly Wool <vitaly.wool@konsulko.se>
--
 fs/bcachefs/darray.c           |    2 -
 fs/bcachefs/util.h             |    2 -
 include/linux/bpfptr.h         |    2 -
 include/linux/slab.h           |   39 ++++++++++++++++++++++---------------
 include/linux/vmalloc.h        |   12 ++++++++---
 lib/rhashtable.c               |    4 +--
 mm/nommu.c                     |    3 +-
 mm/slub.c                      |   64 +++++++++++++++++++++++++++++++++++++++++--------------------
 mm/vmalloc.c                   |   29 ++++++++++++++++++++++-----
 rust/helpers/slab.c            |   10 +++++----
 rust/helpers/vmalloc.c         |    5 ++--
 rust/kernel/alloc.rs           |   54 ++++++++++++++++++++++++++++++++++++++++++++++-----
 rust/kernel/alloc/allocator.rs |   49 +++++++++++++++++++++-------------------------
 rust/kernel/alloc/kbox.rs      |    4 +--
 rust/kernel/alloc/kvec.rs      |   11 ++++++++--
 15 files changed, 200 insertions(+), 90 deletions(-)
Re: [PATCH v13 0/4] support large align and nid in Rust allocators
Posted by Andrew Morton 2 months, 2 weeks ago
On Tue, 15 Jul 2025 15:56:45 +0200 Vitaly Wool <vitaly.wool@konsulko.se> wrote:

> The coming patches provide the ability for Rust allocators to set
> NUMA node and large alignment.
> 
> ...
>
>  fs/bcachefs/darray.c           |    2 -
>  fs/bcachefs/util.h             |    2 -
>  include/linux/bpfptr.h         |    2 -
>  include/linux/slab.h           |   39 ++++++++++++++++++++++---------------
>  include/linux/vmalloc.h        |   12 ++++++++---
>  lib/rhashtable.c               |    4 +--
>  mm/nommu.c                     |    3 +-
>  mm/slub.c                      |   64 +++++++++++++++++++++++++++++++++++++++++--------------------
>  mm/vmalloc.c                   |   29 ++++++++++++++++++++++-----
>  rust/helpers/slab.c            |   10 +++++----
>  rust/helpers/vmalloc.c         |    5 ++--
>  rust/kernel/alloc.rs           |   54 ++++++++++++++++++++++++++++++++++++++++++++++-----
>  rust/kernel/alloc/allocator.rs |   49 +++++++++++++++++++++-------------------------
>  rust/kernel/alloc/kbox.rs      |    4 +--
>  rust/kernel/alloc/kvec.rs      |   11 ++++++++--
>  15 files changed, 200 insertions(+), 90 deletions(-)

I assume we're looking for a merge into mm.git?

We're at -rc7 so let's target 6.17.  Please resend around the end of
the upcoming merge window?
Re: [PATCH v13 0/4] support large align and nid in Rust allocators
Posted by Danilo Krummrich 2 months, 1 week ago
(Cc: Hui)

On Thu Jul 24, 2025 at 10:54 PM CEST, Andrew Morton wrote:
> On Tue, 15 Jul 2025 15:56:45 +0200 Vitaly Wool <vitaly.wool@konsulko.se> wrote:
>
>> The coming patches provide the ability for Rust allocators to set
>> NUMA node and large alignment.
>> 
>> ...
>>
>>  fs/bcachefs/darray.c           |    2 -
>>  fs/bcachefs/util.h             |    2 -
>>  include/linux/bpfptr.h         |    2 -
>>  include/linux/slab.h           |   39 ++++++++++++++++++++++---------------
>>  include/linux/vmalloc.h        |   12 ++++++++---
>>  lib/rhashtable.c               |    4 +--
>>  mm/nommu.c                     |    3 +-
>>  mm/slub.c                      |   64 +++++++++++++++++++++++++++++++++++++++++--------------------
>>  mm/vmalloc.c                   |   29 ++++++++++++++++++++++-----
>>  rust/helpers/slab.c            |   10 +++++----
>>  rust/helpers/vmalloc.c         |    5 ++--
>>  rust/kernel/alloc.rs           |   54 ++++++++++++++++++++++++++++++++++++++++++++++-----
>>  rust/kernel/alloc/allocator.rs |   49 +++++++++++++++++++++-------------------------
>>  rust/kernel/alloc/kbox.rs      |    4 +--
>>  rust/kernel/alloc/kvec.rs      |   11 ++++++++--
>>  15 files changed, 200 insertions(+), 90 deletions(-)
>
> I assume we're looking for a merge into mm.git?

Yes, I think that's what we agreed in v1 -- the bits I maintain should carry my
Acked-by already.

> We're at -rc7 so let's target 6.17.  Please resend around the end of
> the upcoming merge window?

Yes, this is too late for this cycle. Given that we target the next one, there's
a patch in my queue [1] that interacts with this series.

It would be good if you could pick up [1] (once ready) after this series lands.
I asked Hui to rebase onto this series and Cc you for subsequent submissions for
this purpose.

[1] https://lore.kernel.org/lkml/da9b2afca02124ec14fc9ac7f2a2a85e5be96bc7.1753423953.git.zhuhui@kylinos.cn/
Re: [PATCH v13 0/4] support large align and nid in Rust allocators
Posted by Alice Ryhl 2 months, 1 week ago
On Thu, Jul 24, 2025 at 10:54 PM Andrew Morton
<akpm@linux-foundation.org> wrote:
>
> On Tue, 15 Jul 2025 15:56:45 +0200 Vitaly Wool <vitaly.wool@konsulko.se> wrote:
>
> > The coming patches provide the ability for Rust allocators to set
> > NUMA node and large alignment.
> >
> > ...
> >
> >  fs/bcachefs/darray.c           |    2 -
> >  fs/bcachefs/util.h             |    2 -
> >  include/linux/bpfptr.h         |    2 -
> >  include/linux/slab.h           |   39 ++++++++++++++++++++++---------------
> >  include/linux/vmalloc.h        |   12 ++++++++---
> >  lib/rhashtable.c               |    4 +--
> >  mm/nommu.c                     |    3 +-
> >  mm/slub.c                      |   64 +++++++++++++++++++++++++++++++++++++++++--------------------
> >  mm/vmalloc.c                   |   29 ++++++++++++++++++++++-----
> >  rust/helpers/slab.c            |   10 +++++----
> >  rust/helpers/vmalloc.c         |    5 ++--
> >  rust/kernel/alloc.rs           |   54 ++++++++++++++++++++++++++++++++++++++++++++++-----
> >  rust/kernel/alloc/allocator.rs |   49 +++++++++++++++++++++-------------------------
> >  rust/kernel/alloc/kbox.rs      |    4 +--
> >  rust/kernel/alloc/kvec.rs      |   11 ++++++++--
> >  15 files changed, 200 insertions(+), 90 deletions(-)
>
> I assume we're looking for a merge into mm.git?
>
> We're at -rc7 so let's target 6.17.  Please resend around the end of
> the upcoming merge window?

I think it would make sense for this to land through mm.git, so yes
that sounds like a good plan.

Alice
Re: [PATCH v13 0/4] support large align and nid in Rust allocators
Posted by Vlastimil Babka 2 months, 1 week ago
On 7/25/25 09:14, Alice Ryhl wrote:
> On Thu, Jul 24, 2025 at 10:54 PM Andrew Morton
> <akpm@linux-foundation.org> wrote:
>>
>> On Tue, 15 Jul 2025 15:56:45 +0200 Vitaly Wool <vitaly.wool@konsulko.se> wrote:
>>
>> > The coming patches provide the ability for Rust allocators to set
>> > NUMA node and large alignment.
>> >
>> > ...
>> >
>> >  fs/bcachefs/darray.c           |    2 -
>> >  fs/bcachefs/util.h             |    2 -
>> >  include/linux/bpfptr.h         |    2 -
>> >  include/linux/slab.h           |   39 ++++++++++++++++++++++---------------
>> >  include/linux/vmalloc.h        |   12 ++++++++---
>> >  lib/rhashtable.c               |    4 +--
>> >  mm/nommu.c                     |    3 +-
>> >  mm/slub.c                      |   64 +++++++++++++++++++++++++++++++++++++++++--------------------
>> >  mm/vmalloc.c                   |   29 ++++++++++++++++++++++-----
>> >  rust/helpers/slab.c            |   10 +++++----
>> >  rust/helpers/vmalloc.c         |    5 ++--
>> >  rust/kernel/alloc.rs           |   54 ++++++++++++++++++++++++++++++++++++++++++++++-----
>> >  rust/kernel/alloc/allocator.rs |   49 +++++++++++++++++++++-------------------------
>> >  rust/kernel/alloc/kbox.rs      |    4 +--
>> >  rust/kernel/alloc/kvec.rs      |   11 ++++++++--
>> >  15 files changed, 200 insertions(+), 90 deletions(-)
>>
>> I assume we're looking for a merge into mm.git?
>>
>> We're at -rc7 so let's target 6.17.  Please resend around the end of
>> the upcoming merge window?
> 
> I think it would make sense for this to land through mm.git, so yes
> that sounds like a good plan.

Ack.

> Alice