forked from HUAWEI-y550/android_kernel_huawei_msm8916
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
decompressor: add LZ4 decompressor module
Add support for LZ4 decompression in the Linux Kernel. LZ4 Decompression APIs for kernel are based on LZ4 implementation by Yann Collet. Benchmark Results(PATCH v3) Compiler: Linaro ARM gcc 4.6.2 1. ARMv7, 1.5GHz based board Kernel: linux 3.4 Uncompressed Kernel Size: 14MB Compressed Size Decompression Speed LZO 6.7MB 20.1MB/s, 25.2MB/s(UA) LZ4 7.3MB 29.1MB/s, 45.6MB/s(UA) 2. ARMv7, 1.7GHz based board Kernel: linux 3.7 Uncompressed Kernel Size: 14MB Compressed Size Decompression Speed LZO 6.0MB 34.1MB/s, 52.2MB/s(UA) LZ4 6.5MB 86.7MB/s - UA: Unaligned memory Access support - Latest patch set for LZO applied This patch set is for adding support for LZ4-compressed Kernel. LZ4 is a very fast lossless compression algorithm and it also features an extremely fast decoder [1]. But we have five of decompressors already and one question which does arise, however, is that of where do we stop adding new ones? This issue had been discussed and came to the conclusion [2]. Russell King said that we should have: - one decompressor which is the fastest - one decompressor for the highest compression ratio - one popular decompressor (eg conventional gzip) If we have a replacement one for one of these, then it should do exactly that: replace it. The benchmark shows that an 8% increase in image size vs a 66% increase in decompression speed compared to LZO(which has been known as the fastest decompressor in the Kernel). Therefore the "fast but may not be small" compression title has clearly been taken by LZ4 [3]. [1] http://code.google.com/p/lz4/ [2] http://thread.gmane.org/gmane.linux.kbuild.devel/9157 [3] http://thread.gmane.org/gmane.linux.kbuild.devel/9347 LZ4 homepage: http://fastcompression.blogspot.com/p/lz4.html LZ4 source repository: http://code.google.com/p/lz4/ Change-Id: Ib7d1226ac0facea4c66f3ff50661242294ba6746 Signed-off-by: Kyungsik Lee <[email protected]> Signed-off-by: Yann Collet <[email protected]> Cc: "H. Peter Anvin" <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Russell King <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Florian Fainelli <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
- Loading branch information
1 parent
450b22e
commit e51b25d
Showing
3 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
/* | ||
* LZ4 Decompressor for Linux kernel | ||
* | ||
<<<<<<< HEAD | ||
* Copyright (C) 2013, LG Electronics, Kyungsik Lee <[email protected]> | ||
======= | ||
* Copyright (C) 2013 LG Electronics Co., Ltd. (http://www.lge.com/) | ||
>>>>>>> e34e7be... decompressor: add LZ4 decompressor module | ||
* | ||
* Based on LZ4 implementation by Yann Collet. | ||
* | ||
|
@@ -72,8 +76,11 @@ static int lz4_uncompress(const char *source, char *dest, int osize) | |
len = *ip++; | ||
for (; len == 255; length += 255) | ||
len = *ip++; | ||
<<<<<<< HEAD | ||
if (unlikely(length > (size_t)(length + len))) | ||
goto _output_error; | ||
======= | ||
>>>>>>> e34e7be... decompressor: add LZ4 decompressor module | ||
length += len; | ||
} | ||
|
||
|
@@ -108,8 +115,11 @@ static int lz4_uncompress(const char *source, char *dest, int osize) | |
if (length == ML_MASK) { | ||
for (; *ip == 255; length += 255) | ||
ip++; | ||
<<<<<<< HEAD | ||
if (unlikely(length > (size_t)(length + *ip))) | ||
goto _output_error; | ||
======= | ||
>>>>>>> e34e7be... decompressor: add LZ4 decompressor module | ||
length += *ip++; | ||
} | ||
|
||
|
@@ -159,7 +169,11 @@ static int lz4_uncompress(const char *source, char *dest, int osize) | |
|
||
/* write overflow error detected */ | ||
_output_error: | ||
<<<<<<< HEAD | ||
return -1; | ||
======= | ||
return (int) (-(((char *)ip) - source)); | ||
>>>>>>> e34e7be... decompressor: add LZ4 decompressor module | ||
} | ||
|
||
static int lz4_uncompress_unknownoutputsize(const char *source, char *dest, | ||
|
@@ -192,8 +206,11 @@ static int lz4_uncompress_unknownoutputsize(const char *source, char *dest, | |
int s = 255; | ||
while ((ip < iend) && (s == 255)) { | ||
s = *ip++; | ||
<<<<<<< HEAD | ||
if (unlikely(length > (size_t)(length + s))) | ||
goto _output_error; | ||
======= | ||
>>>>>>> e34e7be... decompressor: add LZ4 decompressor module | ||
length += s; | ||
} | ||
} | ||
|
@@ -234,8 +251,11 @@ static int lz4_uncompress_unknownoutputsize(const char *source, char *dest, | |
if (length == ML_MASK) { | ||
while (ip < iend) { | ||
int s = *ip++; | ||
<<<<<<< HEAD | ||
if (unlikely(length > (size_t)(length + s))) | ||
goto _output_error; | ||
======= | ||
>>>>>>> e34e7be... decompressor: add LZ4 decompressor module | ||
length += s; | ||
if (s == 255) | ||
continue; | ||
|
@@ -288,11 +308,19 @@ static int lz4_uncompress_unknownoutputsize(const char *source, char *dest, | |
|
||
/* write overflow error detected */ | ||
_output_error: | ||
<<<<<<< HEAD | ||
return -1; | ||
} | ||
|
||
int lz4_decompress(const unsigned char *src, size_t *src_len, | ||
unsigned char *dest, size_t actual_dest_len) | ||
======= | ||
return (int) (-(((char *) ip) - source)); | ||
} | ||
|
||
int lz4_decompress(const char *src, size_t *src_len, char *dest, | ||
size_t actual_dest_len) | ||
>>>>>>> e34e7be... decompressor: add LZ4 decompressor module | ||
{ | ||
int ret = -1; | ||
int input_len = 0; | ||
|
@@ -307,11 +335,19 @@ int lz4_decompress(const unsigned char *src, size_t *src_len, | |
return ret; | ||
} | ||
#ifndef STATIC | ||
<<<<<<< HEAD | ||
EXPORT_SYMBOL(lz4_decompress); | ||
#endif | ||
|
||
int lz4_decompress_unknownoutputsize(const unsigned char *src, size_t src_len, | ||
unsigned char *dest, size_t *dest_len) | ||
======= | ||
EXPORT_SYMBOL_GPL(lz4_decompress); | ||
#endif | ||
|
||
int lz4_decompress_unknownoutputsize(const char *src, size_t src_len, | ||
char *dest, size_t *dest_len) | ||
>>>>>>> e34e7be... decompressor: add LZ4 decompressor module | ||
{ | ||
int ret = -1; | ||
int out_len = 0; | ||
|
@@ -327,8 +363,14 @@ int lz4_decompress_unknownoutputsize(const unsigned char *src, size_t src_len, | |
return ret; | ||
} | ||
#ifndef STATIC | ||
<<<<<<< HEAD | ||
EXPORT_SYMBOL(lz4_decompress_unknownoutputsize); | ||
|
||
MODULE_LICENSE("Dual BSD/GPL"); | ||
======= | ||
EXPORT_SYMBOL_GPL(lz4_decompress_unknownoutputsize); | ||
|
||
MODULE_LICENSE("GPL"); | ||
>>>>>>> e34e7be... decompressor: add LZ4 decompressor module | ||
MODULE_DESCRIPTION("LZ4 Decompressor"); | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters