From patchwork Mon Mar 18 14:21:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13595398 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 48E18C54E5D for ; Mon, 18 Mar 2024 14:21:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 977606B0085; Mon, 18 Mar 2024 10:21:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 927986B0087; Mon, 18 Mar 2024 10:21:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 816056B0088; Mon, 18 Mar 2024 10:21:55 -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 725426B0085 for ; Mon, 18 Mar 2024 10:21:55 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 38FC48059D for ; Mon, 18 Mar 2024 14:21:55 +0000 (UTC) X-FDA: 81910373790.16.2AB95F0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf30.hostedemail.com (Postfix) with ESMTP id 9FA6180016 for ; Mon, 18 Mar 2024 14:21:53 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=NhwipeGv; spf=pass (imf30.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1710771713; 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:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=F5ye388VWoErT8xKd/JXdRVRXGFtTvAxoGWVnY3cKSY=; b=mSIR4U4u3mOWOyNS0OPMK6RmuxWnKtxdmGmhxYl5+jitGZWpnd9KdmtsfPNjsUPR0BLimk lNb7MLqj9sYGjyltNIHiEV24jml4thiNnwT0uQBdl2r6iRXvhF6ieGEYul4p4bcdbxdmFg t1exVr4N2vazuZ6hAQxL+5z++Yo/cZo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710771713; a=rsa-sha256; cv=none; b=S9qFEWnoauetd7wpCoo7dOC2lUL2GbRqt9vkjk3vsI5dGjd6ceZCKKHtZ4HjvFT5XEb09m fPo3ACeFyWMT1omT9cjzIZBP3GW2mKD2sbTnobyX0B6ew/4jOpZJB2QB0p6i4sOQY8Jftu AMkp9a2XieqOW7l78lJq9kxNUDQMXaU= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=NhwipeGv; spf=pass (imf30.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1710771713; 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=NhwipeGvrm54kiBMjob5kJxMv5bDvidUCd6ySMnKjB0BZagGY7ni2d5J06ypc4A672hju1 eQ/VaWwRIdfTtoW0mgJfQf1n7x2YL9/nVb3luyfI4crQsV19H31dzkqwSJSPJoOLOvpfcB vYPlMOiaXaLb4LL7pAk6MU+6h7SN7xc= 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> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Rspamd-Queue-Id: 9FA6180016 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: ik6qw6kjptgdr1gdwfj4ut77gi5iyn4b X-HE-Tag: 1710771713-568027 X-HE-Meta: U2FsdGVkX1/nGbYgGVAnJSObXedVhILZ7S8F6rgHRv5GNWRbwF/CblCcltIRq7PQBdzRrUb9Vs+lyAdRdBnHlVCeDM0pAipxJ7nmS1sL17mKuq4fzfFBA4vP91r6lnuiysHZyogC1CvRJQBJxRmhS5RN2+BDCNB17qulqPvGhOhjZE+y5qEh0j1TB67ptAt9P1ObHW4i0IygQIY+s2E67veGOpq+GnjewfhVnvdrE7xOHYh5CQtW/Ee0vMWSh0hukOMMPdAt+96EUqWAmp+X5Y8ObXb7kd9n2qKk1fHJcMR+chEyLlykJHgfQsqkgOoA8D73uWG3kgtoF9csPuLXYHzVAF6dMeEObr1FLX3Ku5bMEFtaSX3o2ymIkCmDct+marX1Rzsz6FfJ4l6h4SiHhoBsL0jol8ntrdU4LPdscVs+KqJsxnqM8CDUM2203HrFyMT4a2v11MEOUWZcdhuVdZhnIEipNvdpCkt64uAkAjmgkLEUmRu3yZWbH3TokCgMRmZF+iIfZhGDbiwj52UuQozwsf+jsXVWhLgd85vVGBpTqHo4gBA0T0sZ3IbAujjrk1M3kzfoSerNWVlCurcodfD+m7ZL03p91n5rPNTay05WGLWXd66JFnuj107wgRkInZDysbdphYEIuUusROJQGUJ13GOv+eGAmIm6FW7M6l6sS6kqhpo2sEFK1by9L5LMWyi2CDlD1sLxF18L4Vj9earjKU8DvdOAcTOBoeXT4mCQTQDOy8Sop9KlygDr2Bm8au3GMxteqYNv9FXLlb6yVeCfDadYAtyLVCK/5OJb+4JqTDdgkjiCddHK2IlkfVd7/62ZEahZW4lfqyKD0YxiQE1BKhEpxj4xfSo5LxOqi19tYEGXmGuJl6PY95tFg8VfjKgxxfkk6oc/P5qVkZJ0hfnPkiPsmKn08QmgmGkCncEbm09YefshXjvp/tBqnopg 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: 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(-)