From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47992) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xe4uS-00079J-TP for qemu-devel@nongnu.org; Tue, 14 Oct 2014 12:25:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xe4uP-0001o4-7A for qemu-devel@nongnu.org; Tue, 14 Oct 2014 12:25:16 -0400 Received: from mx1.redhat.com ([209.132.183.28]:14890) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xe4uO-0001ny-VQ for qemu-devel@nongnu.org; Tue, 14 Oct 2014 12:25:13 -0400 Date: Tue, 14 Oct 2014 19:28:39 +0300 From: "Michael S. Tsirkin" Message-ID: <20141014162839.GA17071@redhat.com> References: <543D10DE.2080109@huawei.com> <20141014120815.GA29671@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20141014120815.GA29671@redhat.com> Subject: Re: [Qemu-devel] [Bug?]When close VM the hugepage not freed List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Daniel P. Berrange" Cc: lilijun , Linhaifeng , qemu-devel@nongnu.org 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 :|