This patch provides scripts for hugepage allocation, as well as a bit
of infrastructure and common hook config file that I hope may some day
be enabled by default in libvirt. For now, we place the files in
/usr/share and ask users to install the config file and copy or link
the scripts, more like contrib scripts for now.
Two methods of hugepage allocation are provided, static and dynamic.
The static mechanism allocates pages at libvirt daemon startup and
releases them at shutdown. It allows full size, locality, and policy
configuration. For instance, if I want to allocate a set of 2M pages
exclusively on host NUMA node 1, it can do that, along with plenty
more. This is especially useful for 1G hugepages on x86, since they
can now be allocated dynamically, but become impractical to allocate
due to memory fragmentation as the host runs. Systems dedicated to
hosting VMs are also likely to prefer static allocation. Static
allocation requires explicit XML entries in the hook config file to
be activated.
The dynamic method allocates hugepages only around the instantiation
of the VM. This is enabled by adding an entry for the domain in the
config file and configuring the domain normally for hugepages. The
dynamic hugepage script is activated via the QEMU domain prepare
hook, reads the domain XML and allocates hugepages as necessary. On
domain shutdown, hugepages are freed via the release hook. This
model is more appropriate for systems that are not dedicated VM
hosts and guests that use hugepage sizes and quantities are are
likely to be dynamically allocated as the VM is started.
In addition to the documentation provided within each script, a README
file is provided with overal instructions and summaries of the
individual scripts.
Signed-off-by: Alex Williamson alex.william...@redhat.com
---
Makefile.am|2
configure.ac |3
hooks/Makefile.am | 27
hooks/README | 47 +++
hooks/daemon | 33 +
hooks/daemon.d/Makefile.am | 21 +++
hooks/daemon.d/static-hugepages.sh | 100 +++
hooks/functions.sh | 180 +++
hooks/libvirt-hook-config.xml | 38 ++
hooks/qemu | 40 ++
hooks/qemu.d/Makefile.am | 21 +++
hooks/qemu.d/dynamic-hugepages.sh | 238
libvirt.spec.in| 13 ++
13 files changed, 761 insertions(+), 2 deletions(-)
create mode 100644 hooks/Makefile.am
create mode 100644 hooks/README
create mode 100755 hooks/daemon
create mode 100644 hooks/daemon.d/Makefile.am
create mode 100755 hooks/daemon.d/static-hugepages.sh
create mode 100755 hooks/functions.sh
create mode 100644 hooks/libvirt-hook-config.xml
create mode 100755 hooks/qemu
create mode 100644 hooks/qemu.d/Makefile.am
create mode 100755 hooks/qemu.d/dynamic-hugepages.sh
diff --git a/Makefile.am b/Makefile.am
index 9796069..e4a709a 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -24,7 +24,7 @@ SUBDIRS = . gnulib/lib include src daemon tools docs
gnulib/tests \
examples/dominfo examples/domsuspend examples/apparmor \
examples/xml/nwfilter examples/openauth examples/systemtap \
tools/wireshark examples/dommigrate \
- examples/lxcconvert examples/domtop
+ examples/lxcconvert examples/domtop hooks
ACLOCAL_AMFLAGS = -I m4
diff --git a/configure.ac b/configure.ac
index 93f9e38..b0dc035 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2812,7 +2812,8 @@ AC_CONFIG_FILES([\
examples/xml/nwfilter/Makefile \
examples/lxcconvert/Makefile \
tools/wireshark/Makefile \
-tools/wireshark/src/Makefile])
+tools/wireshark/src/Makefile \
+hooks/Makefile hooks/daemon.d/Makefile hooks/qemu.d/Makefile])
AC_OUTPUT
AC_MSG_NOTICE([])
diff --git a/hooks/Makefile.am b/hooks/Makefile.am
new file mode 100644
index 000..1fe6076
--- /dev/null
+++ b/hooks/Makefile.am
@@ -0,0 +1,27 @@
+## Copyright (C) 2015 Red Hat, Inc.
+##
+## This library is free software; you can redistribute it and/or
+## modify it under the terms of the GNU Lesser General Public
+## License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+##
+## This library 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
+## Lesser General Public License for more details.
+##
+## You should have received a copy of the GNU Lesser General Public
+## License along with this library. If not, see
+## http://www.gnu.org/licenses/.
+
+SUBDIRS = daemon.d qemu.d
+
+hooksdir = $(pkgdatadir)/hooks
+hooks_DATA = \
+ daemon \
+ functions.sh \
+ libvirt-hook-config.xml \
+ qemu \
+ README
+
+EXTRA_DIST =