From patchwork Fri Jul 23 07:01:37 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miles Chen X-Patchwork-Id: 12395379 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 57A61C432BE for ; Fri, 23 Jul 2021 07:08:24 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 90E3360EE6 for ; Fri, 23 Jul 2021 07:08:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 90E3360EE6 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 3258F6B005D; Fri, 23 Jul 2021 03:08:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2D4EE6B006C; Fri, 23 Jul 2021 03:08:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1C3D66B0070; Fri, 23 Jul 2021 03:08:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0046.hostedemail.com [216.40.44.46]) by kanga.kvack.org (Postfix) with ESMTP id 036DF6B005D for ; Fri, 23 Jul 2021 03:08:22 -0400 (EDT) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 97B8A180AD82F for ; Fri, 23 Jul 2021 07:08:22 +0000 (UTC) X-FDA: 78392974044.07.5C07A88 Received: from mailgw01.mediatek.com (mailgw01.mediatek.com [216.200.240.184]) by imf14.hostedemail.com (Postfix) with ESMTP id F2BB5600A3D7 for ; Fri, 23 Jul 2021 07:08:20 +0000 (UTC) X-UUID: 1cdcd838a6f941d8b039648dd9e15068-20210723 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=g97+Ix3+KKhcxRANjFFtWPgCtn1RP3o1xLe5qRKuHaMkGN7Fdg33GzsdcXKJABnZI9Q/9uultxbco2ttABQAIGkXX/P3VzTQQfQZ3hCZzR3Vy2bzzUMe3FWkwjoZEZObLxNHUfhXaFm8JoXFDxoOv2DzcYFFjTP8+RIJ+01nNiI=; X-UUID: 1cdcd838a6f941d8b039648dd9e15068-20210723 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 191894313; Fri, 23 Jul 2021 00:08:12 -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; Fri, 23 Jul 2021 00:01:40 -0700 Received: from mtkcas11.mediatek.inc (172.21.101.40) by mtkmbs01n1.mediatek.inc (172.21.101.68) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 23 Jul 2021 15:01:38 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas11.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 23 Jul 2021 15:01:38 +0800 From: Miles Chen To: Andrew Morton , Mike Rapoport , Mark Rutland CC: , , , , Miles Chen Subject: [RESEND PATCH v2] mm/sparse: clarify pgdat_to_phys Date: Fri, 23 Jul 2021 15:01:37 +0800 Message-ID: <20210723070137.23321-1-miles.chen@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 X-MTK: N X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: F2BB5600A3D7 Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=mediatek.com header.s=dk header.b=g97+Ix3+; dmarc=pass (policy=none) header.from=mediatek.com; spf=pass (imf14.hostedemail.com: domain of miles.chen@mediatek.com designates 216.200.240.184 as permitted sender) smtp.mailfrom=miles.chen@mediatek.com X-Stat-Signature: zs89pqf5aketu4pcxx7mb7okcfuw8iqy X-HE-Tag: 1627024100-831278 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