diff mbox series

[v4,2/3] memory: Extract mtree_info_as() from mtree_info()

Message ID 20210901161943.4174212-3-philmd@redhat.com
State New
Headers show
Series memory: Have 'info mtree' remove duplicated Address Space information | expand

Commit Message

Philippe Mathieu-Daudé Sept. 1, 2021, 4:19 p.m. UTC
While mtree_info() handles both ASes and flatviews cases,
the two cases share basically no code. Split mtree_info_as()
out of mtree_info() to simplify.

Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
---
 softmmu/memory.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

Comments

David Hildenbrand Sept. 1, 2021, 5:11 p.m. UTC | #1
On 01.09.21 18:19, Philippe Mathieu-Daudé wrote:
> While mtree_info() handles both ASes and flatviews cases,
> the two cases share basically no code. Split mtree_info_as()
> out of mtree_info() to simplify.
> 
> Suggested-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>   softmmu/memory.c | 17 ++++++++++-------
>   1 file changed, 10 insertions(+), 7 deletions(-)
> 
> diff --git a/softmmu/memory.c b/softmmu/memory.c
> index 3eb6f52de67..5be7d5e7412 100644
> --- a/softmmu/memory.c
> +++ b/softmmu/memory.c
> @@ -3284,18 +3284,12 @@ static void mtree_info_flatview(bool dispatch_tree, bool owner)
>       g_hash_table_unref(views);
>   }
>   
> -void mtree_info(bool flatview, bool dispatch_tree, bool owner, bool disabled)
> +static void mtree_info_as(bool dispatch_tree, bool owner, bool disabled)
>   {
>       MemoryRegionListHead ml_head;
>       MemoryRegionList *ml, *ml2;
>       AddressSpace *as;
>   
> -    if (flatview) {
> -        mtree_info_flatview(dispatch_tree, owner);
> -
> -        return;
> -    }
> -
>       QTAILQ_INIT(&ml_head);
>   
>       QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) {
> @@ -3316,6 +3310,15 @@ void mtree_info(bool flatview, bool dispatch_tree, bool owner, bool disabled)
>       }
>   }
>   
> +void mtree_info(bool flatview, bool dispatch_tree, bool owner, bool disabled)
> +{
> +    if (flatview) {
> +        mtree_info_flatview(dispatch_tree, owner);
> +    } else {
> +        mtree_info_as(dispatch_tree, owner, disabled);
> +    }
> +}
> +
>   void memory_region_init_ram(MemoryRegion *mr,
>                               Object *owner,
>                               const char *name,
> 

Reviewed-by: David Hildenbrand <david@redhat.com>

I'd just have squashed that into #1.
Richard Henderson Sept. 4, 2021, 9:23 a.m. UTC | #2
On 9/1/21 7:11 PM, David Hildenbrand wrote:
> On 01.09.21 18:19, Philippe Mathieu-Daudé wrote:
>> While mtree_info() handles both ASes and flatviews cases,
>> the two cases share basically no code. Split mtree_info_as()
>> out of mtree_info() to simplify.
>>
>> Suggested-by: Peter Maydell <peter.maydell@linaro.org>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>> ---
>>   softmmu/memory.c | 17 ++++++++++-------
>>   1 file changed, 10 insertions(+), 7 deletions(-)
>>
>> diff --git a/softmmu/memory.c b/softmmu/memory.c
>> index 3eb6f52de67..5be7d5e7412 100644
>> --- a/softmmu/memory.c
>> +++ b/softmmu/memory.c
>> @@ -3284,18 +3284,12 @@ static void mtree_info_flatview(bool dispatch_tree, bool owner)
>>       g_hash_table_unref(views);
>>   }
>> -void mtree_info(bool flatview, bool dispatch_tree, bool owner, bool disabled)
>> +static void mtree_info_as(bool dispatch_tree, bool owner, bool disabled)
>>   {
>>       MemoryRegionListHead ml_head;
>>       MemoryRegionList *ml, *ml2;
>>       AddressSpace *as;
>> -    if (flatview) {
>> -        mtree_info_flatview(dispatch_tree, owner);
>> -
>> -        return;
>> -    }
>> -
>>       QTAILQ_INIT(&ml_head);
>>       QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) {
>> @@ -3316,6 +3310,15 @@ void mtree_info(bool flatview, bool dispatch_tree, bool owner, 
>> bool disabled)
>>       }
>>   }
>> +void mtree_info(bool flatview, bool dispatch_tree, bool owner, bool disabled)
>> +{
>> +    if (flatview) {
>> +        mtree_info_flatview(dispatch_tree, owner);
>> +    } else {
>> +        mtree_info_as(dispatch_tree, owner, disabled);
>> +    }
>> +}
>> +
>>   void memory_region_init_ram(MemoryRegion *mr,
>>                               Object *owner,
>>                               const char *name,
>>
> 
> Reviewed-by: David Hildenbrand <david@redhat.com>
> 
> I'd just have squashed that into #1.

Agreed, it seems like all part of one change.  Anyway,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

r~
diff mbox series

Patch

diff --git a/softmmu/memory.c b/softmmu/memory.c
index 3eb6f52de67..5be7d5e7412 100644
--- a/softmmu/memory.c
+++ b/softmmu/memory.c
@@ -3284,18 +3284,12 @@  static void mtree_info_flatview(bool dispatch_tree, bool owner)
     g_hash_table_unref(views);
 }
 
-void mtree_info(bool flatview, bool dispatch_tree, bool owner, bool disabled)
+static void mtree_info_as(bool dispatch_tree, bool owner, bool disabled)
 {
     MemoryRegionListHead ml_head;
     MemoryRegionList *ml, *ml2;
     AddressSpace *as;
 
-    if (flatview) {
-        mtree_info_flatview(dispatch_tree, owner);
-
-        return;
-    }
-
     QTAILQ_INIT(&ml_head);
 
     QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) {
@@ -3316,6 +3310,15 @@  void mtree_info(bool flatview, bool dispatch_tree, bool owner, bool disabled)
     }
 }
 
+void mtree_info(bool flatview, bool dispatch_tree, bool owner, bool disabled)
+{
+    if (flatview) {
+        mtree_info_flatview(dispatch_tree, owner);
+    } else {
+        mtree_info_as(dispatch_tree, owner, disabled);
+    }
+}
+
 void memory_region_init_ram(MemoryRegion *mr,
                             Object *owner,
                             const char *name,