linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Paul Cercueil <paul@crapouillou.net>
To: Nick Terrell <terrelln@fb.com>
Cc: Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	linux-mips@vger.kernel.org,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	od@zcrc.me
Subject: Re: [PATCH 2/2] MIPS: Add support for ZSTD-compressed kernels
Date: Mon, 24 Aug 2020 23:02:00 +0200	[thread overview]
Message-ID: <CF6LFQ.EXKNOXDIOE502@crapouillou.net> (raw)
In-Reply-To: <41742AA6-8BC0-46E5-8735-9B3D6E83FA2D@fb.com>

Hi Nick,

Le lun. 24 août 2020 à 19:51, Nick Terrell <terrelln@fb.com> a écrit 
:
> 
> 
>>  On Aug 21, 2020, at 9:29 AM, Paul Cercueil <paul@crapouillou.net> 
>> wrote:
>> 
>>  Add support for self-extracting kernels with a ZSTD compression.
>> 
>>  Tested on a kernel for the GCW-Zero, it allows to reduce the size 
>> of the
>>  kernel file from 4.1 MiB with gzip to 3.5 MiB with ZSTD, and boots 
>> just
>>  as fast.
>> 
>>  Signed-off-by: Paul Cercueil <paul@crapouillou.net>
>>  ---
>>  arch/mips/Kconfig                      |  1 +
>>  arch/mips/boot/compressed/Makefile     |  1 +
>>  arch/mips/boot/compressed/decompress.c |  4 ++++
>>  arch/mips/boot/compressed/string.c     | 16 ++++++++++++++++
>>  4 files changed, 22 insertions(+)
>> 
>>  diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig
>>  index c95fa3a2484c..b9d7c4249dc9 100644
>>  --- a/arch/mips/Kconfig
>>  +++ b/arch/mips/Kconfig
>>  @@ -1890,6 +1890,7 @@ config SYS_SUPPORTS_ZBOOT
>>  	select HAVE_KERNEL_LZMA
>>  	select HAVE_KERNEL_LZO
>>  	select HAVE_KERNEL_XZ
>>  +	select HAVE_KERNEL_ZSTD
>> 
>>  config SYS_SUPPORTS_ZBOOT_UART16550
>>  	bool
>>  diff --git a/arch/mips/boot/compressed/Makefile 
>> b/arch/mips/boot/compressed/Makefile
>>  index 6e56caef69f0..86ddc6fc16f4 100644
>>  --- a/arch/mips/boot/compressed/Makefile
>>  +++ b/arch/mips/boot/compressed/Makefile
>>  @@ -70,6 +70,7 @@ tool_$(CONFIG_KERNEL_LZ4)     = lz4
>>  tool_$(CONFIG_KERNEL_LZMA)    = lzma
>>  tool_$(CONFIG_KERNEL_LZO)     = lzo
>>  tool_$(CONFIG_KERNEL_XZ)      = xzkern
>>  +tool_$(CONFIG_KERNEL_ZSTD)    = zstd
> 
> You can use zstd22 here. It will give you slightly better compression
> without any additional memory usage. Also, you should add
> -D__DISABLE_EXPORTS to the KBUILD_CFLAGS like x86 does [1].

Indeed, it's 0.01% smaller :)

What is __DISABLE_EXPORTS for?

-Paul

> 
> [1] 
> https://github.com/torvalds/linux/blob/master/arch/x86/boot/compressed/Makefile
> 
> -Nick
> 
>>  targets += vmlinux.bin.z
>>  $(obj)/vmlinux.bin.z: $(obj)/vmlinux.bin FORCE
>>  diff --git a/arch/mips/boot/compressed/decompress.c 
>> b/arch/mips/boot/compressed/decompress.c
>>  index 88f5d637b1c4..c61c641674e6 100644
>>  --- a/arch/mips/boot/compressed/decompress.c
>>  +++ b/arch/mips/boot/compressed/decompress.c
>>  @@ -72,6 +72,10 @@ void error(char *x)
>>  #include "../../../../lib/decompress_unxz.c"
>>  #endif
>> 
>>  +#ifdef CONFIG_KERNEL_ZSTD
>>  +#include "../../../../lib/decompress_unzstd.c"
>>  +#endif
>>  +
>>  const unsigned long __stack_chk_guard = 0x000a0dff;
>> 
>>  void __stack_chk_fail(void)
>>  diff --git a/arch/mips/boot/compressed/string.c 
>> b/arch/mips/boot/compressed/string.c
>>  index 43beecc3587c..ab95722ec0c9 100644
>>  --- a/arch/mips/boot/compressed/string.c
>>  +++ b/arch/mips/boot/compressed/string.c
>>  @@ -27,3 +27,19 @@ void *memset(void *s, int c, size_t n)
>>  		ss[i] = c;
>>  	return s;
>>  }
>>  +
>>  +void *memmove(void *dest, const void *src, size_t n)
>>  +{
>>  +	unsigned int i;
>>  +	const char *s = src;
>>  +	char *d = dest;
>>  +
>>  +	if ((uintptr_t)dest < (uintptr_t)src) {
>>  +		for (i = 0; i < n; i++)
>>  +			d[i] = s[i];
>>  +	} else {
>>  +		for (i = n; i > 0; i--)
>>  +			d[i - 1] = s[i - 1];
>>  +	}
>>  +	return dest;
>>  +}
>>  --
>>  2.28.0
>> 



  reply	other threads:[~2020-08-24 21:02 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-21 16:29 [PATCH 1/2] lib: decompress_unzstd: Limit output size Paul Cercueil
2020-08-21 16:29 ` [PATCH 2/2] MIPS: Add support for ZSTD-compressed kernels Paul Cercueil
2020-08-24 19:51   ` Nick Terrell
2020-08-24 21:02     ` Paul Cercueil [this message]
2020-08-24 21:45       ` Nick Terrell
2020-08-24 20:11 ` [PATCH 1/2] lib: decompress_unzstd: Limit output size Nick Terrell
2020-08-24 21:05   ` Paul Cercueil
2020-08-24 21:50     ` Nick Terrell

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=CF6LFQ.EXKNOXDIOE502@crapouillou.net \
    --to=paul@crapouillou.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=od@zcrc.me \
    --cc=terrelln@fb.com \
    --cc=tsbogend@alpha.franken.de \
    /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;
as well as URLs for NNTP newsgroup(s).