From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2DB2FC6FA82 for ; Thu, 22 Sep 2022 07:51:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229890AbiIVHvv (ORCPT ); Thu, 22 Sep 2022 03:51:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229519AbiIVHvt (ORCPT ); Thu, 22 Sep 2022 03:51:49 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 43228C88A8 for ; Thu, 22 Sep 2022 00:51:45 -0700 (PDT) Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.56]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4MY6n00vMBzMnh9; Thu, 22 Sep 2022 15:47:00 +0800 (CST) Received: from kwepemm600005.china.huawei.com (7.193.23.191) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 22 Sep 2022 15:51:42 +0800 Received: from [10.67.102.118] (10.67.102.118) by kwepemm600005.china.huawei.com (7.193.23.191) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 22 Sep 2022 15:51:42 +0800 Subject: Re: [PATCH 1/5] hisi_acc_vfio_pci: Fixes a memory leak bug To: Shameerali Kolothum Thodi , "Jason Gunthorpe" , Alex Williamson CC: "cohuck@redhat.com" , "linux-kernel@vger.kernel.org" , "linuxarm@openeuler.org" References: <20220915013157.60771-1-liulongfang@huawei.com> <20220915013157.60771-2-liulongfang@huawei.com> <20220920103443.72654dd7.alex.williamson@redhat.com> <04a17bfa71c440e8a38cba2337a8c6ac@huawei.com> From: liulongfang Message-ID: Date: Thu, 22 Sep 2022 15:51:41 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="gbk" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.102.118] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemm600005.china.huawei.com (7.193.23.191) X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022/9/21 15:27, Shameerali Kolothum Thodi wrote: > > >> -----Original Message----- >> From: liulongfang >> Sent: 21 September 2022 04:13 >> To: Shameerali Kolothum Thodi ; >> Jason Gunthorpe ; Alex Williamson >> >> Cc: cohuck@redhat.com; linux-kernel@vger.kernel.org; >> linuxarm@openeuler.org >> Subject: Re: [PATCH 1/5] hisi_acc_vfio_pci: Fixes a memory leak bug >> >> On 2022/9/21 1:03, Shameerali Kolothum Thodi wrote: >>> >>> >>>> -----Original Message----- >>>> From: Jason Gunthorpe [mailto:jgg@nvidia.com] >>>> Sent: 20 September 2022 17:38 >>>> To: Alex Williamson >>>> Cc: liulongfang ; Shameerali Kolothum Thodi >>>> ; cohuck@redhat.com; >>>> linux-kernel@vger.kernel.org; linuxarm@openeuler.org >>>> Subject: Re: [PATCH 1/5] hisi_acc_vfio_pci: Fixes a memory leak bug >>>> >>>> On Tue, Sep 20, 2022 at 10:34:43AM -0600, Alex Williamson wrote: >>>>> On Thu, 15 Sep 2022 09:31:53 +0800 >>>>> Longfang Liu wrote: >>>>> >>>>>> During the stop copy phase of live migration, the driver allocates a >>>>>> memory for the migrated data to save the data. >>>>>> >>>>>> When an exception occurs when the driver reads device data, the >>>>>> driver will report an error to qemu and exit the current migration state. >>>>>> But this memory is not released, which will lead to a memory leak >>>>>> problem. >>>> >>>> Why isn't it released? The fput() releases it: >>>> >>>> static int hisi_acc_vf_release_file(struct inode *inode, struct file *filp) { >>>> struct hisi_acc_vf_migration_file *migf = filp->private_data; >>>> >>>> hisi_acc_vf_disable_fd(migf); >>>> mutex_destroy(&migf->lock); >>>> kfree(migf); >>>> ^^^^^^^^^^ >>>> >>>> This patch looks wrong to me. >>> >>> That's right. Missed that. Sorry of the oversight. >>> >> Yes, fput will call release in ops of file, here will call hisi_acc_vf_release_file >> to complete the release operation of migf, so this patch is unnecessary. >> >> But there is another place that needs to be modified: >> hisi_acc_vf_disable_fd in hisi_acc_vf_disable_fds is not needed, >> because it will have an fput next. Is this correct? > > I don't think that is correct either. fput() decrements ref count and > will only call release() if the count is zero. We have an explicit get_file() > for the hisi_acc_vf_disable_fds(). Isn't it? > > Thanks, > Shameer > > OK! These are not necessary to be modified, so there is no need to add them to the patchset. I am going to modify the patchset and send it out in the next version. > >>> Thanks, >>> Shameer >>> >>> . >> Thanks, >> Longfang. >>> > . Thanks, Longfang. >