Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2709678rdh; Wed, 27 Sep 2023 10:15:07 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGt7wUcEgBzRLzW/wN7WM1L43yn5aVQpJImooqIQY8oKK1jVuKdoHiGaj3U88dIh0/VqkN2 X-Received: by 2002:a17:903:41d2:b0:1b0:f8:9b2d with SMTP id u18-20020a17090341d200b001b000f89b2dmr2864213ple.29.1695834906841; Wed, 27 Sep 2023 10:15:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695834906; cv=none; d=google.com; s=arc-20160816; b=WgmPUhDcp8J5baZmQFsx3L5hMi3V1eK3lRHbb5IUPmPkO5tV3RUExDQWG9Ww0iCIPZ l4e+b2oLOU96RNWAL4Vy9mkdO7ljM9vuKz6fWz7EVvGQ15+0xSIzMm8Qd+eBBp4d5lL5 V+tIvAzH9wdH7fuWXlvX5mYD9gS5s12rdiV6sCPMa5/s9w7oM4Jc+KUpSx1OzkebwPRc Im3Q3GKr0OrDeJV4YuVLGYS0pIKC5y2zGi7INZLZP2+zgq0LVXJGSlCtkyuG/yXK6Ajz LJy2nrp1vK8w2KxTMvDun+yZsfll79+NMdgZI2W7qFczGgrHtl9jdaDQTBVa2s8g9DZ1 ONVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=CCFQEXiH3YiKMpuHWXBsClFZP/uX5QhpQruXqmOvJLg=; fh=wwGr4anhM3kpcO85TN/G/Arg4GwT9oL7sUCyXzkyrT8=; b=kXQQ/4o/k7P0U/kNHUGTmF5OvHSIOx8d2dh0g2EE02xEyXzaX/MnQZSV0Zjea2NdJz JcUGy4s5RL8B5L6CLhBt+Tp5tAWgcmGz7Ax1wt4hEeaKpU472eSc/vVR96upEY6y1avq lOOPgAliXkBbOUS2jCITxbZnM6bsKs09LJr0KpZM12382TUA97VLLdXmW2RgLE73mX9d dP3N0LWuBXik4nFVFho2K9G2tnawUFLRDy4vWV5Br5WCHf+bMSoMd+VxDJZ5PFCWGYpF Fn7pWTICLyKm0hVo1/kELzpus77EQQtCIi/u1RIhFAjcK8VZZVAiX4zDQ9lQoSptlq4b ZksQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id b2-20020a170902650200b001c362510a4esi14853421plk.613.2023.09.27.10.15.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 10:15:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id BCC4C80A0E16; Wed, 27 Sep 2023 10:00:59 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229597AbjI0RAm (ORCPT + 99 others); Wed, 27 Sep 2023 13:00:42 -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> X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 27 Sep 2023 10:01:00 -0700 (PDT) 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