From 563054a8632ed3fe4721e75f6e6fa976646c32b4 Mon Sep 17 00:00:00 2001 From: Justin M. Forbes Date: Feb 04 2010 15:58:29 +0000 Subject: - 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. --- diff --git a/ksm.init b/ksm.init index 45d617d..0603243 100644 --- a/ksm.init +++ b/ksm.init @@ -40,8 +40,10 @@ default_max_kernel_pages () { start() { echo -n $"Starting $prog: " - KSM_MAX_KERNEL_PAGES=${KSM_MAX_KERNEL_PAGES:-`default_max_kernel_pages`} - echo $KSM_MAX_KERNEL_PAGES > /sys/kernel/mm/ksm/max_kernel_pages + 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" diff --git a/ksmtuned b/ksmtuned index 7da8b68..205ff84 100644 --- a/ksmtuned +++ b/ksmtuned @@ -21,6 +21,14 @@ 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} @@ -35,17 +43,17 @@ KSM_THRES_COEF=${KSM_THRES_COEF:-20} KSM_THRES_CONST=${KSM_THRES_CONST:-2048} total=`awk '/^MemTotal:/ {print $2}' /proc/meminfo` -[ -n "$DEBUG" ] && echo total $total +debug total $total npages=0 sleep=$[KSM_SLEEP_MSEC * 16 * 1024 * 1024 / total] [ $sleep -le 10 ] && sleep=10 -[ -n "$DEBUG" ] && echo sleep $sleep +debug sleep $sleep thres=$[total * KSM_THRES_COEF / 100] if [ $KSM_THRES_CONST -gt $thres ]; then thres=$KSM_THRES_CONST fi -[ -n "$DEBUG" ] && echo thres $thres +debug thres $thres KSMCTL () { case x$1 in @@ -89,22 +97,22 @@ adjust () { local free committed free=`free_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 KSMCTL stop - [ -n "$DEBUG" ] && echo "$[committed + thres] < $total and free > $thres, stop ksm" + debug "$[committed + thres] < $total and free > $thres, stop ksm" return 1 fi - [ -n "$DEBUG" ] && echo "$[committed + thres] > $total, start ksm" + debug "$[committed + thres] > $total, start ksm" if [ $free -lt $thres ]; then npages=`increase_npages $KSM_NPAGES_BOOST` - [ -n "$DEBUG" ] && echo "$free < $thres, boost" + debug "$free < $thres, boost" else npages=`increase_npages $KSM_NPAGES_DECAY` - [ -n "$DEBUG" ] && echo "$free > $thres, decay" + debug "$free > $thres, decay" fi KSMCTL start $npages $sleep - [ -n "$DEBUG" ] && echo "KSMCTL start $npages $sleep" + debug "KSMCTL start $npages $sleep" return 0 } diff --git a/ksmtuned.conf b/ksmtuned.conf index 87b9178..fc4518c 100644 --- a/ksmtuned.conf +++ b/ksmtuned.conf @@ -14,3 +14,8 @@ # KSM_THRES_COEF=20 # KSM_THRES_CONST=2048 + +# uncomment the following if you want ksmtuned debug info + +# LOGFILE=/var/log/ksmtuned +# DEBUG=1 diff --git a/qemu-v2-block-avoid-creating-too-large-iovecs-in-multiwrite_merge.patch b/qemu-v2-block-avoid-creating-too-large-iovecs-in-multiwrite_merge.patch new file mode 100644 index 0000000..c9b918b --- /dev/null +++ b/qemu-v2-block-avoid-creating-too-large-iovecs-in-multiwrite_merge.patch @@ -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 + +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 + #endif + diff --git a/qemu.spec b/qemu.spec index dfc53a8..8e35eb4 100644 --- a/qemu.spec +++ b/qemu.spec @@ -1,7 +1,7 @@ Summary: QEMU is a FAST! processor emulator Name: qemu Version: 0.12.2 -Release: 4%{?dist} +Release: 5%{?dist} # Epoch because we pushed a qemu-1.0 package Epoch: 2 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 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) BuildRequires: SDL-devel zlib-devel which texi2html gnutls-devel cyrus-sasl-devel @@ -232,6 +234,7 @@ such as kvmtrace and kvm_stat. %patch07 -p1 %patch08 -p1 %patch09 -p1 +%patch10 -p1 %build # --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* %changelog +* Thu Feb 04 2010 Justin M. Forbes - 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 - 2:0.12.2-4 - Remove build dependency on iasl now that we have seabios