diff mbox

[v3] memory: reduce heap Rss size around 3M

Message ID 7A85DF989CAE8F42902CF7B31A7D94A139557AC1@shsmsx102.ccr.corp.intel.com
State New
Headers show

Commit Message

Yang Zhong March 15, 2017, 8:20 a.m. UTC
Hello Paolo&peter,

Maybe below patch is much more better, I also did the verification. Please all of you give some comments, many thanks!


Regards,

ZhongYang

-----Original Message-----
From: Paolo Bonzini [mailto:pbonzini@redhat.com] 

Sent: Wednesday, March 15, 2017 4:13 PM
To: Zhong, Yang <yang.zhong@intel.com>; qemu-devel@nongnu.org
Cc: Xu, Anthony <anthony.xu@intel.com>; Peter Maydell <peter.maydell@linaro.org>
Subject: Re: [PATCH v3] memory: reduce heap Rss size around 3M



On 15/03/2017 14:39, Yang Zhong wrote:
> Since cpu-memory and memory have same address space,one malloced 

> memory is enough. This patch will skip memory malloc for memory 

> address space,which will reduce around 3M physical memory in heap.

> 

> Signed-off-by: Yang Zhong <yang.zhong@intel.com>

> ---

>  memory.c | 2 +-

>  1 file changed, 1 insertion(+), 1 deletion(-)

> 

> diff --git a/memory.c b/memory.c

> index 64b0a60..0003b1e 100644

> --- a/memory.c

> +++ b/memory.c

> @@ -2422,7 +2422,7 @@ AddressSpace *address_space_init_shareable(MemoryRegion *root, const char *name)

>      AddressSpace *as;

>  

>      QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) {

> -        if (root == as->root && as->malloced) {

> +        if (root == as->root && as == &address_space_memory) {


Of course you need to keep the as->malloced check, don't you?

>              as->ref_count++;

>              return as;

>          }

> 


This is not really beautiful, but compared to v1 and v2 it has the advantage that it works (with the as->malloced check reintroduced).
Peter, you introduced address_space_init_shareable, what do you think?

Paolo
diff mbox

Patch

diff --git a/memory.c b/memory.c
index 64b0a60..230f2cb 100644
--- a/memory.c
+++ b/memory.c
@@ -2422,7 +2422,7 @@  AddressSpace *address_space_init_shareable(MemoryRegion *root, const char *name)
     AddressSpace *as;

     QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) {
-        if (root == as->root && as->malloced) {
+        if (root == as->root && (as->malloced || as == &address_space_memory)) {
             as->ref_count++;
             return as;
         }