fs/erofs: new filesystem
Subsystems (3)
v4 cover fs/erofs: new filesystem
Changes since v3:
- update tools/docker/Dockerfile;
Changes since v2:
- sync up with erofs-utils 1.4;
- update lib/lz4 to v1.8.3;
- add test for filesystem functions;
Changes since v1:
- fix the inconsistency between From and SoB;
- add missing license header;
Huang Jianan (5):
fs/erofs: add erofs filesystem support
lib/lz4: update LZ4 decompressor module
fs/erofs: add lz4 decompression support
fs/erofs: add filesystem commands
test/py: Add tests for the erofs
MAINTAINERS | 9 + cmd/Kconfig | 6 + cmd/Makefile | 1 + cmd/erofs.c | 42 ++ configs/sandbox_defconfig | 1 + fs/Kconfig | 2 + fs/Makefile | 1 + fs/erofs/Kconfig | 21 + fs/erofs/Makefile | 9 + fs/erofs/data.c | 311 +++++++++++++ fs/erofs/decompress.c | 78 ++++ fs/erofs/decompress.h | 24 + fs/erofs/erofs_fs.h | 436 ++++++++++++++++++ fs/erofs/fs.c | 267 +++++++++++ fs/erofs/internal.h | 313 +++++++++++++ fs/erofs/namei.c | 252 +++++++++++ fs/erofs/super.c | 105 +++++ fs/erofs/zmap.c | 601 ++++++++++++++++++++++++ fs/fs.c | 22 + include/erofs.h | 19 + include/fs.h | 1 + include/u-boot/lz4.h | 49 ++ lib/lz4.c | 679 ++++++++++++++++++++-------- lib/lz4_wrapper.c | 23 +- test/py/tests/test_fs/test_erofs.py | 211 +++++++++ tools/docker/Dockerfile | 1 + 26 files changed, 3269 insertions(+), 215 deletions(-) create mode 100644 cmd/erofs.c create mode 100644 fs/erofs/Kconfig create mode 100644 fs/erofs/Makefile create mode 100644 fs/erofs/data.c create mode 100644 fs/erofs/decompress.c create mode 100644 fs/erofs/decompress.h create mode 100644 fs/erofs/erofs_fs.h create mode 100644 fs/erofs/fs.c create mode 100644 fs/erofs/internal.h create mode 100644 fs/erofs/namei.c create mode 100644 fs/erofs/super.c create mode 100644 fs/erofs/zmap.c create mode 100644 include/erofs.h create mode 100644 test/py/tests/test_fs/test_erofs.py
Signature · 1 line
2.25.1
PATCH v4 1/5 fs/erofs: add erofs filesystem support
This patch mainly deals with uncompressed files.
--- MAINTAINERS | 7 + fs/Kconfig | 2 + fs/Makefile | 1 + fs/erofs/Kconfig | 12 ++ fs/erofs/Makefile | 7 + fs/erofs/data.c | 223 ++++++++++++++++++++++ fs/erofs/erofs_fs.h | 436 ++++++++++++++++++++++++++++++++++++++++++++ fs/erofs/fs.c | 267 +++++++++++++++++++++++++++ fs/erofs/internal.h | 313 +++++++++++++++++++++++++++++++ fs/erofs/namei.c | 252 +++++++++++++++++++++++++ fs/erofs/super.c | 105 +++++++++++ fs/fs.c | 22 +++ include/erofs.h | 19 ++ include/fs.h | 1 + 14 files changed, 1667 insertions(+) create mode 100644 fs/erofs/Kconfig create mode 100644 fs/erofs/Makefile create mode 100644 fs/erofs/data.c create mode 100644 fs/erofs/erofs_fs.h create mode 100644 fs/erofs/fs.c create mode 100644 fs/erofs/internal.h create mode 100644 fs/erofs/namei.c create mode 100644 fs/erofs/super.c create mode 100644 include/erofs.h
MAINTAINERS +7 -0
@@ -808,6 +808,13 @@ S: Maintained F: doc/usage/environment.rst F: scripts/env2string.awk +EROFS +M: Huang Jianan <[email protected]> +L: [email protected] +S: Maintained +F: fs/erofs/ +F: include/erofs.h + FASTBOOT S: Orphaned F: cmd/fastboot.c
fs/Kconfig +2 -0
@@ -24,4 +24,6 @@ source "fs/yaffs2/Kconfig" source "fs/squashfs/Kconfig" +source "fs/erofs/Kconfig" + endmenu
fs/Makefile +1 -0
@@ -25,5 +25,6 @@ obj-$(CONFIG_CMD_UBIFS) += ubifs/ obj-$(CONFIG_YAFFS2) += yaffs2/ obj-$(CONFIG_CMD_ZFS) += zfs/ obj-$(CONFIG_FS_SQUASHFS) += squashfs/ +obj-$(CONFIG_FS_EROFS) += erofs/ endif obj-y += fs_internal.o
fs/erofs/Kconfig new file +12 -0
@@ -0,0 +1,12 @@ +config FS_EROFS + bool "Enable EROFS filesystem support" + help + This provides support for reading images from EROFS filesystem. + EROFS (Enhanced Read-Only File System) is a lightweight read-only + file system for scenarios which need high-performance read-only + requirements. + + It also provides fixed-sized output compression support, which + improves storage density, keeps relatively higher compression + ratios, which is more useful to achieve high performance for + embedded devices with limited memory.
fs/erofs/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +# SPDX-License-Identifier: GPL-2.0+ +# + +obj-$(CONFIG_$(SPL_)FS_EROFS) = fs.o \ + super.o \ + namei.o \ + data.o
fs/erofs/data.c new file +223 -0
223 lines not on this page · raw message
fs/erofs/erofs_fs.h new file +436 -0
436 lines not on this page · raw message
fs/erofs/fs.c new file +267 -0
267 lines not on this page · raw message
fs/erofs/internal.h new file +313 -0
313 lines not on this page · raw message
fs/erofs/namei.c new file +252 -0
252 lines not on this page · raw message
fs/erofs/super.c new file +105 -0
105 lines not on this page · raw message
fs/fs.c +22 -0
@@ -26,6 +26,7 @@#include <linux/math64.h> #include <efi_loader.h> #include <squashfs.h> +#include <erofs.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -304,6 +305,27 @@ static struct fstype_info fstypes[] = { .unlink = fs_unlink_unsupported, .mkdir = fs_mkdir_unsupported, }, +#endif +#if IS_ENABLED (CONFIG_FS_EROFS ) + { + .fstype = FS_TYPE_EROFS, + .name = "erofs", + .null_dev_desc_ok = false, + .probe = erofs_probe, + .opendir = erofs_opendir, + .readdir = erofs_readdir, + .ls = fs_ls_generic, + .read = erofs_read, + .size = erofs_size, + .close = erofs_close, + .closedir = erofs_closedir, + .exists = erofs_exists, + .uuid = fs_uuid_unsupported, + .write = fs_write_unsupported, + .ln = fs_ln_unsupported, + .unlink = fs_unlink_unsupported, + .mkdir = fs_mkdir_unsupported, + }, #endif { .fstype = FS_TYPE_ANY,
include/erofs.h new file +19 -0
@@ -0,0 +1,19 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _EROFS_H_ +#define _EROFS_H_ + +struct disk_partition ; + +int erofs_opendir (const char *filename,struct fs_dir_stream **dirsp); +int erofs_readdir (struct fs_dir_stream *dirs,struct fs_dirent **dentp); +int erofs_probe (struct blk_desc *fs_dev_desc, +struct disk_partition *fs_partition); +int erofs_read (const char *filename,void *buf,loff_t offset, +loff_t len,loff_t *actread); +int erofs_size (const char *filename,loff_t *size); +int erofs_exists (const char *filename); +void erofs_close (void ); +void erofs_closedir (struct fs_dir_stream *dirs); +int erofs_uuid (char *uuid_str); + +#endif /* _EROFS_H */
include/fs.h +1 -0
@@ -17,6 +17,7 @@ struct cmd_tbl;#define FS_TYPE_UBIFS 4#define FS_TYPE_BTRFS 5#define FS_TYPE_SQUASHFS 6 +#define FS_TYPE_EROFS 7struct blk_desc ;
Signature · 1 line
2.25.1
Re: [PATCH v4 1/5] fs/erofs: add erofs filesystem support
Quoted 3 lines · Huang Jianan
This patch mainly deals with uncompressed files.
Signed-off-by Huang Jianan <[email protected]>
Applied to u-boot/next, thanks!
Signature · 1 line
Tom
PATCH v4 2/5 lib/lz4: update LZ4 decompressor module
In reply to Huang JiananUpdate the LZ4 compression module based on LZ4 v1.8.3 in order to use the newest LZ4_decompress_safe_partial() which can now decode exactly the nb of bytes requested.
--- include/u-boot/lz4.h | 49 ++++ lib/lz4.c | 679 +++++++++++++++++++++++++++++++------------ lib/lz4_wrapper.c | 23 +- 3 files changed, 536 insertions(+), 215 deletions(-)
include/u-boot/lz4.h +49 -0
@@ -21,4 +21,53 @@*/ int ulz4fn (const void *src,size_t srcn,void *dst,size_t *dstn); +/** +* LZ4_decompress_safe() - Decompression protected against buffer overflow +* @source: source address of the compressed data +* @dest: output buffer address of the uncompressed data +* which must be already allocated +* @compressedSize: is the precise full size of the compressed block +* @maxDecompressedSize: is the size of 'dest' buffer +* +* Decompresses data from 'source' into 'dest'. +* If the source stream is detected malformed, the function will +* stop decoding and return a negative result. +* This function is protected against buffer overflow exploits, +* including malicious data packets. It never writes outside output buffer, +* nor reads outside input buffer. +* +* Return: number of bytes decompressed into destination buffer +* (necessarily <= maxDecompressedSize) +* or a negative result in case of error +*/ +int LZ4_decompress_safe (const char *source,char *dest, +int compressedSize,int maxDecompressedSize); + +/** +* LZ4_decompress_safe_partial() - Decompress a block of size 'compressedSize' +* at position 'source' into buffer 'dest' +* @source: source address of the compressed data +* @dest: output buffer address of the decompressed data which must be +* already allocated +* @compressedSize: is the precise full size of the compressed block. +* @targetOutputSize: the decompression operation will try +* to stop as soon as 'targetOutputSize' has been reached +* @maxDecompressedSize: is the size of destination buffer +* +* This function decompresses a compressed block of size 'compressedSize' +* at position 'source' into destination buffer 'dest' +* of size 'maxDecompressedSize'. +* The function tries to stop decompressing operation as soon as +* 'targetOutputSize' has been reached, reducing decompression time. +* This function never writes outside of output buffer, +* and never reads outside of input buffer. +* It is therefore protected against malicious data packets. +* +* Return: the number of bytes decoded in the destination buffer +* (necessarily <= maxDecompressedSize) +* or a negative result in case of error +* +*/ +int LZ4_decompress_safe_partial (const char *src,char *dst, +int compressedSize,int targetOutputSize,int dstCapacity);#endif
lib/lz4.c +486 -193
711 lines not on this page · raw message
lib/lz4_wrapper.c +1 -22
@@ -11,27 +11,6 @@#include <asm/unaligned.h> #include <u-boot/lz4.h> -static u16 LZ4_readLE16 (const void *src) -{ -return get_unaligned_le16 (src); -} -static void LZ4_copy4 (void *dst,const void *src) -{ -put_unaligned (get_unaligned ((const u32 *)src), (u32 *)dst); -} -static void LZ4_copy8 (void *dst,const void *src) -{ -put_unaligned (get_unaligned ((const u64 *)src), (u64 *)dst); -} - -typedef uint8_t BYTE ; -typedef uint16_t U16 ; -typedef uint32_t U32 ; -typedef int32_t S32 ; -typedef uint64_t U64 ; - -#define FORCE_INLINE static inline __attribute__((always_inline)) -/* lz4.c is unaltered (except removing unrelated code) from github.com/Cyan4973/lz4. */ #include "lz4.c" /* #include for inlining, do not link! */
@@ -112,7 +91,7 @@ int ulz4fn(const void *src, size_t srcn, void *dst, size_t *dstn)/* constant folding essential, do not touch params! */ ret =LZ4_decompress_generic (in, out, block_size, end - out, endOnInputSize, - full,0 , noDict, out,NULL ,0 ); + decode_full_block, noDict, out,NULL ,0 );if (ret <0 ) { ret = -EPROTO ;/* decompression error */ break ;
Signature · 1 line
2.25.1
Re: [PATCH v4 2/5] lib/lz4: update LZ4 decompressor module
Quoted 5 lines · Huang Jianan
Update the LZ4 compression module based on LZ4 v1.8.3 in order to use the newest
LZ4_decompress_safe_partial()which can now decode exactly the nb of bytes requested.Signed-off-by Huang Jianan <[email protected]>
Applied to u-boot/next, thanks!
Signature · 1 line
Tom
Re: [PATCH v4 2/5] lib/lz4: update LZ4 decompressor module
In reply to Huang JiananHi Jianan,
Quoted 6 lines · Huang Jianan
Update the LZ4 compression module based on LZ4 v1.8.3 in order to use the newest
LZ4_decompress_safe_partial()which can now decode exactly the nb of bytes requested.Signed-off-by Huang Jianan <[email protected]>
I noticed after this commit LZ4 decompression is slower.
ulz4fn function call takes 1.209670 seconds with this commit. After reverting this commit, the ulz4fn function call takes 0.587032 seconds.
I am decompressing a LZ4 compressed kernel (compressed with lz4 v1.9.4 using -9 option for maximum compression) on RK3399.
Any ideas why it is slower with this commit and how the performance regression can be fixed?
Thanks.
Regards,
Jonathan
Re: [PATCH v4 2/5] lib/lz4: update LZ4 decompressor module
Hi,
Quoted 14 lines · Jonathan Liu
Hi Jianan,
Quoted 6 lines · Huang Jianan
Update the LZ4 compression module based on LZ4 v1.8.3 in order to use the newest
LZ4_decompress_safe_partial()which can now decode exactly the nb of bytes requested.Signed-off-by Huang Jianan <[email protected]>I noticed after this commit LZ4 decompression is slower.
ulz4fn function call takes 1.209670 seconds with this commit. After reverting this commit, the ulz4fn function call takes 0.587032 seconds.
Quoted 5 lines
I am decompressing a LZ4 compressed kernel (compressed with lz4 v1.9.4 using -9 option for maximum compression) on RK3399.
Any ideas why it is slower with this commit and how the performance regression can be fixed?
Just the quick glance, I think the issue may be due to memcpy/memmove since it seems the main difference between these two codebases (I'm not sure which LZ4 version the old codebase was based on) and the new version mainly relies on memcpy/memmove instead of its own versions.
Would you mind to check the assembly how memcpy/memset is generated on your platform?
Thanks,
Gao Xiang
Quoted 5 lines
Thanks.
Regards,
Jonathan
Re: [PATCH v4 2/5] lib/lz4: update LZ4 decompressor module
Hi Gao,
Quoted 31 lines · Gao Xiang
Hi,
Quoted 14 lines · Jonathan Liu
Hi Jianan,
Quoted 6 lines · Huang Jianan
Update the LZ4 compression module based on LZ4 v1.8.3 in order to use the newest
LZ4_decompress_safe_partial()which can now decode exactly the nb of bytes requested.Signed-off-by Huang Jianan <[email protected]>I noticed after this commit LZ4 decompression is slower.
ulz4fn function call takes 1.209670 seconds with this commit. After reverting this commit, the ulz4fn function call takes 0.587032 seconds.Quoted 5 lines
I am decompressing a LZ4 compressed kernel (compressed with lz4 v1.9.4 using -9 option for maximum compression) on RK3399.
Any ideas why it is slower with this commit and how the performance regression can be fixed?
Just the quick glance, I think the issue may be due to memcpy/memmove since it seems the main difference between these two codebases (I'm not sure which LZ4 version the old codebase was based on) and the new version mainly relies on memcpy/memmove instead of its own versions.
Quoted 2 lines
Would you mind to check the assembly how memcpy/memset is generated on your platform?
Here is the assembly (-mcpu=cortex-a72.cortex-a53 -march=armv8-a+crc+crypto):000000000028220c <memset>:
#if !CONFIG_IS_ENABLED(TINY_MEMSET)
unsigned long cl = 0;
int i;
/* do it one word at a time (32 bits or 64 bits) while possible */
if ( ((ulong)s & (sizeof(*sl) - 1)) == 0) {
28220c: f2400803 ands x3, x0, #0x7
282210: 540002c1 b.ne 282268 <memset+0x5c> // b.any
for (i = 0; i < sizeof(*sl); i++) {
cl <<= 8;
cl |= c & 0xff;
282214: 92401c26 and x6, x1, #0xff
unsigned long cl = 0;
282218: d2800004 mov x4, #0x0 // #0
28221c: 52800105 mov w5, #0x8 // #8
cl |= c & 0xff;
282220: aa0420c4 orr x4, x6, x4, lsl #8
for (i = 0; i < sizeof(*sl); i++) {
282224: 710004a5 subs w5, w5, #0x1
282228: 54ffffc1 b.ne 282220 <memset+0x14> // b.any
}
while (count >= sizeof(*sl)) {
28222c: cb030045 sub x5, x2, x3
282230: f1001cbf cmp x5, #0x7
282234: 54000148 b.hi 28225c <memset+0x50> // b.pmore
282238: d343fc43 lsr x3, x2, #3
28223c: 928000e4 mov x4, #0xfffffffffffffff8 // #-8
282240: 9b047c63 mul x3, x3, x4
282244: 8b030042 add x2, x2, x3
282248: cb030003 sub x3, x0, x3
unsigned long *sl = (unsigned long *) s;
28224c: d2800004 mov x4, #0x0 // #0
count -= sizeof(*sl);
}
}
#endif /* fill 8 bits at a time */
s8 = (char *)sl;
while (count--)
282250: eb04005f cmp x2, x4
282254: 540000e1 b.ne 282270 <memset+0x64> // b.any
*s8++ = c;
return s;
}
282258: d65f03c0 ret
*sl++ = cl;
28225c: f8236804 str x4, [x0, x3]
count -= sizeof(*sl);
282260: 91002063 add x3, x3, #0x8
282264: 17fffff2 b 28222c <memset+0x20>
unsigned long *sl = (unsigned long *) s;
282268: aa0003e3 mov x3, x0
28226c: 17fffff8 b 28224c <memset+0x40>
*s8++ = c;
282270: 38246861 strb w1, [x3, x4]
282274: 91000484 add x4, x4, #0x1
282278: 17fffff6 b 282250 <memset+0x44>000000000028227c <memcpy>:__used void * memcpy(void *dest, const void *src, size_t count)
{
unsigned long *dl = (unsigned long *)dest, *sl = (unsigned long *)src;
char *d8, *s8;
if (src == dest)
28227c: eb01001f cmp x0, x1
282280: 54000100 b.eq 2822a0 <memcpy+0x24> // b.none
return dest;
/* while all data is aligned (common case), copy a word at a time */
if ( (((ulong)dest | (ulong)src) & (sizeof(*dl) - 1)) == 0) {
282284: aa010003 orr x3, x0, x1
282288: f2400863 ands x3, x3, #0x7
28228c: 54000120 b.eq 2822b0 <memcpy+0x34> // b.none
282290: aa0003e4 mov x4, x0
282294: d2800003 mov x3, #0x0 // #0
}
}
/* copy the reset one byte at a time */
d8 = (char *)dl;
s8 = (char *)sl;
while (count--)
282298: eb03005f cmp x2, x3
28229c: 540001e1 b.ne 2822d8 <memcpy+0x5c> // b.any
*d8++ = *s8++;
return dest;
}
2822a0: d65f03c0 ret
*dl++ = *sl++;
2822a4: f8636824 ldr x4, [x1, x3]
2822a8: f8236804 str x4, [x0, x3]
count -= sizeof(*dl);
2822ac: 91002063 add x3, x3, #0x8
while (count >= sizeof(*dl)) {
2822b0: cb030044 sub x4, x2, x3
2822b4: f1001c9f cmp x4, #0x7
2822b8: 54ffff68 b.hi 2822a4 <memcpy+0x28> // b.pmore
2822bc: d343fc43 lsr x3, x2, #3
2822c0: 928000e4 mov x4, #0xfffffffffffffff8 // #-8
2822c4: 9b047c63 mul x3, x3, x4
2822c8: 8b030042 add x2, x2, x3
2822cc: cb030004 sub x4, x0, x3
2822d0: cb030021 sub x1, x1, x3
2822d4: 17fffff0 b 282294 <memcpy+0x18>
*d8++ = *s8++;
2822d8: 38636825 ldrb w5, [x1, x3]
2822dc: 38236885 strb w5, [x4, x3]
2822e0: 91000463 add x3, x3, #0x1
2822e4: 17ffffed b 282298 <memcpy+0x1c>I tried enabling CONFIG_USE_ARCH_MEMCPY=y, CONFIG_USE_ARCH_MEMSET=y in the .config (but leaving it disabled in SPL/TPL) and it results in Synchronous Abort:
U-Boot SPL 2024.04 (Apr 02 2024 - 10:58:58 +0000)
Trying to boot from MMC1
NOTICE: BL31: v1.3(release):8f40012ab NOTICE: BL31: Built : 14:20:53, Feb 16 2023 NOTICE: BL31: Rockchip release version: v1.1 INFO: GICv3 with legacy support detected. ARM GICV3 driver initialized in EL3 INFO: Using opteed sec cpu_context! INFO: boot cpu mask: 0 INFO: plat_rockchip_pmu_init(1203): pd status 3e INFO: BL31: Initializing runtime services WARNING: No OPTEE provided by BL2 boot loader, Booting device without OPTEE initialization. SMC`s destined for OPTEE will return SMC_UNK ERROR: Error initializing runtime service opteed_fast INFO: BL31: Preparing for EL3 exit to normal world INFO: Entry point address = 0x200000 INFO: SPSR = 0x3c9
"Synchronous Abort" handler, esr 0x96000021, far 0x2957e1
elr: 000000000020233c lr : 000000000026a388
x0 : 00000000002fbf38 x1 : 00000000002957e1
x2 : 0000000000000008 x3 : 0000000000000065
x4 : 00000000002957e9 x5 : 00000000002fbf40
x6 : 0000000000000065 x7 : 0000000000000003
x8 : 00000000002c7960 x9 : 000000000000ffd0
x10: 00000000002fbc5c x11: 00000000000132e8
x12: 00000000002fbce8 x13: 00000000002c7960
x14: 00000000002c7960 x15: 0000000000000000
x16: 0000000000000000 x17: 0000000000000000
x18: 00000000002fbe30 x19: 0000000000000007
x20: 00000000002957d8 x21: 0000000000000009
x22: 000000000029d189 x23: 0000000000000020
x24: 00000000002fbf38 x25: 00000000002957e7
x26: 00000000002957b2 x27: 0000000000007fff
x28: 0000000000000000 x29: 00000000002fbcc0
Code: a9001c06 a93f34ac d65f03c0 361800c2 (f9400026)
Resetting CPU ...
resetting ...
Quoted 3 lines
Thanks,
Gao Xiang
Regards,
Jonathan
Re: [PATCH v4 2/5] lib/lz4: update LZ4 decompressor module
Hi Jonathan,
Could you please try the following patch ? It replaces all memcpy() calls in lz4 with __builtin_memcpy().
lib/lz4.c +10 -8
@@ -34,6 +34,8 @@#include <asm/unaligned.h> #include <u-boot/lz4.h> +#define LZ4_memcpy (dst, src, size) __builtin_memcpy(dst, src, size) +#define FORCE_INLINE inline __attribute__((always_inline)) static FORCE_INLINE u16 LZ4_readLE16(const void *src)
@@ -215,7 +217,7 @@ static FORCE_INLINE int LZ4_decompress_generic( && likely((endOnInput ? ip < shortiend : 1) & (op <= shortoend))) {/* Copy the literals */ -memcpy (op, ip, endOnInput ?16 :8 ); +LZ4_memcpy (op, ip, endOnInput ?16 :8 ); op += length; ip += length;/*
@@ -234,9 +236,9 @@ static FORCE_INLINE int LZ4_decompress_generic( (offset >= 8) && (dict == withPrefix64k || match >= lowPrefix)) {/* Copy the match. */ -memcpy (op +0 , match +0 ,8 ); -memcpy (op +8 , match +8 ,8 ); -memcpy (op +16 , match +16 ,2 ); +LZ4_memcpy (op +0 , match +0 ,8 ); +LZ4_memcpy (op +8 , match +8 ,8 ); +LZ4_memcpy (op +16 , match +16 ,2 ); op += length +MINMATCH ;/* Both stages worked, load the next token. */ continue ;
@@ -416,7 +418,7 @@ _copy_match:size_t const copySize = (size_t )(lowPrefix - match);size_t const restSize = length - copySize; -memcpy (op, dictEnd - copySize, copySize); +LZ4_memcpy (op, dictEnd - copySize, copySize); op += copySize;if (restSize > (size_t )(op - lowPrefix)) {/* overlap copy */
@@ -426,7 +428,7 @@ _copy_match:while (op < endOfMatch) *op++ = *copyFrom++; }else { -memcpy (op, lowPrefix, restSize); +LZ4_memcpy (op, lowPrefix, restSize); op += restSize; } }
@@ -452,7 +454,7 @@ _copy_match:while (op < copyEnd) *op++ = *match++; }else { -memcpy (op, match, mlen); +LZ4_memcpy (op, match, mlen); } op = copyEnd;if (op == oend)
@@ -466,7 +468,7 @@ _copy_match: op[2 ] = match[2 ]; op[3 ] = match[3 ]; match += inc32table[offset]; -memcpy (op +4 , match,4 ); +LZ4_memcpy (op +4 , match,4 ); match -= dec64table[offset]; }else {LZ4_copy8 (op, match);
lib/lz4_wrapper.c +0 -0
@@ -80,7 +80,7 @@ int ulz4fn(const void *src, size_t srcn, void *dst,
size_t *dstn)
if (block_header & LZ4F_BLOCKUNCOMPRESSED_FLAG) { size_t size = min((ptrdiff_t)block_size, (ptrdiff_t)(end - out));
- memcpy(out, in, size);
+ LZ4_memcpy(out, in, size);
out += size;
if (size < block_size) {
ret = -ENOBUFS; /* output overrun */
Thanks,
Jianan
On 2024/5/26 16:06, Jonathan Liu wrote:
Hi Gao,
On Sat, 25 May 2024 at 02:52, Gao Xiang <[email protected]> <[email protected]> wrote:
Hi,
On 2024/5/24 22:26, Jonathan Liu wrote:
Hi Jianan,
On Sat, 26 Feb 2022 at 18:05, Huang Jianan <[email protected]> <[email protected]> wrote:
Update the LZ4 compression module based on LZ4 v1.8.3 in order to use the newest LZ4_decompress_safe_partial() which can now decode exactly the nb of bytes requested.
I noticed after this commit LZ4 decompression is slower.
ulz4fn function call takes 1.209670 seconds with this commit. After reverting this commit, the ulz4fn function call takes 0.587032 seconds.
I am decompressing a LZ4 compressed kernel (compressed with lz4 v1.9.4 using -9 option for maximum compression) on RK3399.
Any ideas why it is slower with this commit and how the performance regression can be fixed?
Just the quick glance, I think the issue may be due to memcpy/memmove since it seems the main difference between these two codebases (I'm not sure which LZ4 version the old codebase was based on) and the new version mainly relies on memcpy/memmove instead of its own versions.
Would you mind to check the assembly how memcpy/memset is generated on your platform?
Here is the assembly (-mcpu=cortex-a72.cortex-a53 -march=armv8-a+crc+crypto):000000000028220c <memset>:
#if !CONFIG_IS_ENABLED(TINY_MEMSET)
unsigned long cl = 0;
int i;
/* do it one word at a time (32 bits or 64 bits) while possible */
if ( ((ulong)s & (sizeof(*sl) - 1)) == 0) {
28220c: f2400803 ands x3, x0, #0x7
282210: 540002c1 b.ne 282268 <memset+0x5c> // b.any
for (i = 0; i < sizeof(*sl); i++) {
cl <<= 8;
cl |= c & 0xff;
282214: 92401c26 and x6, x1, #0xff
unsigned long cl = 0;
282218: d2800004 mov x4, #0x0 // #0
28221c: 52800105 mov w5, #0x8 // #8
cl |= c & 0xff;
282220: aa0420c4 orr x4, x6, x4, lsl #8
for (i = 0; i < sizeof(*sl); i++) {
282224: 710004a5 subs w5, w5, #0x1
282228: 54ffffc1 b.ne 282220 <memset+0x14> // b.any
}
while (count >= sizeof(*sl)) {
28222c: cb030045 sub x5, x2, x3
282230: f1001cbf cmp x5, #0x7
282234: 54000148 b.hi 28225c <memset+0x50> // b.pmore
282238: d343fc43 lsr x3, x2, #3
28223c: 928000e4 mov x4, #0xfffffffffffffff8 // #-8
282240: 9b047c63 mul x3, x3, x4
282244: 8b030042 add x2, x2, x3
282248: cb030003 sub x3, x0, x3
unsigned long *sl = (unsigned long *) s;
28224c: d2800004 mov x4, #0x0 // #0
count -= sizeof(*sl);
}
}
#endif /* fill 8 bits at a time */
s8 = (char *)sl;
while (count--)
282250: eb04005f cmp x2, x4
282254: 540000e1 b.ne 282270 <memset+0x64> // b.any
*s8++ = c;
return s;
}
282258: d65f03c0 ret
*sl++ = cl;
28225c: f8236804 str x4, [x0, x3]
count -= sizeof(*sl);
282260: 91002063 add x3, x3, #0x8
282264: 17fffff2 b 28222c <memset+0x20>
unsigned long *sl = (unsigned long *) s;
282268: aa0003e3 mov x3, x0
28226c: 17fffff8 b 28224c <memset+0x40>
*s8++ = c;
282270: 38246861 strb w1, [x3, x4]
282274: 91000484 add x4, x4, #0x1
282278: 17fffff6 b 282250 <memset+0x44>000000000028227c <memcpy>:__used void * memcpy(void *dest, const void *src, size_t count)
{
unsigned long *dl = (unsigned long *)dest, *sl = (unsigned long *)src;
char *d8, *s8;
if (src == dest)
28227c: eb01001f cmp x0, x1
282280: 54000100 b.eq 2822a0 <memcpy+0x24> // b.none
return dest;
/* while all data is aligned (common case), copy a word at a time */
if ( (((ulong)dest | (ulong)src) & (sizeof(*dl) - 1)) == 0) {
282284: aa010003 orr x3, x0, x1
282288: f2400863 ands x3, x3, #0x7
28228c: 54000120 b.eq 2822b0 <memcpy+0x34> // b.none
282290: aa0003e4 mov x4, x0
282294: d2800003 mov x3, #0x0 // #0
}
}
/* copy the reset one byte at a time */
d8 = (char *)dl;
s8 = (char *)sl;
while (count--)
282298: eb03005f cmp x2, x3
28229c: 540001e1 b.ne 2822d8 <memcpy+0x5c> // b.any
*d8++ = *s8++;
return dest;
}
2822a0: d65f03c0 ret
*dl++ = *sl++;
2822a4: f8636824 ldr x4, [x1, x3]
2822a8: f8236804 str x4, [x0, x3]
count -= sizeof(*dl);
2822ac: 91002063 add x3, x3, #0x8
while (count >= sizeof(*dl)) {
2822b0: cb030044 sub x4, x2, x3
2822b4: f1001c9f cmp x4, #0x7
2822b8: 54ffff68 b.hi 2822a4 <memcpy+0x28> // b.pmore
2822bc: d343fc43 lsr x3, x2, #3
2822c0: 928000e4 mov x4, #0xfffffffffffffff8 // #-8
2822c4: 9b047c63 mul x3, x3, x4
2822c8: 8b030042 add x2, x2, x3
2822cc: cb030004 sub x4, x0, x3
2822d0: cb030021 sub x1, x1, x3
2822d4: 17fffff0 b 282294 <memcpy+0x18>
*d8++ = *s8++;
2822d8: 38636825 ldrb w5, [x1, x3]
2822dc: 38236885 strb w5, [x4, x3]
2822e0: 91000463 add x3, x3, #0x1
2822e4: 17ffffed b 282298 <memcpy+0x1c>I tried enabling CONFIG_USE_ARCH_MEMCPY=y, CONFIG_USE_ARCH_MEMSET=y in the .config (but leaving it disabled in SPL/TPL) and it results in Synchronous Abort:
U-Boot SPL 2024.04 (Apr 02 2024 - 10:58:58 +0000)
Trying to boot from MMC1
NOTICE: BL31: v1.3(release):8f40012ab NOTICE: BL31: Built : 14:20:53, Feb 16 2023 NOTICE: BL31: Rockchip release version: v1.1 INFO: GICv3 with legacy support detected. ARM GICV3 driver initialized in EL3 INFO: Using opteed sec cpu_context! INFO: boot cpu mask: 0 INFO: plat_rockchip_pmu_init(1203): pd status 3e INFO: BL31: Initializing runtime services WARNING: No OPTEE provided by BL2 boot loader, Booting device without OPTEE initialization. SMC`s destined for OPTEE will return SMC_UNK ERROR: Error initializing runtime service opteed_fast INFO: BL31: Preparing for EL3 exit to normal world INFO: Entry point address = 0x200000 INFO: SPSR = 0x3c9
"Synchronous Abort" handler, esr 0x96000021, far 0x2957e1
elr: 000000000020233c lr : 000000000026a388
x0 : 00000000002fbf38 x1 : 00000000002957e1
x2 : 0000000000000008 x3 : 0000000000000065
x4 : 00000000002957e9 x5 : 00000000002fbf40
x6 : 0000000000000065 x7 : 0000000000000003
x8 : 00000000002c7960 x9 : 000000000000ffd0
x10: 00000000002fbc5c x11: 00000000000132e8
x12: 00000000002fbce8 x13: 00000000002c7960
x14: 00000000002c7960 x15: 0000000000000000
x16: 0000000000000000 x17: 0000000000000000
x18: 00000000002fbe30 x19: 0000000000000007
x20: 00000000002957d8 x21: 0000000000000009
x22: 000000000029d189 x23: 0000000000000020
x24: 00000000002fbf38 x25: 00000000002957e7
x26: 00000000002957b2 x27: 0000000000007fff
x28: 0000000000000000 x29: 00000000002fbcc0
Code: a9001c06 a93f34ac d65f03c0 361800c2 (f9400026)
Resetting CPU ...
resetting ...
Thanks,
Gao Xiang
Regards,
Jonathan
Re: [PATCH v4 2/5] lib/lz4: update LZ4 decompressor module
Hi Jianan,
Here are the LZ4 decompression times I got running "time unlz4 ..." on Rock 4 SE with RK3399 CPU.
v2024.04: 1.329 seconds
v2024.04 with 26c7fdadcb7 ("lib/lz4: update LZ4 decompressor module")
reverted: 0.665 seconds
v2024.04 with your patch: 1.216 seconds
I managed to get better performance by optimizing it myself. v2024.04 with my patch: 0.785 seconds
With my patch, it makes no difference if I use __builtin_memcpy or memcpy in lz4.c and lz4_wrapper.c so I just left it using memcpy. It is still slower than reverting the LZ4 update though.
My patch:
lib/lz4.c +18 -5
@@ -41,6 +41,16 @@ static FORCE_INLINE u16 LZ4_readLE16(const void *src)return get_unaligned_le16 (src); } +static FORCE_INLINE void LZ4_copy2(void *dst, const void *src) +{ +put_unaligned (get_unaligned ((const u16 *)src), (u16 *)dst); +} + +static FORCE_INLINE void LZ4_copy4(void *dst, const void *src) +{ +put_unaligned (get_unaligned ((const u32 *)src), (u32 *)dst); +} + static FORCE_INLINE void LZ4_copy8(void *dst, const void *src) {put_unaligned (get_unaligned ((const u64 *)src), (u64 *)dst);
@@ -215,7 +225,10 @@ static FORCE_INLINE int LZ4_decompress_generic( && likely((endOnInput ? ip < shortiend : 1) & (op <= shortoend))) {/* Copy the literals */ -memcpy (op, ip, endOnInput ?16 :8 ); +LZ4_copy8 (op, ip); +if (endOnInput) +LZ4_copy8 (op +8 , ip +8 ); + op += length; ip += length;/*
@@ -234,9 +247,9 @@ static FORCE_INLINE int LZ4_decompress_generic( (offset >= 8) && (dict == withPrefix64k || match >= lowPrefix)) {/* Copy the match. */ -memcpy (op +0 , match +0 ,8 ); -memcpy (op +8 , match +8 ,8 ); -memcpy (op +16 , match +16 ,2 ); +LZ4_copy8 (op, match); +LZ4_copy8 (op +8 , match +8 ); +LZ4_copy2 (op +16 , match +16 ); op += length +MINMATCH ;/* Both stages worked, load the next token. */ continue ;
@@ -466,7 +479,7 @@ _copy_match: op[2 ] = match[2 ]; op[3 ] = match[3 ]; match += inc32table[offset]; -memcpy (op +4 , match,4 ); +LZ4_copy4 (op +4 , match); match -= dec64table[offset]; }else {LZ4_copy8 (op, match);
Let me know if you have any further suggestions.
Thanks.
Regards,
Jonathan
Quoted 295 lines · Jianan Huang
Hi Jonathan,
Could you please try the following patch ? It replaces all
memcpy()calls in lz4 with__builtin_memcpy().lib/lz4.c +10
-8@@ -34,6 +34,8 @@#include <asm/unaligned.h> #include <u-boot/lz4.h> +#define LZ4_memcpy (dst, src, size) __builtin_memcpy(dst, src, size) +#define FORCE_INLINE inline __attribute__((always_inline)) static FORCE_INLINE u16 LZ4_readLE16(const void *src)@@ -215,7 +217,7 @@ static FORCE_INLINE int LZ4_decompress_generic( && likely((endOnInput ? ip < shortiend : 1) & (op <= shortoend))) {/* Copy the literals */ -memcpy (op, ip, endOnInput ?16 :8 ); +LZ4_memcpy (op, ip, endOnInput ?16 :8 ); op += length; ip += length;/* @@ -234,9 +236,9 @@ static FORCE_INLINE int LZ4_decompress_generic( (offset >= 8) && (dict == withPrefix64k || match >= lowPrefix)) {/* Copy the match. */ -memcpy (op +0 , match +0 ,8 ); -memcpy (op +8 , match +8 ,8 ); -memcpy (op +16 , match +16 ,2 ); +LZ4_memcpy (op +0 , match +0 ,8 ); +LZ4_memcpy (op +8 , match +8 ,8 ); +LZ4_memcpy (op +16 , match +16 ,2 ); op += length +MINMATCH ;/* Both stages worked, load the next token. */ continue ;@@ -416,7 +418,7 @@ _copy_match:size_t const copySize = (size_t )(lowPrefix - match);size_t const restSize = length - copySize; -memcpy (op, dictEnd - copySize, copySize); +LZ4_memcpy (op, dictEnd - copySize, copySize); op += copySize;if (restSize > (size_t )(op - lowPrefix)) {/* overlap copy */ @@ -426,7 +428,7 @@ _copy_match:while (op < endOfMatch) *op++ = *copyFrom++; }else { -memcpy (op, lowPrefix, restSize); +LZ4_memcpy (op, lowPrefix, restSize); op += restSize; } }@@ -452,7 +454,7 @@ _copy_match:while (op < copyEnd) *op++ = *match++; }else { -memcpy (op, match, mlen); +LZ4_memcpy (op, match, mlen); } op = copyEnd;if (op == oend)@@ -466,7 +468,7 @@ _copy_match: op[2 ] = match[2 ]; op[3 ] = match[3 ]; match += inc32table[offset]; -memcpy (op +4 , match,4 ); +LZ4_memcpy (op +4 , match,4 ); match -= dec64table[offset]; }else {LZ4_copy8 (op, match);lib/lz4_wrapper.c +1
-1@@ -80,7 +80,7 @@ int ulz4fn(const void *src, size_t srcn, void *dst, size_t *dstn)if (block_header &LZ4F_BLOCKUNCOMPRESSED_FLAG ) {size_t size =min ((ptrdiff_t )block_size, (ptrdiff_t )(end - out)); -memcpy (out, in, size); +LZ4_memcpy (out, in, size); out += size;if (size < block_size) { ret = -ENOBUFS ;/* output overrun */ Thanks,
Jianan
On 2024/5/26 16:06, Jonathan Liu wrote:
Hi Gao,
On Sat, 25 May 2024 at 02:52, Gao Xiang <[email protected]> wrote:
Hi,
On 2024/5/24 22:26, Jonathan Liu wrote:
Hi Jianan,
On Sat, 26 Feb 2022 at 18:05, Huang Jianan <[email protected]> wrote:
Update the LZ4 compression module based on LZ4 v1.8.3 in order to use the newest
LZ4_decompress_safe_partial()which can now decode exactly the nb of bytes requested.Signed-off-by Huang Jianan <[email protected]>I noticed after this commit LZ4 decompression is slower.
ulz4fn function call takes 1.209670 seconds with this commit. After reverting this commit, the ulz4fn function call takes 0.587032 seconds.I am decompressing a LZ4 compressed kernel (compressed with lz4 v1.9.4 using -9 option for maximum compression) on RK3399.
Any ideas why it is slower with this commit and how the performance regression can be fixed?
Just the quick glance, I think the issue may be due to memcpy/memmove since it seems the main difference between these two codebases (I'm not sure which LZ4 version the old codebase was based on) and the new version mainly relies on memcpy/memmove instead of its own versions.
Would you mind to check the assembly how memcpy/memset is generated on your platform?
Here is the assembly (-mcpu=cortex-a72.cortex-a53 -march=armv8-a+crc+crypto):
000000000028220c<memset>:#if !CONFIG_IS_ENABLED(TINY_MEMSET) unsigned long cl = 0; int i; /* do it one word at a time (32 bits or 64 bits) while possible */ if ( ((ulong)s & (sizeof(*sl) - 1)) == 0) { 28220c: f2400803 ands x3, x0, #0x7 282210: 540002c1 b.ne 282268 <memset+0x5c> // b.any for (i = 0; i < sizeof(*sl); i++) { cl <<= 8; cl |= c & 0xff; 282214: 92401c26 and x6, x1, #0xff unsigned long cl = 0; 282218: d2800004 mov x4, #0x0 // #0 28221c: 52800105 mov w5, #0x8 // #8 cl |= c & 0xff; 282220: aa0420c4 orr x4, x6, x4, lsl #8 for (i = 0; i < sizeof(*sl); i++) { 282224: 710004a5 subs w5, w5, #0x1 282228: 54ffffc1 b.ne 282220 <memset+0x14> // b.any } while (count >= sizeof(*sl)) { 28222c: cb030045 sub x5, x2, x3 282230: f1001cbf cmp x5, #0x7 282234: 54000148 b.hi 28225c <memset+0x50> // b.pmore 282238: d343fc43 lsr x3, x2, #3 28223c: 928000e4 mov x4, #0xfffffffffffffff8 // #-8 282240: 9b047c63 mul x3, x3, x4 282244: 8b030042 add x2, x2, x3 282248: cb030003 sub x3, x0, x3 unsigned long *sl = (unsigned long *) s; 28224c: d2800004 mov x4, #0x0 // #0 count -= sizeof(*sl); } } #endif /* fill 8 bits at a time */ s8 = (char *)sl; while (count--) 282250: eb04005f cmp x2, x4 282254: 540000e1 b.ne 282270 <memset+0x64> // b.any *s8++ = c; return s; } 282258: d65f03c0 ret *sl++ = cl; 28225c: f8236804 str x4, [x0, x3] count -= sizeof(*sl); 282260: 91002063 add x3, x3, #0x8 282264: 17fffff2 b 28222c <memset+0x20> unsigned long *sl = (unsigned long *) s; 282268: aa0003e3 mov x3, x0 28226c: 17fffff8 b 28224c <memset+0x40> *s8++ = c; 282270: 38246861 strb w1, [x3, x4] 282274: 91000484 add x4, x4, #0x1 282278: 17fffff6 b 282250 <memset+0x44>
000000000028227c<memcpy>:__usedvoid *memcpy(void *dest, const void *src, size_t count){ unsigned long *dl = (unsigned long *)dest, *sl = (unsigned long *)src; char *d8, *s8; if (src == dest) 28227c: eb01001f cmp x0, x1 282280: 54000100 b.eq 2822a0 <memcpy+0x24> // b.none return dest; /* while all data is aligned (common case), copy a word at a time */ if ( (((ulong)dest | (ulong)src) & (sizeof(*dl) - 1)) == 0) { 282284: aa010003 orr x3, x0, x1 282288: f2400863 ands x3, x3, #0x7 28228c: 54000120 b.eq 2822b0 <memcpy+0x34> // b.none 282290: aa0003e4 mov x4, x0 282294: d2800003 mov x3, #0x0 // #0 } } /* copy the reset one byte at a time */ d8 = (char *)dl; s8 = (char *)sl; while (count--) 282298: eb03005f cmp x2, x3 28229c: 540001e1 b.ne 2822d8 <memcpy+0x5c> // b.any *d8++ = *s8++; return dest; } 2822a0: d65f03c0 ret *dl++ = *sl++; 2822a4: f8636824 ldr x4, [x1, x3] 2822a8: f8236804 str x4, [x0, x3] count -= sizeof(*dl); 2822ac: 91002063 add x3, x3, #0x8 while (count >= sizeof(*dl)) { 2822b0: cb030044 sub x4, x2, x3 2822b4: f1001c9f cmp x4, #0x7 2822b8: 54ffff68 b.hi 2822a4 <memcpy+0x28> // b.pmore 2822bc: d343fc43 lsr x3, x2, #3 2822c0: 928000e4 mov x4, #0xfffffffffffffff8 // #-8 2822c4: 9b047c63 mul x3, x3, x4 2822c8: 8b030042 add x2, x2, x3 2822cc: cb030004 sub x4, x0, x3 2822d0: cb030021 sub x1, x1, x3 2822d4: 17fffff0 b 282294 <memcpy+0x18> *d8++ = *s8++; 2822d8: 38636825 ldrb w5, [x1, x3] 2822dc: 38236885 strb w5, [x4, x3] 2822e0: 91000463 add x3, x3, #0x1 2822e4: 17ffffed b 282298 <memcpy+0x1c>I tried enabling
CONFIG_USE_ARCH_MEMCPY=y,CONFIG_USE_ARCH_MEMSET=yin the .config (but leaving it disabled in SPL/TPL) and it results in Synchronous Abort:
U-Boot SPL 2024.04 (Apr 02 2024 - 10:58:58 +0000)
Trying to boot from MMC1NOTICE: BL31: v1.3(release):8f40012ab NOTICE: BL31: Built : 14:20:53, Feb 16 2023 NOTICE: BL31: Rockchip release version: v1.1 INFO: GICv3 with legacy support detected. ARM GICV3 driver initialized in EL3 INFO: Using opteed sec cpu_context! INFO: boot cpu mask: 0 INFO: plat_rockchip_pmu_init(1203): pd status 3e INFO: BL31: Initializing runtime services WARNING: No OPTEE provided by BL2 boot loader, Booting device without OPTEE initialization. SMC`s destined for OPTEE will return SMC_UNK ERROR: Error initializing runtime service opteed_fast INFO: BL31: Preparing for EL3 exit to normal world INFO: Entry point address = 0x200000 INFO: SPSR = 0x3c9"Synchronous Abort" handler, esr
0x96000021, far0x2957e1
elr:000000000020233clr :000000000026a388
x0 :00000000002fbf38x1 :00000000002957e1
x2 : 0000000000000008 x3 : 0000000000000065
x4 :00000000002957e9x5 :00000000002fbf40
x6 : 0000000000000065 x7 : 0000000000000003
x8 :00000000002c7960x9 :000000000000ffd0
x10:00000000002fbc5cx11:00000000000132e8
x12:00000000002fbce8x13:00000000002c7960
x14:00000000002c7960x15: 0000000000000000
x16: 0000000000000000 x17: 0000000000000000
x18:00000000002fbe30x19: 0000000000000007
x20:00000000002957d8x21: 0000000000000009
x22:000000000029d189x23: 0000000000000020
x24:00000000002fbf38x25:00000000002957e7
x26:00000000002957b2x27:0000000000007fff
x28: 0000000000000000 x29:00000000002fbcc0Code: a9001c06 a93f34ac d65f03c0 361800c2 (f9400026)Resetting CPU ...
resetting ...
Thanks,
Gao XiangRegards,
Jonathan
Re: [PATCH v4 2/5] lib/lz4: update LZ4 decompressor module
Quoted 10 lines · Jonathan Liu
Hi Jianan,
Here are the LZ4 decompression times I got running "time unlz4 ..." on Rock 4 SE with RK3399 CPU.
v2024.04: 1.329 seconds
v2024.04 with26c7fdadcb7("lib/lz4: update LZ4 decompressor module")
reverted: 0.665 seconds
v2024.04 with your patch: 1.216 seconds
Quoted 6 lines
I managed to get better performance by optimizing it myself. v2024.04 with my patch: 0.785 seconds
With my patch, it makes no difference if I use
__builtin_memcpyor memcpy inlz4.candlz4_wrapper.cso I just left it using memcpy. It is still slower than reverting the LZ4 update though.
I'm not sure what's the old version come from, but from the copyright itself it seems some earlier 2015 version. Note that there is no absolute outperform between old version and new version, old version may be lack of some necessary boundary check or lead to some msan warning or something, like a new commit of year 2016:
https://github.com/lz4/lz4/commit/f094f531441140f10fd461ba769f49d10f5cd581
/* costs ~1%; silence an msan warning when offset == 0 */
/*
* note : when partialDecoding, there is no guarantee that
* at least 4 bytes remain available in output buffer
*/
if (!partialDecoding) {
assert(oend > op);
assert(oend - op >= 4);
LZ4_write32(op, (U32)offset);
}For the example above, you could completely remove the line above if you don't care about such warning, as it claims ~1% performance loss.
Also since no u-boot user uses in-place decompression and if you memmove() doesn't behave well, you could update the following line
/* * supports overlapping memory regions; only matters * for in-place decompression scenarios */ memmove(op, ip, length);
into memcpy() instead.
The new lz4 codebase relies on memcpy() / memmove() code optimization more than old version, if memcpy() assembly doesn't generate well on your platform, it might have some issue.
Thanks,
Gao Xiang
Quoted 359 lines
My patch:
lib/lz4.c +18
-5@@ -41,6 +41,16 @@ static FORCE_INLINE u16 LZ4_readLE16(const void *src)return get_unaligned_le16 (src); } +static FORCE_INLINE void LZ4_copy2(void *dst, const void *src) +{ +put_unaligned (get_unaligned ((const u16 *)src), (u16 *)dst); +} + +static FORCE_INLINE void LZ4_copy4(void *dst, const void *src) +{ +put_unaligned (get_unaligned ((const u32 *)src), (u32 *)dst); +} + static FORCE_INLINE void LZ4_copy8(void *dst, const void *src) {put_unaligned (get_unaligned ((const u64 *)src), (u64 *)dst);@@ -215,7 +225,10 @@ static FORCE_INLINE int LZ4_decompress_generic( && likely((endOnInput ? ip < shortiend : 1) & (op <= shortoend))) {/* Copy the literals */ -memcpy (op, ip, endOnInput ?16 :8 ); +LZ4_copy8 (op, ip); +if (endOnInput) +LZ4_copy8 (op +8 , ip +8 ); + op += length; ip += length;/* @@ -234,9 +247,9 @@ static FORCE_INLINE int LZ4_decompress_generic( (offset >= 8) && (dict == withPrefix64k || match >= lowPrefix)) {/* Copy the match. */ -memcpy (op +0 , match +0 ,8 ); -memcpy (op +8 , match +8 ,8 ); -memcpy (op +16 , match +16 ,2 ); +LZ4_copy8 (op, match); +LZ4_copy8 (op +8 , match +8 ); +LZ4_copy2 (op +16 , match +16 ); op += length +MINMATCH ;/* Both stages worked, load the next token. */ continue ;@@ -466,7 +479,7 @@ _copy_match: op[2 ] = match[2 ]; op[3 ] = match[3 ]; match += inc32table[offset]; -memcpy (op +4 , match,4 ); +LZ4_copy4 (op +4 , match); match -= dec64table[offset]; }else {LZ4_copy8 (op, match);Let me know if you have any further suggestions.
Thanks.
Regards,
JonathanQuoted 295 lines · Jianan Huang
Hi Jonathan,
Could you please try the following patch ? It replaces all
memcpy()calls in lz4 with__builtin_memcpy().lib/lz4.c +10
-8@@ -34,6 +34,8 @@#include <asm/unaligned.h> #include <u-boot/lz4.h> +#define LZ4_memcpy (dst, src, size) __builtin_memcpy(dst, src, size) +#define FORCE_INLINE inline __attribute__((always_inline)) static FORCE_INLINE u16 LZ4_readLE16(const void *src)@@ -215,7 +217,7 @@ static FORCE_INLINE int LZ4_decompress_generic( && likely((endOnInput ? ip < shortiend : 1) & (op <= shortoend))) {/* Copy the literals */ -memcpy (op, ip, endOnInput ?16 :8 ); +LZ4_memcpy (op, ip, endOnInput ?16 :8 ); op += length; ip += length;/* @@ -234,9 +236,9 @@ static FORCE_INLINE int LZ4_decompress_generic( (offset >= 8) && (dict == withPrefix64k || match >= lowPrefix)) {/* Copy the match. */ -memcpy (op +0 , match +0 ,8 ); -memcpy (op +8 , match +8 ,8 ); -memcpy (op +16 , match +16 ,2 ); +LZ4_memcpy (op +0 , match +0 ,8 ); +LZ4_memcpy (op +8 , match +8 ,8 ); +LZ4_memcpy (op +16 , match +16 ,2 ); op += length +MINMATCH ;/* Both stages worked, load the next token. */ continue ;@@ -416,7 +418,7 @@ _copy_match:size_t const copySize = (size_t )(lowPrefix - match);size_t const restSize = length - copySize; -memcpy (op, dictEnd - copySize, copySize); +LZ4_memcpy (op, dictEnd - copySize, copySize); op += copySize;if (restSize > (size_t )(op - lowPrefix)) {/* overlap copy */ @@ -426,7 +428,7 @@ _copy_match:while (op < endOfMatch) *op++ = *copyFrom++; }else { -memcpy (op, lowPrefix, restSize); +LZ4_memcpy (op, lowPrefix, restSize); op += restSize; } }@@ -452,7 +454,7 @@ _copy_match:while (op < copyEnd) *op++ = *match++; }else { -memcpy (op, match, mlen); +LZ4_memcpy (op, match, mlen); } op = copyEnd;if (op == oend)@@ -466,7 +468,7 @@ _copy_match: op[2 ] = match[2 ]; op[3 ] = match[3 ]; match += inc32table[offset]; -memcpy (op +4 , match,4 ); +LZ4_memcpy (op +4 , match,4 ); match -= dec64table[offset]; }else {LZ4_copy8 (op, match);lib/lz4_wrapper.c +1
-1@@ -80,7 +80,7 @@ int ulz4fn(const void *src, size_t srcn, void *dst, size_t *dstn)if (block_header &LZ4F_BLOCKUNCOMPRESSED_FLAG ) {size_t size =min ((ptrdiff_t )block_size, (ptrdiff_t )(end - out)); -memcpy (out, in, size); +LZ4_memcpy (out, in, size); out += size;if (size < block_size) { ret = -ENOBUFS ;/* output overrun */ Thanks,
Jianan
On 2024/5/26 16:06, Jonathan Liu wrote:
Hi Gao,
On Sat, 25 May 2024 at 02:52, Gao Xiang <[email protected]> wrote:
Hi,
On 2024/5/24 22:26, Jonathan Liu wrote:
Hi Jianan,
On Sat, 26 Feb 2022 at 18:05, Huang Jianan <[email protected]> wrote:
Update the LZ4 compression module based on LZ4 v1.8.3 in order to use the newest
LZ4_decompress_safe_partial()which can now decode exactly the nb of bytes requested.Signed-off-by Huang Jianan <[email protected]>I noticed after this commit LZ4 decompression is slower.
ulz4fn function call takes 1.209670 seconds with this commit. After reverting this commit, the ulz4fn function call takes 0.587032 seconds.I am decompressing a LZ4 compressed kernel (compressed with lz4 v1.9.4 using -9 option for maximum compression) on RK3399.
Any ideas why it is slower with this commit and how the performance regression can be fixed?
Just the quick glance, I think the issue may be due to memcpy/memmove since it seems the main difference between these two codebases (I'm not sure which LZ4 version the old codebase was based on) and the new version mainly relies on memcpy/memmove instead of its own versions.
Would you mind to check the assembly how memcpy/memset is generated on your platform?
Here is the assembly (-mcpu=cortex-a72.cortex-a53 -march=armv8-a+crc+crypto):
000000000028220c<memset>:#if !CONFIG_IS_ENABLED(TINY_MEMSET) unsigned long cl = 0; int i; /* do it one word at a time (32 bits or 64 bits) while possible */ if ( ((ulong)s & (sizeof(*sl) - 1)) == 0) { 28220c: f2400803 ands x3, x0, #0x7 282210: 540002c1 b.ne 282268 <memset+0x5c> // b.any for (i = 0; i < sizeof(*sl); i++) { cl <<= 8; cl |= c & 0xff; 282214: 92401c26 and x6, x1, #0xff unsigned long cl = 0; 282218: d2800004 mov x4, #0x0 // #0 28221c: 52800105 mov w5, #0x8 // #8 cl |= c & 0xff; 282220: aa0420c4 orr x4, x6, x4, lsl #8 for (i = 0; i < sizeof(*sl); i++) { 282224: 710004a5 subs w5, w5, #0x1 282228: 54ffffc1 b.ne 282220 <memset+0x14> // b.any } while (count >= sizeof(*sl)) { 28222c: cb030045 sub x5, x2, x3 282230: f1001cbf cmp x5, #0x7 282234: 54000148 b.hi 28225c <memset+0x50> // b.pmore 282238: d343fc43 lsr x3, x2, #3 28223c: 928000e4 mov x4, #0xfffffffffffffff8 // #-8 282240: 9b047c63 mul x3, x3, x4 282244: 8b030042 add x2, x2, x3 282248: cb030003 sub x3, x0, x3 unsigned long *sl = (unsigned long *) s; 28224c: d2800004 mov x4, #0x0 // #0 count -= sizeof(*sl); } } #endif /* fill 8 bits at a time */ s8 = (char *)sl; while (count--) 282250: eb04005f cmp x2, x4 282254: 540000e1 b.ne 282270 <memset+0x64> // b.any *s8++ = c; return s; } 282258: d65f03c0 ret *sl++ = cl; 28225c: f8236804 str x4, [x0, x3] count -= sizeof(*sl); 282260: 91002063 add x3, x3, #0x8 282264: 17fffff2 b 28222c <memset+0x20> unsigned long *sl = (unsigned long *) s; 282268: aa0003e3 mov x3, x0 28226c: 17fffff8 b 28224c <memset+0x40> *s8++ = c; 282270: 38246861 strb w1, [x3, x4] 282274: 91000484 add x4, x4, #0x1 282278: 17fffff6 b 282250 <memset+0x44>
000000000028227c<memcpy>:__usedvoid *memcpy(void *dest, const void *src, size_t count){ unsigned long *dl = (unsigned long *)dest, *sl = (unsigned long *)src; char *d8, *s8; if (src == dest) 28227c: eb01001f cmp x0, x1 282280: 54000100 b.eq 2822a0 <memcpy+0x24> // b.none return dest; /* while all data is aligned (common case), copy a word at a time */ if ( (((ulong)dest | (ulong)src) & (sizeof(*dl) - 1)) == 0) { 282284: aa010003 orr x3, x0, x1 282288: f2400863 ands x3, x3, #0x7 28228c: 54000120 b.eq 2822b0 <memcpy+0x34> // b.none 282290: aa0003e4 mov x4, x0 282294: d2800003 mov x3, #0x0 // #0 } } /* copy the reset one byte at a time */ d8 = (char *)dl; s8 = (char *)sl; while (count--) 282298: eb03005f cmp x2, x3 28229c: 540001e1 b.ne 2822d8 <memcpy+0x5c> // b.any *d8++ = *s8++; return dest; } 2822a0: d65f03c0 ret *dl++ = *sl++; 2822a4: f8636824 ldr x4, [x1, x3] 2822a8: f8236804 str x4, [x0, x3] count -= sizeof(*dl); 2822ac: 91002063 add x3, x3, #0x8 while (count >= sizeof(*dl)) { 2822b0: cb030044 sub x4, x2, x3 2822b4: f1001c9f cmp x4, #0x7 2822b8: 54ffff68 b.hi 2822a4 <memcpy+0x28> // b.pmore 2822bc: d343fc43 lsr x3, x2, #3 2822c0: 928000e4 mov x4, #0xfffffffffffffff8 // #-8 2822c4: 9b047c63 mul x3, x3, x4 2822c8: 8b030042 add x2, x2, x3 2822cc: cb030004 sub x4, x0, x3 2822d0: cb030021 sub x1, x1, x3 2822d4: 17fffff0 b 282294 <memcpy+0x18> *d8++ = *s8++; 2822d8: 38636825 ldrb w5, [x1, x3] 2822dc: 38236885 strb w5, [x4, x3] 2822e0: 91000463 add x3, x3, #0x1 2822e4: 17ffffed b 282298 <memcpy+0x1c>I tried enabling
CONFIG_USE_ARCH_MEMCPY=y,CONFIG_USE_ARCH_MEMSET=yin the .config (but leaving it disabled in SPL/TPL) and it results in Synchronous Abort:
U-Boot SPL 2024.04 (Apr 02 2024 - 10:58:58 +0000)
Trying to boot from MMC1NOTICE: BL31: v1.3(release):8f40012ab NOTICE: BL31: Built : 14:20:53, Feb 16 2023 NOTICE: BL31: Rockchip release version: v1.1 INFO: GICv3 with legacy support detected. ARM GICV3 driver initialized in EL3 INFO: Using opteed sec cpu_context! INFO: boot cpu mask: 0 INFO: plat_rockchip_pmu_init(1203): pd status 3e INFO: BL31: Initializing runtime services WARNING: No OPTEE provided by BL2 boot loader, Booting device without OPTEE initialization. SMC`s destined for OPTEE will return SMC_UNK ERROR: Error initializing runtime service opteed_fast INFO: BL31: Preparing for EL3 exit to normal world INFO: Entry point address = 0x200000 INFO: SPSR = 0x3c9"Synchronous Abort" handler, esr
0x96000021, far0x2957e1
elr:000000000020233clr :000000000026a388
x0 :00000000002fbf38x1 :00000000002957e1
x2 : 0000000000000008 x3 : 0000000000000065
x4 :00000000002957e9x5 :00000000002fbf40
x6 : 0000000000000065 x7 : 0000000000000003
x8 :00000000002c7960x9 :000000000000ffd0
x10:00000000002fbc5cx11:00000000000132e8
x12:00000000002fbce8x13:00000000002c7960
x14:00000000002c7960x15: 0000000000000000
x16: 0000000000000000 x17: 0000000000000000
x18:00000000002fbe30x19: 0000000000000007
x20:00000000002957d8x21: 0000000000000009
x22:000000000029d189x23: 0000000000000020
x24:00000000002fbf38x25:00000000002957e7
x26:00000000002957b2x27:0000000000007fff
x28: 0000000000000000 x29:00000000002fbcc0Code: a9001c06 a93f34ac d65f03c0 361800c2 (f9400026)Resetting CPU ...
resetting ...
Thanks,
Gao XiangRegards,
Jonathan
PATCH v4 3/5 fs/erofs: add lz4 decompression support
In reply to Huang JiananSupport EROFS lz4 compressed files.
--- fs/erofs/Kconfig | 9 + fs/erofs/Makefile | 4 +- fs/erofs/data.c | 90 ++++++- fs/erofs/decompress.c | 78 ++++++ fs/erofs/decompress.h | 24 ++ fs/erofs/namei.c | 2 +- fs/erofs/zmap.c | 601 ++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 805 insertions(+), 3 deletions(-) create mode 100644 fs/erofs/decompress.c create mode 100644 fs/erofs/decompress.h create mode 100644 fs/erofs/zmap.c
fs/erofs/Kconfig +9 -0
@@ -10,3 +10,12 @@ config FS_EROFS improves storage density, keeps relatively higher compression ratios, which is more useful to achieve high performance for embedded devices with limited memory. + +config FS_EROFS_ZIP + bool "EROFS Data Compression Support" + depends on FS_EROFS + select LZ4 + default y + help + Enable fixed-sized output compression for EROFS. + If you don't want to enable compression feature, say N.
fs/erofs/Makefile +3 -1
@@ -4,4 +4,6 @@ obj-$(CONFIG_$(SPL_)FS_EROFS) = fs.o \ super.o \ namei.o \ - data.o + data.o \ + decompress.o \ + zmap.o
fs/erofs/data.c +89 -1
107 lines not on this page · raw message
fs/erofs/decompress.c new file +78 -0
78 lines not on this page · raw message
fs/erofs/decompress.h new file +24 -0
@@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +#ifndef __EROFS_DECOMPRESS_H +#define __EROFS_DECOMPRESS_H + +#include "internal.h" + +struct z_erofs_decompress_req { +char *in, *out; + +/* +* initial decompressed bytes that need to be skipped +* when finally copying to output buffer +*/ +unsigned int decodedskip; +unsigned int inputsize, decodedlength; + +/* indicate the algorithm will be used for decompression */ +unsigned int alg; +bool partial_decoding; +}; + +int z_erofs_decompress (struct z_erofs_decompress_req *rq); + +#endif
fs/erofs/namei.c +1 -1
@@ -114,7 +114,7 @@ int erofs_read_inode_from_disk(struct erofs_inode *vi) vi->u.chunkbits =LOG_BLOCK_SIZE + (vi->u.chunkformat &EROFS_CHUNK_FORMAT_BLKBITS_MASK ); }else if (erofs_inode_is_data_compressed (vi->datalayout)) -return -EOPNOTSUPP ; +z_erofs_fill_inode (vi);return 0 ; bogusimode:erofs_err ("bogus i_mode (%o) @ nid %llu" , vi->i_mode, vi->nid |0ULL );
fs/erofs/zmap.c new file +601 -0
601 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH v4 3/5] fs/erofs: add lz4 decompression support
Quoted 3 lines · Huang Jianan
Support EROFS lz4 compressed files.
Signed-off-by Huang Jianan <[email protected]>
Applied to u-boot/next, thanks!
Signature · 1 line
Tom
PATCH v4 4/5 fs/erofs: add filesystem commands
In reply to Huang JiananAdd 'ls' and 'load' commands.
--- MAINTAINERS | 1 + cmd/Kconfig | 6 ++++++ cmd/Makefile | 1 + cmd/erofs.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 50 insertions(+) create mode 100644 cmd/erofs.c
MAINTAINERS +1 -0
@@ -812,6 +812,7 @@ EROFS M: Huang Jianan <[email protected]> L: [email protected] S: Maintained +F: cmd/erofs.c F: fs/erofs/ F: include/erofs.h
cmd/Kconfig +6 -0
@@ -2176,6 +2176,12 @@ config CMD_CRAMFS cramfsls - lists files in a cramfs image cramfsload - loads a file from a cramfs image +config CMD_EROFS + bool "EROFS command support" + select FS_EROFS + help + Support for the EROFS fs + config CMD_EXT2 bool "ext2 command support" select FS_EXT4
cmd/Makefile +1 -0
@@ -60,6 +60,7 @@ obj-$(CONFIG_CMD_EEPROM) += eeprom.o obj-$(CONFIG_EFI) += efi.o obj-$(CONFIG_CMD_EFIDEBUG) += efidebug.o obj-$(CONFIG_CMD_ELF) += elf.o +obj-$(CONFIG_CMD_EROFS) += erofs.o obj-$(CONFIG_HUSH_PARSER) += exit.o obj-$(CONFIG_CMD_EXT4) += ext4.o obj-$(CONFIG_CMD_EXT2) += ext2.o
cmd/erofs.c new file +42 -0
42 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH v4 4/5] fs/erofs: add filesystem commands
Quoted 3 lines · Huang Jianan
Add 'ls' and 'load' commands.
Signed-off-by Huang Jianan <[email protected]>
Applied to u-boot/next, thanks!
Signature · 1 line
Tom
PATCH v4 5/5 test/py: Add tests for the erofs
In reply to Huang JiananAdd Python scripts to test 'ls' and 'load' commands, as well as test related filesystem functions.
--- MAINTAINERS | 1 + configs/sandbox_defconfig | 1 + test/py/tests/test_fs/test_erofs.py | 211 ++++++++++++++++++++++++++++ tools/docker/Dockerfile | 1 + 4 files changed, 214 insertions(+) create mode 100644 test/py/tests/test_fs/test_erofs.py
MAINTAINERS +1 -0
@@ -815,6 +815,7 @@ S: Maintained F: cmd/erofs.c F: fs/erofs/ F: include/erofs.h +F: test/py/tests/test_fs/test_erofs.py FASTBOOT S: Orphaned
configs/sandbox_defconfig +1 -0
@@ -105,6 +105,7 @@ CONFIG_CMD_TPM_TEST=y CONFIG_CMD_BTRFS=y CONFIG_CMD_CBFS=y CONFIG_CMD_CRAMFS=y +CONFIG_CMD_EROFS=y CONFIG_CMD_EXT4_WRITE=y CONFIG_CMD_SQUASHFS=y CONFIG_CMD_MTDPARTS=y
test/py/tests/test_fs/test_erofs.py new file +211 -0
211 lines not on this page · raw message
tools/docker/Dockerfile +1 -0
@@ -48,6 +48,7 @@ RUN apt-get update && apt-get install -y \ dosfstools \ e2fsprogs \ efitools \ + erofs-utils \ expect \ fakeroot \ flex \
Signature · 1 line
2.25.1
Re: [PATCH v4 5/5] test/py: Add tests for the erofs
Quoted 4 lines · Huang Jianan
Add Python scripts to test 'ls' and 'load' commands, as well as test related filesystem functions.
Signed-off-by Huang Jianan <[email protected]>
Applied to u-boot/next, thanks!
Signature · 1 line
Tom
Hi Tom,
Would you mind taking some time to check if this version meets the requirements ?So we could have a chance to be merged into the next version ?
I have triggered a CI via Github PR based on this version :
https://github.com/u-boot/u-boot/pull/133
Thanks,
Jianan
Quoted 61 lines · Huang Jianan
Changes since v3:
- updatetools/docker/Dockerfile;Changes since v2:
- sync up with erofs-utils 1.4;
- update lib/lz4 to v1.8.3;
- add test for filesystem functions;Changes since v1:
- fix the inconsistency between From and SoB;
- add missing license header;Huang Jianan (5):
fs/erofs: add erofs filesystem support
lib/lz4: update LZ4 decompressor module
fs/erofs: add lz4 decompression support
fs/erofs: add filesystem commands
test/py: Add tests for the erofsMAINTAINERS | 9 + cmd/Kconfig | 6 + cmd/Makefile | 1 + cmd/erofs.c | 42 ++ configs/sandbox_defconfig | 1 + fs/Kconfig | 2 + fs/Makefile | 1 + fs/erofs/Kconfig | 21 + fs/erofs/Makefile | 9 + fs/erofs/data.c | 311 +++++++++++++ fs/erofs/decompress.c | 78 ++++ fs/erofs/decompress.h | 24 + fs/erofs/erofs_fs.h | 436 ++++++++++++++++++ fs/erofs/fs.c | 267 +++++++++++ fs/erofs/internal.h | 313 +++++++++++++ fs/erofs/namei.c | 252 +++++++++++ fs/erofs/super.c | 105 +++++ fs/erofs/zmap.c | 601 ++++++++++++++++++++++++ fs/fs.c | 22 + include/erofs.h | 19 + include/fs.h | 1 + include/u-boot/lz4.h | 49 ++ lib/lz4.c | 679 ++++++++++++++++++++-------- lib/lz4_wrapper.c | 23 +- test/py/tests/test_fs/test_erofs.py | 211 +++++++++ tools/docker/Dockerfile | 1 + 26 files changed, 3269 insertions(+), 215 deletions(-)create mode 100644
cmd/erofs.c
create mode 100644fs/erofs/Kconfig
create mode 100644fs/erofs/Makefile
create mode 100644fs/erofs/data.c
create mode 100644fs/erofs/decompress.ccreate mode 100644fs/erofs/decompress.hcreate mode 100644fs/erofs/erofs_fs.h
create mode 100644fs/erofs/fs.c
create mode 100644fs/erofs/internal.h
create mode 100644fs/erofs/namei.c
create mode 100644fs/erofs/super.c
create mode 100644fs/erofs/zmap.c
create mode 100644include/erofs.h
create mode 100644test/py/tests/test_fs/test_erofs.py
Quoted 8 lines · Huang Jianan
Hi Tom,
Would you mind taking some time to check if this version meets the requirements ?So we could have a chance to be merged into the next version ?
I have triggered a CI via Github PR based on this version :
https://github.com/u-boot/u-boot/pull/133
It seems fine, yes. The thing about that PR is that it doesn't use a custom build of the Docker container that also has the tools, so the FS tests aren't actually run. I'll do that when I get to testing and applying this, but if you can do that before hand to ensure the tests really do run and pass, especially on Azure where things can be a tiny bit trickier (since source directory is enforced read-only), that would be great.
Quoted 67 lines
Thanks,
JiananQuoted 61 lines · Huang Jianan
Changes since v3:
- updatetools/docker/Dockerfile;Changes since v2:
- sync up with erofs-utils 1.4;
- update lib/lz4 to v1.8.3;
- add test for filesystem functions;Changes since v1:
- fix the inconsistency between From and SoB;
- add missing license header;Huang Jianan (5):
fs/erofs: add erofs filesystem support
lib/lz4: update LZ4 decompressor module
fs/erofs: add lz4 decompression support
fs/erofs: add filesystem commands
test/py: Add tests for the erofsMAINTAINERS | 9 + cmd/Kconfig | 6 + cmd/Makefile | 1 + cmd/erofs.c | 42 ++ configs/sandbox_defconfig | 1 + fs/Kconfig | 2 + fs/Makefile | 1 + fs/erofs/Kconfig | 21 + fs/erofs/Makefile | 9 + fs/erofs/data.c | 311 +++++++++++++ fs/erofs/decompress.c | 78 ++++ fs/erofs/decompress.h | 24 + fs/erofs/erofs_fs.h | 436 ++++++++++++++++++ fs/erofs/fs.c | 267 +++++++++++ fs/erofs/internal.h | 313 +++++++++++++ fs/erofs/namei.c | 252 +++++++++++ fs/erofs/super.c | 105 +++++ fs/erofs/zmap.c | 601 ++++++++++++++++++++++++ fs/fs.c | 22 + include/erofs.h | 19 + include/fs.h | 1 + include/u-boot/lz4.h | 49 ++ lib/lz4.c | 679 ++++++++++++++++++++-------- lib/lz4_wrapper.c | 23 +- test/py/tests/test_fs/test_erofs.py | 211 +++++++++ tools/docker/Dockerfile | 1 + 26 files changed, 3269 insertions(+), 215 deletions(-)create mode 100644
cmd/erofs.c
create mode 100644fs/erofs/Kconfig
create mode 100644fs/erofs/Makefile
create mode 100644fs/erofs/data.c
create mode 100644fs/erofs/decompress.ccreate mode 100644fs/erofs/decompress.hcreate mode 100644fs/erofs/erofs_fs.h
create mode 100644fs/erofs/fs.c
create mode 100644fs/erofs/internal.h
create mode 100644fs/erofs/namei.c
create mode 100644fs/erofs/super.c
create mode 100644fs/erofs/zmap.c
create mode 100644include/erofs.h
create mode 100644test/py/tests/test_fs/test_erofs.py
Signature · 1 line
Tom
Quoted 10 lines · Tom Rini
Quoted 8 lines · Huang Jianan
Hi Tom,
Would you mind taking some time to check if this version meets the requirements ?So we could have a chance to be merged into the next version ?
I have triggered a CI via Github PR based on this version :
https://github.com/u-boot/u-boot/pull/133
Quoted 7 lines
It seems fine, yes. The thing about that PR is that it doesn't use a custom build of the Docker container that also has the tools, so the FS tests aren't actually run. I'll do that when I get to testing and applying this, but if you can do that before hand to ensure the tests really do run and pass, especially on Azure where things can be a tiny bit trickier (since source directory is enforced read-only), that would be great.
I verified the test on my own machine, but I overlooked that the container used in CI is prebuilt ...
I replaced the container in the .azure-pipelines.yml with my own build and re-triggered the CI on this PR. Now I can see from the log that the newly added test_erofs is working properly.
Thanks,
Jianan
Quoted 65 lines
Quoted 65 lines
Thanks,
JiananQuoted 61 lines · Huang Jianan
Changes since v3:
- updatetools/docker/Dockerfile;Changes since v2:
- sync up with erofs-utils 1.4;
- update lib/lz4 to v1.8.3;
- add test for filesystem functions;Changes since v1:
- fix the inconsistency between From and SoB;
- add missing license header;Huang Jianan (5):
fs/erofs: add erofs filesystem support
lib/lz4: update LZ4 decompressor module
fs/erofs: add lz4 decompression support
fs/erofs: add filesystem commands
test/py: Add tests for the erofsMAINTAINERS | 9 + cmd/Kconfig | 6 + cmd/Makefile | 1 + cmd/erofs.c | 42 ++ configs/sandbox_defconfig | 1 + fs/Kconfig | 2 + fs/Makefile | 1 + fs/erofs/Kconfig | 21 + fs/erofs/Makefile | 9 + fs/erofs/data.c | 311 +++++++++++++ fs/erofs/decompress.c | 78 ++++ fs/erofs/decompress.h | 24 + fs/erofs/erofs_fs.h | 436 ++++++++++++++++++ fs/erofs/fs.c | 267 +++++++++++ fs/erofs/internal.h | 313 +++++++++++++ fs/erofs/namei.c | 252 +++++++++++ fs/erofs/super.c | 105 +++++ fs/erofs/zmap.c | 601 ++++++++++++++++++++++++ fs/fs.c | 22 + include/erofs.h | 19 + include/fs.h | 1 + include/u-boot/lz4.h | 49 ++ lib/lz4.c | 679 ++++++++++++++++++++-------- lib/lz4_wrapper.c | 23 +- test/py/tests/test_fs/test_erofs.py | 211 +++++++++ tools/docker/Dockerfile | 1 + 26 files changed, 3269 insertions(+), 215 deletions(-)create mode 100644
cmd/erofs.c
create mode 100644fs/erofs/Kconfig
create mode 100644fs/erofs/Makefile
create mode 100644fs/erofs/data.c
create mode 100644fs/erofs/decompress.ccreate mode 100644fs/erofs/decompress.hcreate mode 100644fs/erofs/erofs_fs.h
create mode 100644fs/erofs/fs.c
create mode 100644fs/erofs/internal.h
create mode 100644fs/erofs/namei.c
create mode 100644fs/erofs/super.c
create mode 100644fs/erofs/zmap.c
create mode 100644include/erofs.h
create mode 100644test/py/tests/test_fs/test_erofs.py
Quoted 20 lines · Huang Jianan
Quoted 10 lines · Tom Rini
Quoted 8 lines · Huang Jianan
Hi Tom,
Would you mind taking some time to check if this version meets the requirements ?So we could have a chance to be merged into the next version ?
I have triggered a CI via Github PR based on this version :
https://github.com/u-boot/u-boot/pull/133Quoted 7 lines
It seems fine, yes. The thing about that PR is that it doesn't use a custom build of the Docker container that also has the tools, so the FS tests aren't actually run. I'll do that when I get to testing and applying this, but if you can do that before hand to ensure the tests really do run and pass, especially on Azure where things can be a tiny bit trickier (since source directory is enforced read-only), that would be great.
Quoted 5 lines
I verified the test on my own machine, but I overlooked that the container used in CI is prebuilt ...
I replaced the container in the .azure-pipelines.yml with my own build and re-triggered the CI on this PR. Now I can see from the log that the newly addedtest_erofsis working properly.
Great, thanks for confirming!
Signature · 1 line
Tom