Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37754725
en ru br
Репозитории ALT

Группа :: Эмуляторы
Пакет: ksmtuned

 Главная   Изменения   Спек   Патчи   Исходники   Загрузить   Gear   Bugs and FR  Repocop 

pax_global_header00006660000000000000000000000064115200535210014504gustar00rootroot0000000000000052 comment=fa60e9d2168cb3c1efd28524f13a34e28a397d26
ksmtuned-1.0/000075500000000000000000000000001152005352100131745ustar00rootroot00000000000000ksmtuned-1.0/.gear/000075500000000000000000000000001152005352100141705ustar00rootroot00000000000000ksmtuned-1.0/.gear/rules000064400000000000000000000000351152005352100152430ustar00rootroot00000000000000tar: . name=@name@-@version@
ksmtuned-1.0/.gear/tags/000075500000000000000000000000001152005352100151265ustar00rootroot00000000000000ksmtuned-1.0/.gear/tags/list000064400000000000000000000000001152005352100160120ustar00rootroot00000000000000ksmtuned-1.0/TODO000064400000000000000000000000371152005352100136640ustar00rootroot00000000000000
- More docs in ksmtuned.conf
ksmtuned-1.0/ksm.init000064400000000000000000000042321152005352100146540ustar00rootroot00000000000000#!/bin/bash
#
# ksm Kernel Samepage Merging
#
# Author: Dan Kenigsberg <danken@redhat.com>
#
# Copyright 2009 Red Hat, Inc. and/or its affiliates.
# Released under the GPL
#
# chkconfig: 345 84 16
# description: The KSM init script starts and stops the ksm kernel thread.
# config: /etc/sysconfig/ksm
#
### BEGIN INIT INFO
# Provides: ksm
# Required-Start:
# Required-Stop:
# Should-Start:
# Default-Start: 3 4 5
# Short-Description: start and stop ksm
# Description: The KSM init script starts and stops the ksm kernel thread.
### END INIT INFO

. /etc/rc.d/init.d/functions

if [ -f /etc/sysconfig/ksm ]; then
. /etc/sysconfig/ksm
fi

prog=ksm
RETVAL=0

# unless KSM_MAX_KERNEL_PAGES is set, let ksm munch up to half of total memory.
default_max_kernel_pages () {
local total pagesize
total=`awk '/^MemTotal:/ {print $2}' /proc/meminfo`
pagesize=`getconf PAGESIZE`
echo $[total * 1024 / pagesize / 2]
}

start() {
echo -n $"Starting $prog: "
if [ -f /sys/kernel/mm/ksm/max_kernel_pages ]; then
KSM_MAX_KERNEL_PAGES=${KSM_MAX_KERNEL_PAGES:-`default_max_kernel_pages`}
echo $KSM_MAX_KERNEL_PAGES > /sys/kernel/mm/ksm/max_kernel_pages
fi
echo 1 > /sys/kernel/mm/ksm/run
RETVAL=$?
[ $RETVAL = 0 ] && success $"$prog startup" || failure $"$prog startup"
echo
}

stop() {
echo -n $"Stopping $prog: "
echo 0 > /sys/kernel/mm/ksm/run
RETVAL=$?
[ $RETVAL = 0 ] && success $"$prog shutdown" || failure $"$prog shutdown"
echo
}

status() {
if [ ! -f /sys/kernel/mm/ksm/run ] ; then
echo $"$prog not supported"
RETVAL=1
else if [ "$(cat /sys/kernel/mm/ksm/run 2>/dev/null)" != "1" ]; then
echo $"$prog is not running"
RETVAL=1
else
echo $"$prog is running"
RETVAL=0
fi; fi
}

restart() {
stop
start
}

case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
restart
;;
condrestart|try-restart)
status >/dev/null 2>&1 || exit 0
restart
;;
force-reload)
restart
;;
*)
echo $"Usage: $prog {start|stop|restart|force-reload|condrestart|try-restart|status|help}"
RETVAL=2
esac

exit $RETVAL
ksmtuned-1.0/ksm.init.alt000064400000000000000000000037771152005352100154500ustar00rootroot00000000000000#!/bin/bash
#
# ksm Kernel Samepage Merging
#
# Author: Dan Kenigsberg <danken@redhat.com>
#
# Copyright 2009 Red Hat, Inc. and/or its affiliates.
# Released under the GPL
#
# chkconfig: - 84 16
# description: The KSM init script starts and stops the ksm kernel thread.
# config: /etc/sysconfig/ksm
#

