qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>,
	qemu-devel@nongnu.org
Cc: "Marc-André Lureau" <marcandre.lureau@redhat.com>,
	"Daniel P. Berrangé" <berrange@redhat.com>,
	"Thomas Huth" <thuth@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	"Pierrick Bouvier" <pierrick.bouvier@linaro.org>,
	"Richard Henderson" <richard.henderson@linaro.org>,
	"Gustavo Romero" <gustavo.romero@linaro.org>,
	"Alex Bennée" <alex.bennee@linaro.org>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	"Junjie Mao" <junjie.mao@intel.com>,
	"Zhao Liu" <zhao1.liu@intel.com>, "John Snow" <jsnow@redhat.com>,
	"Cleber Rosa" <crosa@redhat.com>,
	"Beraldo Leal" <bleal@redhat.com>,
	"Wainer dos Santos Moschetta" <wainersm@redhat.com>,
	qemu-arm@nongnu.org
Subject: Re: [PATCH v10 7/9] rust: add crate to expose bindings and interfaces
Date: Mon, 30 Sep 2024 11:24:02 +0200	[thread overview]
Message-ID: <e9462238-17fb-4269-bc4a-955d6b8cf4a3@redhat.com> (raw)
In-Reply-To: <20240910-rust-pl011-v10-7-85a89ee33c40@linaro.org>

On 9/10/24 14:35, Manos Pitsidianakis wrote:
> +unsafe impl GlobalAlloc for QemuAllocator {
> +    unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
> +        if matches!(Self::DEFAULT_ALIGNMENT_BYTES, Some(default) if default.checked_rem(layout.align()) == Some(0))
> +        {
> +            g_malloc0(layout.size().try_into().unwrap()).cast::<u8>()
> +        } else {
> +            #[cfg(HAVE_GLIB_WITH_ALIGNED_ALLOC)]
> +            {
> +                g_aligned_alloc0(
> +                    layout.size().try_into().unwrap(),
> +                    1,
> +                    (8 * layout.align()).try_into().unwrap(),
> +                )
> +                .cast::<u8>()
> +            }
> +            #[cfg(not(HAVE_GLIB_WITH_ALIGNED_ALLOC))]
> +            {
> +                qemu_memalign(8 * layout.align(), layout.size()).cast::<u8>()
> +            }

The "8 *" is not needed in either case.

To be honest I'd simply drop the allocator code since you have to respin 
(see Junjie's answer).  The DEFAULT_ALIGNMENT_BYTES trick is nice but 
I'm afraid it can be a source of hard-to-debug bugs.

Anyhow, I'll leave the choice to you as long as it's disabled by 
default, and I think with v11 everything should be ready.

Paolo



  parent reply	other threads:[~2024-09-30  9:25 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-10 12:35 [PATCH v10 0/9] Add Rust build support, ARM PL011 device impl Manos Pitsidianakis
2024-09-10 12:35 ` [PATCH v10 1/9] Require meson version 1.5.0 Manos Pitsidianakis
2024-09-10 12:35 ` [PATCH v10 2/9] build-sys: Add rust feature option Manos Pitsidianakis
2024-09-10 12:35 ` [PATCH v10 3/9] configure, meson: detect Rust toolchain Manos Pitsidianakis
2024-09-10 12:35 ` [PATCH v10 4/9] rust: add bindgen step as a meson dependency Manos Pitsidianakis
2024-09-10 12:35 ` [PATCH v10 5/9] .gitattributes: add Rust diff and merge attributes Manos Pitsidianakis
2024-09-10 12:35 ` [PATCH v10 6/9] meson.build: add HAVE_GLIB_WITH_ALIGNED_ALLOC flag Manos Pitsidianakis
2024-09-10 12:35 ` [PATCH v10 7/9] rust: add crate to expose bindings and interfaces Manos Pitsidianakis
2024-09-14  5:41   ` Junjie Mao
2024-09-30  9:24   ` Paolo Bonzini [this message]
2024-09-10 12:35 ` [PATCH v10 8/9] rust: add utility procedural macro crate Manos Pitsidianakis
2024-09-14  8:12   ` Junjie Mao
2024-09-10 12:35 ` [PATCH v10 9/9] rust: add PL011 device model Manos Pitsidianakis
2024-09-14  8:03   ` Junjie Mao
2024-09-14 11:36     ` Junjie Mao

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=e9462238-17fb-4269-bc4a-955d6b8cf4a3@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=alex.bennee@linaro.org \
    --cc=berrange@redhat.com \
    --cc=bleal@redhat.com \
    --cc=crosa@redhat.com \
    --cc=gustavo.romero@linaro.org \
    --cc=jsnow@redhat.com \
    --cc=junjie.mao@intel.com \
    --cc=manos.pitsidianakis@linaro.org \
    --cc=marcandre.lureau@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=pierrick.bouvier@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=thuth@redhat.com \
    --cc=wainersm@redhat.com \
    --cc=zhao1.liu@intel.com \
    /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).