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 53DD8A0C44; Mon, 14 Jun 2021 12:30:57 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C41D44067A; Mon, 14 Jun 2021 12:30:56 +0200 (CEST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mails.dpdk.org (Postfix) with ESMTP id 2DAA04003F for ; Mon, 14 Jun 2021 12:30:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1623666654; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=f2hakkb1NEWjyzZdsfhxlf+pqmWRpCKreOBmWLwg9Rs=; b=XZ0a8bMUFPzVmhh0xXcDVC/hHGEbi/zrwfO4Hjcyv+RoOAdcEyhfG2MFpfpEx7Zt5jyhaz GExBNfw6O0WtEO97BDkRzyDGdRM0ZikXL7Ayz5jkNVP2A0HK8UauY9Xszp35ztbq+9YtSL F5HacV7iRvLJTyPrf0JKE5jtqLg2YY0= Received: from mail-ua1-f69.google.com (mail-ua1-f69.google.com [209.85.222.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-2-ecg_gH5tNxS0451njpfXKg-1; Mon, 14 Jun 2021 06:30:52 -0400 X-MC-Unique: ecg_gH5tNxS0451njpfXKg-1 Received: by mail-ua1-f69.google.com with SMTP id 45-20020a9f23300000b029025645a7d138so5985524uae.11 for ; Mon, 14 Jun 2021 03:30:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=f2hakkb1NEWjyzZdsfhxlf+pqmWRpCKreOBmWLwg9Rs=; b=tfWMZsNC657TOPyFZKpJpgZ072ohzrS+HMQzCPuW6OM9oB/o6MNWCWsffQo39FwiRH CLdnsd24d79r481d0rZ49k9mX3dR+QBk7OXiWDYUTCyI0M2YTh1k/lShs+JVmlOEXLtu PkreZR/jbvg+mV1aDHo7OTARq5WXkuFqhT9vceZLA111BA1z9xcwWX/Dx225nDUgIUz4 v+w9c30YW65Mha7/j7f0IQZZzotXuuzlnHQURCvosn5obKhEIF4oiGhaiBWIs+rBRc1z wl321qn+NLZjJCl11Gyjjg2l1TzV9u/MNnED+OcpHafLpnVhc048UndyM0+o0qkV8rUi 2gmw== X-Gm-Message-State: AOAM533KviEL/E+a3eFT0rPn8OTD3HyGUgcOA27CcDJFDejVtv8p9F2l /wiJSJEX870eVmbhsU1ekDD521qoUBnFv28/VGqbGImLceK9WHpmxjhjaIhrnXFKNL4KPB6EDNU 9bG4VBkrwqR4YkKihUGY= X-Received: by 2002:a05:6102:243c:: with SMTP id l28mr4295509vsi.27.1623666651568; Mon, 14 Jun 2021 03:30:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx/6BpsGuSUvq98+EqumtWjqIbAeJWd4rEzYYNh3+Ni1YxaxzFSRYOLo4tGIK91ibQihk2pbwUs9+ce1G7/V9M= X-Received: by 2002:a05:6102:243c:: with SMTP id l28mr4295493vsi.27.1623666651332; Mon, 14 Jun 2021 03:30:51 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: David Marchand Date: Mon, 14 Jun 2021 12:30:39 +0200 Message-ID: To: Owen Hilyard Cc: dev , dpdklab , Gaetan Rivet , Jerin Jacob Kollanukkaran Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dmarchan@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-dev] Memory leak in rte_pci_scan 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 Sender: "dev" On Mon, Jun 14, 2021 at 11:11 AM David Marchand wrote: > > On Tue, Jun 8, 2021 at 8:48 PM Owen Hilyard wrote: > > > > Hello All, > > > > As part of the community lab's work to deploy static analysis tools, we've > > been doing test runs of the various tools. One of the problems we found is > > that rte_pci_scan leaks 214368 Bytes every time it is run. There are also > > I suspect the "leak" is on pci device objects that are not released > unless hot(un)plugging. > Cc: Gaetan. I think I found a leak at: https://git.dpdk.org/dpdk/tree/drivers/bus/pci/linux/pci.c#n333 For devices with no kernel driver, 'dev' will be leaked, since there is no reference to it in the pci device list. There will be more things to fix (there is a proposed patch on annotating the dpdk memory allocator for ASAN) but can you try this diff below with the mp patch [1] I sent to see if the situation gets better? diff --git a/drivers/bus/pci/linux/pci.c b/drivers/bus/pci/linux/pci.c index 0dc99e9cb2..5ea76bc867 100644 --- a/drivers/bus/pci/linux/pci.c +++ b/drivers/bus/pci/linux/pci.c @@ -331,7 +331,7 @@ pci_scan_one(const char *dirname, const struct rte_pci_addr *addr) else dev->kdrv = RTE_PCI_KDRV_UNKNOWN; } else { - dev->kdrv = RTE_PCI_KDRV_NONE; + free(dev); return 0; } /* device is valid, add in list (sorted) */ 1: http://patchwork.dpdk.org/project/dpdk/patch/20210614091213.3953-1-david.marchand@redhat.com/ -- David Marchand