. /etc/init.d/functions

if [ -f /etc/sysconfig/ksm ]; then
. /etc/sysconfig/ksm
fi

prog=ksm
RETVAL=0

# unless KSM_MAX_KERNEL_PAGES is set, let ksm munch up to half of total memory.
default_max_kernel_pages () {
local total pagesize
total=`awk '/^MemTotal:/ {print $2}' /proc/meminfo`
pagesize=`getconf PAGESIZE`
echo $[total * 1024 / pagesize / 2]
}

start() {
echo -n $"Starting $prog: "
if [ -f /sys/kernel/mm/ksm/max_kernel_pages ]; then
KSM_MAX_KERNEL_PAGES=${KSM_MAX_KERNEL_PAGES:-`default_max_kernel_pages`}
echo $KSM_MAX_KERNEL_PAGES > /sys/kernel/mm/ksm/max_kernel_pages
fi
echo 1 > /sys/kernel/mm/ksm/run
RETVAL=$?
[ $RETVAL = 0 ] && success $"$prog startup" || failure $"$prog startup"
echo
}

stop() {
echo -n $"Stopping $prog: "
echo 0 > /sys/kernel/mm/ksm/run
RETVAL=$?
[ $RETVAL = 0 ] && success $"$prog shutdown" || failure $"$prog shutdown"
echo
}

status() {
if [ ! -f /sys/kernel/mm/ksm/run ] ; then
echo $"$prog not supported"
RETVAL=1
else if [ "$(cat /sys/kernel/mm/ksm/run 2>/dev/null)" != "1" ]; then
echo $"$prog is not running"
RETVAL=1
else
echo $"$prog is running"
RETVAL=0
fi; fi
}

restart() {
stop
start
}

case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
restart
;;
reload)
restart
;;
condstop)
status >/dev/null 2>&1 || exit 0
stop
;;
condrestart)
status >/dev/null 2>&1 || exit 0
restart
;;
condreload)
status >/dev/null 2>&1 || exit 0
restart
;;
*)
msg_usage "${0##*/} {start|stop|reload|restart|condstop|condrestart|condreload|status}"
RETVAL=1
esac
exit $RETVAL
ksmtuned-1.0/ksm.sysconfig000064400000000000000000000002501152005352100157110ustar00rootroot00000000000000# The maximum number of unswappable kernel pages
# which may be allocated by ksm (0 for unlimited)
# If unset, defaults to half of total memory
# KSM_MAX_KERNEL_PAGES=
ksmtuned-1.0/ksmtuned000064400000000000000000000065621152005352100147620ustar00rootroot00000000000000#!/bin/bash
#
# Copyright 2009 Red Hat, Inc. and/or its affiliates.
# Released under the GPL
#
# Author: Dan Kenigsberg <danken@redhat.com>
#
# ksmtuned - a simple script that controls whether (and with what vigor) ksm
# should search for duplicated pages.
#
# starts ksm when memory commited to qemu processes exceeds a threshold, and
# make ksm work harder and harder untill memory load falls below that
# threshold.
#
# send SIGUSR1 to this process right after a new qemu process is started, or
# following its death, to retune ksm accordingly
#
# needs testing and ironing. contact danken@redhat.com if something breaks.

if [ -f /etc/ksmtuned.conf ]; then
. /etc/ksmtuned.conf
fi

debug() {
if [ -n "$DEBUG" ]; then
s="`/bin/date`: $*"
[ -n "$LOGFILE" ] && echo "$s" >> "$LOGFILE" || echo "$s"
fi
}


KSM_MONITOR_INTERVAL=${KSM_MONITOR_INTERVAL:-60}
KSM_NPAGES_BOOST=${KSM_NPAGES_BOOST:-300}
KSM_NPAGES_DECAY=${KSM_NPAGES_DECAY:--50}

KSM_NPAGES_MIN=${KSM_NPAGES_MIN:-64}
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_THRES_COEF=${KSM_THRES_COEF:-20}
KSM_THRES_CONST=${KSM_THRES_CONST:-2048}

total=`awk '/^MemTotal:/ {print $2}' /proc/meminfo`
debug total $total

npages=0
sleep=$[KSM_SLEEP_MSEC * 16 * 1024 * 1024 / total]
[ $sleep -le 10 ] && sleep=10
debug sleep $sleep
thres=$[total * KSM_THRES_COEF / 100]
if [ $KSM_THRES_CONST -gt $thres ]; then
thres=$KSM_THRES_CONST
fi
debug thres $thres

