linux kernel优化

使用如下patch,关闭串口打印,可以至少节省几百ms的时间。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
diff --git a/arch/arm64/configs/xxx_defconfig b/arch/arm64/configs/xxx_defconfig
index c8036df..81275fa 100755

+++ b/arch/arm64/configs/xxx_defconfig
@@ -2985,6 +2985,7 @@ CONFIG_PRINTK_TIME=y
CONFIG_MESSAGE_LOGLEVEL_DEFAULT=4
# CONFIG_BOOT_PRINTK_DELAY is not set
# CONFIG_DYNAMIC_DEBUG is not set
+CONFIG_PRINTK_NOT_OUTPUT=y

#
# Compile-time checks and compiler options
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 98ee2a3..e997ad7 100755
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -1568,7 +1568,7 @@ static void call_console_drivers(int level,

if (!console_drivers)
return;
-
+#ifdef CONFIG_PRINTK_NOT_OUTPUT
for_each_console(con) {
if (exclusive_console && con != exclusive_console)
continue;
@@ -1584,6 +1584,7 @@ static void call_console_drivers(int level,
else
con->write(con, text, len);
}
+#endif
}