From patchwork Tue Jul 6 05:51:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miles Chen X-Patchwork-Id: 12359755 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-18.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY, URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CCE22C07E96 for ; Tue, 6 Jul 2021 06:02:26 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0E69F6121E for ; Tue, 6 Jul 2021 06:02:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0E69F6121E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:CC :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=tS+PlLxwwTIURSUkJRgze1RaDcJrcWJiYfLO+6qzvlU=; b=1JUBlJAMMPMtbM FtCzTit5in9w4b8GdlB+eyCQdFnttlBl7l7X1wTLa3lhnK4+xHgwl/83HXn+x1yxOjIn/qn3YIhs+ mzaz2sLY3jYWDA+1mMrFuzOMRiiQxngwJ9SmNiMfcqtGnh20kowb8X5fUr05F+Wmy3WFWtsyVnijU cZOaJm6dRwhWIelQikY5bjzU/+9gGJMrMqC4G/uNCzxGhtxaFT0IJ2PENL2jMmP+WvMLSkufKitke k1QYLXidDIfuQSLFWja+JqWXsCR6eN+VaN1m3LkdNI5PxHtSX0QcCexV6ZHdFs1Gv1MeY163iR/KZ UhQvOCu4MShvod5w4EaQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m0e9t-00ANNC-Or; Tue, 06 Jul 2021 06:02:13 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m0e9p-00ANMK-34 for linux-mediatek@lists.infradead.org; Tue, 06 Jul 2021 06:02:10 +0000 X-UUID: 2fb78b0a1aa54da6b907ae305dd54d64-20210705 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:Message-ID:Date:Subject:CC:To:From; bh=3K5LQLnNfzvLMC9jhEwux2ly7arp4H7TgtBfN0imStw=; b=R1M710wqaD5WZ9YSk1VHt80Qe+VdXsudqRwWoXT7LodbOcku0NWr3L3qaZVCK7yMTnTqjMVjgxPWB1R0omAkhUxPCyDe7N2YudKuAnddu+vcaieA/qDrAw0ZVOic0LmEmtjavyleklmd/oqJB4xnAnwvpA1a9j49CUemLBkJ5HY=; X-UUID: 2fb78b0a1aa54da6b907ae305dd54d64-20210705 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1039523358; Mon, 05 Jul 2021 23:01:57 -0700 Received: from MTKMBS01N1.mediatek.inc (172.21.101.68) by MTKMBS62N1.mediatek.inc (172.29.193.41) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 5 Jul 2021 22:51:55 -0700 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs01n1.mediatek.inc (172.21.101.68) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 6 Jul 2021 13:51:53 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 6 Jul 2021 13:51:53 +0800 From: Miles Chen To: Andrew Morton , Mike Rapoport , Mark Rutland CC: , , , , Miles Chen Subject: [PATCH v2] mm/sparse: clarify pgdat_to_phys Date: Tue, 6 Jul 2021 13:51:52 +0800 Message-ID: <20210706055152.15780-1-miles.chen@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210705_230209_186566_637CCF5B X-CRM114-Status: GOOD ( 11.90 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+linux-mediatek=archiver.kernel.org@lists.infradead.org Clarify pgdat_to_phys() by testing if pgdat == &contig_page_data when CONFIG_NUMA=n. contig_page_data is only available when CONFIG_NUMA=n so we have to use #ifndef here. No functional change intended. 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 */ " Comment from Mike [2]: " I'm not sure a macro is better than a static inline. Maybe we'd want to warn if pgdat passed to pgtat_to_phys() is not &contig_page_data, e.g something like static inline phys_addr_t pgdat_to_phys(struct pglist_data *pgdat) { if (!IS_ENABLED(CONFIG_NUMA)) { if (pgdat == &contig_page_data) return __pa_symbol(&contig_page_data); else pr_warn("Unexpected pglist_data pointer!\n"); } return __pa(pgdat); } " [1] https://lore.kernel.org/linux-arm-kernel/20210615131902.GB47121@C02TD0UTHF1T.local/ [2] https://lore.kernel.org/patchwork/patch/1452903/#1650759 Cc: Mike Rapoport Cc: Mark Rutland Signed-off-by: Miles Chen --- 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. --- mm/sparse.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/mm/sparse.c b/mm/sparse.c index 6326cdf36c4f..f73ff3c124c5 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -348,10 +348,11 @@ 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); -#else + if (pgdat == &contig_page_data) + return __pa_symbol(&contig_page_data); + pr_warn("Unexpected pglist_data pointer!\n"); +#endif /* !CONFIG_NUMA */ return __pa(pgdat); -#endif } #ifdef CONFIG_MEMORY_HOTREMOVE