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 D7E3BCD11DB for ; Wed, 20 Mar 2024 08:47:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 703236B0085; Wed, 20 Mar 2024 04:47:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6B3006B0088; Wed, 20 Mar 2024 04:47:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5A2776B0089; Wed, 20 Mar 2024 04:47:36 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 4BF886B0085 for ; Wed, 20 Mar 2024 04:47:36 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id E7F18812FE for ; Wed, 20 Mar 2024 08:47:35 +0000 (UTC) X-FDA: 81916788870.29.05CD680 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf06.hostedemail.com (Postfix) with ESMTP id 09F4318000C for ; Wed, 20 Mar 2024 08:47:33 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=YyfO0oSh; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf06.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1710924454; 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=rFk7i7r/Rth0uc1ovX1/w3IsN+7Z5+mbDrMRpvOVhNM=; b=m3ZaDcUG3W00rLwUx0LsUnxAXlhIivIfzsF44g2mJLXP1hh1zmiz1R+7JVZMWmAYXWDVB3 ss1YyDFNew5lLfxSE+5CUIeO86iplQNR/ka5irJOz2YT0nIuy51aXPVmuZVnjC5ie1FsZx YLBvpsAOSj2BAb0Ms3NA6Yo2aY2SkIA= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=YyfO0oSh; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf06.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710924454; a=rsa-sha256; cv=none; b=6vhssRySXGk4X+5QrKozO0yRHU1X9bKHYeqDSPJr/AB1w2bHUaENLBZNYnOfdAdF/8xRW5 u3B0+zmoR/yHDcPlttlS9SHLIMl7mX3LMYtiDsLp3Acr9cLSmByxVj9MyT17nuwS3Wp22I o5P1vrXMcX7mLCb8EjS/PBskTgtLXls= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710924453; 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=rFk7i7r/Rth0uc1ovX1/w3IsN+7Z5+mbDrMRpvOVhNM=; b=YyfO0oShrH5jxxzWIxx9C1tiFGc/M2rSxPoexE+BRWCfF7PghqaAMIswp7YcFUGAvb13zf w6k8Qsg55mkC3FGwP003XdBQYByR0DmXur6JmVCME3RLPq+iJtMcvVjiwxjdCMsZfgV4cL +3HNNkviID1F+vpE6xVlWHRGIRQIYpo= 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-628-iyzdhYmPMSuJGahHdL-Mxg-1; Wed, 20 Mar 2024 04:47:30 -0400 X-MC-Unique: iyzdhYmPMSuJGahHdL-Mxg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (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 409D02806044; Wed, 20 Mar 2024 08:47:30 +0000 (UTC) Received: from localhost (unknown [10.72.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5AFA810E47; Wed, 20 Mar 2024 08:47:29 +0000 (UTC) Date: Wed, 20 Mar 2024 16:47:22 +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 4/6] mm/mm_init.c: remove meaningless calculation of zone->managed_pages in free_area_init_core() Message-ID: References: <20240318142138.783350-1-bhe@redhat.com> <20240318142138.783350-5-bhe@redhat.com> 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.5 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 09F4318000C X-Stat-Signature: 5gkhd4yy1uyd85g6hc7sf8p5mndcjsr4 X-Rspam-User: X-HE-Tag: 1710924453-750938 X-HE-Meta: U2FsdGVkX1+BdKCq8gCtBpOOeE/5EXJYzITtIBW2RL8vaofsHPgD5YtnWv+gCgUYo5RGY3eHWdk9fD3Ji3EW9QAlCylqAO91cgosBlrb3yMEDq4Wqk610lA4xzlPeoh4a/9C9d04jZhh8mK8fFpY/lxhZ6KuJDmIikkXi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P5g== 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 03/20/24 at 04:18pm, Baoquan He wrote: > On 03/19/24 at 06:17pm, Mike Rapoport wrote: > > On Mon, Mar 18, 2024 at 10:21:36PM +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), directly set zone->present_pages to > > > zone->managed_pages. It will be adjusted in mem_init(). > > > > Do you mean "set zone->managed_pages to zone->present_pages"? > > Hmm, maybe 'set zone->managed_pages as zone->present_pages' > or > 'assign zone->present_pages to zone->managed_pages' > which is more precise. > > Wwill update. > > > > > I think we can just set zone->managed_pages to 0 in free_area_init_core(). > > Anyway it will be reset before the first use. Rethink about this, it's better to set zone->managed_pages to 0 because there isn't any page added to buddy. Will update. > > Yeah, setting to 0 is also fine. I thougt of 0 ever. Considering > zone->present_pages is closer value to actual zone->managed_pages > than 0, and it may be needed in the future in some way before > mem_init(). If no strong objection, I will keep the assigning > 'zone->present_pages' to 'zone->managed_pages'. > > Thanks again for careful reviewing. >