Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp424979rwb; Thu, 22 Sep 2022 01:18:34 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7VFjgDbNIoqnsDlgGqhrHwoo+3Lp2dpSTR0icqaXTLHIYQHpsRJctzOmFt34ElcLJ4s81I X-Received: by 2002:a17:907:a43:b0:77b:ba98:d2f with SMTP id be3-20020a1709070a4300b0077bba980d2fmr1829743ejc.270.1663834713834; Thu, 22 Sep 2022 01:18:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663834713; cv=none; d=google.com; s=arc-20160816; b=mRsNbHe5fKqz+RcN820n/043GCeeJwCakT0B5JF8UZznR717DcC05PYydNBJRAK5b5 gMB0oezi2WzvMjUEjH9z2HeFPLi06SE/vG38NVwvbPM84GKOCVYjs5/OS9veS9i2P8q4 J5O3fGTXvggJG3uURWv1FAMMSjFC5gcAfM5G0xKNVwJZHbjFt4BxQl8qWD50TuwtObe7 IFnu7yFBHehxeWcGJ4Bz3q2JEuxpKl3Oif4aEsKNpsnOG3HFOAjMnl1Ez7ZXAiCjXOdK 44VND1/FREKgd6YDm0uXPqCbNpC32LHIffSwNW3ixtFEV9wzO3IW33chC5l1ROKhGrxM ASZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=bn6u3b7/hsLnukEr2RHqCDvzJC+04M8P3+dti9nrA+g=; b=iNw6ai0DvGhXr0ytEF+12v2QxWODYyi1Gfn8jyueTYwH4kkVh0B//NSZbmA7Hp9Q6X BNrZhEMqLA+PIWt/3c0hk79e3xXSFRG987H2OqAy4umOv75Y6V/LAbbB4kQOxy+WsRwA Tx9K+Tf767sNxK4GLk54jo15kBtocAv3YPRV09oX7uharR5przbX2CKwuYjFtCZ3hEOu oylKJVk140Hgwxmam65mYIPOCyjyIOl3Ob52MOui/1UgQKAN75iY9g8r9gOiwkuyc9Kq MzSvn8TK2yZpJyct7h3O0zg+ExK+w0RPurdQsdu9BxyqETScSdmWFfgG/m3L1+zqQc8p kbtA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hv18-20020a17090760d200b007802b03c3a7si5475876ejc.678.2022.09.22.01.18.04; Thu, 22 Sep 2022 01:18:33 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229585AbiIVHvu (ORCPT + 99 others); Thu, 22 Sep 2022 03:51:50 -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 X-Spam-Status: No, score=-6.1 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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. >