* Wed Nov 24 2021 Miroslav Rezanina <mrezanin@redhat.com> - 6.1.0-8
- kvm-Move-ksmtuned-files-to-separate-package.patch [bz#1971678] - Resolves: bz#1971678 (Split out ksmtuned package from qemu-kvm)
This commit is contained in:
parent
3cb15f8e48
commit
295f9d9b79
13
ksm.service
13
ksm.service
@ -1,13 +0,0 @@
|
||||
[Unit]
|
||||
Description=Kernel Samepage Merging
|
||||
ConditionPathExists=/sys/kernel/mm/ksm
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
RemainAfterExit=yes
|
||||
EnvironmentFile=-/etc/sysconfig/ksm
|
||||
ExecStart=/usr/libexec/ksmctl start
|
||||
ExecStop=/usr/libexec/ksmctl stop
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
@ -1,4 +0,0 @@
|
||||
# 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=
|
77
ksmctl.c
77
ksmctl.c
@ -1,77 +0,0 @@
|
||||
/* Start/stop KSM, for systemd.
|
||||
* Copyright (C) 2009, 2011 Red Hat, Inc.
|
||||
* Written by Paolo Bonzini <pbonzini@redhat.com>.
|
||||
* Based on the original sysvinit script by Dan Kenigsberg <danken@redhat.com>
|
||||
* This file is distributed under the GNU General Public License, version 2
|
||||
* or later. */
|
||||
|
||||
#include <unistd.h>
|
||||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#define KSM_MAX_KERNEL_PAGES_FILE "/sys/kernel/mm/ksm/max_kernel_pages"
|
||||
#define KSM_RUN_FILE "/sys/kernel/mm/ksm/run"
|
||||
|
||||
char *program_name;
|
||||
|
||||
int usage(void)
|
||||
{
|
||||
fprintf(stderr, "Usage: %s {start|stop}\n", program_name);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int write_value(uint64_t value, char *filename)
|
||||
{
|
||||
FILE *fp;
|
||||
if (!(fp = fopen(filename, "w")) ||
|
||||
fprintf(fp, "%llu\n", (unsigned long long) value) == EOF ||
|
||||
fflush(fp) == EOF ||
|
||||
fclose(fp) == EOF)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint64_t ksm_max_kernel_pages()
|
||||
{
|
||||
char *var = getenv("KSM_MAX_KERNEL_PAGES");
|
||||
char *endptr;
|
||||
uint64_t value;
|
||||
if (var && *var) {
|
||||
value = strtoll(var, &endptr, 0);
|
||||
if (value < LLONG_MAX && !*endptr)
|
||||
return value;
|
||||
}
|
||||
/* Unless KSM_MAX_KERNEL_PAGES is set, let KSM munch up to half of
|
||||
* total memory. */
|
||||
return sysconf(_SC_PHYS_PAGES) / 2;
|
||||
}
|
||||
|
||||
int start(void)
|
||||
{
|
||||
if (access(KSM_MAX_KERNEL_PAGES_FILE, R_OK) >= 0)
|
||||
write_value(ksm_max_kernel_pages(), KSM_MAX_KERNEL_PAGES_FILE);
|
||||
return write_value(1, KSM_RUN_FILE);
|
||||
}
|
||||
|
||||
int stop(void)
|
||||
{
|
||||
return write_value(0, KSM_RUN_FILE);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
program_name = argv[0];
|
||||
if (argc < 2) {
|
||||
return usage();
|
||||
} else if (!strcmp(argv[1], "start")) {
|
||||
return start();
|
||||
} else if (!strcmp(argv[1], "stop")) {
|
||||
return stop();
|
||||
} else {
|
||||
return usage();
|
||||
}
|
||||
}
|
139
ksmtuned
139
ksmtuned
@ -1,139 +0,0 @@
|
||||
#!/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 pidlist
|
||||
pidlist=$(pgrep -d ' ' -- '^qemu(-(kvm|system-.+)|:.{1,11})$')
|
||||
if [ -n "$pidlist" ]; then
|
||||
ps -p "$pidlist" -o rsz=
|
||||
fi | awk '{ sum += $1 }; END { print 0+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
|
@ -1,21 +0,0 @@
|
||||
# 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
|
@ -1,12 +0,0 @@
|
||||
[Unit]
|
||||
Description=Kernel Samepage Merging (KSM) Tuning Daemon
|
||||
After=ksm.service
|
||||
Requires=ksm.service
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/sbin/ksmtuned
|
||||
ExecReload=/bin/kill -USR1 $MAINPID
|
||||
Type=forking
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
@ -133,7 +133,7 @@ Obsoletes: %{name}-block-iscsi <= %{version} \
|
||||
Summary: QEMU is a machine emulator and virtualizer
|
||||
Name: qemu-kvm
|
||||
Version: 6.1.0
|
||||
Release: 7%{?rcrel}%{?dist}%{?cc_suffix}
|
||||
Release: 8%{?rcrel}%{?dist}%{?cc_suffix}
|
||||
# Epoch because we pushed a qemu-1.0 package. AIUI this can't ever be dropped
|
||||
# Epoch 15 used for RHEL 8
|
||||
# Epoch 17 used for RHEL 9 (due to release versioning offset in RHEL 8.5)
|
||||
@ -145,13 +145,6 @@ ExclusiveArch: x86_64 %{power64} aarch64 s390x
|
||||
|
||||
Source0: http://wiki.qemu.org/download/qemu-%{version}%{?rcstr}.tar.xz
|
||||
|
||||
# KSM control scripts
|
||||
Source4: ksm.service
|
||||
Source5: ksm.sysconfig
|
||||
Source6: ksmctl.c
|
||||
Source7: ksmtuned.service
|
||||
Source8: ksmtuned
|
||||
Source9: ksmtuned.conf
|
||||
Source10: qemu-guest-agent.service
|
||||
Source11: 99-qemu-guest-agent.rules
|
||||
Source12: bridge.conf
|
||||
@ -753,7 +746,6 @@ cp -a %{kvm_target}-softmmu/qemu-system-%{kvm_target} qemu-kvm
|
||||
cp pc-bios/s390-ccw/s390-ccw.img pc-bios/s390-ccw/s390-netboot.img pc-bios/
|
||||
%endif
|
||||
|
||||
%{__cc} %{_sourcedir}/ksmctl.c %{optflags} -pie %{?build_ldflags} -o ksmctl
|
||||
popd
|
||||
# endif !tools_only
|
||||
%endif
|
||||
@ -797,13 +789,7 @@ popd
|
||||
%endif
|
||||
|
||||
%if !%{tools_only}
|
||||
install -D -p -m 0644 %{_sourcedir}/ksm.service %{buildroot}%{_unitdir}/ksm.service
|
||||
install -D -p -m 0644 %{_sourcedir}/ksm.sysconfig %{buildroot}%{_sysconfdir}/sysconfig/ksm
|
||||
install -D -p -m 0755 %{qemu_kvm_build}/ksmctl %{buildroot}%{_libexecdir}/ksmctl
|
||||
|
||||
install -D -p -m 0644 %{_sourcedir}/ksmtuned.service %{buildroot}%{_unitdir}/ksmtuned.service
|
||||
install -D -p -m 0755 %{_sourcedir}/ksmtuned %{buildroot}%{_sbindir}/ksmtuned
|
||||
install -D -p -m 0644 %{_sourcedir}/ksmtuned.conf %{buildroot}%{_sysconfdir}/ksmtuned.conf
|
||||
install -D -p -m 0644 %{_sourcedir}/vhost.conf %{buildroot}%{_sysconfdir}/modprobe.d/vhost.conf
|
||||
install -D -p -m 0644 %{modprobe_kvm_conf} $RPM_BUILD_ROOT%{_sysconfdir}/modprobe.d/kvm.conf
|
||||
|
||||
@ -1021,17 +1007,6 @@ useradd -r -u 107 -g qemu -G kvm -d / -s /sbin/nologin \
|
||||
modprobe -b kvm &> /dev/null || :
|
||||
fi
|
||||
%endif
|
||||
|
||||
%systemd_post ksm.service
|
||||
%systemd_post ksmtuned.service
|
||||
|
||||
%preun common
|
||||
%systemd_preun ksm.service
|
||||
%systemd_preun ksmtuned.service
|
||||
|
||||
%postun common
|
||||
%systemd_postun_with_restart ksm.service
|
||||
%systemd_postun_with_restart ksmtuned.service
|
||||
# endif !tools_only
|
||||
%endif
|
||||
|
||||
@ -1105,13 +1080,7 @@ useradd -r -u 107 -g qemu -G kvm -d / -s /sbin/nologin \
|
||||
%{_mandir}/man7/qemu-block-drivers.7*
|
||||
%attr(4755, -, -) %{_libexecdir}/qemu-bridge-helper
|
||||
%config(noreplace) %{_sysconfdir}/sasl2/%{name}.conf
|
||||
%{_unitdir}/ksm.service
|
||||
%{_libexecdir}/ksmctl
|
||||
%config(noreplace) %{_sysconfdir}/sysconfig/ksm
|
||||
%{_unitdir}/ksmtuned.service
|
||||
%{_sbindir}/ksmtuned
|
||||
%ghost %{_sysconfdir}/kvm
|
||||
%config(noreplace) %{_sysconfdir}/ksmtuned.conf
|
||||
%dir %{_sysconfdir}/%{name}
|
||||
%config(noreplace) %{_sysconfdir}/%{name}/bridge.conf
|
||||
%config(noreplace) %{_sysconfdir}/modprobe.d/vhost.conf
|
||||
@ -1193,6 +1162,11 @@ useradd -r -u 107 -g qemu -G kvm -d / -s /sbin/nologin \
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Wed Nov 24 2021 Miroslav Rezanina <mrezanin@redhat.com> - 6.1.0-8
|
||||
- kvm-Move-ksmtuned-files-to-separate-package.patch [bz#1971678]
|
||||
- Resolves: bz#1971678
|
||||
(Split out ksmtuned package from qemu-kvm)
|
||||
|
||||
* Fri Nov 19 2021 Miroslav Rezanina <mrezanin@redhat.com> - 6.1.0-7
|
||||
- kvm-migration-Make-migration-blocker-work-for-snapshots-.patch [bz#1996609]
|
||||
- kvm-migration-Add-migrate_add_blocker_internal.patch [bz#1996609]
|
||||
|
Loading…
Reference in New Issue
Block a user