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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8549FE82CB1 for ; Wed, 27 Sep 2023 17:00:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229604AbjI0RAn (ORCPT ); Wed, 27 Sep 2023 13:00:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229582AbjI0RAj (ORCPT ); Wed, 27 Sep 2023 13:00:39 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BCBFFF3 for ; Wed, 27 Sep 2023 10:00:37 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ED933C433C9; Wed, 27 Sep 2023 17:00:35 +0000 (UTC) Date: Wed, 27 Sep 2023 18:00:33 +0100 From: Catalin Marinas To: Liu Shixin Cc: Patrick Wang , Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/3] bootmem: use kmemleak_free_part_phys in free_bootmem_page/put_page_bootmem Message-ID: References: <20230927035923.1425340-1-liushixin2@huawei.com> <20230927035923.1425340-2-liushixin2@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230927035923.1425340-2-liushixin2@huawei.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 27, 2023 at 11:59:21AM +0800, Liu Shixin wrote: > Since kmemleak_alloc_phys() rather than kmemleak_alloc() was called from > memblock_alloc_range_nid(), kmemleak_free_part_phys() should be used to > delete kmemleak object in free_bootmem_page() and put_page_bootmem(). > > Fixes: 028725e73375 ("bootmem: remove the vmemmap pages from kmemleak in free_bootmem_page") > Fixes: dd0ff4d12dd2 ("bootmem: remove the vmemmap pages from kmemleak in put_page_bootmem") > Signed-off-by: Liu Shixin Acked-by: Catalin Marinas > include/linux/bootmem_info.h | 2 +- > mm/bootmem_info.c | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/include/linux/bootmem_info.h b/include/linux/bootmem_info.h > index e1a3c9c9754c..cffa38a73618 100644 > --- a/include/linux/bootmem_info.h > +++ b/include/linux/bootmem_info.h > @@ -60,7 +60,7 @@ static inline void get_page_bootmem(unsigned long info, struct page *page, > > static inline void free_bootmem_page(struct page *page) > { > - kmemleak_free_part(page_to_virt(page), PAGE_SIZE); > + kmemleak_free_part_phys(PFN_PHYS(page_to_pfn(page)), PAGE_SIZE); We have a page_to_phys(), though it looks like the generic implementation (wrongly) assumes a dma_addr_t type rather than phys_addr_t. We have phys_do_dma() for such conversion as it needs to take the device into account, so I guess most page_to_phys() uses under drivers/ are wrong. Maybe as a separate series clean-up those page_to_phys() uses in drivers. > free_reserved_page(page); > } > #endif > diff --git a/mm/bootmem_info.c b/mm/bootmem_info.c > index b1efebfcf94b..fa7cb0c87c03 100644 > --- a/mm/bootmem_info.c > +++ b/mm/bootmem_info.c > @@ -34,7 +34,7 @@ void put_page_bootmem(struct page *page) > ClearPagePrivate(page); > set_page_private(page, 0); > INIT_LIST_HEAD(&page->lru); > - kmemleak_free_part(page_to_virt(page), PAGE_SIZE); > + kmemleak_free_part_phys(PFN_PHYS(page_to_pfn(page)), PAGE_SIZE); > free_reserved_page(page); > } > } > -- > 2.25.1 -- Catalin