From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 498411494A7 for ; Fri, 3 Jan 2025 14:28:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735914483; cv=none; b=UpAPeBXT0MzCiUY6/HgPdE3XjdZ1m47ikLkInezir1oXk0pmKfUV779m202+PDlpzPb5fMVWciPpzlBICjV+da7SoZEptqtFxeu5keJWkDWqNp8vQwa/N6ql+Jo+mivILqNWvcM1VMKHLtBn27XYmaLjBIgBvx69+NYW4cv2YGM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735914483; c=relaxed/simple; bh=kuse9Ev0hFGR1af1XIkvlBqv1hJWyUkfEdcOMtuQuKQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=PlWukdIlLHda5WHp3hXtojLnM3JSPNh0aM8iHW4nrMf2lNPQralnY7sbmJ5MK68IqU6h+AMyU6C/zrJv82yPjryaZcit52FnKTiDGD4WAPeNR3a5fByn9XWQfkIAxpoKKN9xd83IOQTPLnQ32Gick0NJppWDqUxV3ApZnHXzYaA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03CDEC4CECE; Fri, 3 Jan 2025 14:28:01 +0000 (UTC) Date: Fri, 3 Jan 2025 14:27:59 +0000 From: Catalin Marinas To: Guo Weikang Cc: Mike Rapoport , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] mm/memmap: Prevent double scanning of memmap by kmemleak Message-ID: References: <20250103110150.1352226-1-guoweikang.kernel@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250103110150.1352226-1-guoweikang.kernel@gmail.com> On Fri, Jan 03, 2025 at 07:01:50PM +0800, Guo Weikang wrote: > diff --git a/mm/mm_init.c b/mm/mm_init.c > index 24b68b425afb..71b58f5f2492 100644 > --- a/mm/mm_init.c > +++ b/mm/mm_init.c > @@ -1580,6 +1580,10 @@ static void __init free_area_init_core(struct pglist_data *pgdat) > } > } > > +/* > + * Kmemleak will explicitly scan mem_map by traversing all valid `struct *page`, > + * so memblock does not need to be added to the scan list. > + */ > void __init *memmap_alloc(phys_addr_t size, phys_addr_t align, > phys_addr_t min_addr, int nid, bool exact_nid) > { Nitpick: normally I'd place the comment in the code, before the 'if' statement. We keep the comments above functions for a description of the function. > @@ -1587,11 +1591,11 @@ void __init *memmap_alloc(phys_addr_t size, phys_addr_t align, > > if (exact_nid) > ptr = memblock_alloc_exact_nid_raw(size, align, min_addr, > - MEMBLOCK_ALLOC_ACCESSIBLE, > + MEMBLOCK_ALLOC_NOLEAKTRACE, > nid); > else > ptr = memblock_alloc_try_nid_raw(size, align, min_addr, > - MEMBLOCK_ALLOC_ACCESSIBLE, > + MEMBLOCK_ALLOC_NOLEAKTRACE, > nid); > > if (ptr && size > 0) > diff --git a/mm/sparse-vmemmap.c b/mm/sparse-vmemmap.c > index cec67c5f37d8..903a5422907b 100644 > --- a/mm/sparse-vmemmap.c > +++ b/mm/sparse-vmemmap.c > @@ -27,7 +27,7 @@ > #include > #include > #include > - > +#include "internal.h" > #include > #include Another nit: if the original authors of this file preferred the includes to be in blocks, I'd keep the internal.h include as a separate block after the asm/ includes. Apart from these minor things, the patch looks fine. Reviewed-by: Catalin Marinas Thanks. -- Catalin