diff options
author | Florian Fainelli <florian@openwrt.org> | 2009-07-25 23:05:51 +0000 |
---|---|---|
committer | Florian Fainelli <florian@openwrt.org> | 2009-07-25 23:05:51 +0000 |
commit | 397938cc0f71b7b2919517a186778505310b5cac (patch) | |
tree | a93ef39dd5eed95736f684498d352c1a620391f7 /package/compcache | |
parent | f8f734eecef6c9827319ebceca5a1fcbfb800a55 (diff) | |
download | upstream-397938cc0f71b7b2919517a186778505310b5cac.tar.gz upstream-397938cc0f71b7b2919517a186778505310b5cac.tar.bz2 upstream-397938cc0f71b7b2919517a186778505310b5cac.zip |
add compcache (#4481)
SVN-Revision: 16988
Diffstat (limited to 'package/compcache')
-rw-r--r-- | package/compcache/Makefile | 59 | ||||
-rw-r--r-- | package/compcache/files/compcache.config | 3 | ||||
-rw-r--r-- | package/compcache/files/compcache.init | 39 | ||||
-rw-r--r-- | package/compcache/patches/001-lzo-speed.patch | 185 | ||||
-rw-r--r-- | package/compcache/patches/002-compact_lzo-codec.patch | 30 |
5 files changed, 316 insertions, 0 deletions
diff --git a/package/compcache/Makefile b/package/compcache/Makefile new file mode 100644 index 0000000000..a4d8451008 --- /dev/null +++ b/package/compcache/Makefile @@ -0,0 +1,59 @@ +# +# Copyright (C) 2006 OpenWrt.org +# +# This is free software, licensed under the GNU General Public License v2. +# See /LICENSE for more information. +# +# $Id: Makefile 6562 2009-01-21 11:19:24 ghd $ + +include $(TOPDIR)/rules.mk +include $(INCLUDE_DIR)/kernel.mk + +PKG_NAME:=compcache +PKG_VERSION:=0.5 +PKG_RELEASE:=$(PKG_VERSION)-1 +PKG_SOURCE_URL:=http://compcache.googlecode.com/files/ +PKG_MD5SUM:=eea73324e9e69178866f6c0fbc852f1f + +#PKG_BUILD_DIR:=$(KERNEL_BUILD_DIR)/$(PKG_NAME) + +PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz + +include $(INCLUDE_DIR)/package.mk + +define KernelPackage/compcache + SUBMENU:=Other modules + DEPENDS:=@LINUX_2_6 @BUSYBOX_CONFIG_SWAPONOFF + TITLE:=Driver for compressed ram swap device + VERSION:=$(LINUX_VERSION)-$(BOARD)-$(LINUX_RELEASE)+$(PKG_RELEASE) + FILES:=$(PKG_BUILD_DIR)/compcache.$(LINUX_KMOD_SUFFIX) \ + $(PKG_BUILD_DIR)/sub-projects/compression/lzo-kmod/lzo1x.$(LINUX_KMOD_SUFFIX) \ + $(PKG_BUILD_DIR)/sub-projects/allocators/xvmalloc-kmod/xvmalloc.$(LINUX_KMOD_SUFFIX) +# AUTOLOAD:=$(call AutoLoad,10,xvmalloc lzo1x compcache+compcache_size_kbytes=2048) +endef + +BUILDFLAGS:=-DCONFIG_BLK_DEV_COMPCACHE_DEBUG=0 \ + -DCONFIG_BLK_DEV_COMPCACHE_STATS=1 \ + -DCONFIG_XV_DEBUG=0 \ + -DCONFIG_XV_STATS=1 \ + -g -Wall + + +define Build/Compile + $(MAKE) -C "$(LINUX_DIR)" \ + CROSS_COMPILE="$(KERNEL_CROSS)" \ + CC="$(KERNEL_CC)" \ + ARCH="$(LINUX_KARCH)" \ + SUBDIRS="$(PKG_BUILD_DIR)" \ + EXTRA_CFLAGS="$(BUILDFLAGS)" \ + modules +endef + +define KernelPackage/compcache/install + $(INSTALL_DIR) $(1)/etc/config + $(INSTALL_DATA) ./files/compcache.config $(1)/etc/config/compcache + $(INSTALL_DIR) $(1)/etc/init.d + $(INSTALL_BIN) ./files/compcache.init $(1)/etc/init.d/compcache +endef + +$(eval $(call KernelPackage,compcache)) diff --git a/package/compcache/files/compcache.config b/package/compcache/files/compcache.config new file mode 100644 index 0000000000..96ee19284a --- /dev/null +++ b/package/compcache/files/compcache.config @@ -0,0 +1,3 @@ +config compcache + option 'enabled' '0' + option 'size_kbytes' '2048' diff --git a/package/compcache/files/compcache.init b/package/compcache/files/compcache.init new file mode 100644 index 0000000000..5c85e5ddd2 --- /dev/null +++ b/package/compcache/files/compcache.init @@ -0,0 +1,39 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2008 OpenWrt.org +START=19 + +load_modules() { + local section="$1" + config_get "size_kbytes" "$section" "size_kbytes" + config_get_bool "enabled" "$section" "enabled" '1' + if [ "$enabled" -gt 0 ]; then + if [ "`lsmod | grep 'compcache'`" != "" ]; then + echo "compcache allready loaded" + else + insmod xvmalloc + insmod lzo1x + insmod compcache compcache_size_kbytes=$size_kbytes + fi + fi +} + +remove_modules() { + local section="$1" + config_get_bool "enabled" "$section" "enabled" '1' + if [ "$enabled" -gt 0 ]; then + [ "`cat /proc/swaps | grep 'ramzswap0'`" != "" ] && swapoff /dev/ramzswap0 + [ "`lsmod | grep 'compcache'`" != "" ] && rmmod compcache > /dev/null + [ "`lsmod | grep 'lzo1x'`" != "" ] && rmmod lzo1x > /dev/null + [ "`lsmod | grep 'xvmalloc'`" != "" ] && rmmod xvmalloc > /dev/null + fi +} + +start() { + config_load "compcache" + config_foreach load_modules "compcache" +} + +stop() { + config_load "compcache" + config_foreach remove_modules "compcache" +} diff --git a/package/compcache/patches/001-lzo-speed.patch b/package/compcache/patches/001-lzo-speed.patch new file mode 100644 index 0000000000..df27b9bb6a --- /dev/null +++ b/package/compcache/patches/001-lzo-speed.patch @@ -0,0 +1,185 @@ +diff -uNr compcache-0.5/sub-projects/compression/lzo-kmod/lzo1x_compress.c compcache-0.5/sub-projects/compression/lzo-kmod/lzo1x_compress.c +--- compcache-0.5/sub-projects/compression/lzo-kmod/lzo1x_compress.c 2008-08-13 06:33:34.000000000 +0200 ++++ compcache-0.5/sub-projects/compression/lzo-kmod/lzo1x_compress.c 2009-01-21 08:00:35.000000000 +0100 +@@ -62,8 +62,12 @@ + goto literal; + + try_match: ++#ifdef CONFIG_HAVE_EFFICIENT_UNALIGNED_ACCESS + if (get_unaligned((const unsigned short *)m_pos) + == get_unaligned((const unsigned short *)ip)) { ++#else ++ if (m_pos[0] == ip[0] && m_pos[1] == ip[1]) { ++#endif + if (likely(m_pos[2] == ip[2])) + goto match; + } +@@ -94,9 +98,14 @@ + } + *op++ = tt; + } +- do { +- *op++ = *ii++; +- } while (--t > 0); ++ if (t >= 2 * 4) { ++ memcpy(op, ii, t); ++ op += t; ++ ii += t; ++ } else ++ do { ++ *op++ = *ii++; ++ } while (--t > 0); + } + + ip += 3; +@@ -208,9 +217,14 @@ + + *op++ = tt; + } +- do { +- *op++ = *ii++; +- } while (--t > 0); ++ if (t >= 2 * 4) { ++ memcpy(op, ii, t); ++ op += t; ++ ii += t; ++ } else ++ do { ++ *op++ = *ii++; ++ } while (--t > 0); + } + + *op++ = M4_MARKER | 1; +@@ -224,4 +238,3 @@ + + MODULE_LICENSE("GPL"); + MODULE_DESCRIPTION("LZO1X-1 Compressor"); +- +diff -uNr compcache-0.5/sub-projects/compression/lzo-kmod/lzo1x_decompress.c compcache-0.5/sub-projects/compression/lzo-kmod/lzo1x_decompress.c +--- compcache-0.5/sub-projects/compression/lzo-kmod/lzo1x_decompress.c 2008-08-13 06:33:42.000000000 +0200 ++++ compcache-0.5/sub-projects/compression/lzo-kmod/lzo1x_decompress.c 2009-01-21 07:49:41.000000000 +0100 +@@ -45,10 +45,7 @@ + goto output_overrun; + if (HAVE_IP(t + 1, ip_end, ip)) + goto input_overrun; +- do { +- *op++ = *ip++; +- } while (--t > 0); +- goto first_literal_run; ++ goto prep_first_literal_run; + } + + while ((ip < ip_end)) { +@@ -71,23 +68,20 @@ + if (HAVE_IP(t + 4, ip_end, ip)) + goto input_overrun; + +- COPY4(op, ip); +- op += 4; +- ip += 4; +- if (--t > 0) { +- if (t >= 4) { +- do { +- COPY4(op, ip); +- op += 4; +- ip += 4; +- t -= 4; +- } while (t >= 4); +- if (t > 0) { +- do { +- *op++ = *ip++; +- } while (--t > 0); +- } +- } else { ++ t += (4 - 1); ++ if (t >= 2 * 4) { ++ memcpy(op, ip, t); ++ op += t; ++ ip += t; ++ } else { ++ do { ++ COPY4(op, ip); ++ op += 4; ++ ip += 4; ++ t -= 4; ++ } while (t >= 4); ++ if (t > 0) { ++prep_first_literal_run: + do { + *op++ = *ip++; + } while (--t > 0); +@@ -139,8 +133,7 @@ + t += 31 + *ip++; + } + m_pos = op - 1; +- m_pos -= le16_to_cpu(get_unaligned( +- (const unsigned short *)ip)) >> 2; ++ m_pos -= get_unaligned_le16(ip) >> 2; + ip += 2; + } else if (t >= 16) { + m_pos = op; +@@ -158,8 +151,7 @@ + } + t += 7 + *ip++; + } +- m_pos -= le16_to_cpu(get_unaligned( +- (const unsigned short *)ip)) >> 2; ++ m_pos -= get_unaligned_le16(ip) >> 2; + ip += 2; + if (m_pos == op) + goto eof_found; +@@ -184,21 +176,33 @@ + if (HAVE_OP(t + 3 - 1, op_end, op)) + goto output_overrun; + +- if (t >= 2 * 4 - (3 - 1) && (op - m_pos) >= 4) { +- COPY4(op, m_pos); +- op += 4; +- m_pos += 4; +- t -= 4 - (3 - 1); +- do { ++ if (t >= 2 * 4 - (3 - 1)) { ++ /* ++ * Assume memcpy don't copy ++ * more than 32 bytes at once ++ */ ++ if ((op - m_pos) >= 32) { ++ t += (3 - 1); ++ memcpy(op, m_pos, t); ++ op += t; ++ m_pos += t; ++ } else if ((op - m_pos) >= 4) { + COPY4(op, m_pos); + op += 4; + m_pos += 4; +- t -= 4; +- } while (t >= 4); +- if (t > 0) ++ t -= 4 - (3 - 1); + do { +- *op++ = *m_pos++; +- } while (--t > 0); ++ COPY4(op, m_pos); ++ op += 4; ++ m_pos += 4; ++ t -= 4; ++ } while (t >= 4); ++ if (t > 0) ++ do { ++ *op++ = *m_pos++; ++ } while (--t > 0); ++ } else ++ goto copy_match; + } else { + copy_match: + *op++ = *m_pos++; +@@ -247,9 +251,7 @@ + *out_len = op - out; + return LZO_E_LOOKBEHIND_OVERRUN; + } +- + EXPORT_SYMBOL_GPL(lzo1x_decompress_safe); + + MODULE_LICENSE("GPL"); + MODULE_DESCRIPTION("LZO1X Decompressor"); +- diff --git a/package/compcache/patches/002-compact_lzo-codec.patch b/package/compcache/patches/002-compact_lzo-codec.patch new file mode 100644 index 0000000000..4b560f317f --- /dev/null +++ b/package/compcache/patches/002-compact_lzo-codec.patch @@ -0,0 +1,30 @@ +--- compcache-0.5/Makefile.bak 2008-12-10 07:25:44.000000000 +0100 ++++ compcache-0.5/Makefile 2009-01-21 08:25:38.000000000 +0100 +@@ -4,15 +4,13 @@ + -DCONFIG_XV_STATS \ + -g -Wall + +-obj-m += sub-projects/compression/lzo-kmod/lzo1x_decompress.o \ +- sub-projects/compression/lzo-kmod/lzo1x_compress.o \ ++obj-m += sub-projects/compression/lzo-kmod/lzo1x.o \ + sub-projects/allocators/xvmalloc-kmod/xvmalloc.o \ + compcache.o + + all: + make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules +- @ln -sf sub-projects/compression/lzo-kmod/lzo1x_decompress.ko +- @ln -sf sub-projects/compression/lzo-kmod/lzo1x_compress.ko ++ @ln -sf sub-projects/compression/lzo-kmod/lzo1x.ko + @ln -sf sub-projects/allocators/xvmalloc-kmod/xvmalloc.ko + + clean: +--- compcache-0.5/sub-projects/compression/lzo-kmod/lzo1x.c~ 1970-01-01 01:00:00.000000000 +0100 ++++ compcache-0.5/sub-projects/compression/lzo-kmod/lzo1x.c 2008-05-06 09:38:12.000000000 +0200 +@@ -0,0 +1,7 @@ ++#include <linux/module.h> ++ ++#include "lzo1x_compress.c" ++#include "lzo1x_decompress.c" ++ ++MODULE_LICENSE("GPL"); ++MODULE_DESCRIPTION("LZO1X Lib"); |