KSMCTL () {
case x$1 in
xstop)
echo 0 > /sys/kernel/mm/ksm/run
;;
xstart)
echo $2 > /sys/kernel/mm/ksm/pages_to_scan
echo $3 > /sys/kernel/mm/ksm/sleep_millisecs
echo 1 > /sys/kernel/mm/ksm/run
;;
esac
}

committed_memory () {
# calculate how much memory is committed to running qemu processes
local progname
progname=${1:-qemu-kvm}
ps -C "$progname" -o rsz | awk '{ sum += $1 }; END { print sum }'
}

free_memory () {
awk '/^(MemFree|Buffers|Cached):/ {free += $2}; END {print free}' \
/proc/meminfo
}

increase_npages() {
local delta
delta=${1:-0}
npages=$[npages + delta]
if [ $npages -lt $KSM_NPAGES_MIN ]; then
npages=$KSM_NPAGES_MIN
elif [ $npages -gt $KSM_NPAGES_MAX ]; then
npages=$KSM_NPAGES_MAX
fi
echo $npages
}


adjust () {
local free committed
free=`free_memory`
committed=`committed_memory`
debug committed $committed free $free
if [ $[committed + thres] -lt $total -a $free -gt $thres ]; then
KSMCTL stop
debug "$[committed + thres] < $total and free > $thres, stop ksm"
return 1
fi
debug "$[committed + thres] > $total, start ksm"
if [ $free -lt $thres ]; then
npages=`increase_npages $KSM_NPAGES_BOOST`
debug "$free < $thres, boost"
else
npages=`increase_npages $KSM_NPAGES_DECAY`
debug "$free > $thres, decay"
fi
KSMCTL start $npages $sleep
debug "KSMCTL start $npages $sleep"
return 0
}

function nothing () {
:
}

loop () {
trap nothing SIGUSR1
while true
do
sleep $KSM_MONITOR_INTERVAL &
wait $!
adjust
done
}

PIDFILE=${PIDFILE-/var/run/ksmtune.pid}
if touch "$PIDFILE"; then
loop &
echo $! > "$PIDFILE"
fi
ksmtuned-1.0/ksmtuned.conf000064400000000000000000000007361152005352100157030ustar00rootroot00000000000000# Configuration file for ksmtuned.

# How long ksmtuned should sleep between tuning adjustments
# KSM_MONITOR_INTERVAL=60

# Millisecond sleep between ksm scans for 16Gb server.
# Smaller servers sleep more, bigger sleep less.
# KSM_SLEEP_MSEC=10

# KSM_NPAGES_BOOST=300
# KSM_NPAGES_DECAY=-50
# KSM_NPAGES_MIN=64
# KSM_NPAGES_MAX=1250

# KSM_THRES_COEF=20
# KSM_THRES_CONST=2048

# uncomment the following if you want ksmtuned debug info

# LOGFILE=/var/log/ksmtuned
# DEBUG=1
ksmtuned-1.0/ksmtuned.init000064400000000000000000000036601152005352100157200ustar00rootroot00000000000000#!/bin/bash
#
# ksmtuned Kernel Samepage Merging (KSM) Tuning Daemon
#
# Author: Dan Kenigsberg <danken@redhat.com>
#
# Copyright 2009 Red Hat, Inc. and/or its affiliates.
# Released under the GPL
#
# chkconfig: 345 85 15
# description: The KSM tuning daemon controls whether (and with what vigor) \
# ksm should ksm search duplicated pages.
# processname: ksmtuned
# config: /etc/ksmtuned.conf
# pidfile: /var/run/ksmtuned.pid
#
### BEGIN INIT INFO
# Provides: ksmtuned
# Required-Start:
# Required-Stop:
# Should-Start:
# Default-Start: 3 4 5
# 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
# memory pages.
# needs testing and ironing. contact danken@redhat.com if something breaks.
### END INIT INFO

. /etc/rc.d/init.d/functions

prog=ksmtuned
ksmtuned=/usr/sbin/ksmtuned
pidfile=${PIDFILE-/var/run/ksmtune.pid}
RETVAL=0

start() {
echo -n $"Starting $prog: "
daemon --pidfile=${pidfile} $ksmtuned
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/$prog
}

stop() {
echo -n $"Stopping $prog: "
killproc -p ${pidfile}
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/$prog
}

