Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp3341457lqp; Tue, 26 Mar 2024 06:49:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCV5tyBv/SH/OxnA3USlifg0R+63UyC4Mg6npYPqAZVFKZmu6TwMEibSFXPVvYrIa39T2f4fRgKZj6nNLUidBDCJLj4bW/Cnm73TMhXnLA== X-Google-Smtp-Source: AGHT+IHR/3l+542JYvJE82AvXSQB+C68neBtGxzljzlf/brD7oEjAvD/Lm/DdVuIor2pMiA+lEZ8 X-Received: by 2002:a05:6a00:b42:b0:6ea:bdbc:963 with SMTP id p2-20020a056a000b4200b006eabdbc0963mr1413554pfo.0.1711460984246; Tue, 26 Mar 2024 06:49:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711460984; cv=pass; d=google.com; s=arc-20160816; b=R+RRe03RVLY8P/lMnHW1cpFEF6XUw/V1y63Vz7LI5QKtsGDKRKJP6+hTSPuXd/K6a/ zEhGjNEDMeZ9yNgiDgZrb1WeoV8XDZlXdtZwk0w1gnKxxqjXvQBCsDE+AH374X45DZzM x8cBQVl7vHuZilQjqBlbuKn3n1hXhk2Nxdttio/NAow43vZ7oPxztc4XEcEOWsnovISE eF1TkpdFswQIYWql7ISgwb3MZVthlMe+gG6Z0wYjo3kkCEKaLpYmAOO6KkHW9cAS1ZKR sgvIMDcqqtnhD+FFyECnADVYIMGFjXQJgcD0F/YOOhGWD2krU9U26t87E85qE//d/UVB l0Gw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=fzgh4GVszcwQ5kywfb8L4k+Qo7qZ/xV1p+DuS7SPp54=; fh=smc9EHtY7RJf9+fv+Z6wjjmC/KV3iHouIV5F+Ma95GA=; b=hQYeU2XaBxqTyqjxSD4NeNRav171JZhu6aAyfFCTCogG4fdfMxqhoCfp273xOVFqhK sKPzfYycEjEWGEWFNZgDttUpGKsPJTe+knp9UIYrlY2JUcf9EPdOBPG7K/yzhdYDF3ZU 8r8t2M22Jb5QKwXTN/BQ0QK3vksQzGkahSV5qqTn0nvYFDQ3oplBfX8zUHdaL/qqFZu5 YwXq8dW9cFPEsG1Y0LQT7uOu9W2lVrl2XOTBlng9+GcCbpmJXJSSjlepXEPT0/xhdoac fSGPLseZqpYk8O0/f98Sd+YuyiTZLD8G/ZQ3JZH1SrGv5amm9g5G2EaG7yyK1NDsiNEO hBMw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NHSNzpqy; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-119095-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119095-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id du19-20020a056a002b5300b006e54b34bfc7si7253040pfb.299.2024.03.26.06.49.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Mar 2024 06:49:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-119095-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NHSNzpqy; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-119095-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-119095-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 9A7F2291580 for ; Tue, 26 Mar 2024 13:49:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C2F2274C05; Tue, 26 Mar 2024 13:49:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="NHSNzpqy" Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 51F29182A3 for ; Tue, 26 Mar 2024 13:49:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711460964; cv=none; b=ZC6qrtLLw2fz5OxQiPwVvciLrCIHC7H81xKkpvrDkLrq64P6D6oelyQ2/Oc6W7V1e2tJCXeq7I8JtFRkhiLrvGqL2eHayPpcVBgKNBXr5c+qbMHa+cfD6atHdya1GbXsIh09EUPSnoL/QpZ7J8ukOHTIAa/besyOgEITP4yOHhk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711460964; c=relaxed/simple; bh=O8KKFlT6qa6PCFXShzq2SjS4xWvEkwxrtJmnpqCLQk0=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=pYzE9+eOHMq/HWEJ5OdbhFtQYbpNDu4v5vvJFUrSqkZ+MPG2omSaty8UX7vZORLa9u+1grvLnnMcycn+TIV0ypEY5whBB4msA9qKXm6SAGVhyxnWoDuadouquy9X1tNr7H88/2oacCwRB+PSk4ALtxTl7HcpiyZV/LB/si4qZHQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=NHSNzpqy; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711460961; 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: in-reply-to:in-reply-to:references:references; bh=fzgh4GVszcwQ5kywfb8L4k+Qo7qZ/xV1p+DuS7SPp54=; b=NHSNzpqyBS9it6GnNCJ0rYKZvoDQoECOCHjViA9LtJ1Q+a2OhzeZJ1O0NUd+0lAV34bCVO 67RG1pt6pbBR94bOprWhIOK6SjN6OuA6IC3ewZIN7D0spiLy2wT/lGKVbmmWtTifG+wHZd 9TpFQC6/HBO+CZbJH/mXkVSgEfjH/RI= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-661-yNP3kpugPDeb38rdMr3mQQ-1; Tue, 26 Mar 2024 09:49:16 -0400 X-MC-Unique: yNP3kpugPDeb38rdMr3mQQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5195C28EC117; Tue, 26 Mar 2024 13:49:16 +0000 (UTC) Received: from localhost (unknown [10.72.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6D083C041F3; Tue, 26 Mar 2024 13:49:15 +0000 (UTC) Date: Tue, 26 Mar 2024 21:49:07 +0800 From: Baoquan He To: Mike Rapoport Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, x86@kernel.org, linuxppc-dev@lists.ozlabs.org, akpm@linux-foundation.org Subject: Re: [PATCH v2 3/6] mm/mm_init.c: add new function calc_nr_all_pages() Message-ID: References: <20240325145646.1044760-1-bhe@redhat.com> <20240325145646.1044760-4-bhe@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 On 03/26/24 at 08:57am, Mike Rapoport wrote: > Hi Baoquan, > > On Mon, Mar 25, 2024 at 10:56:43PM +0800, Baoquan He wrote: > > This is a preparation to calculate nr_kernel_pages and nr_all_pages, > > both of which will be used later in alloc_large_system_hash(). > > > > nr_all_pages counts up all free but not reserved memory in memblock > > allocator, including HIGHMEM memory. While nr_kernel_pages counts up > > all free but not reserved low memory in memblock allocator, excluding > > HIGHMEM memory. > > Sorry I've missed this in the previous review, but I think this patch and > the patch "remove unneeded calc_memmap_size()" can be merged into "remove > meaningless calculation of zone->managed_pages in free_area_init_core()" > with an appropriate update of the commit message. > > With the current patch splitting there will be compilation warning about unused > function for this and the next patch. Thanks for careful checking. We need to make patch bisect-able to not break compiling so that people can spot the cirminal commit, that's for sure. Do we need care about the compiling warning from intermediate patch in one series? Not sure about it. I always suggest people to seperate out this kind of newly added function to a standalone patch for better reviewing and later checking, and I saw a lot of commits like this by searching with 'git log --oneline | grep helper' > > > Signed-off-by: Baoquan He > > --- > > mm/mm_init.c | 24 ++++++++++++++++++++++++ > > 1 file changed, 24 insertions(+) > > > > diff --git a/mm/mm_init.c b/mm/mm_init.c > > index 153fb2dc666f..c57a7fc97a16 100644 > > --- a/mm/mm_init.c > > +++ b/mm/mm_init.c > > @@ -1264,6 +1264,30 @@ static void __init reset_memoryless_node_totalpages(struct pglist_data *pgdat) > > pr_debug("On node %d totalpages: 0\n", pgdat->node_id); > > } > > > > +static void __init calc_nr_kernel_pages(void) > > +{ > > + unsigned long start_pfn, end_pfn; > > + phys_addr_t start_addr, end_addr; > > + u64 u; > > +#ifdef CONFIG_HIGHMEM > > + unsigned long high_zone_low = arch_zone_lowest_possible_pfn[ZONE_HIGHMEM]; > > +#endif > > + > > + for_each_free_mem_range(u, NUMA_NO_NODE, MEMBLOCK_NONE, &start_addr, &end_addr, NULL) { > > + start_pfn = PFN_UP(start_addr); > > + end_pfn = PFN_DOWN(end_addr); > > + > > + if (start_pfn < end_pfn) { > > + nr_all_pages += end_pfn - start_pfn; > > +#ifdef CONFIG_HIGHMEM > > + start_pfn = clamp(start_pfn, 0, high_zone_low); > > + end_pfn = clamp(end_pfn, 0, high_zone_low); > > +#endif > > + nr_kernel_pages += end_pfn - start_pfn; > > + } > > + } > > +} > > + > > static void __init calculate_node_totalpages(struct pglist_data *pgdat, > > unsigned long node_start_pfn, > > unsigned long node_end_pfn) > > -- > > 2.41.0 > > > > -- > Sincerely yours, > Mike. >