--- /dev/null
+RELEASE=1.8
+
+PACKAGE=ksm-control-daemon
+PKGVER=1.0
+PKGREL=6
+
+KSM_DEB=${PACKAGE}_${PKGVER}-${PKGREL}_all.deb
+
+all: ${KSM_DEB}
+
+${KSM_DEB} ksm: ksm-control-scripts.org/ksm.init
+ rm -rf ksm-control-scripts
+ rsync -a --exclude .git ksm-control-scripts.org/ ksm-control-scripts
+ cp -a debian ksm-control-scripts
+ cd ksm-control-scripts; dpkg-buildpackage -rfakeroot -us -uc
+ lintian ${KSM_DEB} || true
+
+ksm-control-scripts.org/ksm.init:
+ git clone git://gitorious.org/ksm-control-scripts/ksm-control-scripts.git ksm-control-scripts.org
+ touch $@
+
+
+.PHONY: upload
+upload: ${KSM_DEB}
+ umount /pve/${RELEASE}; mount /pve/${RELEASE} -o rw
+ mkdir -p /pve/${RELEASE}/extra
+ rm -rf /pve/${RELEASE}/extra/Packages*
+ rm -rf /pve/${RELEASE}/extra/${PACKAGE}_*.deb
+ cp ${KSM_DEB} /pve/${RELEASE}/extra
+ cd /pve/${RELEASE}/extra; dpkg-scanpackages . /dev/null | gzip -9c > Packages.gz
+ umount /pve/${RELEASE}; mount /pve/${RELEASE} -o ro
+
+.PHONY: distclean
+distclean: clean
+ rm -rf ksm-control-scripts.org
+
+.PHONY: clean
+clean:
+ rm -rf *~ ksm-control-scripts ${PACKAGE}_*
\ No newline at end of file
--- /dev/null
+ksm-control-daemon (1.0-6) unstable; urgency=low
+
+ * add runlevel 2 to LSM header (init script)
+
+ -- Proxmox Support Team <support@proxmox.com> Tue, 14 Jun 2011 06:02:52 +0200
+
+ksm-control-daemon (1.0-5) unstable; urgency=low
+
+ * update to latest available version
+
+ -- Proxmox Support Team <support@proxmox.com> Mon, 07 Feb 2011 07:10:26 +0100
+
+ksm-control-daemon (1.0-4) unstable; urgency=low
+
+ * set KSM_SLEEP_MSEC=100 to reducd cpu load
+
+ -- Proxmox Support Team <support@proxmox.com> Fri, 28 May 2010 07:53:00 +0200
+
+ksm-control-daemon (1.0-3) unstable; urgency=low
+
+ * fix committed_memory calculation
+
+ -- Proxmox Support Team <support@proxmox.com> Mon, 01 Feb 2010 14:49:42 +0100
+
+ksm-control-daemon (1.0-2) unstable; urgency=low
+
+ * fix bug in init script (s/$prox/$prog/)
+
+ * fix default path (/etc/default/ksmtuned)
+
+ -- Proxmox Support Team <support@proxmox.com> Tue, 29 Dec 2009 16:02:36 +0100
+
+ksm-control-daemon (1.0-1) unstable; urgency=low
+
+ * first release
+
+ -- Proxmox Support Team <support@proxmox.com> Tue, 15 Dec 2009 12:30:41 +0100
+
--- /dev/null
+Source: ksm-control-daemon
+Section: admin
+Priority: optional
+Maintainer: Proxmox Support Team <support@proxmox.com>
+Build-Depends: debhelper (>= 7)
+Standards-Version: 3.7.3
+Homepage: http://pve.proxmox.com
+
+Package: ksm-control-daemon
+Architecture: all
+Depends: bash (>= 3.2)
+Description: The KSM tuning daemon
+ This package contains the KSM tuning daemon which controls whether
+ ksm should ksm search duplicated pages.
--- /dev/null
+Copyright 2009 Red Hat, Inc. and/or its affiliates.
+Released under the GPL
+
+Author: Dan Kenigsberg <danken@redhat.com>
+
+Debian package created by Proxmox Server Solutions GmbH <support@proxmox.com>
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License along
+with this program; if not, write to the Free Software Foundation, Inc.,
+51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+The complete text of the GNU General
+Public License can be found in `/usr/share/common-licenses/GPL-2'.
--- /dev/null
+# Defaults for ksmtuned initscript
+# sourced by /etc/init.d/ksmtuned
+# installed at /etc/default/ksmtuned by the maintainer scripts
+
+#
+# This is a POSIX shell fragment
+#
+
+
+# start ksmtuned at boot [yes|no]
+START=yes
+
--- /dev/null
+Index: new/ksmtuned
+===================================================================
+--- new.orig/ksmtuned 2011-06-14 06:00:42.000000000 +0200
++++ new/ksmtuned 2011-06-14 06:01:01.000000000 +0200
+@@ -37,7 +37,7 @@
+ KSM_NPAGES_MAX=${KSM_NPAGES_MAX:-1250}
+ # millisecond sleep between ksm scans for 16Gb server. Smaller servers sleep
+ # more, bigger sleep less.
+-KSM_SLEEP_MSEC=${KSM_SLEEP_MSEC:-10}
++KSM_SLEEP_MSEC=${KSM_SLEEP_MSEC:-100}
+
+ KSM_THRES_COEF=${KSM_THRES_COEF:-20}
+ KSM_THRES_CONST=${KSM_THRES_CONST:-2048}
+Index: new/ksmtuned.conf
+===================================================================
+--- new.orig/ksmtuned.conf 2011-06-14 05:58:03.000000000 +0200
++++ new/ksmtuned.conf 2011-06-14 06:01:01.000000000 +0200
+@@ -5,7 +5,7 @@
+
+ # Millisecond sleep between ksm scans for 16Gb server.
+ # Smaller servers sleep more, bigger sleep less.
+-# KSM_SLEEP_MSEC=10
++# KSM_SLEEP_MSEC=100
+
+ # KSM_NPAGES_BOOST=300
+ # KSM_NPAGES_DECAY=-50
--- /dev/null
+Index: new/ksmtuned.init
+===================================================================
+--- new.orig/ksmtuned.init 2011-06-14 05:58:03.000000000 +0200
++++ new/ksmtuned.init 2011-06-14 06:01:38.000000000 +0200
+@@ -19,7 +19,8 @@
+ # Required-Start:
+ # Required-Stop:
+ # Should-Start:
+-# Default-Start: 3 4 5
++# Default-Start: 2 3 4 5
++# Default-Stop: 0 1 6
+ # Short-Description: tune the speed of ksm
+ # Description: The Kernel Samepage Merging control Daemon is a simple script
+ # that controls whether (and with what vigor) should ksm search duplicated
+@@ -27,27 +28,50 @@
+ # needs testing and ironing. contact danken@redhat.com if something breaks.
+ ### END INIT INFO
+
+-. /etc/rc.d/init.d/functions
++. /lib/lsb/init-functions
++
++PATH=/sbin:/bin:/usr/sbin:/usr/bin
+
+ prog=ksmtuned
+ ksmtuned=/usr/sbin/ksmtuned
++DESC="KSM control daemon"
++
+ pidfile=${PIDFILE-/var/run/ksmtune.pid}
+ RETVAL=0
+
++test -x $ksmtuned || exit 0
++
++# Include defaults if available
++if [ -f /etc/default/$prog ] ; then
++ . /etc/default/$prog
++fi
++
++if [ "$START" != "yes" ]; then
++ exit 0
++fi
++
+ start() {
+- echo -n $"Starting $prog: "
+- daemon --pidfile=${pidfile} $ksmtuned
++
++ [ -d /sys/kernel/mm/ksm/ ] || exit 0;
++
++ log_daemon_msg "Starting $DESC" $prog
++ pid=$( pidofproc -p ${pidfile} $ksmtuned )
++ if [ -n "$pid" ] ; then
++ log_begin_msg "Already running."
++ log_end_msg 0
++ exit 0
++ fi
++
++ start-stop-daemon --start --quiet --pidfile=${pidfile} --exec $ksmtuned
+ RETVAL=$?
+- echo
+- [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
++ log_end_msg $RETVAL
+ }
+
+ stop() {
+- echo -n $"Stopping $prog: "
+- killproc -p ${pidfile}
++ log_daemon_msg "Stopping $DESC" $prog
++ start-stop-daemon --stop --quiet --pidfile ${pidfile}
+ RETVAL=$?
+- echo
+- [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
++ log_end_msg $RETVAL
+ }
+
+ restart() {
+@@ -55,10 +79,6 @@
+ start
+ }
+
+-condrestart() {
+- [ -e /var/lock/subsys/$prog ] && restart || :
+-}
+-
+ case "$1" in
+ start)
+ start
+@@ -67,27 +87,28 @@
+ stop
+ ;;
+ status)
+- status -p ${pidfile} $prog
+- RETVAL=$?
++ pidofproc -p ${pidfile} $ksmtuned >/dev/null
++ RETVAL=$?
++ if [ $RETVAL -eq 0 ]; then
++ log_success_msg "$DESC is running."
++ else
++ log_failure_msg "$DESC is not running."
++ fi
+ ;;
+ restart|force-reload)
+ restart
+ ;;
+- condrestart|try-restart)
+- condrestart
+- ;;
+- retune)
+- pid=`cat ${pidfile} 2> /dev/null`
+- RETVAL=$?
+- if [ -z "$pid" ]; then
+- echo $"Cannot retune, service is not running."
+- else
++ reload)
++ pid=$( pidofproc -p ${pidfile} $ksmtuned )
++ if [ -n "$pid" ] ; then
+ kill -SIGUSR1 $pid
+ RETVAL=$?
+- fi
++ else
++ log_failure_msg "$DESC is not running."
++ fi
+ ;;
+ *)
+- echo $"Usage: $prog {start|stop|restart|force-reload|condrestart|try-restart|status|retune|help}"
++ echo $"Usage: $prog {start|stop|restart|force-reload|status|reload|help}"
+ RETVAL=2
+ esac
+
--- /dev/null
+Index: new/ksmtuned
+===================================================================
+--- new.orig/ksmtuned 2011-02-07 06:43:33.000000000 +0100
++++ new/ksmtuned 2011-02-07 07:07:22.000000000 +0100
+@@ -71,7 +71,7 @@
+ committed_memory () {
+ # calculate how much memory is committed to running qemu processes
+ local progname
+- progname=${1:-qemu-kvm}
++ progname=${1:-kvm}
+ ps -C "$progname" -o rsz | awk '{ sum += $1 }; END { print sum }'
+ }
+
+@@ -124,8 +124,7 @@
+ trap nothing SIGUSR1
+ while true
+ do
+- sleep $KSM_MONITOR_INTERVAL &
+- wait $!
++ sleep $KSM_MONITOR_INTERVAL
+ adjust
+ done
+ }
--- /dev/null
+init-script.diff
+ksmtuned.diff
+adjust-ksm-slepp.diff
--- /dev/null
+#! /bin/sh
+
+# Abort if any command returns an error value
+set -e
+
+# This script is called as the last step of the installation of the
+# package. All the package's files are in place, dpkg has already
+# done its automatic conffile handling, and all the packages we depend
+# of are already fully installed and configured.
+
+# The following idempotent stuff doesn't generally need protecting
+# against being run in the abort-* cases.
+
+
+case "$1" in
+ configure)
+ # Configure this package. If the package must prompt the user for
+ # information, do it here.
+
+ # There are three sub-cases:
+ if test "${2+set}" != set; then
+ # We're being installed by an ancient dpkg which doesn't remember
+ # which version was most recently configured, or even whether
+ # there is a most recently configured version.
+ :
+
+ elif test -z "$2" -o "$2" = "<unknown>"; then
+ # The package has not ever been configured on this system, or was
+ # purged since it was last configured.
+ :
+
+ else
+ # Version $2 is the most recently configured version of this
+ # package.
+ :
+
+ fi ;;
+ abort-upgrade)
+ # Back out of an attempt to upgrade this package FROM THIS VERSION
+ # to version $2. Undo the effects of "prerm upgrade $2".
+ :
+
+ ;;
+ abort-remove)
+ if test "$2" != in-favour; then
+ echo "$0: undocumented call to \`postinst $*'" 1>&2
+ exit 0
+ fi
+ # Back out of an attempt to remove this package, which was due to
+ # a conflict with package $3 (version $4). Undo the effects of
+ # "prerm remove in-favour $3 $4".
+ :
+
+ ;;
+ abort-deconfigure)
+ if test "$2" != in-favour -o "$5" != removing; then
+ echo "$0: undocumented call to \`postinst $*'" 1>&2
+ exit 0
+ fi
+ # Back out of an attempt to deconfigure this package, which was
+ # due to package $6 (version $7) which we depend on being removed
+ # to make way for package $3 (version $4). Undo the effects of
+ # "prerm deconfigure in-favour $3 $4 removing $6 $7".
+ :
+
+ ;;
+ *) echo "$0: didn't understand being called with \`$1'" 1>&2
+ exit 0;;
+esac
+
+if [ -x "/etc/init.d/ksmtuned" ]; then
+ update-rc.d ksmtuned defaults 21 >/dev/null 2>&1
+ if [ -x "`which invoke-rc.d 2>/dev/null`" ]; then
+ invoke-rc.d ksmtuned start || exit $?
+ else
+ /etc/init.d/ksmtuned start || exit $?
+ fi
+fi
+
+exit 0
--- /dev/null
+#! /bin/sh
+
+# Abort if any command returns an error value
+set -e
+
+if [ "$1" = purge ]; then
+ update-rc.d ksmtuned remove >/dev/null 2>&1
+fi
--- /dev/null
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+ifneq "$(wildcard /usr/share/quilt/quilt.make)" ""
+include /usr/share/quilt/quilt.make
+endif
+
+destdir := $(CURDIR)/debian/ksm-control-daemon
+
+configure: configure-stamp
+configure-stamp:
+ dh_testdir
+ # Add here commands to configure the package.
+
+ touch configure-stamp
+
+
+build: patch build-stamp
+
+build-stamp: configure-stamp
+ dh_testdir
+
+ # Add here commands to compile the package.
+ # nothing to do
+
+ touch $@
+
+clean: unpatch
+ dh_testdir
+ dh_testroot
+ rm -f build-stamp configure-stamp
+
+ # Add here commands to clean up after the build process.
+ # nothing to do
+
+ dh_clean
+
+install: build
+ dh_testdir
+ dh_testroot
+ dh_clean -k
+ dh_installdirs
+
+ # Add here commands to install the package into debian/ksm-control-scripts.
+ #$(MAKE) DESTDIR=$(CURDIR)/debian/ksm-control-scripts install
+
+ install -D -m 0755 $(CURDIR)/ksmtuned.init $(destdir)/etc/init.d/ksmtuned
+ install -D -m 0755 $(CURDIR)/ksmtuned $(destdir)/usr/sbin/ksmtuned
+ install -D -m 0644 $(CURDIR)/debian/defaults $(destdir)/etc/default/ksmtuned
+ install -D -m 0644 $(CURDIR)/ksmtuned.conf $(destdir)/etc/ksmtuned.conf
+
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+ dh_testdir
+ dh_testroot
+ dh_installchangelogs
+ dh_installdocs
+ dh_installexamples
+# dh_install
+# dh_installmenu
+# dh_installdebconf
+# dh_installlogrotate
+# dh_installemacsen
+# dh_installpam
+# dh_installmime
+# dh_python
+# dh_installinit
+# dh_installcron
+# dh_installinfo
+ dh_installman
+ dh_link
+ dh_strip
+ dh_compress
+ dh_fixperms
+# dh_perl
+# dh_makeshlibs
+ dh_installdeb
+ dh_shlibdeps
+ dh_gencontrol
+ dh_md5sums
+ dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure