2021-11-20 03:43:12

by Jubin Zhong

[permalink] [raw]
Subject: [PATCH v2] kbuild: Enable armthumb BCJ filter for Thumb-2 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 <[email protected]>

----
v1:
https://lore.kernel.org/lkml/[email protected]/
---
lib/decompress_unxz.c | 6 +++++-
scripts/xz_wrap.sh | 6 ++++++
2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/lib/decompress_unxz.c b/lib/decompress_unxz.c
index 9f4262e..9d9cb48 100644
--- 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
diff --git a/scripts/xz_wrap.sh b/scripts/xz_wrap.sh
index 76e9cbc..3824fdf 100755
--- a/scripts/xz_wrap.sh
+++ b/scripts/xz_wrap.sh
@@ -9,6 +9,8 @@
# You can do whatever you want with this file.
#

+. include/config/auto.conf
+
BCJ=
LZMA2OPTS=

@@ -20,4 +22,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



2021-11-21 21:43:21

by Lasse Collin

[permalink] [raw]
Subject: Re: [PATCH v2] kbuild: Enable armthumb BCJ filter for Thumb-2 kernel

On 2021-11-20 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.
>
> Signed-off-by: Jubin Zhong <[email protected]>

I still didn't test it but it looks good to me.

Acked-by: Lasse Collin <[email protected]>

--
Lasse Collin

2022-03-21 22:06:09

by Jubin Zhong

[permalink] [raw]
Subject: Re: Re: [PATCH v2] kbuild: Enable armthumb BCJ filter for Thumb-2 kernel

>On 2021-11-20 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.
>>
>> Signed-off-by: Jubin Zhong <[email protected]>

>I still didn't test it but it looks good to me.

Hi, this patch is not accepted into the kernel mainline yet.
Please let me know if there is any problem with the patch, thanks.

2022-03-27 19:34:15

by Lasse Collin

[permalink] [raw]
Subject: Re: [PATCH v2] kbuild: Enable armthumb BCJ filter for Thumb-2 kernel

On 2022-03-21 Jubin Zhong wrote:
> >On 2021-11-20 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.
> >>
> >> Signed-off-by: Jubin Zhong <[email protected]>
>
> >I still didn't test it but it looks good to me.
>
> Hi, this patch is not accepted into the kernel mainline yet.
> Please let me know if there is any problem with the patch, thanks.

I see no replies and don't know what could be wrong. So perhaps you
could resend it with my Acked-by.

--
Lasse Collin

2022-03-28 15:47:10

by Jubin Zhong

[permalink] [raw]
Subject: [PATCH v2 RESEND] kbuild: Enable armthumb BCJ filter for Thumb-2 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 <[email protected]>
Acked-by: Lasse Collin <[email protected]>

----
v1:
https://lore.kernel.org/lkml/[email protected]/
---
lib/decompress_unxz.c | 6 +++++-
scripts/xz_wrap.sh | 6 ++++++
2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/lib/decompress_unxz.c b/lib/decompress_unxz.c
index 9f4262e..9d9cb48 100644
--- 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
diff --git a/scripts/xz_wrap.sh b/scripts/xz_wrap.sh
index 76e9cbc..3824fdf 100755
--- a/scripts/xz_wrap.sh
+++ b/scripts/xz_wrap.sh
@@ -9,6 +9,8 @@
# You can do whatever you want with this file.
#

+. include/config/auto.conf
+
BCJ=
LZMA2OPTS=

@@ -20,4 +22,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