mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-12-05 09:46:43 +07:00
4f3865fb57
Upgrade the zlib_inflate implementation in the kernel from a patched version 1.1.3/4 to a patched 1.2.3. The code in the kernel is about seven years old and I noticed that the external zlib library's inflate performance was significantly faster (~50%) than the code in the kernel on ARM (and faster again on x86_32). For comparison the newer deflate code is 20% slower on ARM and 50% slower on x86_32 but gives an approx 1% compression ratio improvement. I don't consider this to be an improvement for kernel use so have no plans to change the zlib_deflate code. Various changes have been made to the zlib code in the kernel, the most significant being the extra functions/flush option used by ppp_deflate. This update reimplements the features PPP needs to ensure it continues to work. This code has been tested on ARM under both JFFS2 (with zlib compression enabled) and ppp_deflate and on x86_32. JFFS2 sees an approx. 10% real world file read speed improvement. This patch also removes ZLIB_VERSION as it no longer has a correct value. We don't need version checks anyway as the kernel's module handling will take care of that for us. This removal is also more in keeping with the zlib author's wishes (http://www.zlib.net/zlib_faq.html#faq24) and I've added something to the zlib.h header to note its a modified version. Signed-off-by: Richard Purdie <rpurdie@rpsys.net> Acked-by: Joern Engel <joern@wh.fh-wedel.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
107 lines
2.7 KiB
C
107 lines
2.7 KiB
C
/* zutil.h -- internal interface and configuration of the compression library
|
|
* Copyright (C) 1995-1998 Jean-loup Gailly.
|
|
* For conditions of distribution and use, see copyright notice in zlib.h
|
|
*/
|
|
|
|
/* WARNING: this file should *not* be used by applications. It is
|
|
part of the implementation of the compression library and is
|
|
subject to change. Applications should only use zlib.h.
|
|
*/
|
|
|
|
/* @(#) $Id: zutil.h,v 1.1 2000/01/01 03:32:23 davem Exp $ */
|
|
|
|
#ifndef _Z_UTIL_H
|
|
#define _Z_UTIL_H
|
|
|
|
#include <linux/zlib.h>
|
|
#include <linux/string.h>
|
|
#include <linux/kernel.h>
|
|
|
|
typedef unsigned char uch;
|
|
typedef unsigned short ush;
|
|
typedef unsigned long ulg;
|
|
|
|
/* common constants */
|
|
|
|
#define STORED_BLOCK 0
|
|
#define STATIC_TREES 1
|
|
#define DYN_TREES 2
|
|
/* The three kinds of block type */
|
|
|
|
#define MIN_MATCH 3
|
|
#define MAX_MATCH 258
|
|
/* The minimum and maximum match lengths */
|
|
|
|
#define PRESET_DICT 0x20 /* preset dictionary flag in zlib header */
|
|
|
|
/* target dependencies */
|
|
|
|
/* Common defaults */
|
|
|
|
#ifndef OS_CODE
|
|
# define OS_CODE 0x03 /* assume Unix */
|
|
#endif
|
|
|
|
/* functions */
|
|
|
|
typedef uLong (*check_func) (uLong check, const Byte *buf,
|
|
uInt len);
|
|
|
|
|
|
/* checksum functions */
|
|
|
|
#define BASE 65521L /* largest prime smaller than 65536 */
|
|
#define NMAX 5552
|
|
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
|
|
|
|
#define DO1(buf,i) {s1 += buf[i]; s2 += s1;}
|
|
#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1);
|
|
#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2);
|
|
#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
|
|
#define DO16(buf) DO8(buf,0); DO8(buf,8);
|
|
|
|
/* ========================================================================= */
|
|
/*
|
|
Update a running Adler-32 checksum with the bytes buf[0..len-1] and
|
|
return the updated checksum. If buf is NULL, this function returns
|
|
the required initial value for the checksum.
|
|
An Adler-32 checksum is almost as reliable as a CRC32 but can be computed
|
|
much faster. Usage example:
|
|
|
|
uLong adler = adler32(0L, NULL, 0);
|
|
|
|
while (read_buffer(buffer, length) != EOF) {
|
|
adler = adler32(adler, buffer, length);
|
|
}
|
|
if (adler != original_adler) error();
|
|
*/
|
|
static inline uLong zlib_adler32(uLong adler,
|
|
const Byte *buf,
|
|
uInt len)
|
|
{
|
|
unsigned long s1 = adler & 0xffff;
|
|
unsigned long s2 = (adler >> 16) & 0xffff;
|
|
int k;
|
|
|
|
if (buf == NULL) return 1L;
|
|
|
|
while (len > 0) {
|
|
k = len < NMAX ? len : NMAX;
|
|
len -= k;
|
|
while (k >= 16) {
|
|
DO16(buf);
|
|
buf += 16;
|
|
k -= 16;
|
|
}
|
|
if (k != 0) do {
|
|
s1 += *buf++;
|
|
s2 += s1;
|
|
} while (--k);
|
|
s1 %= BASE;
|
|
s2 %= BASE;
|
|
}
|
|
return (s2 << 16) | s1;
|
|
}
|
|
|
|
#endif /* _Z_UTIL_H */
|