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: 12359757 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=-17.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MIME_BASE64_TEXT,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 EFF38C07E96 for ; Tue, 6 Jul 2021 06:02:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 733616121E for ; Tue, 6 Jul 2021 06:02:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 733616121E Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 392766B0011; Tue, 6 Jul 2021 02:02:11 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 342796B0036; Tue, 6 Jul 2021 02:02:11 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1E33B6B005D; Tue, 6 Jul 2021 02:02:11 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0004.hostedemail.com [216.40.44.4]) by kanga.kvack.org (Postfix) with ESMTP id EC4DF6B0011 for ; Tue, 6 Jul 2021 02:02:10 -0400 (EDT) Received: from smtpin35.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 6DAAE824999B for ; Tue, 6 Jul 2021 06:02:10 +0000 (UTC) X-FDA: 78331117620.35.0AF2B32 Received: from mailgw01.mediatek.com (mailgw01.mediatek.com [216.200.240.184]) by imf04.hostedemail.com (Postfix) with ESMTP id B07EE50000A0 for ; Tue, 6 Jul 2021 06:02:06 +0000 (UTC) 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 Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=mediatek.com header.s=dk header.b=R1M710wq; dmarc=pass (policy=none) header.from=mediatek.com; spf=pass (imf04.hostedemail.com: domain of miles.chen@mediatek.com designates 216.200.240.184 as permitted sender) smtp.mailfrom=miles.chen@mediatek.com X-Rspamd-Server: rspam02 X-Stat-Signature: kwxf76dojy8oxc7kmitg8spm4zr77cf9 X-Rspamd-Queue-Id: B07EE50000A0 X-HE-Tag: 1625551326-537960 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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