Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp1317122pxv; Fri, 23 Jul 2021 05:35:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWxOjGzy5PEXvwkoeeaE4zN7RRMAUPJUZHSv9965gGGVcZktpx2ib0uL8liOSLMv14spvE X-Received: by 2002:a6b:dd02:: with SMTP id f2mr3858373ioc.11.1627043721409; Fri, 23 Jul 2021 05:35:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627043721; cv=none; d=google.com; s=arc-20160816; b=iHw3HcReVYHLVEMu4ZZDaOK5zgEQaZDiZ0+j249xO9THHocNQrSH2s39eh9UQS7N3X 7zhcYLoUw+uDMdEGRF8aGAd5Ett1pfXDzPI3vKSpRhQajaFWtn/fCB78CphHJ7Fh2r0g xyx47WKN8th5QyT1uL4yUZenKmUKQjQEiGHayJFgHB44PkPq1VJHxVHCGhTOmdQCxhG0 IgKNUL/Kw/0RaATRgfXqD2jIG1SgENxxW8wpy7QUQSux5V1qS6tNbMRejJOd1+e1CB3o 0WsXttfUb25630+C3blN6uz9w5XQBjTSmtbntkoQuEA5YRaLOm+N6eN8aToSG5qRLifl 4dGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=Ha/6HMJWU58CNOZibi3NIF9LDSCEtXh4wkSmH5dKzlo=; b=cKcaNpAiER6nvGbyMsNBDGAM7EbEdInDxrzdTiM5b4EQFS8v8wpe2wGPARoPtpu/4T fzKvpwkdTWc5DQDZQ8w5EW1v6572W6DSBQrlYtEfaye0tFBkv8Vtgc8kba0ibMSQvFaB hgc9mCDfmnTAPdVZpycVi+A/08LtQnljzkc1WS/jrD2ZPgoJ5g2VDRvFosIlxxkpWsHI 70XvQEGetQYuhy7N59cbumraOyPFMiWAGXVIYokgHiGHpDii2deT9PBTQ6NcRODJACd8 D5/Zhyp2EDRmcMxBI2cBrM98XT2iEwZAABrEOjXg8Tzs/tibugRh9Sd29NMMsUOkCUz9 tDTg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x17si24833876jat.44.2021.07.23.05.35.10; Fri, 23 Jul 2021 05:35:21 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234885AbhGWLx3 (ORCPT + 99 others); Fri, 23 Jul 2021 07:53:29 -0400 Received: from mailgw01.mediatek.com ([60.244.123.138]:60102 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S234751AbhGWLxZ (ORCPT ); Fri, 23 Jul 2021 07:53:25 -0400 X-UUID: ee1dfeca99cb451e9e6338fd5619f132-20210723 X-UUID: ee1dfeca99cb451e9e6338fd5619f132-20210723 Received: from mtkcas10.mediatek.inc [(172.21.101.39)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 568177637; Fri, 23 Jul 2021 20:33:54 +0800 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 Content-Type: text/plain X-MTK: N Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 -- 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