Message ID | 20231122043550.489889-1-bhe@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:2b07:b0:403:3b70:6f57 with SMTP id io7csp1093623vqb; Tue, 21 Nov 2023 20:36:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IGpiAUOdQVag2s0KKi6prAOw4osAHoL/7FvQSpU65/bTisAuYFwyTGuBmUjiNsuCZ7/z07e X-Received: by 2002:a05:6808:1d1:b0:3b5:6549:ea49 with SMTP id x17-20020a05680801d100b003b56549ea49mr1532881oic.31.1700627795347; Tue, 21 Nov 2023 20:36:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700627795; cv=none; d=google.com; s=arc-20160816; b=NaO//lk1CMNuEmvG5MkNYPlo5VediPaqcqtGiVgjkagSg7nVvQQxkbQvMVurJLUehI /rkYiFg1gf6Mwr7Sgzoyiho/NeAdSj7Jj12I0Vr3MBOmDGg6cn9z8a417tzyAXZnnM+G XVJDRSauxYukfglS6+waW/LyXiD6SG76vMxa1UWeP/39BXMqRdkHmjiZyBcMX+6miHiI swLRxFCMnoJwWv4Zxk3DXWabeCf7JUtfx9WI5e2c3YPmzUha3YtqYFZdT+wpcPrKL+3L rl0Emqk4VW8kd7QlYS96gDeLrQtjG1OyvCKA2wMO5Zxc9dXupXMckmn/5hDferiXAmJA wgWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=z5Llx2phfB7hptylQeopcoFDKXqvVDVH9ZvTWbzDxa0=; fh=lV1FR6SWM+x4aQLe/yF1DoifltxDcgCu75+xmy78kEw=; b=vHcqDyCxluUdeWh4DMp3cO8LLoXSmx6vKEEUHqIfymmFci13QJWFm86laAFvgunQPj 6//L4ue1evpQh3K1XeUW4OUHCIyAEnFoujo5DOig8fpoCuauy4W60t60ysoxOhRgO3tV iyrc7bTOIJxCZxlqhCUbxxe9LmsUKZG/hGJ5HJuYoOfSEBdCu0X83Hxe52Q2YJjZRm3C QCfHt9cphMalotbFb27PZRaNMOXVE56ogzubwG9vdZ1OyEhxw8KHl7p2bPdQlfWDIsGb yEFVF//nPsulMv7d+KTlZxcyPoPv9V5xir6nhyCm9yG+m0GSRfvGsZrPdWdpPjPD36Zu KoDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bLpe7G9F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id b12-20020a056a00114c00b006c386ea46dbsi11772153pfm.35.2023.11.21.20.36.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 20:36:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=bLpe7G9F; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 6661D8026638; Tue, 21 Nov 2023 20:36:32 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229813AbjKVEgH (ORCPT <rfc822;ouuuleilei@gmail.com> + 99 others); Tue, 21 Nov 2023 23:36:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229498AbjKVEgF (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 21 Nov 2023 23:36:05 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 61958199 for <linux-kernel@vger.kernel.org>; Tue, 21 Nov 2023 20:36:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1700627760; 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=bLpe7G9Fgn/CSFtnhRwyIYzPrRtI7Lmfg90HQY7OOBeaV8SLYDyU5P18tlUGmvhgVjMEC3 CibNB8/qtEaZK5raFoFKm5sNr7OjZrvx3SKpF+1eiE8P3lKZBCigE1DhEpl0U51VlQgfuU 1bpMGvTUUvSwbUp11ZueLwTLkF5+zHs= 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 <bhe@redhat.com> To: linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, akpm@linux-foundation.org, rppt@kernel.org, Baoquan He <bhe@redhat.com> 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 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 21 Nov 2023 20:36:32 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783237490785203263 X-GMAIL-MSGID: 1783237490785203263 |
Series |
mm/page.c: move mem_init_print_info() to later place
|
|
Commit Message
Baoquan He
Nov. 22, 2023, 4:35 a.m. UTC
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 <bhe@redhat.com>
---
include/linux/gfp.h | 1 +
init/main.c | 1 +
mm/mm_init.c | 3 +--
3 files changed, 3 insertions(+), 2 deletions(-)
Comments
Hi Baoquan, On Wed, Nov 22, 2023 at 12:35:50PM +0800, Baoquan He wrote: > Subject: [PATCH] mm/page.c: move mem_init_print_info() to later place We don't have mm/page.c, > 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 > --------------------------------------------------------------------------- At this point only the pages that were initialized and free are available. The message does not reflect that large part of memory is still not initialized, but it's not wrong. > 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 > ------------------------------------------------------------------------- If we print this message that late, some of the memory will be allocated from buddy and it maybe confusing. I suggest to print how much memory is not yet initialized and leave mem_init_print_info() where it is now. > Signed-off-by: Baoquan He <bhe@redhat.com> > --- > 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(); No need to make mem_init_print_info() global and call it from main.c, you can call it from page_alloc_init_late(). > 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 > -- > 2.41.0 >
On 11/22/23 at 05:08pm, Mike Rapoport wrote: > Hi Baoquan, > > > On Wed, Nov 22, 2023 at 12:35:50PM +0800, Baoquan He wrote: > > > Subject: [PATCH] mm/page.c: move mem_init_print_info() to later place > > We don't have mm/page.c, Thanks for reviewing. Yes, this was queued in my local branch long time ago, I forgot to update the file name. > > > 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 > > --------------------------------------------------------------------------- > > At this point only the pages that were initialized and free are available. > The message does not reflect that large part of memory is still not initialized, > but it's not wrong. Agree. I noticed this because I often need check the memory init and memory size during kernel bootup. The current message gives people a shock at first glance because it looks like a huge reserved memory existing in system. > > > 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 > > ------------------------------------------------------------------------- > > If we print this message that late, some of the memory will be allocated > from buddy and it maybe confusing. that's true. > > I suggest to print how much memory is not yet initialized and leave > mem_init_print_info() where it is now. Sounds great to me, will work out a new version as suggested. > > > Signed-off-by: Baoquan He <bhe@redhat.com> > > --- > > 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(); > > No need to make mem_init_print_info() global and call it from main.c, you > can call it from page_alloc_init_late(). Agree, that's much better if we take that way. > > > 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 > > -- > > 2.41.0 > > > > -- > Sincerely yours, > Mike. >
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