rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Uladzislau Rezki <urezki@gmail.com>
To: Boqun Feng <boqun.feng@gmail.com>
Cc: Vitaly Wool <vitaly.wool@konsulko.se>,
	linux-mm@kvack.org, akpm@linux-foundation.org,
	linux-kernel@vger.kernel.org, Uladzislau Rezki <urezki@gmail.com>,
	Danilo Krummrich <dakr@kernel.org>,
	Alice Ryhl <aliceryhl@google.com>,
	rust-for-linux@vger.kernel.org
Subject: Re: [PATCH v3 2/2] rust: support align and NUMA id in allocations
Date: Wed, 25 Jun 2025 18:07:06 +0200	[thread overview]
Message-ID: <aFweqnzDyxWyt7UF@pc636> (raw)
In-Reply-To: <aFv11ORZDmM7g6S-@Mac.home>

On Wed, Jun 25, 2025 at 06:12:52AM -0700, Boqun Feng wrote:
> On Wed, Jun 25, 2025 at 08:30:26AM +0200, Vitaly Wool wrote:
> [...]
> > @@ -151,16 +159,11 @@ unsafe fn realloc(
> >          layout: Layout,
> >          old_layout: Layout,
> >          flags: Flags,
> > +        nid: Option<i32>,
> >      ) -> Result<NonNull<[u8]>, AllocError> {
> > -        // TODO: Support alignments larger than PAGE_SIZE.
> 
> Thanks a lot for doing this! While you're at it, maybe we can add a few
> tests for various alignments of allocation? I'm thinking:
> 
> #[repr(align(65536)]
> pub struct Test64k {
>     a: i32
> }
> 
> #[kunit_tests(rust_vbox)]
> mod tests {
>     #[test]
>     fn large_allocation() -> Result {
>         // Better use `new_uninit()` to avoid allocation on the stack.
>         let x = VBox::<Test64k>::new_uninit(...)?;
> 
> 	assert!(x.as_ptr().addr() & (kernel::sizes::SZ_64K - 1) == 0);
>     }
> }
> 
> Thoughts?
> 
> Regards,
> Boqun
> 
> > -        if layout.align() > bindings::PAGE_SIZE {
> > -            pr_warn!("Vmalloc does not support alignments larger than PAGE_SIZE yet.\n");
> > -            return Err(AllocError);
> > -        }
> > -
> >          // SAFETY: If not `None`, `ptr` is guaranteed to point to valid memory, which was previously
> >          // allocated with this `Allocator`.
> > -        unsafe { ReallocFunc::VREALLOC.call(ptr, layout, old_layout, flags) }
> > +        unsafe { ReallocFunc::VREALLOC.call(ptr, layout, old_layout, flags, nid) }
> >      }
> >  }
> >  
> [...]
>
At least we are lacking of vrealloc() exercising in the vmalloc-test suite.
I am not sure it makes a lot of sense to add a kunit test on top of rust-wrapper
around vrealloc().

From my side, i will add the test case to the test_vmalloc.c test-suite.

--
Uladzislau Rezki

  reply	other threads:[~2025-06-25 16:07 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-25  6:29 [PATCH v3 0/2] support large align and nid in Rust allocators Vitaly Wool
2025-06-25  6:30 ` [PATCH v3 1/2] mm/vmalloc: allow to set node and align in vrealloc Vitaly Wool
2025-06-25  9:58   ` Uladzislau Rezki
2025-06-25  6:30 ` [PATCH v3 2/2] rust: support align and NUMA id in allocations Vitaly Wool
2025-06-25 13:12   ` Boqun Feng
2025-06-25 16:07     ` Uladzislau Rezki [this message]
2025-06-25 16:12       ` Boqun Feng
2025-06-25 16:45         ` Uladzislau Rezki
2025-06-25 18:56   ` Danilo Krummrich
2025-06-25 19:07     ` Danilo Krummrich
2025-06-25 20:22       ` Vitaly Wool
2025-06-25 21:20         ` Danilo Krummrich
2025-06-25 21:10 ` [PATCH v3 0/2] support large align and nid in Rust allocators Andrew Morton
2025-06-25 21:15   ` Danilo Krummrich
2025-06-25 21:34     ` Andrew Morton
2025-06-25 21:36       ` Vitaly Wool

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=aFweqnzDyxWyt7UF@pc636 \
    --to=urezki@gmail.com \
    --cc=akpm@linux-foundation.org \
    --cc=aliceryhl@google.com \
    --cc=boqun.feng@gmail.com \
    --cc=dakr@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=vitaly.wool@konsulko.se \
    /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).