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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA624C43334 for ; Thu, 9 Jun 2022 18:06:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5B0786B00D1; Thu, 9 Jun 2022 14:06:46 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 55FE78D0033; Thu, 9 Jun 2022 14:06:46 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 427A36B00D3; Thu, 9 Jun 2022 14:06:46 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 304A56B00D1 for ; Thu, 9 Jun 2022 14:06:46 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay11.hostedemail.com (Postfix) with ESMTP id EEF8B80F77 for ; Thu, 9 Jun 2022 18:06:45 +0000 (UTC) X-FDA: 79559477970.29.67A3962 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf06.hostedemail.com (Postfix) with ESMTP id 47EBA18006D for ; Thu, 9 Jun 2022 18:06:45 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 53F87B82F6D; Thu, 9 Jun 2022 18:06:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AC8DDC34114; Thu, 9 Jun 2022 18:06:40 +0000 (UTC) Date: Thu, 9 Jun 2022 19:06:36 +0100 From: Catalin Marinas To: Patrick Wang Cc: akpm@linux-foundation.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, yee.lee@mediatek.com Subject: Re: [PATCH v3 1/3] mm: kmemleak: add OBJECT_PHYS flag for objects allocated with physical address Message-ID: References: <20220609124950.1694394-1-patrick.wang.shcn@gmail.com> <20220609124950.1694394-2-patrick.wang.shcn@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220609124950.1694394-2-patrick.wang.shcn@gmail.com> ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1654798005; a=rsa-sha256; cv=none; b=e9ToVJ7qUUCePNFWOwbQgjxRON1h77NHww8UYkULIdhnxLPtFi3k1Wbb6jWXsXUVZUwxYD E91SfJQgozx8JMoP/O3Ldw3DZbD/qDpmNs1Hmi4Pc4TF2bpJEvCbwO8TNfPjP9JhpyrJT5 YC7I13VJyJctskXcGNo4edn/aWy3uc4= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=none; spf=pass (imf06.hostedemail.com: domain of cmarinas@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=cmarinas@kernel.org; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1654798005; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Axsz2MrTV/lSyLfcWMxebrJyY66Ya1uOcWoLBCHoSIc=; b=JUKaykeE1l+AL0lC+sdo2l6+Ipg/WtiYR4z/VGuvCcb86jQMdJNdnqlKV2/5yKDMnn2I/Y H3evejKqWJprt13d0ClN6TfYLrqArzZpZmQrqxfJhhlpdi+80VGBcnpmO92GmgxrcifUN8 IftQQdZ+VS1qNpDOzwuXf+nm1960Grc= X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 47EBA18006D X-Rspam-User: Authentication-Results: imf06.hostedemail.com; dkim=none; spf=pass (imf06.hostedemail.com: domain of cmarinas@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=cmarinas@kernel.org; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" header.from=arm.com (policy=none) X-Stat-Signature: q7begtor9gdt9ucdfneowetwaofhffz3 X-HE-Tag: 1654798005-83348 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Jun 09, 2022 at 08:49:48PM +0800, Patrick Wang wrote: > @@ -1125,15 +1142,18 @@ EXPORT_SYMBOL(kmemleak_no_scan); > * address argument > * @phys: physical address of the object > * @size: size of the object > - * @min_count: minimum number of references to this object. > - * See kmemleak_alloc() > * @gfp: kmalloc() flags used for kmemleak internal memory allocations > */ > -void __ref kmemleak_alloc_phys(phys_addr_t phys, size_t size, int min_count, > - gfp_t gfp) > +void __ref kmemleak_alloc_phys(phys_addr_t phys, size_t size, gfp_t gfp) > { > + pr_debug("%s(0x%pa, %zu)\n", __func__, &phys, size); > + > if (PHYS_PFN(phys) >= min_low_pfn && PHYS_PFN(phys) < max_low_pfn) > - kmemleak_alloc(__va(phys), size, min_count, gfp); > + /* > + * Create object with OBJECT_PHYS flag and > + * assume min_count 0. > + */ > + create_object_phys((unsigned long)__va(phys), size, 0, gfp); > } > EXPORT_SYMBOL(kmemleak_alloc_phys); > > diff --git a/mm/memblock.c b/mm/memblock.c > index e4f03a6e8e56..749abd2685c4 100644 > --- a/mm/memblock.c > +++ b/mm/memblock.c > @@ -1345,8 +1345,8 @@ __next_mem_pfn_range_in_zone(u64 *idx, struct zone *zone, > * from the regions with mirroring enabled and then retried from any > * memory region. > * > - * In addition, function sets the min_count to 0 using kmemleak_alloc_phys for > - * allocated boot memory block, so that it is never reported as leaks. > + * In addition, function using kmemleak_alloc_phys for allocated boot > + * memory block, it is never reported as leaks. > * > * Return: > * Physical address of allocated memory block on success, %0 on failure. > @@ -1398,12 +1398,12 @@ phys_addr_t __init memblock_alloc_range_nid(phys_addr_t size, > */ > if (end != MEMBLOCK_ALLOC_NOLEAKTRACE) > /* > - * The min_count is set to 0 so that memblock allocated > - * blocks are never reported as leaks. This is because many > - * of these blocks are only referred via the physical > - * address which is not looked up by kmemleak. > + * Memblock allocated blocks are never reported as > + * leaks. This is because many of these blocks are > + * only referred via the physical address which is > + * not looked up by kmemleak. > */ > - kmemleak_alloc_phys(found, size, 0, 0); > + kmemleak_alloc_phys(found, size, 0); > > return found; > } > diff --git a/tools/testing/memblock/linux/kmemleak.h b/tools/testing/memblock/linux/kmemleak.h > index 462f8c5e8aa0..5fed13bb9ec4 100644 > --- a/tools/testing/memblock/linux/kmemleak.h > +++ b/tools/testing/memblock/linux/kmemleak.h > @@ -7,7 +7,7 @@ static inline void kmemleak_free_part_phys(phys_addr_t phys, size_t size) > } > > static inline void kmemleak_alloc_phys(phys_addr_t phys, size_t size, > - int min_count, gfp_t gfp) > + gfp_t gfp) > { > } If you respin, I'd move the prototype change to a separate patch (and make it first in the series). Otherwise it looks fine: Reviewed-by: Catalin Marinas