Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2153836ybc; Wed, 20 Nov 2019 09:39:29 -0800 (PST) X-Google-Smtp-Source: APXvYqwLIQUkB7kJdFJBIdlRxmu1BPDJOF+otGSsCIsPbofZauAZuV2BLUTAYKMnxTxbeyUx4BgL X-Received: by 2002:a5d:4146:: with SMTP id c6mr4773134wrq.250.1574271569373; Wed, 20 Nov 2019 09:39:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574271569; cv=none; d=google.com; s=arc-20160816; b=sIKATxDNG/wxZSmswgdMfegw38g2ebQcebs22FufcDzjGEiurWJDqiKuty+0ZzRlxj vlGWs97ThsGXJGpR+Bok7GENYOVkT1Z1FsU/VhACMooz3qdPZ+27sqWmY6MbRfzv9lAi DiZNOfY5NldlcNioqaBBofICLFhGEwhQSAmUe1xiJlHnY7TI8rpn4pnmUD6HIZeu6C0b /xFr4wa/ATDXIMPkhNcAqx7fbhXfmGTtW4gJz0RUlVX83hEexLx89tZEd5SXYrFxdins 4giSPT7Ifq0nM9r70JimEguyW67Pxy/T5NV+F6RbdnW5T+KJKIVmbCL4UJ1ucpIcPNxk Zp1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=80u+/R+UMHu8tkZPlpcdWGuQDIUGNyNbiLcz9QEBKHw=; b=j7wD5fKlOXmZVuwOTopLkjCTGapp2KJZqmG+RI31FjBqb0rxHdNZJGYs49V3hZMjOH 2hiUnDGsFf+Ngu+TpjtaPMhgIo/esltm+FSvq4S82VF9zCFsGDG/ZPC3WDUoWKxD+aYj j4UNhgfYcLKe3MmfeIOpE5/BlD8u0IHftxqQ2hxeLgZPkWG3oMBydx3qYz4FEtPW3ugk eKkmKI27Ik5LNtu4hMm6CXdOyhPOHqo6hOt/EM66nqg4ESFqqQzwFYAdOw2j0bHgPDj5 gRXNHxnm1TD7coUISuz9LORExn//+RimbmM6FPSybkUDYOjlyVVni6YPMRmyvh4xiwll uyog== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h43si8136edb.89.2019.11.20.09.39.00; Wed, 20 Nov 2019 09:39:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729558AbfKTRMR (ORCPT + 99 others); Wed, 20 Nov 2019 12:12:17 -0500 Received: from foss.arm.com ([217.140.110.172]:43184 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727644AbfKTRMR (ORCPT ); Wed, 20 Nov 2019 12:12:17 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 1695F1FB; Wed, 20 Nov 2019 09:12:16 -0800 (PST) Received: from e121166-lin.cambridge.arm.com (e121166-lin.cambridge.arm.com [10.1.196.255]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9D6743F703; Wed, 20 Nov 2019 09:12:14 -0800 (PST) Date: Wed, 20 Nov 2019 17:12:12 +0000 From: Lorenzo Pieralisi To: Dexuan Cui Cc: kys@microsoft.com, haiyangz@microsoft.com, sthemmin@microsoft.com, sashal@kernel.org, bhelgaas@google.com, linux-hyperv@vger.kernel.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, mikelley@microsoft.com, Alexander.Levin@microsoft.com Subject: Re: [PATCH v2 4/4] PCI: hv: kmemleak: Track the page allocations for struct hv_pcibus_device Message-ID: <20191120171212.GD3279@e121166-lin.cambridge.arm.com> References: <1574234218-49195-1-git-send-email-decui@microsoft.com> <1574234218-49195-5-git-send-email-decui@microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1574234218-49195-5-git-send-email-decui@microsoft.com> User-Agent: Mutt/1.9.4 (2018-02-28) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 19, 2019 at 11:16:58PM -0800, Dexuan Cui wrote: > The page allocated for struct hv_pcibus_device contains pointers to other > slab allocations in new_pcichild_device(). Since kmemleak does not track > and scan page allocations, the slab objects will be reported as leaks > (false positives). Use the kmemleak APIs to allow tracking of such pages. > > Reported-by: Lili Deng > Signed-off-by: Dexuan Cui > --- > > This is actually v1. I use "v2" in the Subject just to be consistent with > the other patches in the patchset. That's a mistake, you should have posted patches separately. I need hyper-V ACKs on this series to get it through. Thanks, Lorenzo > Without the patch, we can see the below warning in dmesg, if kmemleak is > enabled: > > kmemleak: 1 new suspected memory leaks (see /sys/kernel/debug/kmemleak) > > and "cat /sys/kernel/debug/kmemleak" shows: > > unreferenced object 0xffff9217d1f2bec0 (size 192): > comm "kworker/u256:7", pid 100821, jiffies 4501481057 (age 61409.997s) > hex dump (first 32 bytes): > a8 60 b1 63 17 92 ff ff a8 60 b1 63 17 92 ff ff .`.c.....`.c.... > 02 00 00 00 00 00 00 00 80 92 cd 61 17 92 ff ff ...........a.... > backtrace: > [<0000000006f7ae93>] pci_devices_present_work+0x326/0x5e0 [pci_hyperv] > [<00000000278eb88a>] process_one_work+0x15f/0x360 > [<00000000c59501e6>] worker_thread+0x49/0x3c0 > [<000000000a0a7a94>] kthread+0xf8/0x130 > [<000000007075c2e7>] ret_from_fork+0x35/0x40 > > drivers/pci/controller/pci-hyperv.c | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c > index d7e05d436b5e..cc73f49c9e03 100644 > --- a/drivers/pci/controller/pci-hyperv.c > +++ b/drivers/pci/controller/pci-hyperv.c > @@ -46,6 +46,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -2907,6 +2908,16 @@ static int hv_pci_probe(struct hv_device *hdev, > hbus = (struct hv_pcibus_device *)get_zeroed_page(GFP_KERNEL); > if (!hbus) > return -ENOMEM; > + > + /* > + * kmemleak doesn't track page allocations as they are not commonly > + * used for kernel data structures, but here hbus->children indeed > + * contains pointers to hv_pci_dev structs, which are dynamically > + * created in new_pcichild_device(). Allow kmemleak to scan the page > + * so we don't get a false warning of memory leak. > + */ > + kmemleak_alloc(hbus, PAGE_SIZE, 1, GFP_KERNEL); > + > hbus->state = hv_pcibus_init; > > /* > @@ -3133,6 +3144,8 @@ static int hv_pci_remove(struct hv_device *hdev) > > hv_put_dom_num(hbus->sysdata.domain); > > + /* Remove kmemleak object previously allocated in hv_pci_probe() */ > + kmemleak_free(hbus); > free_page((unsigned long)hbus); > return ret; > } > -- > 2.19.1 >