From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39815) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xf3c7-0001W0-VW for qemu-devel@nongnu.org; Fri, 17 Oct 2014 05:14:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xf3c3-0008Ct-57 for qemu-devel@nongnu.org; Fri, 17 Oct 2014 05:14:23 -0400 Received: from szxga01-in.huawei.com ([119.145.14.64]:5236) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xf3c2-00087H-Fj for qemu-devel@nongnu.org; Fri, 17 Oct 2014 05:14:19 -0400 Message-ID: <5440DDD1.60702@huawei.com> Date: Fri, 17 Oct 2014 17:13:53 +0800 From: Linhaifeng MIME-Version: 1.0 References: <1413534437-13516-1-git-send-email-haifeng.lin@huawei.com> <20141017083358.GB5874@redhat.com> <5440D9D7.4010600@huawei.com> In-Reply-To: <5440D9D7.4010600@huawei.com> Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] fix the memory leak for share hugepage List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gonglei , "Daniel P. Berrange" Cc: jerry.lilijun@huawei.com, qemu-devel@nongnu.org, mst@redhat.com On 2014/10/17 16:56, Gonglei 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. >> > > Actually, when vhost-user close the FD manually, the hugepage leak too > unless the vhost-user process exit. So, maybe the FD is not a separate > copy IMHO, but simply add the ref-count of FD. When QEMU exit, > because the ref is not zero, the operate system will not free the FD > automatically, and when vhost-user close the FD, because of the same > reason, OS will not free FD resource. > > BTW, I don't think this patch is good. When Qemu exit exceptionally, > sush as 'by kill -9', this problem of memory leak still exist. > So,we should close qemu by 'kill -15' or close with virsh. > Best Regards, > -Gonglei > > > > > . > -- Regards, Haifeng