qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: "Daniel P. Berrange" <berrange@redhat.com>
Cc: lilijun <jerry.lilijun@huawei.com>,
	Linhaifeng <haifeng.lin@huawei.com>,
	qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [Bug?]When close VM the hugepage not freed
Date: Tue, 14 Oct 2014 19:28:39 +0300	[thread overview]
Message-ID: <20141014162839.GA17071@redhat.com> (raw)
In-Reply-To: <20141014120815.GA29671@redhat.com>

On Tue, Oct 14, 2014 at 01:08:15PM +0100, Daniel P. Berrange wrote:
> On Tue, Oct 14, 2014 at 08:02:38PM +0800, Linhaifeng wrote:
> > Hi,all
> > 
> > I was trying to use hugepage with VM and found that the hugepage not freed when close VM.
> > 
> > 
> > 1.Before start VM the /proc/meminfo is:
> > AnonHugePages:    124928 kB
> > HugePages_Total:    4096
> > HugePages_Free:     3072
> > HugePages_Rsvd:        0
> > HugePages_Surp:        0
> > Hugepagesize:       2048 kB
> > 
> > 2.Start VM the /proc/meminfo is:
> > AnonHugePages:    139264 kB
> > HugePages_Total:    4096
> > HugePages_Free:     2048
> > HugePages_Rsvd:        0
> > HugePages_Surp:        0
> > Hugepagesize:       2048 kB
> > 
> > 3.Close VM the /proc/meminfo is:
> > AnonHugePages:    124928 kB
> > HugePages_Total:    4096
> > HugePages_Free:     2048
> > HugePages_Rsvd:        0
> > HugePages_Surp:        0
> > Hugepagesize:       2048 kB
> > 
> > We can see there are 1024 hugepage leak!
> > 
> > I try to found which function used to free hugepage but i'm not sure
> > where the qemu_ram_free is the function to free hugepage.
> > I found that the qemu_ram_free function not call unlink and we know
> > unlink is used to free hugepage(see example of hugepage-mmap.c in
> > kernel source).
> 
> We can't rely on 'qemu_ram_free' ever executing because we must
> ensure hugepages are freed upon QEMU crash.
> 
> It seems we should rely on UNIX filesytstem semantics and simply
> unlink the memory segment the moment we create it & open the FD.
> That way the kernel will automatically free it when the FD is
> closed when QEMU process exits.
> 
> 
> Regards,
> Daniel

We being libvirt?

> -- 
> |: http://berrange.com      -o-    http://www.flickr.com/photos/dberrange/ :|
> |: http://libvirt.org              -o-             http://virt-manager.org :|
> |: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
> |: http://entangle-photo.org       -o-       http://live.gnome.org/gtk-vnc :|

  reply	other threads:[~2014-10-14 16:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-14 12:02 [Qemu-devel] [Bug?]When close VM the hugepage not freed Linhaifeng
2014-10-14 12:08 ` Daniel P. Berrange
2014-10-14 16:28   ` Michael S. Tsirkin [this message]
2014-10-15  7:03     ` Daniel P. Berrange
2014-10-15  1:32   ` Linhaifeng
2014-10-15  7:39 ` Linhaifeng

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=20141014162839.GA17071@redhat.com \
    --to=mst@redhat.com \
    --cc=berrange@redhat.com \
    --cc=haifeng.lin@huawei.com \
    --cc=jerry.lilijun@huawei.com \
    --cc=qemu-devel@nongnu.org \
    /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).