From patchwork Mon Mar 25 15:04:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13602383 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 79BB7CD11BF for ; Mon, 25 Mar 2024 15:05:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0B4446B0093; Mon, 25 Mar 2024 11:05:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 017A96B0095; Mon, 25 Mar 2024 11:05:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CBFD56B0096; Mon, 25 Mar 2024 11:05:17 -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 B62736B0093 for ; Mon, 25 Mar 2024 11:05:17 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 6E48BA0785 for ; Mon, 25 Mar 2024 15:05:17 +0000 (UTC) X-FDA: 81935884674.16.ABB5DF9 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf04.hostedemail.com (Postfix) with ESMTP id 8FD6F40031 for ; Mon, 25 Mar 2024 15:05:15 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=GI0zueDW; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf04.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.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=1711379115; 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:in-reply-to:references:references:dkim-signature; bh=U3ff8oMNADHzptakpSPieIZTUIjO9rvhm+AtNOQoYNI=; b=RAR34X3dUp+HTnmtBAI290Ei07cfRCfo8FBedo5XPZTpRKRmkM0jYUledbuetUkTO0PaOK EH5cM9JMq3D66+1T9eKgInHa1smzB+lI80ECZtr25/sW7A5bhTnusSZg60ww0zKxMhXg7E 7eXtSa5h1JRdzzfyRjZcVijOI6eUuow= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=GI0zueDW; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf04.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711379115; a=rsa-sha256; cv=none; b=qll9ha8HgBNCAe24lIL3uJOGprlV1L1+7D5ZA2AvX6RETMxRB7lbP3G7jDAWxb9jtsByKf Rq6adtyE5o+HCAHk0ngGB3CV25K0QJE0ysMQnW24SVNsZ3z2seQP1TR/LMkuUunqZTmXbF zg+25SFkvk4PnJIdiXCwjxtYHIJJmkU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711379114; 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: in-reply-to:in-reply-to:references:references; bh=U3ff8oMNADHzptakpSPieIZTUIjO9rvhm+AtNOQoYNI=; b=GI0zueDWp6jHRmoZ+AZHQoO3dwogiAtXK2i84V3Dw4fSrsl4hE53Mc6Sg3cyz93XQbWQCV 7k48kS3MTfA0Rt3zZia8jZdEStKpimV+B7aPsQn7hHYcbpqnnrtrXz+1RIOStKNDl8AoBG F3ky+T0w3tHWZYJG/E4MT6nIjQkmQwQ= 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-335-zoT4-6ziN_K3fLKul_roIA-1; Mon, 25 Mar 2024 11:05:12 -0400 X-MC-Unique: zoT4-6ziN_K3fLKul_roIA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (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 A0FF63C0DF64; Mon, 25 Mar 2024 15:05:11 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (unknown [10.72.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6DEB2C04124; Mon, 25 Mar 2024 15:05:09 +0000 (UTC) From: Baoquan He To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, rppt@kernel.org, mgorman@suse.de, Baoquan He Subject: [PATCH 1/7] mm/mm_init.c: remove the useless dma_reserve Date: Mon, 25 Mar 2024 23:04:53 +0800 Message-ID: <20240325150459.1045407-2-bhe@redhat.com> In-Reply-To: <20240325150459.1045407-1-bhe@redhat.com> References: <20240325150459.1045407-1-bhe@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-type: text/plain X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 8FD6F40031 X-Stat-Signature: thown9gaojp6dd71jrzksr5k4ybhf58b X-HE-Tag: 1711379115-560546 X-HE-Meta: U2FsdGVkX1/yI4QCWf4WDjvcvBdmsnOVSuoLeqSNs7FRoM43wOqWW6L5MB9l4Pl7l1pOf38ma1OeYQ4IPsrZehMJGsyAXqN1qjZOWidziaG3kYl+4Afk2L2IUlcA+okmGMaDmECDkncDfiyj0lL9WWWKp+y7X4+qtqHWlx63uldLPYayNsa9+nLQa2IIlKq0b5wTUZGDx63/gy2m5yj9pC19saBTHv6d0Oj2giHOAs9nCCxq3d27vKIMkQl080MsmR28kz9iczwv0gHXJm+NxCVZPc26QZo4f+QtOI3UCMibHDHqTRjjbwDlRn/6xgCziPBgcz5KbNdnr89ruTefjTtj/qiOv423rrlJY1yiIobif4k2/7ej3GYkV1bwIvbDGpYnbjGMPL7sGjyp2hQ2SMiS7mexL/odLC6NMfiTG/BFYDMMsfVlO3puw90p4LP+FyOS0GKzmDosSo5ZE77s5k3h2sZRhhWyCbqkzMeO6B3E2D3JPh3hMCnV4JbdIkqOeNHC/oKY+MymjHjBs4mmnnCLnkgOl7859cfdvoDP6NCftUGUIztMcYrDam8Mpi+xYOCJC0wYAzT9SeH+Dh2oymIrhcBrdgJ6gBhdq2Bp90xZ2IIMV19U/VrDnpIFbv6koGnBVtZJLS/uenEb8JMP18Ved8UjfjYr5MRJq3HRqflx6GmOLyfefwfjN0/jub89NUbu1CQkjYUkriHO67WpEdJYJAw9KJnKA1bglepDNtfR9WDJ6BhtjGXscDTBdZS56p9Z3jZJiqYm+h8Ps17qFkOYNS2PN4u8pCdLOwu8ul8RHZonaN5Y6XiIfMBb7H9tmZERtOK2FOLfw3hrzhN8xX1YSU8O+ilZQjdaGcJiGHHJpgXbZxbLusvWlRDhnzXquotX030imQiOvQ1yrnWdQTAW57I7R70myMfeiamiMcp0Cud37GDFEaDLjCpaE2T1 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: Now nobody calls set_dma_reserve() to set value for dma_reserve, remove global dma_reserve and the codes using it. Signed-off-by: Baoquan He --- include/linux/mm.h | 1 - mm/mm_init.c | 23 ----------------------- 2 files changed, 24 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 0436b919f1c7..ad19350e1538 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3210,7 +3210,6 @@ static inline int early_pfn_to_nid(unsigned long pfn) extern int __meminit early_pfn_to_nid(unsigned long pfn); #endif -extern void set_dma_reserve(unsigned long new_dma_reserve); extern void mem_init(void); extern void __init mmap_init(void); diff --git a/mm/mm_init.c b/mm/mm_init.c index 549e76af8f82..153fb2dc666f 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -226,7 +226,6 @@ static unsigned long required_movablecore_percent __initdata; static unsigned long nr_kernel_pages __initdata; static unsigned long nr_all_pages __initdata; -static unsigned long dma_reserve __initdata; static bool deferred_struct_pages __meminitdata; @@ -1583,12 +1582,6 @@ static void __init free_area_init_core(struct pglist_data *pgdat) zone_names[j], memmap_pages, freesize); } - /* Account for reserved pages */ - if (j == 0 && freesize > dma_reserve) { - freesize -= dma_reserve; - pr_debug(" %s zone: %lu pages reserved\n", zone_names[0], dma_reserve); - } - if (!is_highmem_idx(j)) nr_kernel_pages += freesize; /* Charge for highmem memmap if there are enough kernel pages */ @@ -2547,22 +2540,6 @@ void *__init alloc_large_system_hash(const char *tablename, return table; } -/** - * set_dma_reserve - set the specified number of pages reserved in the first zone - * @new_dma_reserve: The number of pages to mark reserved - * - * The per-cpu batchsize and zone watermarks are determined by managed_pages. - * In the DMA zone, a significant percentage may be consumed by kernel image - * and other unfreeable allocations which can skew the watermarks badly. This - * function may optionally be used to account for unfreeable pages in the - * first zone (e.g., ZONE_DMA). The effect will be lower watermarks and - * smaller per-cpu batchsize. - */ -void __init set_dma_reserve(unsigned long new_dma_reserve) -{ - dma_reserve = new_dma_reserve; -} - void __init memblock_free_pages(struct page *page, unsigned long pfn, unsigned int order) { From patchwork Mon Mar 25 15:04:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13602384 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 10E7FC54E58 for ; Mon, 25 Mar 2024 15:05:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 968126B0095; Mon, 25 Mar 2024 11:05:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8515D6B0099; Mon, 25 Mar 2024 11:05:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6A7546B009A; Mon, 25 Mar 2024 11:05:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 501E86B0095 for ; Mon, 25 Mar 2024 11:05:20 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 0A87F1C0398 for ; Mon, 25 Mar 2024 15:05:20 +0000 (UTC) X-FDA: 81935884800.30.33E8A93 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf26.hostedemail.com (Postfix) with ESMTP id 33B83140021 for ; Mon, 25 Mar 2024 15:05:18 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="hc2CkX/x"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf26.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.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=1711379118; 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:in-reply-to:references:references:dkim-signature; bh=1Ez2QF5MYw9LVg300C2Oo4I1YSujmhzgBkyBgmFJgxw=; b=yS1QabYOVuBAleB9ESxmuWyI/J0b4Jk31u6hea9akjToKdH84nn++jhvxLEMqZ/2itdDNI mLeDKKIfElinoTP3HcpW7mg6m3hz7XJ9b7uTJTrICyPetfOYZFJ7raSZ9ENP1Q8LB2+g+U FcLuv8t22VZuvp8gq7SZIpUVQgRLd3E= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="hc2CkX/x"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf26.hostedemail.com: domain of bhe@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=bhe@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711379118; a=rsa-sha256; cv=none; b=tkop0UEI4KcPDPz35BRe3NOtCm3UG+XfZb9ZUHR8yJG0SxbhSmU9/B88900Y+aSorEZrY0 UUHi+euOU9OF9mNI0l1bpjbfyoEIt36E3dME162cYQHWBayxxpIL7pQBg5fxZgsCoV/oOP i8tLhe+X7WVUYrJWOl3OVvaVXxCFA+I= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711379117; 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: in-reply-to:in-reply-to:references:references; bh=1Ez2QF5MYw9LVg300C2Oo4I1YSujmhzgBkyBgmFJgxw=; b=hc2CkX/xlgts3PRd1xVeoU2wZakf4pl36Z3l1IsgaiHaNwbs5xwMA4R04VOqoUkxBqzXGs a4lCf+sQkSObZOZNcPRwO1D6GQOCOU7Gk7zGSW2LunYtOsk6VxtArmYfn66aYn+QvVTdFx gviKrxQ3Mptw1P2wAdGhTAllg/Z8Nu4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-313-6aVqa4z6M2qwjG0KqT3yug-1; Mon, 25 Mar 2024 11:05:16 -0400 X-MC-Unique: 6aVqa4z6M2qwjG0KqT3yug-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (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 BD8C187984D; Mon, 25 Mar 2024 15:05:14 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (unknown [10.72.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 45FA6C04121; Mon, 25 Mar 2024 15:05:11 +0000 (UTC) From: Baoquan He To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, rppt@kernel.org, mgorman@suse.de, Baoquan He Subject: [PATCH 2/7] mm/mm_init.c: add new function calc_nr_all_pages() Date: Mon, 25 Mar 2024 23:04:54 +0800 Message-ID: <20240325150459.1045407-3-bhe@redhat.com> In-Reply-To: <20240325150459.1045407-1-bhe@redhat.com> References: <20240325150459.1045407-1-bhe@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-type: text/plain X-Rspam-User: X-Stat-Signature: w81gs1h1xw9om7z6trgf1o4xab4kwote X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 33B83140021 X-HE-Tag: 1711379118-453962 X-HE-Meta: U2FsdGVkX1+0S55xKYfi0ZxM8wsdEcLqwdemm2GrKJamrTvm2PZ/Y6E6cFir36fWGBFtmvso1cwx3HCygcSPxBnnfeHNBeFCgawkQLZ/z6KHWc7768BgffIVCtmhUT4nSKDKmB0d7mh/b8Ms5HaigDSBZ7/GC/SgqJi1umnazNHZnUaLWBj2+J06b9VVNgftuUiB1XlRCjEQjuDkSBtHIiqVZxaVNdIyzIR2V7FDB3Ci1w/sDySsPx54BsNZUZ4M0wJSneHZZTcHN3/mq7BK2C2g3cFJ02T+seO0d+pNQpPP1G7iTjbzuunHra3EMu0d8FvhCy098iFJpmPCZJbGEqwDpY7BbR3iTnNim51abQqI+gzfL7o2ykDPOzkwQklPn+Ix4psa0gNAmSBIpITGKCI91/L6ei+aHbo2xhDkiNd5RcBTXeQUbsUyPaH31ImoKcbafZMHscKzjdAhPEINRLkpomS5f/2tZTXuVmtaGkQWokJKoglYoNAPkuPrK0V9Tq7e9vCU6hI1c7R+OT07x/wgnB5fMNXpD8SMZe0XV0bt/mY/t+A80q7Ft/y6UgePtMjxiuSGUJF6IJ7YBbOHQBz+ZYlvJK/rc+ntoys/d6vdhxKCXo510XDzflDtJGrnCztRSULf3pCUtupUnFCYduZqRuBZjRTYH5wM2SgXthkEjr2u3QMbllTVR4OTfOIqbn3VTuxCRokqTgm5aTtKB6uQkjrdGVgHDE51HI7CXrw9J5Hi7KH6iCgIehWhMpYubiEoHLaZkRkxD0WkWhvbA4T0W4XV4rcJe07dyYmUWpwgY941nOf15DtBrSXpvGZ9H0glLYhcLrp4io2pCn+TQJC56eSP1XU90uc5cFZbAacCuLIOy72HjBioU3jhL65YUKQzoF2alqQQ0eqKSjwz+4OsDh0BWcOSBaV7lUqsTVvyDiEXiMcAuaTboa1J7voHKUKgy1FhHMZH6SyX1vA Yo1kPcvU bCe9EDcH+1pBAy2tHKfgSSEvh9Lm1l0Eeb2vmC125E3K3v1NUCJ+LIDqX7D04SN7uPkM692WMpuScJcPfc0WbdsZLkE4keJVHiul8DOS9XmDiv31j5ZjL2+LFsGXVRS4fn0qudpogS8GpkoLBnrLalPllA6dNX8LfJ7n06zMLL8UxtHucOGf635nVwd8TgK3FTfDIlsMarMtr42ZCYj99RFAXgg== 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: 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 --- 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) From patchwork Mon Mar 25 15:04:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13602385 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 91E28C54E64 for ; Mon, 25 Mar 2024 15:05:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1C7CC6B009B; Mon, 25 Mar 2024 11:05:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 14D976B009C; Mon, 25 Mar 2024 11:05:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F09FD6B009E; Mon, 25 Mar 2024 11:05:25 -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 D73F16B009C for ; Mon, 25 Mar 2024 11:05:25 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 57A3B16082D for ; Mon, 25 Mar 2024 15:05:25 +0000 (UTC) X-FDA: 81935885010.08.5867D7F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf19.hostedemail.com (Postfix) with ESMTP id 4D18D1A0003 for ; Mon, 25 Mar 2024 15:05:23 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="XHMJ/MNS"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf19.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=1711379123; 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:in-reply-to:references:references:dkim-signature; bh=5tjcWip8Jh3x6TpRu3FCVwM3jxp/f+pF40FWxJhLLRM=; b=haC805c7UMtqk1vnPtnCyFhz2JBWveKVvAFGAdaeEnOGcxTvrQiWWTt2ffL4P/ic6qwWKP 9L9030oDD/vvLT2iJGz2C9x+JbXSNvTg6txpWi4cp/1vbd57+r15F03FQiObrxuQYPW03H FNxi2P2MRADS93Faalh09Hlf5KcdyH0= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="XHMJ/MNS"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf19.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=1711379123; a=rsa-sha256; cv=none; b=BJQ7//N54aCNoUEmL1rhZTd00IyjQd4ZfSmqZHUaga13w4Vi2ZgVqsADr2I5p/Y+zMtLoT BeexTGTVnchyTo9MVcnh+1LR9j6eD2/yKoww4st6cH4OcKMM+AtsyPHgzHjuY6IANC9Spn iaPLFwp5hzE4dL3ZFGb+bEF+5Kd5X/4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711379122; 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: in-reply-to:in-reply-to:references:references; bh=5tjcWip8Jh3x6TpRu3FCVwM3jxp/f+pF40FWxJhLLRM=; b=XHMJ/MNSllAM91QTWOeupOel662JOBBQuNtD2uOq9SAFgr7/bDshzNBTL2Fjh0VrnceloD M+sqfgKMT0SQpH660g6DcVDewGBbZ1uzaWWIZcHBpSO8chpyIKO8P4/yXZc0YHPGCvpiZc 5KO8YbdRVExDY46eQtwbSsmCKkaj/I4= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-362-WN62Vo3yNfmGnYcHNz1UDw-1; Mon, 25 Mar 2024 11:05:19 -0400 X-MC-Unique: WN62Vo3yNfmGnYcHNz1UDw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (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 A02C980026F; Mon, 25 Mar 2024 15:05:17 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (unknown [10.72.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 615D1C04120; Mon, 25 Mar 2024 15:05:15 +0000 (UTC) From: Baoquan He To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, rppt@kernel.org, mgorman@suse.de, Baoquan He Subject: [PATCH 3/7] mm/mm_init.c: remove meaningless calculation of zone->managed_pages in free_area_init_core() Date: Mon, 25 Mar 2024 23:04:55 +0800 Message-ID: <20240325150459.1045407-4-bhe@redhat.com> In-Reply-To: <20240325150459.1045407-1-bhe@redhat.com> References: <20240325150459.1045407-1-bhe@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-type: text/plain X-Rspamd-Queue-Id: 4D18D1A0003 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: ad4qzq1c3hke8b5tusi8rcrekoatb8w9 X-HE-Tag: 1711379123-721042 X-HE-Meta: U2FsdGVkX19TnTLk6VKDj1NyByXgeOTnO8ZAMTUj26nSCkRT9b7eKwvDKLOrxZtULLPALooTPatALjuDn5+kf7NHjFCPrnQKjQt+jv8IOafP6gBSkL8e7fehHeKopDPz7hJoUA4dEVnbrCmbXEfWoR5gw9I3DGuxHL95yr9NIIkPDFxYID0jzHCI7O0VmjsPbONMOs6tsSa0rU4ao1F55dE2uaPZPvaWCk5TLCs60bGg9r9O6Eu+9hDYd7ZpRQnArIMgx5c0GVIjJxOqDG93cnHAaYGbZlbmHE2t3Zdq5rrCWncVzZ0OANfGrIgGqffAON4uBtwJ2ai1O8lXxA5FOIxMRjyeTxxIdxojGV3yZ63ckGomC17K4XrZTItkRClxOkglUstNh2YUuqXDEWdrenThQD3X4t0DRQApFCyg8ZfE58aViXxUJCpv46yE2s5pGfTrUWHVD/YrGb8Sq1jS2XgzB381q8h5ixsqwFkY8DjDdqWwyXe4m1ocx5mh7JkNE/bE2ksmn3fKCYkoePDeDJUyB/scOXWw8SuTMvZnGZ5P1RJrbUjBWIGqUdutZ/3jcJ4LD7DuJ3fnzkdFJkOe4qet7++XoVWanQA3+cK0zVtMc9Q/8bn+sY+MmmOlJSojF1/m6R8ewd+1p6Sn2XwLxkAs0TMWUKBm/+l6zNOrY5yXn3jI1sBeej5RjXVu/dM5tK2lo3u/it767d4HSRUuG6xZ4M9rxhuqF8nOwv11e0uAA0lhkBj+Eo0hAKN7+kx9BDkqPbxymDnTvrDk7zUBNjtsxElhXcVkVjO8LdO5G+i9735to1GHbawArLFrl5o0j9lXg/eX4YCTpypbJ2+uJmbcjBFIfdfhCenuwoa2qFBUgp7eaHW6ghfpjbuvZ8J/UE4j7cLpiPK2sKGqSwp391btivsf3Ab4KxsreolAWR9tYhSsRUpcsEKGFfCvLrUP 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: 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 --- mm/mm_init.c | 46 +++++----------------------------------------- 1 file changed, 5 insertions(+), 41 deletions(-) diff --git a/mm/mm_init.c b/mm/mm_init.c index c57a7fc97a16..7f71e56e83f3 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -1565,15 +1565,6 @@ void __ref free_area_init_core_hotplug(struct pglist_data *pgdat) } #endif -/* - * Set up the zone data structures: - * - mark all pages reserved - * - mark all memory queues empty - * - clear the memory bitmaps - * - * NOTE: pgdat should get zeroed by caller. - * NOTE: this function is only called during early init. - */ static void __init free_area_init_core(struct pglist_data *pgdat) { enum zone_type j; @@ -1584,41 +1575,13 @@ static void __init free_area_init_core(struct pglist_data *pgdat) for (j = 0; j < MAX_NR_ZONES; j++) { struct zone *zone = pgdat->node_zones + j; - unsigned long size, freesize, memmap_pages; - - size = zone->spanned_pages; - freesize = zone->present_pages; - - /* - * Adjust freesize so that it accounts for how much memory - * is used by this zone for memmap. This affects the watermark - * and per-cpu initialisations - */ - memmap_pages = calc_memmap_size(size, freesize); - if (!is_highmem_idx(j)) { - if (freesize >= memmap_pages) { - freesize -= memmap_pages; - if (memmap_pages) - pr_debug(" %s zone: %lu pages used for memmap\n", - zone_names[j], memmap_pages); - } else - pr_warn(" %s zone: %lu memmap pages exceeds freesize %lu\n", - zone_names[j], memmap_pages, freesize); - } - - if (!is_highmem_idx(j)) - nr_kernel_pages += freesize; - /* Charge for highmem memmap if there are enough kernel pages */ - else if (nr_kernel_pages > memmap_pages * 2) - nr_kernel_pages -= memmap_pages; - nr_all_pages += freesize; + unsigned long size = zone->spanned_pages; /* - * Set an approximate value for lowmem here, it will be adjusted - * when the bootmem allocator frees pages into the buddy system. - * And all highmem pages will be managed by the buddy system. + * Initialize zone->managed_pages as 0 , it will be reset + * when memblock allocator frees pages into buddy system. */ - zone_init_internals(zone, j, nid, freesize); + zone_init_internals(zone, j, nid, 0); if (!size) continue; @@ -1915,6 +1878,7 @@ void __init free_area_init(unsigned long *max_zone_pfn) check_for_memory(pgdat); } + calc_nr_kernel_pages(); memmap_init(); /* disable hash distribution for systems with a single node */ From patchwork Mon Mar 25 15:04:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13602386 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 026DFC54E58 for ; Mon, 25 Mar 2024 15:05:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 45B346B009C; Mon, 25 Mar 2024 11:05:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2FB446B009F; Mon, 25 Mar 2024 11:05:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0B2126B009D; Mon, 25 Mar 2024 11:05:26 -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 D48D46B009B for ; Mon, 25 Mar 2024 11:05:25 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 5F2D7808CC for ; Mon, 25 Mar 2024 15:05:25 +0000 (UTC) X-FDA: 81935885010.01.D53C810 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf13.hostedemail.com (Postfix) with ESMTP id 6069D20029 for ; Mon, 25 Mar 2024 15:05:23 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=dhMA8tJX; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf13.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=1711379123; 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:in-reply-to:references:references:dkim-signature; bh=MVO6euUmFTCPCHk6L2/T00GcEz6lDO4YO+24ug8h660=; b=jMBqDAQe+Sgb1U7MC03nxG9XJNC+WV9lXYra835VY5bsvOMtQvtRSFeAPjI+SgSv7ZEufB ftI+QdyC8uVGVboqOqC3dHd2CLd6bsc/ZTeG/sAPNRDKKChAAYceYc4UH3QfCxQv/Pz9wA N9FOuk/YIU37GR9pU0745caYTLlwF+A= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=dhMA8tJX; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf13.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=1711379123; a=rsa-sha256; cv=none; b=rhGqVUCmJ8xOSJDcY7gLCTVckoav5rZTm09M1tGPqTZtOessrdg9SbzybxqsohO+bRLHGu zYzbU4ijtdzSB2Ezz7nRGFYRA9cqs241ZTJaumuTFgW7DWpA7RlSDRabCitMD8qBzA4rqj miwhQw5eXv3nrKNiLD0NO9KBB/F9IJE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711379122; 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: in-reply-to:in-reply-to:references:references; bh=MVO6euUmFTCPCHk6L2/T00GcEz6lDO4YO+24ug8h660=; b=dhMA8tJXW4hmpM/4jaVS1k3BJU8swEPGtU1/B/ZEA+d9ZTVfBVtlpU1hTKPPF9Wza0hliI nh1KxaFFn+u9/F+ATqwgtNiep92Uy8xAFMQ99M8tg2HEQP+TmZfJE2n/JMZQu4vtFyKz2A xN4XhmyZxZeMdxlDV7GLYugfPinGdDs= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-586-S5cVOsf1NnSk-zSGtEMnPw-1; Mon, 25 Mar 2024 11:05:20 -0400 X-MC-Unique: S5cVOsf1NnSk-zSGtEMnPw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (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 78CBE811E81; Mon, 25 Mar 2024 15:05:20 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (unknown [10.72.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 43CA5C04121; Mon, 25 Mar 2024 15:05:17 +0000 (UTC) From: Baoquan He To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, rppt@kernel.org, mgorman@suse.de, Baoquan He Subject: [PATCH 4/7] mm/mm_init.c: remove unneeded calc_memmap_size() Date: Mon, 25 Mar 2024 23:04:56 +0800 Message-ID: <20240325150459.1045407-5-bhe@redhat.com> In-Reply-To: <20240325150459.1045407-1-bhe@redhat.com> References: <20240325150459.1045407-1-bhe@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-type: text/plain X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 6069D20029 X-Stat-Signature: f7ocdwu35c58r6m3of1e6bkeaagzu4fp X-Rspam-User: X-HE-Tag: 1711379123-24610 X-HE-Meta: U2FsdGVkX19AGYyMq5b+cH3uhB+ImpvEMF6nfC5IDUOhbKIGn9Oe7L2wfcr5R74mTLZNCWLrrz5vq2tomG4r2svFvOkqcv31imX7YYK1BPV5wblLNMlaqOI6am8rGnTY4MSAwMtFgdrTK1WSeqPy8PhVRmMxmIXOOGMtSLJGl6vCCk+dMs+VEY76PBKqjqPnxnRJ1lfZDaHgL5AxVxviIsPrOrWnPWS4NdlYhKtvHvsPgtiZ2QYozyqgWre+2WB41NhCLurnjqjfm6vBcoHcD3XdeuFrpgaf8n7zGJ6WG8d3NAW2OCc3idkd8mwZ6C02SANuT9N4RuV7WGr0TDrA81SPoT5Ge5d4bkI6IE63spmDVLpf65BDtu9D6pBhX7VIKE5iiazcObvgq8HGRzpmdOy5GQqBhv9tnPj6n7NmCvjAc0y6fXoApxKG3GW3FBn9Uzu5dII380k/Jljt8v6lhydoBDtJNbYFp/if0egu1nId0IAdpIZmh7e+fjAcc26tRdg2Y6wovsCvsyt2NlvWrhaeZmWdsemyYyb76ArjiPvYN21qv/V84qCpQlKN2MfRGsdfyA6sN3E+S8VRB292t+3Ku7Pma2TaPz1sxTMS1Jp5SyfSfpop8gKJ1EfKKdcnnAaYUF/IEucJuc6/4dizv2MsM9++I8Na9n8w7ctb/OvYC0ub1Nf1Vt5W28nsahGf0CvM+s+Nvw/0+t5TPJslpE6WbNNr8H52/DMj4s34uOZH2ExyfaR/hUXFlbLK7IPv0Dj0iCsEC+8yf1Ge/ertDSl9eAMRCTo/a3XZxkK2Bhs37S6csEAvJRg1dajkPSPrCKKwbIqz2HaylM7n2fPFiZTvZxtZKcQriD+Az4fB7ShaxtiXwzyNZJh/BQldwOgwIHvkjLBcuJL9S30PTlBvQ1C58en0YKjGm6Xco+DXCEDi46QnEdeyuol1CRDvGKPeSzRswhOoezAP8+1mfHy 0nWuRAVa 7IYtXOsL7crrb61bwNY2B4q9syi7EnpFEVmCQMgEGU7mNbsTrItOoEsotCUUmDzf1Nf9rR+76lJjhDwGA20zTbwVuv9TYLePJHPEtHbuHxMlZOtkty20RQJ6DBVez2Gv4wl79vweO91l6Da6yIw8OAAhgLttlMDGRziprCQhPtCyugqNsqYBHGBwk0rFhGupaS/Pl0Q2+d5UCjDYfW+0QzfG1wQ== 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: Nobody calls calc_memmap_size() now. Signed-off-by: Baoquan He --- mm/mm_init.c | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/mm/mm_init.c b/mm/mm_init.c index 7f71e56e83f3..e269a724f70e 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -1331,26 +1331,6 @@ static void __init calculate_node_totalpages(struct pglist_data *pgdat, pr_debug("On node %d totalpages: %lu\n", pgdat->node_id, realtotalpages); } -static unsigned long __init calc_memmap_size(unsigned long spanned_pages, - unsigned long present_pages) -{ - unsigned long pages = spanned_pages; - - /* - * Provide a more accurate estimation if there are holes within - * the zone and SPARSEMEM is in use. If there are holes within the - * zone, each populated memory region may cost us one or two extra - * memmap pages due to alignment because memmap pages for each - * populated regions may not be naturally aligned on page boundary. - * So the (present_pages >> 4) heuristic is a tradeoff for that. - */ - if (spanned_pages > present_pages + (present_pages >> 4) && - IS_ENABLED(CONFIG_SPARSEMEM)) - pages = present_pages; - - return PAGE_ALIGN(pages * sizeof(struct page)) >> PAGE_SHIFT; -} - #ifdef CONFIG_TRANSPARENT_HUGEPAGE static void pgdat_init_split_queue(struct pglist_data *pgdat) { From patchwork Mon Mar 25 15:04:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13602387 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 B05B7C54E64 for ; Mon, 25 Mar 2024 15:05:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B3BC46B009E; Mon, 25 Mar 2024 11:05:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AC4136B009F; Mon, 25 Mar 2024 11:05:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8CB066B00A0; Mon, 25 Mar 2024 11:05:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 7693F6B009E for ; Mon, 25 Mar 2024 11:05:30 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 4A200120540 for ; Mon, 25 Mar 2024 15:05:30 +0000 (UTC) X-FDA: 81935885220.16.4D07A83 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf14.hostedemail.com (Postfix) with ESMTP id BCCE710001D for ; Mon, 25 Mar 2024 15:05:27 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JbbvHXSy; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf14.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=1711379127; 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:in-reply-to:references:references:dkim-signature; bh=5/dwNQotPOuDzP94j8tfuuqXGBTyVS8xmsMLBZwx3Fc=; b=qfDXWtoosRJHwJqJg6cSKBvPzLZgLsfsJiEevxGFv6I98RPwaJvRMZvT/TJIlQmgqsJY2L P9nP8gEnqfCPUXFDDkAuLeaoMTHAdNSfSOOKNJvUdpq3YzHRy6rCxNthyVXDIQCeBGrdYF DS9hmu5s/cRQSvBluF5IVvXjV70/lJk= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JbbvHXSy; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf14.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=1711379127; a=rsa-sha256; cv=none; b=z/oc9EkAn4Q+Mnyd8klWytg3d9RxZfe/YpzuRwatr0qOFl2lxBnzwSLqcAqFEImala1qUm TFzqUqA/9q3TPOgqrpB6M1HJppLRFXVXs6g1+V9G/4FPEpYiFMMt/QToXR+wf/A52OjH2H lbWf4f5HhnYXaVHtvcK7LnWj4qC51Po= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711379127; 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: in-reply-to:in-reply-to:references:references; bh=5/dwNQotPOuDzP94j8tfuuqXGBTyVS8xmsMLBZwx3Fc=; b=JbbvHXSyWl5KPYyoIatLAGoKMZce/2wGRd3srq3ve/pPzXj5o0wG27F1DeEwyP7ZYinETl xLjPMFs5k3NZbiy0yBoWQl09mgEO3DUv7UOiRF8Qk5WdffF+yiE2sy+wR6jAgO5+I04V+c S2FEuh0KHWqAQUsvgG2Gqxvbmg4uBXU= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-618-sFEyEP_lPgyKztPHpbRCbw-1; Mon, 25 Mar 2024 11:05:24 -0400 X-MC-Unique: sFEyEP_lPgyKztPHpbRCbw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (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 5A656101A58D; Mon, 25 Mar 2024 15:05:23 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (unknown [10.72.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2125FC04120; Mon, 25 Mar 2024 15:05:20 +0000 (UTC) From: Baoquan He To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, rppt@kernel.org, mgorman@suse.de, Baoquan He Subject: [PATCH 5/7] mm/mm_init.c: remove arch_reserved_kernel_pages() Date: Mon, 25 Mar 2024 23:04:57 +0800 Message-ID: <20240325150459.1045407-6-bhe@redhat.com> In-Reply-To: <20240325150459.1045407-1-bhe@redhat.com> References: <20240325150459.1045407-1-bhe@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-type: text/plain X-Rspamd-Queue-Id: BCCE710001D X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 5ydimnnbsw7cn9c9p6b7p3r8nogwts1x X-HE-Tag: 1711379127-884878 X-HE-Meta: U2FsdGVkX1+p2SX/JjyD6Ml4+B5aUiSJ79ZhzmURPEfPOIxXfAnnFtjdGjBbGGlyLdiOt8aF0gngtUBkId5IxRdTfmnG8LNzI6X+Y49mkRvPaAAW6nBZzqj270BnQ9av+MHXCDtCSPP/SgCVXD4FsGNAgXJFTxNZkQYebRUWRxWb45MpX0Gdjjd0TgBVX7+8yi0TbQuPGC0ihlW9nuIeRuoJEBW8kygSghBCev1BYOZxNHpJ/2fLX3m2mAj/LK4kJbBqzWkV0eQX9hsC2HP6wGMSDvpedkKjnvHaBWLnMDJXKV4pfnme6+Zbqp4p5aU2mhVCfyqH//fx4gQCDIw754ZcWteY6IG6xMeGukkcqkRH4YlRASLmG8CD3jLTQ168LCpJr1tJjwJFYubVxJ2BPgPxlryEa1uJACKQ6hJU7tZODCBl5l5a4Wi9mmMgI0GOmJdS0uQh4Bpk2wAnYdNQylMaHrCh/iBTnEurKu2pTiBhrAZZh+7C7Xs68f2jYJmiCQXMU5ImYEbucP4vbqqsHWpl5K7ZYcsLNdwMiVCiBk5pDwUqYo4U9ETToV4HIQtxLzeB/oyi6MrGZka0ApVhi3twmgLz1QciDmCaMZKPzx7iapmo4zginORy3xoQCYY1LVzI2R7tgNZamrvGP2waVRQIBqA0EIlZfrkEhZhHFVM8zW8JS0PDbKw3vv7/A9nwwfJnZ+fh3sgwlGBIg3pdju+9kwk7qhg7b4/ogm650KLJPTfXearcoxXm7gpi9E94Fl252z+9y/Mf/4+5beurSM9DfXzWyfc0Q0TDRjBqpM95K3VDfITjBgSlBi8yfiPtbIRjTsSJv81e2PsbyMxX61qoTlsMJ/cCci7yWwvIUw8NHd0OvMZTZ2vRentTunVQWHxyqGsOAp66Bfd3BvkOWcbkU6g2bt0iAKH3C6VBFOInx8yrLzGNKiFc6fXNBBZY/TjVkac9okwFp4onLnu lhDv1f6x 5ku3JLF4PyslJ5DJQBZmOibjVExYgp6LPP6ar7lX/b9slP7QK7RP9eG6xTC4UkHFEgB9ul+F10PPIhPmJ9MfrgM+71AisA2DNwUrAGtsFXp/2HTx+Yjwpz7sVcLt0MSB7gUVsG1qDekQQVrGRULBmcQ7FJobph23b4pMBkYKIWYOPnLmXwy2b2L0VdisulGYe6uS2l2VbylXSUWPfuqDvfuqjeA== 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: Since the current calculation of calc_nr_kernel_pages() has taken into consideration of kernel reserved memory, no need to have arch_reserved_kernel_pages() any more. Signed-off-by: Baoquan He --- arch/powerpc/include/asm/mmu.h | 4 ---- arch/powerpc/kernel/fadump.c | 5 ----- include/linux/mm.h | 3 --- mm/mm_init.c | 12 ------------ 4 files changed, 24 deletions(-) diff --git a/arch/powerpc/include/asm/mmu.h b/arch/powerpc/include/asm/mmu.h index 3b72c7ed24cf..aa5c0fd5edb1 100644 --- a/arch/powerpc/include/asm/mmu.h +++ b/arch/powerpc/include/asm/mmu.h @@ -406,9 +406,5 @@ extern void *abatron_pteptrs[2]; #include #endif -#if defined(CONFIG_FA_DUMP) || defined(CONFIG_PRESERVE_FA_DUMP) -#define __HAVE_ARCH_RESERVED_KERNEL_PAGES -#endif - #endif /* __KERNEL__ */ #endif /* _ASM_POWERPC_MMU_H_ */ diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c index d14eda1e8589..ae8c7619e597 100644 --- a/arch/powerpc/kernel/fadump.c +++ b/arch/powerpc/kernel/fadump.c @@ -1735,8 +1735,3 @@ static void __init fadump_reserve_crash_area(u64 base) memblock_reserve(mstart, msize); } } - -unsigned long __init arch_reserved_kernel_pages(void) -{ - return memblock_reserved_size() / PAGE_SIZE; -} diff --git a/include/linux/mm.h b/include/linux/mm.h index ad19350e1538..ab1ba0a31429 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -3221,9 +3221,6 @@ static inline void show_mem(void) extern long si_mem_available(void); extern void si_meminfo(struct sysinfo * val); extern void si_meminfo_node(struct sysinfo *val, int nid); -#ifdef __HAVE_ARCH_RESERVED_KERNEL_PAGES -extern unsigned long arch_reserved_kernel_pages(void); -#endif extern __printf(3, 4) void warn_alloc(gfp_t gfp_mask, nodemask_t *nodemask, const char *fmt, ...); diff --git a/mm/mm_init.c b/mm/mm_init.c index e269a724f70e..089dc60159e9 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -2373,17 +2373,6 @@ void __init page_alloc_init_late(void) page_alloc_sysctl_init(); } -#ifndef __HAVE_ARCH_RESERVED_KERNEL_PAGES -/* - * Returns the number of pages that arch has reserved but - * is not known to alloc_large_system_hash(). - */ -static unsigned long __init arch_reserved_kernel_pages(void) -{ - return 0; -} -#endif - /* * Adaptive scale is meant to reduce sizes of hash tables on large memory * machines. As memory size is increased the scale is also increased but at @@ -2426,7 +2415,6 @@ void *__init alloc_large_system_hash(const char *tablename, if (!numentries) { /* round applicable memory size up to nearest megabyte */ numentries = nr_kernel_pages; - numentries -= arch_reserved_kernel_pages(); /* It isn't necessary when PAGE_SIZE >= 1MB */ if (PAGE_SIZE < SZ_1M) From patchwork Mon Mar 25 15:04:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13602388 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 A2BB6C54E58 for ; Mon, 25 Mar 2024 15:05:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4FA366B00A0; Mon, 25 Mar 2024 11:05:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 483656B00A2; Mon, 25 Mar 2024 11:05:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2D4586B00A1; Mon, 25 Mar 2024 11:05:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 0F8B26B009F for ; Mon, 25 Mar 2024 11:05:33 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id CED5B1A05B3 for ; Mon, 25 Mar 2024 15:05:32 +0000 (UTC) X-FDA: 81935885304.07.AA72F44 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf19.hostedemail.com (Postfix) with ESMTP id D75961A001E for ; Mon, 25 Mar 2024 15:05:30 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IFsfE4LU; spf=pass (imf19.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1711379131; a=rsa-sha256; cv=none; b=4z38Lwv0OZ8vi7MQeomud1RfhBaGRr9ftx0crmcAxy14Eue0KiA2+vCQxhLVICGukD428T rBietT8Mh0g/WMx3kWwL1vUqMTI8ZOgHhQ19pzV/O/cS6JgJbyDsQu5QxCb+e/GO5F3h8o 4MnaM9NybVk8wLVAfrlUK/BabQqHugM= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=IFsfE4LU; spf=pass (imf19.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=1711379131; 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:in-reply-to:references:references:dkim-signature; bh=62MNx0xItSDlm7BWyxiaL7hkcreRJtBILyc9X1U9tZs=; b=CgUpTvQtL6z0EqxtQiyRZzoDvWHMUEfpM2MHk+mdJ0o0GvdCOrlrNIsGaD2R2zPm7+iW5l i6hubbs0FQIpVSqO2vx73p52YY+8nqF1IDCwXdsJG2W7MTeAOP/lur7ZmWIkAxf9nc97Iv uvt32szLJBmAVTNb7ykB8kc7VkmHeiA= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711379130; 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: in-reply-to:in-reply-to:references:references; bh=62MNx0xItSDlm7BWyxiaL7hkcreRJtBILyc9X1U9tZs=; b=IFsfE4LURKiIx/X1B0oyL6qQlBxs2GBqdffDGDfwxB9qSNEpGHdyvy31QhbflOcgS61pAy nfVZKuY5VEuudQgr7SJZbRjmb9MWE0D5gbeWWf0pf/ZhSotfbsAseuy1ldsb1/KIEG4ywh GqGEEIjBvosAn6Acut5xk8WAj5ellUw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-641-WhcoI3peNh6W4z2_OQeP7Q-1; Mon, 25 Mar 2024 11:05:28 -0400 X-MC-Unique: WhcoI3peNh6W4z2_OQeP7Q-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (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 3F0B7101A588; Mon, 25 Mar 2024 15:05:26 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (unknown [10.72.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 03E49C04121; Mon, 25 Mar 2024 15:05:23 +0000 (UTC) From: Baoquan He To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, rppt@kernel.org, mgorman@suse.de, Baoquan He Subject: [PATCH 6/7] mm: move array mem_section init code out of memory_present() Date: Mon, 25 Mar 2024 23:04:58 +0800 Message-ID: <20240325150459.1045407-7-bhe@redhat.com> In-Reply-To: <20240325150459.1045407-1-bhe@redhat.com> References: <20240325150459.1045407-1-bhe@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-type: text/plain X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: D75961A001E X-Stat-Signature: kc499stq7fsw3y8cutpzr9u9xs5jhzcf X-Rspam-User: X-HE-Tag: 1711379130-279157 X-HE-Meta: U2FsdGVkX19aWI+aXT6ssL6d71VRBvu/w3Dxwmx8wV+XLUeSK6pV7tzdeEDcJn4krjd5liqMDDo6n02C1gUAIumR/e5UVu4HkSbNUhVhfRr+9eWMiThLV3T0MjYSyO3lDKb9ziDnW0M1Rb8DjHXKqRR+iqjWgxpu7IXG/RiYOKp8/5v7DqFANvIbJANZRjdvZT5sz1UsiAOR8sQgizWabmnTwsdoSqGch7oliDeRns3RAJQPGUtVhShlHsKFvf9qYNLInQk1KoXzpvsVaO2z6/yk5PN52ko32AV9ET5BlayevAnyCdbu5O0XOX5EptdE5L13zat8n0nVS03/RlpP2CCB3HmDuocYIS4hEovcvPRQFc/KXSkuTyLIpxo97nNCFWKSvjpila0wvX2iQqNClZvcaj/LodtZDnMqAUJjyVUfYuwH0BLdoECCwYIfUdlrpi/D2FhDzVSKa/AmjZ+WORbIbd6xDfCw65Z9vsfJTwrDqTwGK4BEzw9INsCljpPMlyjGFwUj+v0uFU4VvHICFiBHIrM8wXO/OQqxGxYmRANAf6JC9ZW+2IAZCXCvtaqXfsoVxM3L7kn2PGfE7GpEsfuNLG9Prc4xI22XL+TIA6lz7jQSqaQadg83MKfAz3uEoKYDXOE+vwg2NwWgNwIe2L1bOKKZKv5UwP/SAVHEaoOcJ0CTQ+Ql5Xum19UUJoqpdg3ytMu/YTxaI5ALUWLvRFoTMOJ9IddOMdV25sDWpTiHs+AeLjeRdLjUOj/pOHqLfwBwtz6/LdNiqgLbWN6y427PwLGCE+IWkbv9dVihnczldWDl5ww+QjGoh+CnEJ05CoW/7Z6IuJZW+9lGw+e7A3OtsgF3gDBMsaIvUqJUGxgjMxt9tzN+SWRFZJ89vtf3I73mNPV7Ci/RKg7C6lajOD/FCRJRBEfRHTWE/M8j7zDIguFcFvk2D2HypRElNfyJNCxWN1TVW3c7vFjasUA 2ftzVAIG aWDoo5EPp/08kL2KAAcDOtxNKseAK9ms7oqiPnLS0DGgf1yGHC9iT5CusRCvI+Gpv3PyfBwZNInsY/Rfukn+/InnBIq2GXm/P2MrtxRd4vlk1QYkrNxyAGjQPf5TDilsrmm53LxIzuRzNSN6AIZeh/19q0W2rtPWX/WOX1LHCWC5Hr6+F7b1Jo/oF6P5DLCxrMQflHIHb4J16ehBF458BrXK0Og== 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: When CONFIG_SPARSEMEM_EXTREME is enabled, mem_section need be initialized to point at a two-dimensional array, and its 1st dimension of length NR_SECTION_ROOTS will be dynamically allocated. Once the allocation is done, it's available for all nodes. So take the 1st dimension of mem_section initialization out of memory_present()(), and put it into memblocks_present() which is a more appripriate place. Signed-off-by: Baoquan He --- mm/sparse.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/mm/sparse.c b/mm/sparse.c index aed0951b87fa..46e88549d1a6 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -226,19 +226,6 @@ static void __init memory_present(int nid, unsigned long start, unsigned long en { unsigned long pfn; -#ifdef CONFIG_SPARSEMEM_EXTREME - if (unlikely(!mem_section)) { - unsigned long size, align; - - size = sizeof(struct mem_section *) * NR_SECTION_ROOTS; - align = 1 << (INTERNODE_CACHE_SHIFT); - mem_section = memblock_alloc(size, align); - if (!mem_section) - panic("%s: Failed to allocate %lu bytes align=0x%lx\n", - __func__, size, align); - } -#endif - start &= PAGE_SECTION_MASK; mminit_validate_memmodel_limits(&start, &end); for (pfn = start; pfn < end; pfn += PAGES_PER_SECTION) { @@ -267,6 +254,19 @@ static void __init memblocks_present(void) unsigned long start, end; int i, nid; +#ifdef CONFIG_SPARSEMEM_EXTREME + if (unlikely(!mem_section)) { + unsigned long size, align; + + size = sizeof(struct mem_section *) * NR_SECTION_ROOTS; + align = 1 << (INTERNODE_CACHE_SHIFT); + mem_section = memblock_alloc(size, align); + if (!mem_section) + panic("%s: Failed to allocate %lu bytes align=0x%lx\n", + __func__, size, align); + } +#endif + for_each_mem_pfn_range(i, MAX_NUMNODES, &start, &end, &nid) memory_present(nid, start, end); } From patchwork Mon Mar 25 15:04:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13602389 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 7350FC54E64 for ; Mon, 25 Mar 2024 15:05:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 03E816B00A4; Mon, 25 Mar 2024 11:05:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EE28F6B00A6; Mon, 25 Mar 2024 11:05:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D82766B00A8; Mon, 25 Mar 2024 11:05:39 -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 C33786B00A4 for ; Mon, 25 Mar 2024 11:05:39 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id A4A8A160203 for ; Mon, 25 Mar 2024 15:05:39 +0000 (UTC) X-FDA: 81935885598.27.3F01DFD Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf01.hostedemail.com (Postfix) with ESMTP id 700864001A for ; Mon, 25 Mar 2024 15:05:36 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="bDtl/bfk"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf01.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=1711379137; a=rsa-sha256; cv=none; b=8LgyfFSKGR0TEcjniTKTamNiWKmB9rSe+kzHghZ2AV2qpHEyztlpAH3jH/JNzxQu7cEPxN yHF1Qdu/KTG2wt6U2oUwQml6v4Xnh3xJ7eRSItLrlZxc9MnmSN5VJJF6svRPV3kZHMild/ x8Zq4DdsxuuITByvlCNeqrDFcXz/XHM= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b="bDtl/bfk"; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf01.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=1711379137; 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:in-reply-to:references:references:dkim-signature; bh=wNbJUTamfWLGhNZqABfVMlJmVmVJ2sSKLjjKRbFhlPE=; b=qvedRKBdNPe329JGR4eKIyjoBf0iHKOi4XVoSJv8xLZIs/hDmKJZMv2KeMpDbVs9o0nxfN bn38ZsrOApkiEEoHK3vvbDJjAwf2UGh29PzO7EYRJWyCY6JWKn2bhPNy07aHz8q0M+MPdi 0epAXSvWhT11u2lrhLHMCFLfRGoPKrI= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711379136; 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: in-reply-to:in-reply-to:references:references; bh=wNbJUTamfWLGhNZqABfVMlJmVmVJ2sSKLjjKRbFhlPE=; b=bDtl/bfk91N+qd2fWmK6vokzO2lcI/87fk3pWiW44/oTfRCIGvTH1AhTAGfFzEpFKdDpqT NtY2TW9M4+YQfNIQ/BEUDafa677Nx1OXYJMJB0ratcoHnwuLlOKqXVMv07n4S1dP3hte1O 9ff0EQCAQ2TmYc11UXI2tZx8nyvy53s= 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-662-kO_TMJkuPg-FmYUEcG3pkQ-1; Mon, 25 Mar 2024 11:05:30 -0400 X-MC-Unique: kO_TMJkuPg-FmYUEcG3pkQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (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 5B57F28C97EB; Mon, 25 Mar 2024 15:05:30 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (unknown [10.72.116.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id E7F8DC04120; Mon, 25 Mar 2024 15:05:26 +0000 (UTC) From: Baoquan He To: linux-mm@kvack.org Cc: akpm@linux-foundation.org, rppt@kernel.org, mgorman@suse.de, Baoquan He Subject: [PATCH 7/7] mm/init: remove the unnecessary special treatment for memory-less node Date: Mon, 25 Mar 2024 23:04:59 +0800 Message-ID: <20240325150459.1045407-8-bhe@redhat.com> In-Reply-To: <20240325150459.1045407-1-bhe@redhat.com> References: <20240325150459.1045407-1-bhe@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-type: text/plain X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 700864001A X-Stat-Signature: 3taix1teftgx3nqgc5m9ujx4ot3gnqqo X-HE-Tag: 1711379136-608806 X-HE-Meta: U2FsdGVkX18X3D+t97ClFf5sLsVzDRcuWkxTLiBbeGjFoBng2bqtUIlioBMvxrWKBvi1QA8Qwo2Xf4wmCFqgl86avdsk/T/G06zJJOUntaHCZaIjFQ/yEvvuAeAMHWK5Xm0ig8q8uuEfyppx1qetTy4fszhUKz0duB5V8RpVkhCt8CxEjTgGlEkJMRDX9aE6MZjPSqbXtKo12CAcTBJXId9tA9QgFO+ndADKPk6oxKgtzzHlUOevLAFdHAZpGd4Ov8wvOmM3DAuE5O9mk9NricwSslywJVtnOPJkG7sCli8ntyUzRv4J3c7/qPzOXwF1kSrSqmQfLvegCWqsdTSu8UZaxx3zEmFWYZq3iG8OTbbFPfaBXgNlYRZqq3HdS1q9+bQ7LStSTw/8Ep7Bg3aUKRj0Kgo2vnG3lEj4IwHDh5LPwRaF/7aSj5nUwZiCoUzmayOeNV5mlmeRUYa//Uo4/Io+v/DLiDkfTFvrmIU15mRILUsv1KgKUggQMDPxmwHsSFFS0ry9MCWot2n+a0OlloKkaEyh6832ILA4OAYydHt3WQd+7ejvxQ2RF24G3Qet2AGR/6g1mRuE4dvOt5ptiqUOumx7Rmat1MOeKW1GkfZj9ys8EnIwtPdNAiXyTjr46piKeby8Onw/GL+1VIaAbc8gPM3LO7fdYhWmO5lGoi/2xJK3BCMxyqMdc1nB7uPF9lGXSJzZXm8CGPbKeQtHXimgxXNf3Hb1WUd26NVsIXc6ipakJ1cpvIY2LKjyBMF9KK65YInH9/4N4UJuzSNmjRKl93aQv2TdRm21YZoXsvMyAcTNeq1Srvi+zuQalkYQ2e8a+6qmgtYiLbhJoDiV+eRwnP48sGJF+aUzW+8jf2AlOK4+TOxhNKZttMtBURIvds4BjLu/EmaK9Cb+m6pCOfgwkzP9skD448bLdNO198O2Ws1YrtlYwKhz1ADzLQK5jim/SBsOXhMhKZY/OTr YbItjp3c luSiQNhxV+3nAjIUhCFtOklaARBz4tA/WlMVsZhwxBZJPECS/Ns8nVszMyubOIV4tOw5KW1I0xbgoEEYAJ99Kok+PvaLN+j7erc+LT+LSLDLiXAbnG3ca3Idrjzen2SjlzRlFG0uScoVAX+BzD3PK87U4jlrNn/gKgdJiF+haAr3S/tY= 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: Because memory-less node's ->node_present_pages and its zone's ->present_pages are all 0, the judgement before calling node_set_state() to set N_MEMORY, N_HIGH_MEMORY, N_NORMAL_MEMORY for node is enough to skip memory-less node. The 'continue;' statement inside for_each_node() loop of free_area_init() is gilding the lily. Here, remove the special handling to make memory-less node share the same code flow as normal node. And the code comment above the 'continue' statement is not needed either. Signed-off-by: Baoquan He --- mm/mm_init.c | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/mm/mm_init.c b/mm/mm_init.c index 089dc60159e9..99681ffb9091 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -1834,28 +1834,16 @@ void __init free_area_init(unsigned long *max_zone_pfn) panic("Cannot allocate %zuB for node %d.\n", sizeof(*pgdat), nid); arch_refresh_nodedata(nid, pgdat); - free_area_init_node(nid); - - /* - * We do not want to confuse userspace by sysfs - * files/directories for node without any memory - * attached to it, so this node is not marked as - * N_MEMORY and not marked online so that no sysfs - * hierarchy will be created via register_one_node for - * it. The pgdat will get fully initialized by - * hotadd_init_pgdat() when memory is hotplugged into - * this node. - */ - continue; } pgdat = NODE_DATA(nid); free_area_init_node(nid); /* Any memory on that node */ - if (pgdat->node_present_pages) + if (pgdat->node_present_pages) { node_set_state(nid, N_MEMORY); - check_for_memory(pgdat); + check_for_memory(pgdat); + } } calc_nr_kernel_pages();