From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36315) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xf7YN-0004rW-Fu for qemu-devel@nongnu.org; Fri, 17 Oct 2014 09:26:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xf7YJ-00049M-5Q for qemu-devel@nongnu.org; Fri, 17 Oct 2014 09:26:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38077) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xf7YI-00049A-Tf for qemu-devel@nongnu.org; Fri, 17 Oct 2014 09:26:43 -0400 Date: Fri, 17 Oct 2014 14:26:26 +0100 From: "Daniel P. Berrange" Message-ID: <20141017132626.GA6628@redhat.com> References: <1413534437-13516-1-git-send-email-haifeng.lin@huawei.com> <20141017083358.GB5874@redhat.com> <5440D9F7.5070708@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <5440D9F7.5070708@huawei.com> Subject: Re: [Qemu-devel] [PATCH] fix the memory leak for share hugepage Reply-To: "Daniel P. Berrange" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Linhaifeng Cc: mst@redhat.com, qemu-devel@nongnu.org, jerry.lilijun@huawei.com On Fri, Oct 17, 2014 at 04:57:27PM +0800, Linhaifeng wrote: > > > On 2014/10/17 16:33, Daniel P. Berrange wrote: > > On Fri, Oct 17, 2014 at 04:27:17PM +0800, haifeng.lin@huawei.com wrote: > >> From: linhaifeng > >> > >> The VM start with share hugepage should close the hugefile fd > >> when exit.Because the hugepage fd may be send to other process > >> e.g vhost-user If qemu not close the fd the other process can > >> not free the hugepage otherwise exit process,this is ugly,so > >> qemu should close all shared fd when exit. > >> > >> Signed-off-by: linhaifeng > > > > Err, all file descriptors are closed automatically when a process > > exits. So manually calling close(fd) before exit can't have any > > functional effect on a resource leak. > > > > If QEMU has sent the FD to another process, that process has a > > completely separate copy of the FD. Closing the FD in QEMU will > > not close the FD in the other process. You need the other process > > to exit for the copy to be closed. > > > > Regards, > > Daniel > > > Hi,daniel > > QEMU send the fd by unix domain socket.unix domain socket just install the fd to > other process and inc the f_count,if qemu not close the fd the f_count is not dec. > Then the other process even close the fd the hugepage would not freed whise the other process exit. The kernel always closes all FDs when a process exits. So if this FD is not being correctly closed then it is a kernel bug. There should never be any reason for an application to do close(fd) before exiting. Regards, Daniel -- |: 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 :|