Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp1968485pxv; Sat, 24 Jul 2021 00:50:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzKJsLabyO1/oku/sVoas45U4X/D65q9krMgfpgZ0PNEMxGQ7WqqprCcjuZZbb99hR6ugUb X-Received: by 2002:a17:907:1614:: with SMTP id hb20mr8291981ejc.387.1627113058881; Sat, 24 Jul 2021 00:50:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627113058; cv=none; d=google.com; s=arc-20160816; b=l1sE0GykB67XqljsZbxuUXVvDxSzBxSxq96ma18h+m8fFAUmt9YW78Uk9lI/45/jRP TX5+EX0vHmWm29dTpSa4/+vdhfvpnstDN3qBGlTvqZ0Ept4xkJAeRiiXIRqdVRTh4sw2 9Gnx9AAUpWP+wdge/xrCHzyzU7eVbEUdqAgxYFfqwkduI/ATeonP6N6oaLutPlOzOrf+ w2ljj47+vpRo1FlBLxbs+6sn4eCk26Nsr8jf8g4E85YhRlvtyVAx+0ugpQP96TbeIIuI wKW9981y5CT9zE4b68oHGlGGwwHl8n7OdVkJdS5DKPf9fnQJ6MI4oeJe4o7z0IwL7WSU aVKQ== 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:dkim-signature; bh=lmDVZinSVY+EVaOxTtZWsIkWBPYNbjEnqZy+Grav89I=; b=pC/qY3CprH3vL8/Ye1/ymFQH7giHfQ08cFxg0Wd5eKiHs3x6r9bNgp3Ra5Jgkv/G6v tcrfJZ8nEFQTFPJGL6l8P3yC29WSO4OSa+Am7NFrSaBWoCfQY7KX212v0Yv0wc4qUqFy vljYjR/RxEh2q90U6Zzm7eNDPHpTnXe9FTVtQjXBhhOLc+ru1nxRqmtGAWVz8F67vras yX7y4iUP1ZpKZs/dinszSU4hvEiu74DMsIbmv9gSjxTu43WPPV8OfwZyqve+XOb+fqlE GMYUaJY7Ix0uy3JF23oPobEg6w54GKJPNfL1uf6aVT+Zt6q3Zb73wt6Q0mYXohJV4UN8 od4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dV+JwbWV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lf5si34578578ejc.236.2021.07.24.00.50.35; Sat, 24 Jul 2021 00:50:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=dV+JwbWV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234587AbhGXHHI (ORCPT + 99 others); Sat, 24 Jul 2021 03:07:08 -0400 Received: from mail.kernel.org ([198.145.29.99]:40444 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234403AbhGXHHG (ORCPT ); Sat, 24 Jul 2021 03:07:06 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id D02E160E93; Sat, 24 Jul 2021 07:47:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1627112859; bh=83jYqHd7Z3wZAPt5SDx4EmmdLiCWHkDxcjRrWNIZ0kE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=dV+JwbWV9suCiexF3CXkLJt4ap8IBg5xYeWS7BVIDBXUtK33/2VPwz9pSvQdHO1A3 yIrHu3+n1ufzNNfG1igKzqVT1hcEH/iMlQUvkRPrv1HO9FmO4HHM/SaoH5vdLO75Xt 82aiN+l4G+1Z9Kz8UTGFmXYa8xad5zeGCLzUMdP9E5ezcoOVBqOb4kWVXT59yaFEhG i4D04rUrLcpJ7HtUr13dBD0kkYLRCN0WmdAo3q9UC98qSWlbPf0QIr3JtqkWtNqMtA QZpyiVT0NIL/r+deATsBXLKcs9QG7X31C5TzhlzS1KQisaBB6aZjXeWW9cy28+fjEQ 5+UMcZFUNjrJQ== Date: Sat, 24 Jul 2021 10:47:33 +0300 From: Mike Rapoport To: Miles Chen Cc: Andrew Morton , Mark Rutland , David Hildenbrand , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, wsd_upstream@mediatek.com Subject: Re: [PATCH v3] mm/sparse: clarify pgdat_to_phys Message-ID: References: <20210723123342.26406-1-miles.chen@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210723123342.26406-1-miles.chen@mediatek.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jul 23, 2021 at 08:33:42PM +0800, Miles Chen wrote: > Clarify pgdat_to_phys() by testing if > pgdat == &contig_page_data when CONFIG_NUMA=n. > > We only expect contig_page_data in such case, so we > use &contig_page_data directly instead of pgdat. > > No functional change intended when CONFIG_BUG_VM=n. > > Comment from Mark [1]: > " > ... and I reckon it'd be clearer and more robust to define > pgdat_to_phys() in the same ifdefs as contig_page_data so > that these, stay in-sync. e.g. have: > > | #ifdef CONFIG_NUMA > | #define pgdat_to_phys(x) virt_to_phys(x) > | #else /* CONFIG_NUMA */ > | > | extern struct pglist_data contig_page_data; > | ... > | #define pgdat_to_phys(x) __pa_symbol(&contig_page_data) > | > | #endif /* CONIFIG_NUMA */ > " > > [1] https://lore.kernel.org/linux-arm-kernel/20210615131902.GB47121@C02TD0UTHF1T.local/ > > Cc: Mike Rapoport > Cc: Mark Rutland > Cc: David Hildenbrand > Signed-off-by: Miles Chen Acked-by: Mike Rapoport > > -- > > Change since v1: > Thanks for Mike's comment, check if pgdat == &contig_page_data, > so it is clearer that we only expect contig_page_data when > CONFIG_NUMA=n. > > Change since v2: > use VM_BUG_ON() to avoid runtime checking when CONFIG_BUG_VM=n > --- > mm/sparse.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/mm/sparse.c b/mm/sparse.c > index 6326cdf36c4f..d13d831f88a5 100644 > --- a/mm/sparse.c > +++ b/mm/sparse.c > @@ -348,7 +348,8 @@ size_t mem_section_usage_size(void) > static inline phys_addr_t pgdat_to_phys(struct pglist_data *pgdat) > { > #ifndef CONFIG_NUMA > - return __pa_symbol(pgdat); > + VM_BUG_ON(pgdat != &contig_page_data); > + return __pa_symbol(&contig_page_data); > #else > return __pa(pgdat); > #endif > -- > 2.18.0 > -- Sincerely yours, Mike.