From: "Eric W. Biederman" <ebiederm@xmission.com>
To: Albert Huang <huangjie.albert@bytedance.com>
Cc: Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
Masahiro Yamada <masahiroy@kernel.org>,
Michal Marek <michal.lkml@markovi.net>,
Nick Desaulniers <ndesaulniers@google.com>,
"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
Kuppuswamy Sathyanarayanan
<sathyanarayanan.kuppuswamy@linux.intel.com>,
Tony Luck <tony.luck@intel.com>,
Michael Roth <michael.roth@amd.com>,
Nathan Chancellor <nathan@kernel.org>,
Ard Biesheuvel <ardb@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
Joerg Roedel <jroedel@suse.de>,
Sean Christopherson <seanjc@google.com>,
Peter Zijlstra <peterz@infradead.org>,
Kees Cook <keescook@chromium.org>,
linux-kernel@vger.kernel.org, kexec@lists.infradead.org,
linux-kbuild@vger.kernel.org
Subject: Re: [PATCH 3/4] x86: Support the uncompressed kernel to speed up booting
Date: Mon, 25 Jul 2022 11:57:36 -0500 [thread overview]
Message-ID: <87fsipf7un.fsf@email.froward.int.ebiederm.org> (raw)
In-Reply-To: <20220725083904.56552-4-huangjie.albert@bytedance.com> (Albert Huang's message of "Mon, 25 Jul 2022 16:38:55 +0800")
Albert Huang <huangjie.albert@bytedance.com> writes:
> From: "huangjie.albert" <huangjie.albert@bytedance.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
Why in the world are you using arch/x86/boot/compressed/... for an
uncompressed kernel. Especially if you don't plan to process
relocations.
Even if it somehow makes sense why have you not followed the pattern
used by the rest of the code and implemented a file that implements
a no-op __decompress routine?
Eric
> Signed-off-by: huangjie.albert <huangjie.albert@bytedance.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
> # ---------------------------------------------------------------------------
next prev parent reply other threads:[~2022-07-25 16:58 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-25 8:38 [PATCH 0/4] faster kexec reboot Albert Huang
2022-07-25 8:38 ` [PATCH 1/4] kexec: reuse crash kernel reserved memory for normal kexec Albert Huang
2022-07-25 12:02 ` Jason A. Donenfeld
2022-07-25 12:56 ` Fwd: [External] " 黄杰
2022-07-25 13:30 ` 黄杰
2022-07-25 8:38 ` [PATCH 2/4] kexec: add CONFING_KEXEC_PURGATORY_SKIP_SIG Albert Huang
2022-07-25 12:15 ` Jason A. Donenfeld
2022-07-25 13:32 ` [External] " 黄杰
2022-07-28 1:57 ` 黄杰
2022-07-25 12:56 ` Fwd: " 黄杰
2022-07-25 8:38 ` [PATCH 3/4] x86: Support the uncompressed kernel to speed up booting Albert Huang
2022-07-25 12:55 ` Fwd: " 黄杰
2022-07-25 16:57 ` Eric W. Biederman [this message]
2022-07-25 8:38 ` [PATCH 4/4] x86: boot: avoid memory copy if kernel is uncompressed Albert Huang
2022-07-25 12:55 ` Fwd: " 黄杰
2022-07-25 12:54 ` Fwd: [PATCH 0/4] faster kexec reboot 黄杰
2022-07-25 17:04 ` Eric W. Biederman
2022-07-26 5:53 ` [External] " 黄杰
2022-07-28 1:55 ` 黄杰
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87fsipf7un.fsf@email.froward.int.ebiederm.org \
--to=ebiederm@xmission.com \
--cc=ardb@kernel.org \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=hpa@zytor.com \
--cc=huangjie.albert@bytedance.com \
--cc=jroedel@suse.de \
--cc=keescook@chromium.org \
--cc=kexec@lists.infradead.org \
--cc=kirill.shutemov@linux.intel.com \
--cc=linux-kbuild@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=masahiroy@kernel.org \
--cc=michael.roth@amd.com \
--cc=michal.lkml@markovi.net \
--cc=mingo@redhat.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=peterz@infradead.org \
--cc=sathyanarayanan.kuppuswamy@linux.intel.com \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--cc=tony.luck@intel.com \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox