From patchwork Wed Nov 22 04:35:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Baoquan He X-Patchwork-Id: 13463969 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 6BCA1C61D92 for ; Wed, 22 Nov 2023 04:36:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AD5FD6B0550; Tue, 21 Nov 2023 23:36:02 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A5F326B0551; Tue, 21 Nov 2023 23:36:02 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8FF6F6B0552; Tue, 21 Nov 2023 23:36:02 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 7D45C6B0550 for ; Tue, 21 Nov 2023 23:36:02 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 4C713B528D for ; Wed, 22 Nov 2023 04:36:02 +0000 (UTC) X-FDA: 81484327764.10.74465D3 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf17.hostedemail.com (Postfix) with ESMTP id 889174000C for ; Wed, 22 Nov 2023 04:35:59 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=M+veOpEc; spf=pass (imf17.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.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=1700627759; a=rsa-sha256; cv=none; b=LIMd9FjoDO0YuOWUeQWFHwMh4aO5ogr9l2HeJ8INMSUfDI72ElFO4jP+URChU2ZKB+JihJ sQkOhuiqSr1RpdHDbqk/7UTbgDNY+PybQ7MJxhpzuoPjQrFipS3wxAVYgpS8PHoooaO6xY oIcgm9p77mz/sW+2QRcchAf1wrRDTeo= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=M+veOpEc; spf=pass (imf17.hostedemail.com: domain of bhe@redhat.com designates 170.10.133.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=1700627759; 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=z5Llx2phfB7hptylQeopcoFDKXqvVDVH9ZvTWbzDxa0=; b=BTTz7WJCw8JbY2FGP2k/aG7QIFh/6qUmOhhJ+8w/M4fmjIvf2X4S3rrZrIupj65u38OQo4 ZWZvENl+gy7dafLuOe+6EAbJe2eiKn5i9jr1W54WPZKvaHZd+HwUiOg0vE45i4ZNBT+iaS we1iEWHEFLsxX+8DLUWjm5TteLnrzvo= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700627758; 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=z5Llx2phfB7hptylQeopcoFDKXqvVDVH9ZvTWbzDxa0=; b=M+veOpEcPoqD5+97zg8FBHiD0ZJVfijxWY+Pqq91C4S6cCO8sRzMeRzcuyozCtO8G9NwZa qTq3QdjUAQirLpJKKDICFOK5wd4mvPQcB9MGTnTAcWRNowKGrVfdXz8YBLI2TMrnTBSiSL d+BEst83WGnwEcC8IznVVatahwuO+pM= 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-292-Rlt5mkkbPW6BumRYVMuWjA-1; Tue, 21 Nov 2023 23:35:57 -0500 X-MC-Unique: Rlt5mkkbPW6BumRYVMuWjA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (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 C3C38280640E; Wed, 22 Nov 2023 04:35:56 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (unknown [10.72.112.97]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7D3871C060AE; Wed, 22 Nov 2023 04:35:54 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, rppt@kernel.org, Baoquan He Subject: [PATCH] mm/page.c: move mem_init_print_info() to later place Date: Wed, 22 Nov 2023 12:35:50 +0800 Message-ID: <20231122043550.489889-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 889174000C X-Stat-Signature: 8knh3fhgh89xg7br6qe6qnoiq1yor6u7 X-Rspam-User: X-HE-Tag: 1700627759-844988 X-HE-Meta: U2FsdGVkX1+lUKLWdmD8tzuWb78//c/Hl19nG9TKERou339cIiGGRo3DcbYa5wEF9I7wTuggR236wrJi8uHWZHqAUO4FMjOKnAdhM/AH4hzPzKWclVD6UrEeHz3oLlnIuUznzmkRHVGvWdqIQfD4gm2T6WCJSl7Qt0Zo/yDUlV2buna627wRV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ender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Currently if CONFIG_DEFERRED_STRUCT_PAGE_INIT is enabled, only part of pages are initialized and added into buddy allocator at early stage. Then the system memory information printed by mem_init_print_info() is incorrect. The snippets of boot log are pasted here: ----------------------------------------------------------------------- [ 0.059606] mem auto-init: stack:all(zero), heap alloc:off, heap free:off [ 0.059622] software IO TLB: area num 64. [ 0.143887] Memory: 1767888K/133954872K available (20480K kernel code, 3284K rwdata, 8972K rodata, 4572K init, 4916K bss, 2529756K reserved, 0K cma-reserved) [ 0.145111] SLUB: HWalign=64, Order=0-3, MinObjects=0, CPUs=64, Nodes=2 --------------------------------------------------------------------------- Here, move mem_init_print_info() to later place until page init is finished. After the fix, the printed memory information is like this: ------------------------------------------------------------------------- [ +0.001002] smpboot: Total of 64 processors activated (293724.92 BogoMIPS) [ +0.050086] node 0 deferred pages initialised in 45ms [ +0.007309] node 1 deferred pages initialised in 53ms [ 4.035449] Memory: 131272772K/133954872K available (20480K kernel code, 3284K rwdata, 8972K rodata, 4572K init, 4916K bss, 2529700K reserved, 0K cma-reserved) [ +0.015995] devtmpfs: initialized [ +0.003943] x86/mm: Memory block size: 2048MB ------------------------------------------------------------------------- Signed-off-by: Baoquan He --- include/linux/gfp.h | 1 + init/main.c | 1 + mm/mm_init.c | 3 +-- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/include/linux/gfp.h b/include/linux/gfp.h index de292a007138..2d69fa59b489 100644 --- a/include/linux/gfp.h +++ b/include/linux/gfp.h @@ -335,6 +335,7 @@ void drain_local_pages(struct zone *zone); void page_alloc_init_late(void); void setup_pcp_cacheinfo(void); +void mem_init_print_info(void); /* * gfp_allowed_mask is set to GFP_BOOT_MASK during early boot to restrict what diff --git a/init/main.c b/init/main.c index e24b0780fdff..88f238a478a1 100644 --- a/init/main.c +++ b/init/main.c @@ -1547,6 +1547,7 @@ static noinline void __init kernel_init_freeable(void) workqueue_init_topology(); padata_init(); page_alloc_init_late(); + mem_init_print_info(); do_basic_setup(); diff --git a/mm/mm_init.c b/mm/mm_init.c index 077bfe393b5e..d08f7c7f75f1 100644 --- a/mm/mm_init.c +++ b/mm/mm_init.c @@ -2703,7 +2703,7 @@ static void __init report_meminit(void) pr_info("mem auto-init: clearing system memory may take some time...\n"); } -static void __init mem_init_print_info(void) +void __init mem_init_print_info(void) { unsigned long physpages, codesize, datasize, rosize, bss_size; unsigned long init_code_size, init_data_size; @@ -2774,7 +2774,6 @@ void __init mm_core_init(void) kmsan_init_shadow(); stack_depot_early_init(); mem_init(); - mem_init_print_info(); kmem_cache_init(); /* * page_owner must be initialized after buddy is ready, and also after