restart() {
stop
start
}

condrestart() {
[ -e /var/lock/subsys/$prog ] && restart || :
}

case "$1" in
start)
start
;;
stop)
stop
;;
status)
status -p ${pidfile} $prog
RETVAL=$?
;;
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
kill -SIGUSR1 $pid
RETVAL=$?
fi
;;
*)
echo $"Usage: $prog {start|stop|restart|force-reload|condrestart|try-restart|status|retune|help}"
RETVAL=2
esac

exit $RETVAL
ksmtuned-1.0/ksmtuned.init.alt000064400000000000000000000031721152005352100164750ustar00rootroot00000000000000#!/bin/bash
#
# ksmtuned Kernel Samepage Merging (KSM) Tuning Daemon
#
# Author: Dan Kenigsberg <danken@redhat.com>
#
# Copyright 2009 Red Hat, Inc. and/or its affiliates.
# Released under the GPL
#
# chkconfig: - 85 15
# description: The KSM tuning daemon controls whether (and with what vigor) \
# ksm should ksm search duplicated pages.
# processname: ksmtuned
# config: /etc/ksmtuned.conf
# pidfile: /var/run/ksmtuned.pid
#

. /etc/init.d/functions

prog=ksmtuned
ksmtuned=/usr/sbin/ksmtuned
PIDFILE=/var/run/ksmtune.pid
LOCKFILE=/var/lock/subsys/ksmtuned
RETVAL=0

start() {
start_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --expect-user root -- ksmtuned
RETVAL=$?
return $RETVAL
}

stop() {
stop_daemon --pidfile "$PIDFILE" --lockfile "$LOCKFILE" --displayname ksmtuned bash
RETVAL=$?
return $RETVAL
}


restart() {
stop
start
}

condrestart() {
[ -e $LOCKFILE ] && restart || :
}


case "$1" in
start)
start
;;
stop)
stop
;;
status)
status --pidfile "$PIDFILE" --expect-user root --displayname ksmtuned bash
RETVAL=$?
;;
restart)
restart
;;
reload)
restart
;;
condstop)
if [ -e "$LOCKFILE" ]; then
stop
fi
;;
condrestart)
if [ -e "$LOCKFILE" ]; then
restart
fi
;;
condreload)
if [ -e "$LOCKFILE" ]; then
reload
fi
;;
retune)
pid=`cat ${pidfile} 2> /dev/null`
RETVAL=$?
if [ -z "$pid" ]; then
echo $"Cannot retune, service is not running."
else
kill -SIGUSR1 $pid
RETVAL=$?
fi
;;
*)
msg_usage "${0##*/} {start|stop|reload|restart|condstop|condrestart|condreload|status|retune}"
RETVAL=1
esac

exit $RETVAL
ksmtuned-1.0/ksmtuned.spec000064400000000000000000000021631152005352100157040ustar00rootroot00000000000000Name: ksmtuned
Version: 1.0
Release: alt2

Summary: KSM
License: GPLv3
Group: Emulators

Url: http://gitorious.org/ksm-control-scripts/ksm-control-scripts/trees/master
Packager: Slava Dubrovskiy <dubrsl@altlinux.org>
BuildArch: noarch

Source: %name-%version.tar

%description
The Kernel Samepage Merging control Daemon is a simple script that controls whether (and with what vigor) should ksm search duplicated memory pages.

%prep
%setup

%install
install -pD -m644 ksm.sysconfig %buildroot%_sysconfdir/sysconfig/ksm
install -pD -m644 ksmtuned.conf %buildroot%_sysconfdir/ksmtuned.conf
install -pD -m755 ksm.init.alt %buildroot%_initdir/ksm
install -pD -m755 ksmtuned.init.alt %buildroot%_initdir/ksmtuned
install -pD -m755 ksmtuned %buildroot%_sbindir/ksmtuned

%files
%_sbindir/*
%_initdir/*
%_sysconfdir/sysconfig/*
%_sysconfdir/ksmtuned.conf


%post
%post_service %name
%post_service ksm

%preun
%preun_service %name
%preun_service ksm

%changelog
* Tue Jan 25 2011 Slava Dubrovskiy <dubrsl@altlinux.org> 1.0-alt2
- Rebuild and merge with upstream

* Sat Dec 27 2010 Viacheslav Biriukov <sample@altlinux.org> 1.0-alt1
- bild for ALT
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin