linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kbuild: Enable armthumb BCJ filter for Thumb-2 kernel
@ 2021-11-19 12:07 Jubin Zhong
  2021-11-19 19:46 ` Lasse Collin
  0 siblings, 1 reply; 3+ messages in thread
From: Jubin Zhong @ 2021-11-19 12:07 UTC (permalink / raw)
  To: lasse.collin, akpm; +Cc: wangfangpeng1, liaohua4, zhongjubin, linux-kernel

xz_wrap.sh use $SRCARCH to detect the BCJ filter. However, assigning
arm BCJ filter to Thumb-2 kernel is not optimal. In my case, about 5%
decrease of image size is observed with armthumb BCJ filter:

Test results:
  hardware:      QEMU emulator version 3.1.0
  config:        vexpress_defconfig with THUMB2_KERNEL & KERNEL_XZ on
  arm BCJ:       4029808
  armthumb BCJ:  3827280

Choose armthumb BCJ filter for Thumb-2 kernel to make smaller images.

Signed-off-by: Jubin Zhong <zhongjubin@huawei.com>
---
 lib/decompress_unxz.c | 3 +++
 scripts/xz_wrap.sh    | 5 +++++
 2 files changed, 8 insertions(+)

diff --git a/lib/decompress_unxz.c b/lib/decompress_unxz.c
index 9f4262e..7d6b952 100644
--- a/lib/decompress_unxz.c
+++ b/lib/decompress_unxz.c
@@ -131,6 +131,9 @@
 #ifdef CONFIG_ARM
 #	define XZ_DEC_ARM
 #endif
+#ifdef CONFIG_THUMB2_KERNEL
+#	define XZ_DEC_ARMTHUMB
+#endif
 #ifdef CONFIG_IA64
 #	define XZ_DEC_IA64
 #endif
diff --git a/scripts/xz_wrap.sh b/scripts/xz_wrap.sh
index 76e9cbc..47409bb 100755
--- a/scripts/xz_wrap.sh
+++ b/scripts/xz_wrap.sh
@@ -8,6 +8,7 @@
 # This file has been put into the public domain.
 # You can do whatever you want with this file.
 #
+. include/config/auto.conf
 
 BCJ=
 LZMA2OPTS=
@@ -20,4 +21,8 @@ case $SRCARCH in
 	sparc)          BCJ=--sparc ;;
 esac
 
+if [ -n "${CONFIG_THUMB2_KERNEL}" ];then
+	BCJ=--armthumb
+fi
+
 exec $XZ --check=crc32 $BCJ --lzma2=$LZMA2OPTS,dict=32MiB
-- 
1.8.5.6


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] kbuild: Enable armthumb BCJ filter for Thumb-2 kernel
  2021-11-19 12:07 [PATCH] kbuild: Enable armthumb BCJ filter for Thumb-2 kernel Jubin Zhong
@ 2021-11-19 19:46 ` Lasse Collin
  2021-11-20  3:18   ` Jubin Zhong
  0 siblings, 1 reply; 3+ messages in thread
From: Lasse Collin @ 2021-11-19 19:46 UTC (permalink / raw)
  To: Jubin Zhong; +Cc: akpm, wangfangpeng1, liaohua4, linux-kernel

On 2021-11-19 Jubin Zhong wrote:
> xz_wrap.sh use $SRCARCH to detect the BCJ filter. However, assigning
> arm BCJ filter to Thumb-2 kernel is not optimal. In my case, about 5%
> decrease of image size is observed with armthumb BCJ filter:
> 
> Test results:
>   hardware:      QEMU emulator version 3.1.0
>   config:        vexpress_defconfig with THUMB2_KERNEL & KERNEL_XZ on
>   arm BCJ:       4029808
>   armthumb BCJ:  3827280
> 
> Choose armthumb BCJ filter for Thumb-2 kernel to make smaller images.

I didn't test the patch but it looks reasonable to me. Below are a small
optimization idea and two very minor style suggestions.

> --- a/lib/decompress_unxz.c
> +++ b/lib/decompress_unxz.c
> @@ -131,6 +131,9 @@
>  #ifdef CONFIG_ARM
>  #	define XZ_DEC_ARM
>  #endif
> +#ifdef CONFIG_THUMB2_KERNEL
> +#	define XZ_DEC_ARMTHUMB
> +#endif
>  #ifdef CONFIG_IA64
>  #	define XZ_DEC_IA64
>  #endif

If a Thumb-2 kernel will always use the ARM-Thumb BCJ filter, one can
save a few bytes from the pre-boot code by omitting the ARM BCJ filter:

--- a/lib/decompress_unxz.c
+++ b/lib/decompress_unxz.c
@@ -129,7 +129,11 @@
 #	define XZ_DEC_POWERPC
 #endif
 #ifdef CONFIG_ARM
-#	define XZ_DEC_ARM
+#	ifdef CONFIG_THUMB2_KERNEL
+#		define XZ_DEC_ARMTHUMB
+#	else
+#		define XZ_DEC_ARM
+#	endif
 #endif
 #ifdef CONFIG_IA64
 #	define XZ_DEC_IA64

> --- a/scripts/xz_wrap.sh
> +++ b/scripts/xz_wrap.sh
> @@ -8,6 +8,7 @@
>  # This file has been put into the public domain.
>  # You can do whatever you want with this file.
>  #
> +. include/config/auto.conf

I suggest adding an empty line before this new line so that it is
clearly separated from the header comment.

> +if [ -n "${CONFIG_THUMB2_KERNEL}" ];then

I suggest adding a space after the semi-colon: ]; then

With or without the above modifications:

Acked-by: Lasse Collin <lasse.collin@tukaani.org>

-- 
Lasse Collin

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] kbuild: Enable armthumb BCJ filter for Thumb-2 kernel
  2021-11-19 19:46 ` Lasse Collin
@ 2021-11-20  3:18   ` Jubin Zhong
  0 siblings, 0 replies; 3+ messages in thread
From: Jubin Zhong @ 2021-11-20  3:18 UTC (permalink / raw)
  To: lasse.collin; +Cc: akpm, liaohua4, linux-kernel, wangfangpeng1, zhongjubin

> If a Thumb-2 kernel will always use the ARM-Thumb BCJ filter, one can
> save a few bytes from the pre-boot code by omitting the ARM BCJ filter:
>
> --- a/lib/decompress_unxz.c
> +++ b/lib/decompress_unxz.c
> @@ -129,7 +129,11 @@
>  #	define XZ_DEC_POWERPC
>  #endif
>  #ifdef CONFIG_ARM
> -#	define XZ_DEC_ARM
> +#	ifdef CONFIG_THUMB2_KERNEL
> +#		define XZ_DEC_ARMTHUMB
> +#	else
> +#		define XZ_DEC_ARM
> +#	endif
>  #endif
>  #ifdef CONFIG_IA64
>  #	define XZ_DEC_IA64
>
>> --- a/scripts/xz_wrap.sh
>> +++ b/scripts/xz_wrap.sh
>> @@ -8,6 +8,7 @@
>>  # This file has been put into the public domain.
>>  # You can do whatever you want with this file.
>>  #
>> +. include/config/auto.conf
>
> I suggest adding an empty line before this new line so that it is
> clearly separated from the header comment.
>
>> +if [ -n "${CONFIG_THUMB2_KERNEL}" ];then
>
> I suggest adding a space after the semi-colon: ]; then
>
> With or without the above modifications:

Thanks for your advices. I will incorporate the above modifications and send patch v2.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-11-20  3:18 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-19 12:07 [PATCH] kbuild: Enable armthumb BCJ filter for Thumb-2 kernel Jubin Zhong
2021-11-19 19:46 ` Lasse Collin
2021-11-20  3:18   ` Jubin Zhong

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).