- Avoid creating too large iovecs in multiwrite merge (#559717)

- Don't try to set max_kernel_pages during ksm init on newer kernels
    (#558281)
- Add logfile options for ksmtuned debug.
This commit is contained in:
Justin M. Forbes 2010-02-04 15:58:29 +00:00
parent e00a20d4f7
commit c03c84ed12
5 changed files with 76 additions and 12 deletions

View File

@ -40,8 +40,10 @@ default_max_kernel_pages () {
start() { start() {
echo -n $"Starting $prog: " echo -n $"Starting $prog: "
KSM_MAX_KERNEL_PAGES=${KSM_MAX_KERNEL_PAGES:-`default_max_kernel_pages`} if [ -f /sys/kernel/mm/ksm/max_kernel_pages ]; then
echo $KSM_MAX_KERNEL_PAGES > /sys/kernel/mm/ksm/max_kernel_pages 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 echo 1 > /sys/kernel/mm/ksm/run
RETVAL=$? RETVAL=$?
[ $RETVAL = 0 ] && success $"$prog startup" || failure $"$prog startup" [ $RETVAL = 0 ] && success $"$prog startup" || failure $"$prog startup"

View File

@ -21,6 +21,14 @@ if [ -f /etc/ksmtuned.conf ]; then
. /etc/ksmtuned.conf . /etc/ksmtuned.conf
fi 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_MONITOR_INTERVAL=${KSM_MONITOR_INTERVAL:-60}
KSM_NPAGES_BOOST=${KSM_NPAGES_BOOST:-300} KSM_NPAGES_BOOST=${KSM_NPAGES_BOOST:-300}
KSM_NPAGES_DECAY=${KSM_NPAGES_DECAY:--50} KSM_NPAGES_DECAY=${KSM_NPAGES_DECAY:--50}
@ -35,17 +43,17 @@ KSM_THRES_COEF=${KSM_THRES_COEF:-20}
KSM_THRES_CONST=${KSM_THRES_CONST:-2048} KSM_THRES_CONST=${KSM_THRES_CONST:-2048}
total=`awk '/^MemTotal:/ {print $2}' /proc/meminfo` total=`awk '/^MemTotal:/ {print $2}' /proc/meminfo`
[ -n "$DEBUG" ] && echo total $total debug total $total
npages=0 npages=0
sleep=$[KSM_SLEEP_MSEC * 16 * 1024 * 1024 / total] sleep=$[KSM_SLEEP_MSEC * 16 * 1024 * 1024 / total]
[ $sleep -le 10 ] && sleep=10 [ $sleep -le 10 ] && sleep=10
[ -n "$DEBUG" ] && echo sleep $sleep debug sleep $sleep
thres=$[total * KSM_THRES_COEF / 100] thres=$[total * KSM_THRES_COEF / 100]
if [ $KSM_THRES_CONST -gt $thres ]; then if [ $KSM_THRES_CONST -gt $thres ]; then
thres=$KSM_THRES_CONST thres=$KSM_THRES_CONST
fi fi
[ -n "$DEBUG" ] && echo thres $thres debug thres $thres
KSMCTL () { KSMCTL () {
case x$1 in case x$1 in
@ -89,22 +97,22 @@ adjust () {
local free committed local free committed
free=`free_memory` free=`free_memory`
committed=`committed_memory` committed=`committed_memory`
[ -n "$DEBUG" ] && echo committed $committed free $free debug committed $committed free $free
if [ $[committed + thres] -lt $total -a $free -gt $thres ]; then if [ $[committed + thres] -lt $total -a $free -gt $thres ]; then
KSMCTL stop KSMCTL stop
[ -n "$DEBUG" ] && echo "$[committed + thres] < $total and free > $thres, stop ksm" debug "$[committed + thres] < $total and free > $thres, stop ksm"
return 1 return 1
fi fi
[ -n "$DEBUG" ] && echo "$[committed + thres] > $total, start ksm" debug "$[committed + thres] > $total, start ksm"
if [ $free -lt $thres ]; then if [ $free -lt $thres ]; then
npages=`increase_npages $KSM_NPAGES_BOOST` npages=`increase_npages $KSM_NPAGES_BOOST`
[ -n "$DEBUG" ] && echo "$free < $thres, boost" debug "$free < $thres, boost"
else else
npages=`increase_npages $KSM_NPAGES_DECAY` npages=`increase_npages $KSM_NPAGES_DECAY`
[ -n "$DEBUG" ] && echo "$free > $thres, decay" debug "$free > $thres, decay"
fi fi
KSMCTL start $npages $sleep KSMCTL start $npages $sleep
[ -n "$DEBUG" ] && echo "KSMCTL start $npages $sleep" debug "KSMCTL start $npages $sleep"
return 0 return 0
} }

View File

@ -14,3 +14,8 @@
# KSM_THRES_COEF=20 # KSM_THRES_COEF=20
# KSM_THRES_CONST=2048 # KSM_THRES_CONST=2048
# uncomment the following if you want ksmtuned debug info
# LOGFILE=/var/log/ksmtuned
# DEBUG=1

View File

@ -0,0 +1,41 @@
If we go over the maximum number of iovecs support by syscall we get
back EINVAL from the kernel which translate to I/O errors for the guest.
Add a MAX_IOV defintion for platforms that don't have it. For now we use
the same 1024 define that's used on Linux and various other platforms,
but until the windows block backend implements some kind of vectored I/O
it doesn't matter.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Index: qemu/block.c
===================================================================
--- qemu.orig/block.c 2010-01-26 10:59:39.757004445 +0100
+++ qemu/block.c 2010-01-26 11:01:38.056023231 +0100
@@ -1689,6 +1689,10 @@ static int multiwrite_merge(BlockDriverS
merge = bs->drv->bdrv_merge_requests(bs, &reqs[outidx], &reqs[i]);
}
+ if (reqs[outidx].qiov->niov + reqs[i].qiov->niov + 1 > IOV_MAX) {
+ merge = 0;
+ }
+
if (merge) {
size_t size;
QEMUIOVector *qiov = qemu_mallocz(sizeof(*qiov));
Index: qemu/qemu-common.h
===================================================================
--- qemu.orig/qemu-common.h 2010-01-26 14:41:40.894254285 +0100
+++ qemu/qemu-common.h 2010-01-26 14:42:27.267275698 +0100
@@ -54,6 +54,10 @@ struct iovec {
void *iov_base;
size_t iov_len;
};
+/*
+ * Use the same value as Linux for now.
+ */
+#define IOV_MAX 1024
#else
#include <sys/uio.h>
#endif

View File

@ -1,7 +1,7 @@
Summary: QEMU is a FAST! processor emulator Summary: QEMU is a FAST! processor emulator
Name: qemu Name: qemu
Version: 0.12.2 Version: 0.12.2
Release: 4%{?dist} Release: 5%{?dist}
# Epoch because we pushed a qemu-1.0 package # Epoch because we pushed a qemu-1.0 package
Epoch: 2 Epoch: 2
License: GPLv2+ and LGPLv2+ and BSD License: GPLv2+ and LGPLv2+ and BSD
@ -35,6 +35,8 @@ Patch07: qemu-Move-virtio-serial-to-Makefile.objs.patch
Patch08: qemu-virtio-serial-Use-MSI-vectors-for-port-virtqueues.patch Patch08: qemu-virtio-serial-Use-MSI-vectors-for-port-virtqueues.patch
Patch09: qemu-virtio-console-Rename-virtio-serial.c-back-to-virti.patch Patch09: qemu-virtio-console-Rename-virtio-serial.c-back-to-virti.patch
Patch10: qemu-v2-block-avoid-creating-too-large-iovecs-in-multiwrite_merge.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: SDL-devel zlib-devel which texi2html gnutls-devel cyrus-sasl-devel BuildRequires: SDL-devel zlib-devel which texi2html gnutls-devel cyrus-sasl-devel
@ -232,6 +234,7 @@ such as kvmtrace and kvm_stat.
%patch07 -p1 %patch07 -p1
%patch08 -p1 %patch08 -p1
%patch09 -p1 %patch09 -p1
%patch10 -p1
%build %build
# --build-id option is used fedora 8 onwards for giving info to the debug packages. # --build-id option is used fedora 8 onwards for giving info to the debug packages.
@ -515,6 +518,11 @@ fi
%{_mandir}/man1/qemu-img.1* %{_mandir}/man1/qemu-img.1*
%changelog %changelog
* Thu Feb 04 2010 Justin M. Forbes <jforbes@redhat.com> - 2:0.12.2-5
- Avoid creating too large iovecs in multiwrite merge (#559717)
- Don't try to set max_kernel_pages during ksm init on newer kernels (#558281)
- Add logfile options for ksmtuned debug.
* Wed Jan 27 2010 Amit Shah <amit.shah@redhat.com> - 2:0.12.2-4 * Wed Jan 27 2010 Amit Shah <amit.shah@redhat.com> - 2:0.12.2-4
- Remove build dependency on iasl now that we have seabios - Remove build dependency on iasl now that we have seabios