Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp1139209pxv; Fri, 23 Jul 2021 00:14:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzN0S/04VEvDwR2xA6BDm16Oc3oOWPGVYuAFp81GUdC8TtHfqYVWjxfmyzUa3lhpCa0N6vN X-Received: by 2002:a17:907:1c9f:: with SMTP id nb31mr3504117ejc.342.1627024494560; Fri, 23 Jul 2021 00:14:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627024494; cv=none; d=google.com; s=arc-20160816; b=l8Z53o1E4GBRrGGOEH8WL7rVtEWjpVDYZ+FJzEClZ3TUEaYpyyurmsnEEoq8zURh3s sAaQzpoFToQHZ3TKu8fcR25lwjINmqXQ+Ew9aGsIDUDo93nCLGvH6pzRfieQfs4clDf9 SyQ99+cb0Xy33TLZuQ1TjzjcJ0AOcXhabtlQYHzxvXxh20recA+Kf+eCKx/vJjeaXDoe pCSaBDx1WtCp4hbMP7Tc5BdX6iofdDmJ9CZbulDSzqY8j7jC1EpMe4iq+JZCm4qrlxbw JTXySArQNkOTrU/m6IvBLI3PJoXXjuFIuOQynx1JZ7brhEtqvAPkeGhQ1bhMn1CvlNvs tkjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :from:references:cc:to:subject:dkim-signature; bh=yQQEn4AJk4jpfjaQyvDLnuQEm5eCkpcI1tfMEOwcZwY=; b=tbs10+lC6H2MUL9pxhu8VCqeLP9XWTDdItondf6qzlHbKlxJhiiPeH134wrDiz4981 wdfREakwJox5YjSwXJzXEEO5WGnLb51J91FEYBdIcaHddX7Wz/dS3V4UG0Kws56I7jqD uvkpwQpr/bczSGCjzF+FHENz4nbt/ug7lbkv6xNjSU7VhqGgoBKDdEon3fhwR8r6WuZn N1QlE19+Vld5Bz8GTWjfrQpYJZlJrnii9tQYvPcMDVKVmR4v9oWSc9gS/Tk9PIpeFIUw oiSHCW+O8GCQkojtndhSyCNTws983LNhfjWPudH3lH5oVVpzp6+O0lN8fYhMcYB5ip75 bF/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="G/CEcc01"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id la20si38529517ejc.685.2021.07.23.00.14.31; Fri, 23 Jul 2021 00:14:54 -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; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="G/CEcc01"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234163AbhGWGa1 (ORCPT + 99 others); Fri, 23 Jul 2021 02:30:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:57054 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234089AbhGWGa0 (ORCPT ); Fri, 23 Jul 2021 02:30:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1627024257; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=yQQEn4AJk4jpfjaQyvDLnuQEm5eCkpcI1tfMEOwcZwY=; b=G/CEcc01rfEO3ccNf5+973RfnSy58PoRVp8bTVGi0QvHZJLe/LMAexgfrZOD13RUEUASBA TJg03Ed8m4xBs27ZcnV3SB6Scjg0T6qfyKWs+TrRfMQMOtIYXKALlWddmMHaaxvzm1jIOQ scClPWEuMz12ieKJetUZpcBt49WpaZ0= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-479-yhGbjeMsNgOim7ImQqk7mA-1; Fri, 23 Jul 2021 03:10:56 -0400 X-MC-Unique: yhGbjeMsNgOim7ImQqk7mA-1 Received: by mail-wm1-f71.google.com with SMTP id g21-20020a1c20150000b0290205f5e73b37so475105wmg.3 for ; Fri, 23 Jul 2021 00:10:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:organization :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=yQQEn4AJk4jpfjaQyvDLnuQEm5eCkpcI1tfMEOwcZwY=; b=sK0AeaAQY/T0auoDh15Z0/06iElpwDfCAceO1aZDSW82u/DnSdsNvzTdSP6XjEx3DI Vyweuc8FrPqeFx/VWE/1QWNe997vK1zyHNHRf8wTk8XG2VoaWlDHT5I+QaoX6J8Khw9j 0N/rmVRMLx6vKBILOjfhrmAqvsnaurWOLEpTyadx5bxdHr/G6NVnBEXxu9jOm0EOQrrK g+dO6oiuBW1/ndxG5P6TXdtbdhFX+hgC2iUnZgHaFqYZhCv1Wx1BM/sN83RHhhsWxvPe jEwcrH/bzBDqmEQ/G6xYteLlgwKk19nrlpwQftX/2QfklmqaoTcCcMVrYaBBh+ehdR1R AsjQ== X-Gm-Message-State: AOAM532sBeKbdvfg0RRHGPCUEUyAoC3unOZuHBVbi2iCzaSdXvX/FGTq Pblm4ZXn/iZGqcUOfrczaZDVaVqDnFvjkfApc6mPVW2MAXtapIwv1ae7Lfy9VqtxdAsfUlWmdb8 oflNga0NFSTe2meOgUCWmT7wN X-Received: by 2002:a1c:5419:: with SMTP id i25mr3030821wmb.71.1627024255010; Fri, 23 Jul 2021 00:10:55 -0700 (PDT) X-Received: by 2002:a1c:5419:: with SMTP id i25mr3030796wmb.71.1627024254780; Fri, 23 Jul 2021 00:10:54 -0700 (PDT) Received: from [192.168.3.132] (p5b0c676e.dip0.t-ipconnect.de. [91.12.103.110]) by smtp.gmail.com with ESMTPSA id 6sm4458632wmi.3.2021.07.23.00.10.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 23 Jul 2021 00:10:54 -0700 (PDT) Subject: Re: [RESEND PATCH v2] mm/sparse: clarify pgdat_to_phys To: Miles Chen , Andrew Morton , Mike Rapoport , Mark Rutland Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org, wsd_upstream@mediatek.com References: <20210723070137.23321-1-miles.chen@mediatek.com> From: David Hildenbrand Organization: Red Hat Message-ID: Date: Fri, 23 Jul 2021 09:10:53 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210723070137.23321-1-miles.chen@mediatek.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 23.07.21 09:01, Miles Chen wrote: > 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"); Shouldn't this rather be a VM_BUG_ON()? Because it looks like something that should barely happen and we might not want to perform runtime checks on each and every system? -- Thanks, David / dhildenb