Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp3141682lqp; Mon, 25 Mar 2024 23:58:14 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUXHSQQXDgFqEqyWKB727x85Z8aJ5CZaBoeMghJcZ2ItuWstJmgCfdSQlxprocRLNLAyHaCuf8y0mW0LwpQZV2cTr6eBspOxWrL9LMLvQ== X-Google-Smtp-Source: AGHT+IGL7Hjo3cC4XdwuvtzdCxF1l2WIS8SkAOQnxoR4V2dXFTfWJ3hkKb7d6QDEuo/RAvHIvw5c X-Received: by 2002:a0d:d50c:0:b0:610:1cd9:8c37 with SMTP id x12-20020a0dd50c000000b006101cd98c37mr2113174ywd.30.1711436294530; Mon, 25 Mar 2024 23:58:14 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711436294; cv=pass; d=google.com; s=arc-20160816; b=mmNf7csykQr7P2UxAthJiOtLxMlA6wfjpI6bTzqsA4LLc8lzpbN43Z+2xwdAoOBRQ+ szNzWZiIEbmGYWIzBHaw3SVA4nuzYpXzCUSYZBxqWFiZP+8f4+X2TKsVoNe+tzHVNsDM HMY6Z7aUIU8ommYxMhxOb35wUtX2KLSooAHmKnkHjJeRiLl6fEDvJ6anh1bWqSJVSBNb dW3Mi6AC3c2ICxwH4P/SANYzgzRTtZ1XTnPooJZ6qt64ICjh++NoxsX2ZRJAGwmNlwcW Mzbkv7KdFZGfmD1tI2t8Q4Z2pH/D2KMv6pYPBgeCmIrMkkOwQzBu4JO6LP1Iy3p3MPWi UUjg== 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=ZFFfJW0sbZgVzZCyUsqWO0DGAOyHJJG2oUtMxtK+8gU=; fh=KGm8PY/IetsVJWKK6UNUWrv2dd7n9qXKtm51kzc4YLY=; b=z8cunTBgDiRF+Is9nV3vyytlcoVx8Q6sSa8k2kXVajzlees+1/pmhRQxHxEaligqeN tGLcI+hhxSTy5/Z/IsdTe+TUS7UX7rbyqeJeyhT3sQ3Hoi8W8N8UF1OFaqvWpeYTKdrh ieJGp8FpnEnsLmLQ2QZGIjrc9O/b0WVr/kD2uU2UqNlFlCnfbxYO2OdjbgqD0HAaXIlE AynTSdyTXZ5J1SdNYmqfvpun96IA73+Sk72dZHw2FyLChydyVXnQ/Ur6acEy3J1knyFj ZhFj2l/VrYINdKFFjdT7PZW0pgEgRBebBoo+L5d7+VALfxy228469s74QmGngXfj94Rk JZrA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ay3TqeCm; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-118435-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-118435-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id h17-20020ac87d51000000b0043131a43ed9si7249373qtb.120.2024.03.25.23.58.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 23:58:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-118435-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ay3TqeCm; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-118435-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-118435-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 428B31C2C4BF for ; Tue, 26 Mar 2024 06:58:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EF8B271742; Tue, 26 Mar 2024 06:58:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ay3TqeCm" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 F0B84129A71 for ; Tue, 26 Mar 2024 06:58:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711436291; cv=none; b=P25U7KSgL4DO8R+BMrQXypjxcgAPjc/3+CHfTIZVe3K6mLTXg2UW79Qe2D4Pwt2fiAS0pkqVe31AVdIRzNQVhKB9ILWG+hfOrWMvzHoiPY5+w3XrhcVJrwXI1SAceGYiA6hN+ZMOZ5lRfRi2MCELn+/4KX1OU8ywho13SI4rW4Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711436291; c=relaxed/simple; bh=Oto1Bgx2nEcBajuiq3zg5pa2/Kdk7vuiCcvbsEb1ox4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=WvAMOLitua8tfq89yoTSYXhRPchydrU3vsSrK5RSE8gCy/g2dJlHBbBrEMukt3uZewp+7duXvAGTHbWwWNDLhlbsyFLZoPAYSrnabyd4wSNKFYLtlHsKywc2lvEyU/wxIWYPAiaCbuNBBQbRAmJuCVOBLEfwEwRZmyrYVmiYHHI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ay3TqeCm; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D0DFC433F1; Tue, 26 Mar 2024 06:58:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711436290; bh=Oto1Bgx2nEcBajuiq3zg5pa2/Kdk7vuiCcvbsEb1ox4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ay3TqeCmVtCa4qF1OL7AxLUF84qxvhegocKTuLWHsbSzS0UgBlX6f7JYNGb8GsCCe qFmQRDbOM1FkEdIcqkVwhm64D+hPxIJNp6dbf8c0W/FuEw56ogMEjRCM/FOdLWKAbZ 0yHansf3kxUb5Lg4jDxjCOL5HNwe/eO/kiY4JrnAhwSZ5dG1adz9keSrXWgyqnlyI1 WcvlKvRNMtOCP7F40tIJ1Dvam3LfxDgwCOx6j8B7kc4BEl++YLMZJu715mR4qd56gl FDAxb7ulwHdEUegXRfRWU/qnUO20UzXt3ALdHLqKNdWqmYi24QG6HIL2SjP2TydLZT zKa93/C8jXs1g== Date: Tue, 26 Mar 2024 08:57:29 +0200 From: Mike Rapoport To: Baoquan He 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: <20240325145646.1044760-4-bhe@redhat.com> 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. > 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.