[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CABKxMyM89vRT3wbKSPcoH+zZ7Lx+rpTaxfTi98xakGRhsYBv0g@mail.gmail.com>
Date: Mon, 25 Jul 2022 20:55:18 +0800
From: 黄杰 <huangjie.albert@...edance.com>
To: linux-kernel <linux-kernel@...r.kernel.org>
Subject: Fwd: [PATCH 3/4] x86: Support the uncompressed kernel to speed up booting
---------- Forwarded message ---------
发件人: Albert Huang <huangjie.albert@...edance.com>
Date: 2022年7月25日周一 16:40
Subject: [PATCH 3/4] x86: Support the uncompressed kernel to speed up booting
To:
Cc: huangjie.albert <huangjie.albert@...edance.com>, Thomas Gleixner
<tglx@...utronix.de>, Ingo Molnar <mingo@...hat.com>, Borislav Petkov
<bp@...en8.de>, Dave Hansen <dave.hansen@...ux.intel.com>,
<x86@...nel.org>, H. Peter Anvin <hpa@...or.com>, Eric Biederman
<ebiederm@...ssion.com>, Masahiro Yamada <masahiroy@...nel.org>,
Michal Marek <michal.lkml@...kovi.net>, Nick Desaulniers
<ndesaulniers@...gle.com>, Kirill A. Shutemov
<kirill.shutemov@...ux.intel.com>, Kuppuswamy Sathyanarayanan
<sathyanarayanan.kuppuswamy@...ux.intel.com>, Tony Luck
<tony.luck@...el.com>, Michael Roth <michael.roth@....com>, Nathan
Chancellor <nathan@...nel.org>, Ard Biesheuvel <ardb@...nel.org>, Mark
Rutland <mark.rutland@....com>, Joerg Roedel <jroedel@...e.de>, Sean
Christopherson <seanjc@...gle.com>, Peter Zijlstra
<peterz@...radead.org>, Kees Cook <keescook@...omium.org>,
<linux-kernel@...r.kernel.org>, <kexec@...ts.infradead.org>,
<linux-kbuild@...r.kernel.org>
From: "huangjie.albert" <huangjie.albert@...edance.com>
Although the compressed kernel can save the time of loading the
kernel into the memory and save the disk space for storing the kernel,
but in some time-sensitive scenarios, the time for decompressing the
kernel is intolerable. Therefore, it is necessary to support uncompressed
kernel images, so that the time of kernel decompression can be saved when
the kernel is started.
This part of the time on my machine is approximately:
image type image size times
compressed(gzip) 8.5M 159ms
uncompressed 53M 8.5ms
Signed-off-by: huangjie.albert <huangjie.albert@...edance.com>
---
arch/x86/Kconfig | 1 +
arch/x86/boot/compressed/Makefile | 5 ++++-
arch/x86/boot/compressed/misc.c | 13 +++++++++++++
scripts/Makefile.lib | 5 +++++
4 files changed, 23 insertions(+), 1 deletion(-)
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index adbd3a2bd60f..231187624c68 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -221,6 +221,7 @@ config X86
select HAVE_KERNEL_LZO
select HAVE_KERNEL_XZ
select HAVE_KERNEL_ZSTD
+ select HAVE_KERNEL_UNCOMPRESSED
select HAVE_KPROBES
select HAVE_KPROBES_ON_FTRACE
select HAVE_FUNCTION_ERROR_INJECTION
diff --git a/arch/x86/boot/compressed/Makefile
b/arch/x86/boot/compressed/Makefile
index 19e1905dcbf6..0c8417a2f792 100644
--- a/arch/x86/boot/compressed/Makefile
+++ b/arch/x86/boot/compressed/Makefile
@@ -26,7 +26,7 @@ OBJECT_FILES_NON_STANDARD := y
KCOV_INSTRUMENT := n
targets := vmlinux vmlinux.bin vmlinux.bin.gz vmlinux.bin.bz2
vmlinux.bin.lzma \
- vmlinux.bin.xz vmlinux.bin.lzo vmlinux.bin.lz4 vmlinux.bin.zst
+ vmlinux.bin.xz vmlinux.bin.lzo vmlinux.bin.lz4 vmlinux.bin.zst
vmlinux.bin.none
# CLANG_FLAGS must come before any cc-disable-warning or cc-option calls in
# case of cross compiling, as it has the '--target=' flag, which is needed to
@@ -139,6 +139,8 @@ $(obj)/vmlinux.bin.lz4: $(vmlinux.bin.all-y) FORCE
$(call if_changed,lz4_with_size)
$(obj)/vmlinux.bin.zst: $(vmlinux.bin.all-y) FORCE
$(call if_changed,zstd22_with_size)
+$(obj)/vmlinux.bin.none: $(vmlinux.bin.all-y) FORCE
+ $(call if_changed,none)
suffix-$(CONFIG_KERNEL_GZIP) := gz
suffix-$(CONFIG_KERNEL_BZIP2) := bz2
@@ -147,6 +149,7 @@ suffix-$(CONFIG_KERNEL_XZ) := xz
suffix-$(CONFIG_KERNEL_LZO) := lzo
suffix-$(CONFIG_KERNEL_LZ4) := lz4
suffix-$(CONFIG_KERNEL_ZSTD) := zst
+suffix-$(CONFIG_KERNEL_UNCOMPRESSED) := none
quiet_cmd_mkpiggy = MKPIGGY $@
cmd_mkpiggy = $(obj)/mkpiggy $< > $@
diff --git a/arch/x86/boot/compressed/misc.c b/arch/x86/boot/compressed/misc.c
index cf690d8712f4..c23c0f525d93 100644
--- a/arch/x86/boot/compressed/misc.c
+++ b/arch/x86/boot/compressed/misc.c
@@ -181,6 +181,19 @@ void __puthex(unsigned long value)
}
}
+#ifdef CONFIG_KERNEL_UNCOMPRESSED
+#include <linux/decompress/mm.h>
+static int __decompress(unsigned char *buf, long len,
+ long (*fill)(void*, unsigned long),
+ long (*flush)(void*, unsigned long),
+ unsigned char *outbuf, long olen,
+ long *pos, void (*error)(char *x))
+{
+ memcpy(outbuf, buf, olen);
+ return 0;
+}
+#endif
+
#ifdef CONFIG_X86_NEED_RELOCS
static void handle_relocations(void *output, unsigned long output_len,
unsigned long virt_addr)
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 3fb6a99e78c4..c89d5466c617 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -438,6 +438,11 @@ quiet_cmd_lz4 = LZ4 $@
quiet_cmd_lz4_with_size = LZ4 $@
cmd_lz4_with_size = { cat $(real-prereqs) | $(LZ4) -l -c1 stdin stdout; \
$(size_append); } > $@
+# none
+quiet_cmd_none = NONE $@
+ cmd_none = (cat $(filter-out FORCE,$^) && \
+ $(call size_append, $(filter-out FORCE,$^))) > $@ || \
+ (rm -f $@ ; false)
# U-Boot mkimage
# ---------------------------------------------------------------------------
--
2.31.1
Powered by blists - more mailing lists