qemu-arm
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 1/6] memory: Do not increase refcount on global system_memory


From: Peter Maydell
Subject: Re: [PATCH 1/6] memory: Do not increase refcount on global system_memory region
Date: Thu, 19 Aug 2021 15:23:48 +0100

On Thu, 19 Aug 2021 at 15:20, Philippe Mathieu-Daudé <philmd@redhat.com> wrote:
>
> system_memory is statically allocated in memory_map_init()
> (softmmu/physmem.c) and is never destroyed. No need to
> increment its refcount.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
>  softmmu/memory.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/softmmu/memory.c b/softmmu/memory.c
> index bfedaf9c4df..185f978c925 100644
> --- a/softmmu/memory.c
> +++ b/softmmu/memory.c
> @@ -24,7 +24,7 @@
>  #include "qemu/qemu-print.h"
>  #include "qom/object.h"
>  #include "trace.h"
> -
> +#include "exec/address-spaces.h"
>  #include "exec/memory-internal.h"
>  #include "exec/ram_addr.h"
>  #include "sysemu/kvm.h"
> @@ -2923,7 +2923,9 @@ void address_space_remove_listeners(AddressSpace *as)
>
>  void address_space_init(AddressSpace *as, MemoryRegion *root, const char 
> *name)
>  {
> -    memory_region_ref(root);
> +    if (root != get_system_memory()) {
> +        memory_region_ref(root);
> +    }

...but there's no need to have an odd special in this code either,
is there? What harm does it do if the system memory MR has a lot of
references ?

-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]