[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20260122073446.45628-3-yang.yicong@picoheart.com>
Date: Thu, 22 Jan 2026 15:34:46 +0800
From: "Yicong Yang" <yang.yicong@...oheart.com>
To: <rafael@...nel.org>, <lenb@...nel.org>, <tglx@...nel.org>,
<gregkh@...uxfoundation.org>, <dakr@...nel.org>
Cc: <akpm@...ux-foundation.org>, <apatel@...tanamicro.com>, <pjw@...nel.org>,
<palmer@...belt.com>, <aou@...s.berkeley.edu>, <alex@...ti.fr>,
<geshijian@...oheart.com>, <weidong.wd@...oheart.com>,
<yang.yicong@...oheart.com>, <linux-acpi@...r.kernel.org>,
<linux-kernel@...r.kernel.org>, <linux-riscv@...ts.infradead.org>
Subject: [PATCH 2/2] init: Move console_on_rootfs after async_synchronize_full
Currently the console_on_rootfs() is called before
async_synchronize_full(), the console initialization
could be still in process in theory due to async
probe, etc. Make it after the async_synchronize_full()
to make sure the initialization work is done.
Log the error code as well if we failed to open the console.
Signed-off-by: Yicong Yang <yang.yicong@...oheart.com>
---
init/main.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/init/main.c b/init/main.c
index b84818ad9685..c37ba5f89b96 100644
--- a/init/main.c
+++ b/init/main.c
@@ -1578,6 +1578,7 @@ static int __ref kernel_init(void *unused)
kernel_init_freeable();
/* need to finish all async __init code before freeing the memory */
async_synchronize_full();
+ console_on_rootfs();
system_state = SYSTEM_FREEING_INITMEM;
kprobe_free_init_mem();
@@ -1647,7 +1648,7 @@ void __init console_on_rootfs(void)
struct file *file = filp_open("/dev/console", O_RDWR, 0);
if (IS_ERR(file)) {
- pr_err("Warning: unable to open an initial console.\n");
+ pr_err("Warning: unable to open an initial console, err = %ld\n", PTR_ERR(file));
return;
}
init_dup(file);
@@ -1690,7 +1691,6 @@ static noinline void __init kernel_init_freeable(void)
kunit_run_all_tests();
wait_for_initramfs();
- console_on_rootfs();
/*
* check if there is an early userspace init. If yes, let it do all
--
2.34.1
Powered by blists - more mailing lists