[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [RFC PATCH 6/6] memory: Have address_space_create() re-use global &a
From: |
Philippe Mathieu-Daudé |
Subject: |
Re: [RFC PATCH 6/6] memory: Have address_space_create() re-use global &address_space_memory |
Date: |
Thu, 19 Aug 2021 16:41:48 +0200 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 |
On 8/19/21 4:34 PM, Peter Maydell wrote:
> On Thu, 19 Aug 2021 at 15:21, Philippe Mathieu-Daudé <philmd@redhat.com>
> wrote:
>>
>> We already have a global AddressSpace created along with the
>> global get_system_memory(): address_space_memory. Return it
>> directly instead of creating the same AS with a different name.
>>
>
>> diff --git a/softmmu/memory.c b/softmmu/memory.c
>> index 16a2b518d8d..e4506b5a0d5 100644
>> --- a/softmmu/memory.c
>> +++ b/softmmu/memory.c
>> @@ -2941,6 +2941,10 @@ AddressSpace *address_space_create(MemoryRegion
>> *root, const char *name)
>> {
>> AddressSpace *as;
>>
>> + if (root == get_system_memory()) {
>> + return &address_space_memory;
>> + }
>
> But most ASes aren't set up with address_space_create().
> This doesn't do anything for the common case where the
> AS is initialized with address_space_init().
>
> This also seems to me to be the tail wagging the dog. If we think
> 'info mtree' has too much duplicate information (which it certainly
> does) then we should make mtree_info() smarter about reducing that
> duplication. Off the top of my head, we could change the code that
> prints ASes to do something like:
>
> hashtable = an empty hashtable;
> QEMU_FOREACH(as, ...) {
> qemu_printf("address-space: %s\n", as->name);
> name = lookup as->root in hashtable;
> if (name) {
> qemu_printf("...same as address-space %s\n", name);
> continue;
> }
> add (as->root, as->name) to hashtable;
> mtree_print_mr(as->root...);
> qemu_printf("\n");
> }
Got it, thanks for the review, explanation & suggestion :)
- Re: [PATCH 2/6] memory: Introduce address_space_create(), (continued)
[PATCH 5/6] hw/usb: Replace alloc() + address_space_init() by address_space_create(), Philippe Mathieu-Daudé, 2021/08/19
[RFC PATCH 6/6] memory: Have address_space_create() re-use global &address_space_memory, Philippe Mathieu-Daudé, 2021/08/19