Received: by 2002:ab2:6991:0:b0:1f2:fff1:ace7 with SMTP id v17csp135051lqo; Wed, 27 Mar 2024 08:50:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWnmZfUEmm4C5nQEnMuv2zx8AQcSzo35xgkkhCUiDe5mN400+gzfRcKQcV5KUEM/ZK7t/99W4IBj/Vjonu8y0YmSDmMzt0KlrYxfsjl5Q== X-Google-Smtp-Source: AGHT+IEcPN1rM09ddrPMqEOK2c7+uvwMXyf404Jvo7g1wNsd/TV5AsUKQgbpgI6kAFb33X8ErNdm X-Received: by 2002:a17:902:ce86:b0:1e0:b62c:3ae2 with SMTP id f6-20020a170902ce8600b001e0b62c3ae2mr102707plg.10.1711554619627; Wed, 27 Mar 2024 08:50:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711554619; cv=pass; d=google.com; s=arc-20160816; b=qVukkRfMGOhbMu8zu046s8wiBufdON/4Hz9sWgVoQqqMbTo6ttb/ORWYOi7076x8nX l8GKicomd7NI/8rDeWRQ76RYs2Ejq5/FlRD1ptzUZPSlLTdcw7PaTcn04yufJ8tgirFm P53RbtKthhDEyTgV9l0SP7dDdWC4NU9/IZZBjXL3CLb8E9iy2qnGhSDgD0756utUI4tV Alswv1hBeSPLUJRMYD/TZyLiZ6ya1hWZ1btcMfcisps4+J0Dvp1th9BCVlTsxWM6HvlZ is57ZhjN7G0CX07LiblXpPihzqa8/vGStHEFlKAlu8ShsaBri95uJzfD8nsv+54zA7OM wXCw== 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=rATdLTObDwylu0nu470hnr834O2jOH2Pl2iT/o+Ne7w=; fh=KGm8PY/IetsVJWKK6UNUWrv2dd7n9qXKtm51kzc4YLY=; b=zp4DUvaJ6Pq5OA5efaQ23htoqOoDpPtNtIRvmnBDOgVgXMPkaqoa5uQmY8uCDSCBjM HsCTOdAab5x0jFjdwdo0Q3MAPeoSMqsar2Fg5L0Kiu+DIrIr0a/1SUsKtTU2p+F6eDpG uufFGNYD2mVID33lDDDV/KdhNBbmYfnazyTbPPUI+PKzqI8MapcFtH+hykHmML0CDsV7 X1/d8itoItVDCGPG+Sl8hVHEldj/wddt6hKfiGuSmVXySqwRNwUE0RS0WhG8o6k7tNYg ZDRRBb/gqCkOGeP9KTjfk4H2L6bfwEzPLOi1kemuFZ7Htces5CkQzBRTrGXkMN5WWC4J SfDw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Y7y9hYHu; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-121546-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121546-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id w6-20020a170902e88600b001e0abeb8fafsi8787911plg.477.2024.03.27.08.50.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Mar 2024 08:50:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-121546-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Y7y9hYHu; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-121546-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-121546-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 97406295B18 for ; Wed, 27 Mar 2024 15:43:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A85AA131736; Wed, 27 Mar 2024 15:40:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Y7y9hYHu" 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 D6E24131188 for ; Wed, 27 Mar 2024 15:40:55 +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=1711554055; cv=none; b=fsH7ejoAfq25Rw5e0xk/Kt41jcH/IyctWfkSDD5YUPBmYcNMjlw4HBoEsoO4yC/cKJPkl0zKVecgvw3rYzJw1fzMzFeXg7yPt7eQTOHXtMKnCEhzvZ+hFJWD38urLU/Yhh8nqdekP7TlDU+soXtCCcH1uawsVAU6DfBr+d79dKs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711554055; c=relaxed/simple; bh=HNlX16yEhkMKnQYWOX4sU3T+8rc8JG5/hnyo+cviw3k=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=sSkQ7WNsupbKR3/RqHggSm2XJTr49CuKpl66f2KFm+SbZTPsMuhcJmMxIkZUJIMKBnLYYD4Fega4telwhOsvxtNApKpQvMeQy8nzlNJranRPrHcrgUJTQ1g+YcebZCacEk5FxoxR0yGTA9sUcTUnysmSxG4BWFFatWsP+4rI5lI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Y7y9hYHu; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0BEBEC433A6; Wed, 27 Mar 2024 15:40:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711554055; bh=HNlX16yEhkMKnQYWOX4sU3T+8rc8JG5/hnyo+cviw3k=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Y7y9hYHuRLtHvFLwO8Y4NO0itC/fk4QqmGjSusGf91p3QG5DF6iyq1cxHOvvstzI0 edCWgqhb/0nQbxWRTgf8biJg0d5OeT9/fbxX6E/GjmojuvotpQOzjJ0fTSE+bjk13Z 21wIMYhkIy7dr+27z0Yzz2IZdMF9m0HoRyEgdrtyqkn7d/Lxic2MM5TmmEfclHRjaG TMc7uLg0ymzMNuHxyfmESWSNzMzcnrRwnwI18Zrdq9w7rmLyzP1CQ4DRxYinYyq+xY P3tSh6w6HlL+vOS/Flq9BgOvcdfVDQyD20LMrIQR5rBkNZ0rl1e+G4RbiPKlwZFoGN dI6A4osqTA2Qg== Date: Wed, 27 Mar 2024 17:40:12 +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> 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. > > Signed-off-by: Baoquan He Reviewed-by: Mike Rapoport (IBM) > --- > 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.