]> git.proxmox.com Git - mirror_qemu.git/commit
rcu: reduce more than 7MB heap memory by malloc_trim()
authorYang Zhong <yang.zhong@intel.com>
Wed, 20 Dec 2017 13:16:46 +0000 (21:16 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 21 Dec 2017 08:30:32 +0000 (09:30 +0100)
commit5a22ab71623c0fb709d49df353bdf2ec7c445c4c
tree291556c8f9de0574891260e025bbefe7f18baddd
parent6b012d2311e5ba0a952c2dcfe4327a73353c9fdb
rcu: reduce more than 7MB heap memory by malloc_trim()

Since there are some issues in memory alloc/free machenism
in glibc for little chunk memory, if Qemu frequently
alloc/free little chunk memory, the glibc doesn't alloc
little chunk memory from free list of glibc and still
allocate from OS, which make the heap size bigger and bigger.

This patch introduce malloc_trim(), which will free heap
memory when there is no rcu call during rcu thread loop.
malloc_trim() can be enabled/disabled by --enable-malloc-trim/
--disable-malloc-trim in the Qemu configure command. The
default malloc_trim() is enabled for libc.

Below are test results from smaps file.
(1)without patch
55f0783e1000-55f07992a000 rw-p 00000000 00:00 0  [heap]
Size:              21796 kB
Rss:               14260 kB
Pss:               14260 kB

(2)with patch
55cc5fadf000-55cc61008000 rw-p 00000000 00:00 0  [heap]
Size:              21668 kB
Rss:                6940 kB
Pss:                6940 kB

Signed-off-by: Yang Zhong <yang.zhong@intel.com>
Message-Id: <1513775806-19779-1-git-send-email-yang.zhong@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
configure
util/rcu.c