Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp1329963pxv; Fri, 23 Jul 2021 05:56:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJztZO0faDlFWQ4L18JdyMwlAyTbGZLYiZSW0DocxurgJZQ5fROECC8GK0X2yyPUGuPSoH5j X-Received: by 2002:a17:906:4158:: with SMTP id l24mr4408052ejk.245.1627045013835; Fri, 23 Jul 2021 05:56:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627045013; cv=none; d=google.com; s=arc-20160816; b=hkt3s00EN7/XQeTmXzfVo7R+UTdAlAWf0RIalQw43Zsc4q0DT8lztWXdZ/WGrh+qYb ppvvaKmkHIdTe0Qk8lvX9L7FIEwrWeNpy3azUAKDKSro+UOBEGaRcoUWJ2wKxtQhGB0A bOJDJmhrV9UzO4V2AT2z9PbdVuS+dJkUFryBJs1PI0MCxZT5TDnP42qEC2og6RHwIZue rZCzqISNGUmjkJQ8QsXpun0HOW+eqCyk801fvwNdUySo76S2yhwHRDuim+zXlLPbKOvW DJL8iPcuiPfNxbBmxfUuUzSG/aA/01kB5ism5C4nqvqHTATJTsuNh7ozP6OqF4WIRfrV 7quA== 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=rtohglzzzr374jKgrWszd7PUWfTWiFAWrR6LAClff6I=; b=BWHmKz3AxgMkwRpf2+n9/4lGks6s8B5/9NZPqMZIRol5szCBIvWfkC+yjXOheW2tZu PR2tdib5BQJdfSYTWcXn0zPmBcbZjkztfKyvjmFMLymmoZpuhHOxispGs7Lq7DzvDvqv +/wKLDteWgJIunkVu347FEup54OzFRBalGGooy6myTGm/Em+bA7orKB1VFkM9u3LSAlK tGExrnO+wD+mvvABx5K3rGX/koEUuA0FWVCFGHTuSz+sKLHCQ5qDFZdi7FtF3XCYqmRg EYazsGe5qj2bpe4bWJYEWr23dPkbDoxtmX9YMSE1MOXseaOObJCh/yIvtW1HPBz0+a9y vxnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=COLzZ0zg; 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 rl22si4194646ejb.701.2021.07.23.05.56.29; Fri, 23 Jul 2021 05:56:53 -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=COLzZ0zg; 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 S235069AbhGWMOA (ORCPT + 99 others); Fri, 23 Jul 2021 08:14:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:37394 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234988AbhGWMN7 (ORCPT ); Fri, 23 Jul 2021 08:13:59 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1627044873; 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=rtohglzzzr374jKgrWszd7PUWfTWiFAWrR6LAClff6I=; b=COLzZ0zgJ1hJnZDjGVnplWERNgR44x4pPVEkHAaSYdFMXEhIaM/FYkm1byI/K0cCBl/Ctq 1/UouZOfKtnGdgg8KHurgefYeAl/FOqZHrSTt9L4aEE5Hsgo+1YY+i+sEgdtOfjFJYg2v1 trXSgWJI3ibevYW5Z8FDzjYlogGG+l4= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-319-4wO3MJg4MHWJOJCr7P2dDA-1; Fri, 23 Jul 2021 08:54:31 -0400 X-MC-Unique: 4wO3MJg4MHWJOJCr7P2dDA-1 Received: by mail-wr1-f69.google.com with SMTP id v15-20020a5d4a4f0000b0290141a87409b5so943774wrs.16 for ; Fri, 23 Jul 2021 05:54:31 -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=rtohglzzzr374jKgrWszd7PUWfTWiFAWrR6LAClff6I=; b=jzQlAuKE2DRWb1SMj8pEO+QYlN8xMCyk76ORNOiiHx3VfVW+qWCKVDrThTSpuOatfV 2Z0jv51wvOScuM8WrfKUjtkwZ0r4lT8fTGVUQkpQMxEnaGqvCF3NjPeSoJXEGxsWHZvn IFNnHKW0z0YYotOGsVsk9aE/2GVNfObjq43BPLmTewtilhVkqnTdHoO8ayutomEoDCT9 ABA+KsK4mJenCoTdsUy6K0BAck39S6aVU8qblLvwjazYfGb4ls+bxtOYf8Gn4aFLChGD Og0E0Wo1QsdedauQNbfLT1i55CRahQrVP5hZnxdj0iRvpiuOxcbuHDz12m2En6E7150a f9kw== X-Gm-Message-State: AOAM530szAzaiVVJAYekTqlFcp898N0iK3pvMy8gzRWRuTiww0fC47WS JKAqHQjGKqlEY3Hpifr25cj2PKMMzRq+u5ny9ufNj3r/Gl2upmopsA4yzalA/AzD4elFK+UCjvy dNjcRcDLlBSndhzGMQ6e9klX+ X-Received: by 2002:a5d:488a:: with SMTP id g10mr5048113wrq.327.1627044870618; Fri, 23 Jul 2021 05:54:30 -0700 (PDT) X-Received: by 2002:a5d:488a:: with SMTP id g10mr5048100wrq.327.1627044870401; Fri, 23 Jul 2021 05:54:30 -0700 (PDT) Received: from [192.168.3.132] (p5b0c676e.dip0.t-ipconnect.de. [91.12.103.110]) by smtp.gmail.com with ESMTPSA id g3sm32896895wru.95.2021.07.23.05.54.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 23 Jul 2021 05:54:30 -0700 (PDT) Subject: Re: [PATCH v3] 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: <20210723123342.26406-1-miles.chen@mediatek.com> From: David Hildenbrand Organization: Red Hat Message-ID: <571dcb1d-1f3a-0633-17e1-1ca9856bee5e@redhat.com> Date: Fri, 23 Jul 2021 14:54:29 +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: <20210723123342.26406-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 14:33, Miles Chen wrote: > 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 > Reviewed-by: David Hildenbrand -- Thanks, David / dhildenb