From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C5FBFC47DD9 for ; Wed, 27 Mar 2024 15:41:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5E4006B00AC; Wed, 27 Mar 2024 11:41:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 595116B00AD; Wed, 27 Mar 2024 11:41:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 45BFB6B00AE; Wed, 27 Mar 2024 11:41:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 26FE96B00AC for ; Wed, 27 Mar 2024 11:41:24 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id E417E140A91 for ; Wed, 27 Mar 2024 15:41:23 +0000 (UTC) X-FDA: 81943233246.26.1569C19 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf18.hostedemail.com (Postfix) with ESMTP id 4640C1C0008 for ; Wed, 27 Mar 2024 15:41:22 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=dkFAoSvE; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf18.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1711554082; h=from:from:sender: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=TEEj67rXwtgv+ORrEdvwHmvIYF+fv97LRua1AQhlmu4=; b=DFy786AVvAm3munKWP//QWYgHaDhWtse2ZyancksYscIEayfmSFb06QKrg3tKT0oidnuTN EV8OxiFxD1wn5i2pvv4vD84VwgWkhe1JX08fXsaT9ZUtoMbOL4yGpUNS8kMicjvngE6er2 Zba+/FaruA6rwImrtdREUau9txmd/uQ= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=dkFAoSvE; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf18.hostedemail.com: domain of rppt@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=rppt@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711554082; a=rsa-sha256; cv=none; b=eypwBIkdhOHvBfWXumJO4H0QQThNG5/UnManzpiqfV8PXSJQbZVTEGUMr3SIl3BlgiTNBX KBo+fkE29Ao5grU+3P3CI4eMV5gUTzHugowLqgOW38JRgClC3l/YIrqUM4FYtv7O5chKhk n/+u0rH1JVoug/XCutDWRUS8kuowIIE= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 6EC51615AD; Wed, 27 Mar 2024 15:41:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0F2D3C433C7; Wed, 27 Mar 2024 15:41:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711554081; bh=YkpXI8Y4E5O0pSnw1xlG7QH+gWTbFLfo1f7E5+HqAZM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=dkFAoSvECyFOu4CWh7hFOPMthOkr2i/TebRy5IlzhK+g5sPwyAtlgNi0H4s/QuTWQ p6mv6hTx4moEGi2CbURw76YIz/ZIklvZ2sAmsMbZ2YxnQwiR+VQvb1Xoti0mPvRTP+ Wtt/YX34R4BJzWV2fbhV0pcrYowD31U4eG0N/Mkmobhe7NrfK54W0B/lBcqQbZQBPn pQSf5FjkUMtIptLuKVlNsq5LrZNQptBdoWxNXpO6W+QRfH7E5uhvXsJh4Xc+nvsCkz EO0OiTf1wxEv7h6euXU/0Pi7zjLjfz2+3S2zhs/xQ52LYDpY9Pian1dnYPcxnRCv7i 8W3n4Jqw67LZg== Date: Wed, 27 Mar 2024 17:40:38 +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 4/6] mm/mm_init.c: remove meaningless calculation of zone->managed_pages in free_area_init_core() Message-ID: References: <20240325145646.1044760-1-bhe@redhat.com> <20240325145646.1044760-5-bhe@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240325145646.1044760-5-bhe@redhat.com> X-Rspamd-Queue-Id: 4640C1C0008 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: gccjfdcp9dxp84twrrqnapxz1xgnr9na X-HE-Tag: 1711554082-649341 X-HE-Meta: U2FsdGVkX19O21qD3wm5C8AW74sYkNOdfe9UCmfSagSdyjNVoMT0qI934QAvoiONkJbnxRswu0ZXTlY7Ku1Hg1LTicYusebbEk712GWWIws8j9ieCTf9oE/V9OXUNN10smkcvnhdBtWantozNgwvj7QzZu5gYw29b3swfyFt40Ma/0cwR05lVZ3HEQITgJDjNzs/3cI2lwIJ2dxZWjaXaF0wkKb1SqYKVC86L3qB/w05c7KEghB312wQnfKxouVsp+BUS1Znjko3jI7FpEOFhAVqBtwGUCJoi6AMZi2vx/812QSDcdrsoKS3bgEW5bwFzAU62Ci3aE4tEDXZWR91FU5pjB0ISiY3LDAs+p2sjZFYY/QH4cQPEM/IN19ZrJegT6tU8fIvDpsazeAvwcMZJOp1fcn9yw0/Q1spRySDX9bCkQbzH8Bdnd5xyrSR+af4ZYLNTS/pwRtBXXYoS2mmuiHhP3vzm3Jb51uQFtJUptIQrvT5pmS6sN4JSDEOjDlPus8IuRLyGnjLSl5ymcV6a4NoSVLl+uI5VgOP/1Dd18nAVqzNU0m7HwbnKN8vnK4DkFByaalmxQrvAk9bm+O2mxjsoPQ/N3r/OdI+EFbebEKFpJs3XW4eGYBDu3UflBlxcolsangzDGjwV3eeRj9cZjUUV9nCurl9FLyi5IBaKQYBgOOlofcpiyGuTEh870N14LTyqfrTpYZmMzAhgR2Y/oI0L3aDfVHLstjSrUFYbYnj1jl8jUE4cFuTtVkrsiepxOOQ4xN3Y1Q2ksrkYEBr5ZpFmVALj5fI6EJ9oi9XsW04NW2ux0h5P03Pbwhu4i4OdD1jee86Eog/NtUTuoK45tkQNgTUpvDE56SsCWyLkZxtIw6npUZTM13Jt2lSSOhr/2UhHbRQVLOPX8CBNkH1QWY+5Ej4CEiz19EoL8vtfT7BkltI2GA160wQjGkPAqrbui8cGKNhDORCQmxDLC9 XWUO9PtQ QfS5wTycgB+u4aPOST867NfZkuj1aQJVAo+OQQoC9FcamNmPZwiW4RZB0Ykm5IWtfx6lP0E7U7jL1KzxTk3b3kKDREKKDkVkGnT0un4VpGwLRNjr2BigRFewzehcHGgYJdV9L6rO7gZ7PL41XvlL/UupHPs6a/vXyfAMJ6Tg0qCtBjDOMvxRzDss/DNDO9BevhUfSa6OD8zjCNsz7H2nZFllCLtgX1MjaRdE7L7frXRHLqeUyrXFkB8u7VMJewOzCUZQShEWUCtqekY503UcnX8vp+PEE+uPDT3FCwWLUDBoDRCfDJj4EwwTaIELsQhVh6Cm+ X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Mon, Mar 25, 2024 at 10:56:44PM +0800, Baoquan He wrote: > Currently, in free_area_init_core(), when initialize zone's field, a > rough value is set to zone->managed_pages. That value is calculated by > (zone->present_pages - memmap_pages). > > In the meantime, add the value to nr_all_pages and nr_kernel_pages which > represent all free pages of system (only low memory or including HIGHMEM > memory separately). Both of them are gonna be used in > alloc_large_system_hash(). > > However, the rough calculation and setting of zone->managed_pages is > meaningless because > a) memmap pages are allocated on units of node in sparse_init() or > alloc_node_mem_map(pgdat); The simple (zone->present_pages - > memmap_pages) is too rough to make sense for zone; > b) the set zone->managed_pages will be zeroed out and reset with > acutal value in mem_init() via memblock_free_all(). Before the > resetting, no buddy allocation request is issued. > > Here, remove the meaningless and complicated calculation of > (zone->present_pages - memmap_pages), initialize zone->managed_pages as 0 > which reflect its actual value because no any page is added into buddy > system right now. It will be reset in mem_init(). > > And also remove the assignment of nr_all_pages and nr_kernel_pages in > free_area_init_core(). Instead, call the newly added calc_nr_kernel_pages() > to count up all free but not reserved memory in memblock and assign to > nr_all_pages and nr_kernel_pages. The counting excludes memmap_pages, > and other kernel used data, which is more accurate than old way and > simpler, and can also cover the ppc required arch_reserved_kernel_pages() > case. > > And also clean up the outdated code comment above free_area_init_core(). > And free_area_init_core() is easy to understand now, no need to add > words to explain. > > Signed-off-by: Baoquan He Reviewed-by: Mike Rapoport (IBM) > --- > mm/mm_init.c | 46 +++++----------------------------------------- > 1 file changed, 5 insertions(+), 41 deletions(-)