From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: David Hildenbrand <david@redhat.com>,
Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>,
Alistair Francis <alistair@alistair23.me>,
Jianxian Wen <jianxian.wen@verisilicon.com>,
QEMU Developers <qemu-devel@nongnu.org>,
Peter Xu <peterx@redhat.com>, qemu-arm <qemu-arm@nongnu.org>,
Gerd Hoffmann <kraxel@redhat.com>,
"Edgar E. Iglesias" <edgar.iglesias@gmail.com>,
Paolo Bonzini <pbonzini@redhat.com>
Subject: Re: [PATCH 2/6] memory: Introduce address_space_create()
Date: Thu, 19 Aug 2021 16:36:19 +0200 [thread overview]
Message-ID: <c2935c37-9c08-ed76-31d1-85d69d8c8877@redhat.com> (raw)
In-Reply-To: <CAFEAcA_GxyOYSfg+Su4iNrGNXyBB-KCfNQ+m+k9RywBGkQa08A@mail.gmail.com>
On 8/19/21 4:24 PM, Peter Maydell wrote:
> On Thu, 19 Aug 2021 at 15:20, Philippe Mathieu-Daudé <philmd@redhat.com> wrote:
>>
>> Introduce address_space_create(). In is similar to
>> address_space_init() but returns a pointer to a heap
>> allocated AddressSpace.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>> ---
>> include/exec/memory.h | 14 ++++++++++++++
>> softmmu/memory.c | 10 ++++++++++
>> 2 files changed, 24 insertions(+)
>>
>> diff --git a/include/exec/memory.h b/include/exec/memory.h
>> index c3d417d317f..b353a48c25f 100644
>> --- a/include/exec/memory.h
>> +++ b/include/exec/memory.h
>> @@ -2418,6 +2418,20 @@ MemTxResult memory_region_dispatch_write(MemoryRegion *mr,
>> */
>> void address_space_init(AddressSpace *as, MemoryRegion *root, const char *name);
>>
>> +/**
>> + * address_space_create: Create and initializes an address space
>> + *
>> + * @root: a #MemoryRegion that routes addresses for the address space
>> + * @name: an address space name. The name is only used for debugging
>> + * output.
>> + *
>> + * Returns pointer to initialized #AddressSpace.
>> + *
>> + * The caller is responsible for releasing the pointer returned
>> + * with address_space_destroy() after use.
>> + */
>> +AddressSpace *address_space_create(MemoryRegion *root, const char *name);
>> +
>
> I'm not really a fan of this as an API -- almost always I think
> devices would do better to have an AddressSpace foo field in
> their device struct and call address_space_init() on that.
> Hiding the heap allocation inside this function makes it harder
> to notice it during code review, I think.
So I understand you rather I discard this (simple) approach and
rather modify 'info mtree' "was designed on the assumption that
there's really only one or two interesting address spaces." [*]
[*] https://www.mail-archive.com/qemu-devel@nongnu.org/msg829821.html
next prev parent reply other threads:[~2021-08-19 14:37 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-19 14:20 [PATCH 0/6] memory: Introduce address_space_create(), re-use &address_space_memory Philippe Mathieu-Daudé
2021-08-19 14:20 ` [PATCH 1/6] memory: Do not increase refcount on global system_memory region Philippe Mathieu-Daudé
2021-08-19 14:23 ` Peter Maydell
2021-08-19 14:20 ` [PATCH 2/6] memory: Introduce address_space_create() Philippe Mathieu-Daudé
2021-08-19 14:24 ` Peter Maydell
2021-08-19 14:36 ` Philippe Mathieu-Daudé [this message]
2021-08-19 14:20 ` [PATCH 3/6] memory: Have cpu_address_space_init() use address_space_create() Philippe Mathieu-Daudé
2021-08-19 14:20 ` [PATCH 4/6] hw/dma: Replace alloc() + address_space_init() by address_space_create() Philippe Mathieu-Daudé
2021-08-19 14:22 ` Peter Maydell
2021-08-19 14:32 ` Philippe Mathieu-Daudé
2021-08-19 14:38 ` Peter Maydell
2021-08-19 14:41 ` Philippe Mathieu-Daudé
2021-08-19 14:20 ` [PATCH 5/6] hw/usb: " Philippe Mathieu-Daudé
2021-08-19 14:20 ` [RFC PATCH 6/6] memory: Have address_space_create() re-use global &address_space_memory Philippe Mathieu-Daudé
2021-08-19 14:34 ` Peter Maydell
2021-08-19 14:41 ` Philippe Mathieu-Daudé
2021-08-20 6:07 ` Gerd Hoffmann
2021-08-20 7:17 ` Philippe Mathieu-Daudé
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=c2935c37-9c08-ed76-31d1-85d69d8c8877@redhat.com \
--to=philmd@redhat.com \
--cc=alistair@alistair23.me \
--cc=david@redhat.com \
--cc=edgar.iglesias@gmail.com \
--cc=jianxian.wen@verisilicon.com \
--cc=kraxel@redhat.com \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=peterx@redhat.com \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
/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).