From patchwork Fri Jul 23 12:33:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miles Chen X-Patchwork-Id: 12396023 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 A985EC4338F for ; Fri, 23 Jul 2021 12:34:11 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0645460E8C for ; Fri, 23 Jul 2021 12:34:10 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0645460E8C 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 4001A6B005D; Fri, 23 Jul 2021 08:34:10 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3B03F6B006C; Fri, 23 Jul 2021 08:34:10 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2A0106B0070; Fri, 23 Jul 2021 08:34:10 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0204.hostedemail.com [216.40.44.204]) by kanga.kvack.org (Postfix) with ESMTP id 119D06B005D for ; Fri, 23 Jul 2021 08:34:10 -0400 (EDT) Received: from smtpin34.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 9DD70181AEF32 for ; Fri, 23 Jul 2021 12:34:09 +0000 (UTC) X-FDA: 78393795018.34.E623084 Received: from mailgw02.mediatek.com (mailgw02.mediatek.com [216.200.240.185]) by imf09.hostedemail.com (Postfix) with ESMTP id F1B68300290E for ; Fri, 23 Jul 2021 12:34:07 +0000 (UTC) X-UUID: 126ab4cdd51441348e4fe1a56bfc28db-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=7k+4gCx3PtKX+KCF8SFCmpOW09BJ7u9okbHhvR14epE=; b=Lpt0sHPIDcwFmzg78IZepNIpizv/IRVyQAeg/8bFN0jlHBvPiq8hQ24gcHrpS0RYhaM6RvrsIWNlSAHC0q20LusMyvggNwGjhfbPAyKGA1RTMMv4FmDjSBdx9dFOwqn8KW30SWjgZs5eR6LQA+YEAXZotFM9lVi8UCZ/o0ETIQU=; X-UUID: 126ab4cdd51441348e4fe1a56bfc28db-20210723 Received: from mtkcas67.mediatek.inc [(172.29.193.45)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1312386840; Fri, 23 Jul 2021 05:34:02 -0700 Received: from MTKMBS01N1.mediatek.inc (172.21.101.68) by MTKMBS62DR.mediatek.inc (172.29.94.18) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 23 Jul 2021 05:34:00 -0700 Received: from mtkcas07.mediatek.inc (172.21.101.84) by mtkmbs01n1.mediatek.inc (172.21.101.68) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 23 Jul 2021 20:33:46 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas07.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Fri, 23 Jul 2021 20:33:46 +0800 From: Miles Chen To: Andrew Morton , Mike Rapoport , Mark Rutland , David Hildenbrand CC: , , , , Miles Chen Subject: [PATCH v3] mm/sparse: clarify pgdat_to_phys Date: Fri, 23 Jul 2021 20:33:42 +0800 Message-ID: <20210723123342.26406-1-miles.chen@mediatek.com> X-Mailer: git-send-email 2.18.0 MIME-Version: 1.0 X-MTK: N Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=mediatek.com header.s=dk header.b=Lpt0sHPI; spf=pass (imf09.hostedemail.com: domain of miles.chen@mediatek.com designates 216.200.240.185 as permitted sender) smtp.mailfrom=miles.chen@mediatek.com; dmarc=pass (policy=none) header.from=mediatek.com X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: F1B68300290E X-Stat-Signature: s8pz8jtxa977f8enr66f8qerjxcwhmxr X-HE-Tag: 1627043647-175707 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000073, 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. 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 Reviewed-by: David Hildenbrand 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