On 8/19/21 4:34 PM, Peter Maydell wrote:
> On Thu, 19 Aug 2021 at 15:21, Philippe Mathieu-Daudé <phi...@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 :)


Reply via email to