From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 21F4CA0540; Mon, 4 Jul 2022 15:34:44 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B43B9410E5; Mon, 4 Jul 2022 15:34:43 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mails.dpdk.org (Postfix) with ESMTP id 38A0340E09; Mon, 4 Jul 2022 15:34:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656941681; x=1688477681; h=message-id:date:subject:to:cc:references:from: in-reply-to:content-transfer-encoding:mime-version; bh=ANtjgPphSXjA294LrXsprhWSlUA/eE2ibGmVukCV8+E=; b=am4t5TTuJ2vPETa9bXUETiyr7YdIE6m94ZU5AP7uscIsdp/LBmodeVo2 WD9boxCwDZM0kWzcwmNnFFuI4KElPaYDiQK6GXOrc4Iq1SxrIyX9Hdpuj ULWd64oz4U5CvbcUDJKFJH4ryXxIwQcJPpzct0sdSDF41XQUtOsMJckkm yJehHJQUCpw2lvQJ/lxlF1F30u6mngujtL8R4RdAEwLYXWOeQxKLqoeFo rt2ZsrXOYRGgizn9RrP254UIgRvI9lUh6YwyIeaCxjVIeOMzyMix26O5j Fo5nu9Bdl6WAF7pQ8UiXz4pE7gt2kSgSbkfhCDgSmwCm7wwowRusOxN5P Q==; X-IronPort-AV: E=McAfee;i="6400,9594,10397"; a="347109367" X-IronPort-AV: E=Sophos;i="5.92,243,1650956400"; d="scan'208";a="347109367" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 04 Jul 2022 06:34:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,243,1650956400"; d="scan'208";a="542591875" Received: from orsmsx605.amr.corp.intel.com ([10.22.229.18]) by orsmga003.jf.intel.com with ESMTP; 04 Jul 2022 06:34:40 -0700 Received: from orsmsx611.amr.corp.intel.com (10.22.229.24) by ORSMSX605.amr.corp.intel.com (10.22.229.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Mon, 4 Jul 2022 06:34:39 -0700 Received: from orsmsx606.amr.corp.intel.com (10.22.229.19) by ORSMSX611.amr.corp.intel.com (10.22.229.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27; Mon, 4 Jul 2022 06:34:39 -0700 Received: from ORSEDG601.ED.cps.intel.com (10.7.248.6) by orsmsx606.amr.corp.intel.com (10.22.229.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.27 via Frontend Transport; Mon, 4 Jul 2022 06:34:39 -0700 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (104.47.55.109) by edgegateway.intel.com (134.134.137.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2308.27; Mon, 4 Jul 2022 06:34:39 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MaC0ssSylZ58ol7IKqY+XDY1bd5oRyRmKXPz359i3yyIBUYqsav0nrQ5oTag5N/MDhCiV+LFhd30AZKG7L/TuguTOCit/7DjPAZU0pbZFN5hYyCdwvkly3g9Myy4yfhQ8MnIyzWLssFRdHrTyF54ZZUgrzYZPPY3bSBNfFQKBSvqdh4hN6tAS7i8oc3UtcxUfiXmfGpa2tDXmMkDIFyHhha37c4p3icjR/9TJyL8qVvTyLIAp6z07SDTFLjGH2XX0RP+T+QRjnW94lu/szrOqLD9OWAli5OFkUkrhgSbR3vTdQlksVIGqYeAFtgBUHpkDD9gGbXV/5GT53FcUm3C+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=fMkW1ttR3122MfaeJb7F97P88HSZHN1C673iPHhGpr8=; b=CZK5ZbhLE3v16Efvh4TSo+CXl/kYzTigqo7HmNQiMdTC96CxMQJgqD0wqqGL+6LWwvxWW3uW08KUXyfbIF0D0Zxes7s+VaMgd1DYPnDdBltHfHpJIE3830ylytdLnZhISzz+/pbiUWpT5ROpCf++V+9PbyTwmxNdSPRoLPjaaGpfI+KEyOVlFQgAZynK70JYsVRMLh5Pjtgyl4voFqz5L/vh6w1ClaeIv0mrDqX7Y9eCjsKw9ok23e62ruMq+a7WMYJJt1Iz3X0t/hNMecVHLD5lPOgtljSppI8jap9YAySl7cFPrpvaCEoWp9F5qrbyoAi8numnhiBw/jfmwIYh1g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=intel.com; Received: from MW4PR11MB5872.namprd11.prod.outlook.com (2603:10b6:303:169::14) by SJ1PR11MB6202.namprd11.prod.outlook.com (2603:10b6:a03:45b::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5395.20; Mon, 4 Jul 2022 13:34:37 +0000 Received: from MW4PR11MB5872.namprd11.prod.outlook.com ([fe80::21c8:d7ec:9943:9d06]) by MW4PR11MB5872.namprd11.prod.outlook.com ([fe80::21c8:d7ec:9943:9d06%5]) with mapi id 15.20.5395.020; Mon, 4 Jul 2022 13:34:37 +0000 Message-ID: Date: Mon, 4 Jul 2022 14:34:31 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.11.0 Subject: Re: [PATCH v2 1/3] dma/idxd: fix memory leak in pci close Content-Language: en-US To: Bruce Richardson CC: , , Xingguang He References: <20220408141504.1319913-1-kevin.laatz@intel.com> <20220703122243.929642-1-kevin.laatz@intel.com> <20220703122243.929642-2-kevin.laatz@intel.com> From: Kevin Laatz In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-ClientProxiedBy: LO4P265CA0198.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:318::11) To MW4PR11MB5872.namprd11.prod.outlook.com (2603:10b6:303:169::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: de4239c4-beba-4eea-5777-08da5dc1f0b2 X-MS-TrafficTypeDiagnostic: SJ1PR11MB6202:EE_ X-LD-Processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YKy/pWkQ/dkt/eMU80JzV49fgdxxgbNsxtvCWgy5jcA9yVVSQ0emoxjhE3E4IxSiO4h2TNDlFNUZ6vG2hvDjjjX5h2jGLN/bueK+cwHVBEGjkIoUQG5/HspGPbuZNejitKxYZ0Z7QI9RNYrnlupkJvHpeTcm8i6UEV753ow3VutUWZPsbiZxx+JAz42QT5dcZ3vtcqJw+X1X5gcSHdGtQoYnl8jXB9QuIkgCTMkvezkdVD6F3BbGB1KAat2AxUXKFHLV9xdQZUOUNWY37owOwUi79hWfuJtyyWbS2Y6NaByjRa5HeyYSxAYZ8eH3oPfX0VSZLO6IThhLsW4Hv5Knn1sj1RIT4SCu9dDie7ZBMa9DSpGGn+SL7S9EVHZENeQCwjxml0eJcE7U19PZsQNmNWCDnWETe+ijKGa4Ihs+QCpAlTCtOhkZmYBeRFdTDJ1y3lcg2d6WcpnHEVkUQJFUa2TcZUIMGRKttpSIAEXrO4H3pks1Ix5bqjSkLIqa6Hff9hBvnXXfsI79UP12F8hsKRddUA0C2gYsR9n3MUx7BWxSW7meJAh406bP54ldde9zdX/t9qxP38FtOsIK9abAxOsaBONPLe8U5tXa5/6WwH9PFPDsZGbTJ3FeXJwci0yDdpkowCs0630VBpqs3bZJx1cnZ/h4+sx763UuzlVHhShtQILdCiiGA9MAu3a3p201FJNMxRWfgwSJ8fOR96f042WlOFCtNJw9nfjbeMEIZ+d0pUvG25g8IQ2OBJ/K7AKXhWmMkpSzMEBYxmUbp8HWkWe3IErspO/yj35N5ZDVganZZ+wxo8U/oDN2a2WkdKyHP77Cd/hZQobLAfb213okaQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:MW4PR11MB5872.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(136003)(396003)(366004)(346002)(39860400002)(376002)(6506007)(6512007)(86362001)(6666004)(38100700002)(53546011)(5660300002)(26005)(31686004)(8936002)(6862004)(31696002)(36756003)(2906002)(316002)(82960400001)(66946007)(6636002)(478600001)(6486002)(41300700001)(186003)(2616005)(107886003)(66476007)(450100002)(4326008)(8676002)(66556008)(44832011)(83380400001)(37006003)(45980500001)(43740500002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?K2YzTnVUMCtMQ1k4YmhMUVZsU3hUUXBLRlVnWlZaNjF2QmVXQWdPQlBQWTBW?= =?utf-8?B?cE02ak5waUphbUlRVlRYYkFGMS9zR2VGZnhmQWxQbkw5TmpTdTVDWDF2MHEw?= =?utf-8?B?YzlOdWtzUzVPN1lrMTJpVkFOTUk5RmQ4a2dscUlBWmUvQU0yQmlNa1FrcCtD?= =?utf-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aUNUOHJIb01IaVJONHd6bDZFM1duVXVsSklz?= =?utf-8?B?R1M5MXNXQ0gxUUdOVzR1Ynp3ZEluU21oVmF2YlcraFBJcmg0OWt6Q0U1bXFs?= =?utf-8?B?Y0daRTd2bmZUVk9HWGYvcnU3eWRhMUlzYVo4WHhsSXl6RGZjM2VyQVdlTlh1?= =?utf-8?Q?d5EiY2Zp3WYGs47NObKNQeazU?= X-MS-Exchange-CrossTenant-Network-Message-Id: de4239c4-beba-4eea-5777-08da5dc1f0b2 X-MS-Exchange-CrossTenant-AuthSource: MW4PR11MB5872.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jul 2022 13:34:37.6980 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: I/fWWu/JTw6umuIdODZbYVHPBRXIwrkvEueOpUgW9ySECNWsgB+QNOTKzpDFzQgC4rTlK0dQYYBVPqQ1P61l2g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ1PR11MB6202 X-OriginatorOrg: intel.com X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On 04/07/2022 14:19, Bruce Richardson wrote: > On Sun, Jul 03, 2022 at 01:22:41PM +0100, Kevin Laatz wrote: >> ASAN reports a memory leak for the 'pci' pointer in the 'idxd_dmadev' >> struct. >> >> This is fixed by free'ing the struct when the last queue on the PCI >> device is being closed. >> >> Fixes: 9449330a8458 ("dma/idxd: create dmadev instances on PCI probe") >> Cc: stable@dpdk.org >> Cc: bruce.richardson@intel.com >> >> Reported-by: Xingguang He >> Signed-off-by: Kevin Laatz >> --- >> drivers/dma/idxd/idxd_common.c | 2 ++ >> drivers/dma/idxd/idxd_internal.h | 2 ++ >> drivers/dma/idxd/idxd_pci.c | 34 +++++++++++++++++++++++++------- >> 3 files changed, 31 insertions(+), 7 deletions(-) >> > Some comments inline below. > > /Bruce > >> diff --git a/drivers/dma/idxd/idxd_common.c b/drivers/dma/idxd/idxd_common.c >> index c77200a457..d347bbed21 100644 >> --- a/drivers/dma/idxd/idxd_common.c >> +++ b/drivers/dma/idxd/idxd_common.c >> @@ -620,6 +620,8 @@ idxd_dmadev_create(const char *name, struct rte_device *dev, >> dmadev->fp_obj->dev_private = idxd; >> >> idxd->dmadev->state = RTE_DMA_DEV_READY; >> + if (idxd->u.pci != NULL) >> + rte_atomic16_inc(&idxd->u.pci->ref_count); >> >> return 0; >> > I don't think this belongs in the common code. Can it be put somewhere in > the pci-specific driver code to avoid issues, e.g. after idxd_dmadev_create > returns in probe_pci() function. Sure, I'll look to move it in v3. [snip] > > @@ -159,12 +178,13 @@ init_pci_device(struct rte_pci_device *dev, struct idxd_dmadev *idxd, > uint8_t lg2_max_batch, lg2_max_copy_size; > unsigned int i, err_code; > > - pci = malloc(sizeof(*pci)); > + pci = rte_malloc(NULL, sizeof(*pci), 0); > Any particular reason for the change from regular malloc to rte_malloc? Mainly consistency, its the only place in the driver where malloc is used instead of rte_malloc. I have no strong preference here - I can remove the change for v3. /Kevin