From: Paolo Bonzini <pbonzini@redhat.com>
To: Yang Zhong <yang.zhong@intel.com>, qemu-devel@nongnu.org
Cc: anthony.xu@intel.com
Subject: Re: [Qemu-devel] [PATCH v2] memory: reduce heap Rss size around 3M
Date: Fri, 10 Mar 2017 09:40:17 +0100 [thread overview]
Message-ID: <d6936cdb-66c8-72a9-9e54-988ac6b77e4c@redhat.com> (raw)
In-Reply-To: <1489153475-14888-1-git-send-email-yang.zhong@intel.com>
On 10/03/2017 14:44, 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 284894b..6af80e7 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->ref_count++;
> return as;
> }
>
This has the same problem as v1.
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
prev parent reply other threads:[~2017-03-10 8:40 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-10 13:44 [Qemu-devel] [PATCH v2] memory: reduce heap Rss size around 3M Yang Zhong
2017-03-10 8:40 ` Paolo Bonzini [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d6936cdb-66c8-72a9-9e54-988ac6b77e4c@redhat.com \
--to=pbonzini@redhat.com \
--cc=anthony.xu@intel.com \
--cc=qemu-devel@nongnu.org \
--cc=yang.zhong@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).