From: Uladzislau Rezki <urezki@gmail.com>
To: Boqun Feng <boqun.feng@gmail.com>
Cc: Uladzislau Rezki <urezki@gmail.com>,
Vitaly Wool <vitaly.wool@konsulko.se>,
linux-mm@kvack.org, akpm@linux-foundation.org,
linux-kernel@vger.kernel.org, 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:45:23 +0200 [thread overview]
Message-ID: <aFwno6S5x7M-_YDP@pc636> (raw)
In-Reply-To: <aFwf5bWd4JtotCc0@Mac.home>
On Wed, Jun 25, 2025 at 09:12:21AM -0700, Boqun Feng wrote:
> On Wed, Jun 25, 2025 at 06:07:06PM +0200, Uladzislau Rezki wrote:
> > 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.
> >
>
> Thanks! But we will need these tests from Rust side anyway, to test
> 1) whether the Rust wrapper does the right thing, and 2) whether any C
> change cause the behavior changes on the API that Rust wrapper rely on.
>
Ah. Got it :)
--
Uladzislau Rezki
next prev parent reply other threads:[~2025-06-25 16:45 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
2025-06-25 16:12 ` Boqun Feng
2025-06-25 16:45 ` Uladzislau Rezki [this message]
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=aFwno6S5x7M-_YDP@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.