Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp265594lqt; Mon, 18 Mar 2024 07:22:22 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX+wbcgvXGWjB9en4ppMPHrfn1sS/CvXxNqTKtCJbyA4CSL/SeZ6WPoz/80vg47UsLRBoCBreNwGdKudDoftUHOKgyT/NZbnXaZP7l3Pg== X-Google-Smtp-Source: AGHT+IEW1DMBRbBpYVL74L/x4wLUSWR2Ogk9tuIXXQHajXWpnfhBMPA0OlWYJiZH5T8iEyOTHpNr X-Received: by 2002:a05:6402:428b:b0:568:376e:ea2a with SMTP id g11-20020a056402428b00b00568376eea2amr7815195edc.40.1710771742203; Mon, 18 Mar 2024 07:22:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710771742; cv=pass; d=google.com; s=arc-20160816; b=PgB4papcnP9livhkcDvrD2JgFtVB8cPCucUcb/S1fwnR1UtxwO0hOS1V4vnDYZ4M79 Pr3mAElhNCfF6P1n+5kAOdLSC6YCeiXXThkDijZ/Lg9pRDaAeNtmeykalnIvF3ujbf/F 9p5KEUKXFCqJSabLSzQE2ZmtoHBEfxD9MGupIK3JWmyAqGn0/xRS0wiYfnmDkret3Rra 4QoQ2F5IaIRBORzxKKz4svQLhhp3om6+6N1TVkl2C3vbbBVwJd/YIhDX1PLDVIT1/CWQ yap0Kcf6nrYZ4sPzT4ia9aTGf0+kJZjpPrjWxt+YmThGOOeQJBkn0No++pSi98I+rajk 9kTA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=F5ye388VWoErT8xKd/JXdRVRXGFtTvAxoGWVnY3cKSY=; fh=c/oh5Up+S96DG6r/ur5MAfFIcXhUC0de4lfxNiuupEI=; b=MIiWrTei/CqeFsknn00QQpd/yi04eGc9pbd+VrFslQsjTzItz4lhN+BrxzVBA2/Qwp CiJIEgfuE7YroL+YltuCDeI0T1U1CXNgA7dtZ+dxrzA0ryJ2JDKSHLU8VOGpCYTdD4se gWxCBuuIEKKgktl4GRU/PelDev0GYNZtO1B6em941oY8pXfAvhb+VATn2JWWpUu1Z6Pz 7uNcPoR8HuimqHfNh3RRPZbQV0qPGm+hvOskXdqYmoMQaeN7rdY+bJtGVfaTRLA0fUS8 zdAbwFXoZOzTkVu+nsin2e2rAAK0phY/dhMt8ZxyYNdWhgI3JXqZpiK4ASPGHYryoYcP Lj5A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=K04WwRbW; 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-106209-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106209-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id fe12-20020a056402390c00b00568b5ce1579si3022971edb.120.2024.03.18.07.22.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Mar 2024 07:22:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-106209-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=K04WwRbW; 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-106209-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-106209-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 am.mirrors.kernel.org (Postfix) with ESMTPS id E60851F21675 for ; Mon, 18 Mar 2024 14:22:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9819B4E1D1; Mon, 18 Mar 2024 14:21:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="K04WwRbW" 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 EE6014CDEB for ; Mon, 18 Mar 2024 14:21:52 +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=1710771714; cv=none; b=MFmLkE3yi6CoH5o+VIc/GHmfM8x/LYCOM+68Ib0Bw31VMgy1+WP6xx41Mjey2wEoVW7gxxE32xh6rIBSm4wbpcTN9Yw0/3IqW6hIvfdeVzRoWUUL+6DzGVexorHpeaB6j1LjET8vMtFt1vgl2J8xECqqo4NnF10S2rWJRpSnxEQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710771714; c=relaxed/simple; bh=fbmmrMFnYH8ln09BbkU1anr7KedTZF03Qizagwy4S3A=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-type; b=DSCJQrLZtfGQUS0GGeGVypGaxtGQfeeicfJx5tR6RUAkosykyj/tzsvtmF9Q+4krP3XjbzJHKZ8pBL85694eld/sLcrYhhOiYJ1LL91KqBOMOvxc94+SwW9QUht5D5/6cZOVEJ+eh8CDRRCAnFt0DBB6F54P7lU6Hnn0Bx4YXwU= 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=K04WwRbW; 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=1710771711; 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: content-transfer-encoding:content-transfer-encoding; bh=F5ye388VWoErT8xKd/JXdRVRXGFtTvAxoGWVnY3cKSY=; b=K04WwRbWPa/jwg4p6XHqAx7xMTDQz4CQp5LBDpWKm43uiYvfZM7GYqSswwgLYuXtEGXa8K SSdVpnIR9k9P3V0et/yA42t8PO9jo49ZJuzeT+eXhTe4Xs/3KatK6VLRH/yHtKNKF0fsk1 JhA1R1yPz6uaZCw5trF/cjCYSzx9Zvw= 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-505-wJFmYP1ANHGgSGjgt3Fcnw-1; Mon, 18 Mar 2024 10:21:49 -0400 X-MC-Unique: wJFmYP1ANHGgSGjgt3Fcnw-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (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 02C8F3C0F180; Mon, 18 Mar 2024 14:21:49 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (unknown [10.72.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id C88FE492BD0; Mon, 18 Mar 2024 14:21:45 +0000 (UTC) From: Baoquan He To: linux-mm@kvack.org Cc: linux-kernel@vger.kernel.org, x86@kernel.org, linuxppc-dev@lists.ozlabs.org, akpm@linux-foundation.org, rppt@kernel.org, Baoquan He Subject: [PATCH 0/6] mm/mm_init.c: refactor free_area_init_core() Date: Mon, 18 Mar 2024 22:21:32 +0800 Message-ID: <20240318142138.783350-1-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 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 In function free_area_init_core(), the code calculating zone->managed_pages and the subtracting dma_reserve from DMA zone looks very confusing. From git history, the code calculating zone->managed_pages was for zone->present_pages originally. The early rough assignment is for optimize zone's pcp and water mark setting. Later, managed_pages was introduced into zone to represent the number of managed pages by buddy. Now, zone->managed_pages is zeroed out and reset in mem_init() when calling memblock_free_all(). zone's pcp and wmark setting relying on actual zone->managed_pages are done later than mem_init() invocation. So we don't need rush to early calculate and set zone->managed_pages, just set it as zone->present_pages, will adjust it in mem_init(). And also add a new function calc_nr_kernel_pages() to count up free but not reserved pages in memblock, then assign it to nr_all_pages and nr_kernel_pages after memmap pages are allocated. Baoquan He (6): mm/mm_init.c: remove the useless dma_reserve x86: remove unneeded memblock_find_dma_reserve() mm/mm_init.c: add new function calc_nr_all_pages() mm/mm_init.c: remove meaningless calculation of zone->managed_pages in free_area_init_core() mm/mm_init.c: remove unneeded calc_memmap_size() mm/mm_init.c: remove arch_reserved_kernel_pages() arch/powerpc/include/asm/mmu.h | 4 -- arch/powerpc/kernel/fadump.c | 5 -- arch/x86/include/asm/pgtable.h | 1 - arch/x86/kernel/setup.c | 2 - arch/x86/mm/init.c | 47 ------------- include/linux/mm.h | 4 -- mm/mm_init.c | 117 +++++++++------------------------ 7 files changed, 30 insertions(+), 150 deletions(-) -- 2.41.0