memory: reduce heap Rss size around 3M
PATCH 1/1 memory: reduce heap Rss size around 3M
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.
--- memory.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
memory.c +4 -2
@@ -2422,8 +2422,10 @@ 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) { - as->ref_count++; +if (root == as->root) { +if (as->malloced) { + as->ref_count++; + }return as; } }
Signature · 1 line
1.9.1
Quoted 5 lines · Yang Zhong
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 <[email protected]>
Quoted 22 lines
--- memory.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)memory.c +4
-2@@ -2422,8 +2422,10 @@ 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) { - as->ref_count++; +if (root == as->root) { +if (as->malloced) { + as->ref_count++; + }return as; } }
Quoted 21 lines · Philippe Mathieu-Daudé
Quoted 5 lines · Yang Zhong
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 <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>Quoted 12 lines
--- memory.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)memory.c +0
-0@@ -2422,8 +2422,10 @@ AddressSpace *address_space_init_shareable(MemoryRegion *root, const char *name)AddressSpace *as;
Quoted 11 lines
Quoted 11 lines
memory.c +4
-2QTAILQ_FOREACH(as, &address_spaces, address_spaces_link) { -if (root == as->root && as->malloced) { - as->ref_count++; +if (root == as->root) { +if (as->malloced) { + as->ref_count++; + }return as; }}
This is wrong. If as->malloced is false, the AddressSpace might be embedded in another struct. This other struct could be freed when as->ref_count is still greater than 0, causing a use-after-free bug.
Paolo