Unverified Commit 58ec40f9 authored by Nils Goroll's avatar Nils Goroll

Initial public release

parents
# editors
*~
# general
core.*
# build system
.deps/
.libs/
autom4te.cache/
build-aux/
m4/
*.la
*.lo
*.o
*.tar.gz
Makefile
Makefile.in
aclocal.m4
config.h
config.h.in
config.log
config.status
configure
libtool
stamp-h1
# test suite
*.log
*.trs
fellowfile
# vmodtool
vcc_*_if.[ch]
vmod_slash.rst
# vsctool
VSC_*.[ch]
VSC_*.rst
# dot
src/fcs_states.dot
# man
*.1
*.7
*_options.rst
*_synopsis.rst
vmod_*.3
slashmap.rst
# bin
slashmap
slash
buddy_test
buddy_test_witness
buddy_test_when
fellow_log_test
fellow_log_test_ndebug
fellow_cache_test
fellow_log_dbg
# coverage
*.gcda
*.gcno
/src/coverage
The slash project is provided under:
SPDX-License-Identifier: LGPL-2.1-only
with the exception of some files taken from the Varnish-Cache project
which are licensed under
SPDX-License-Identifier: BSD-2-Clause
Both licences are provided in the LICENSES directory.
\ No newline at end of file
================================
SLASH/ Installation Instructions
================================
.. role:: ref(emphasis)
Installing from Source
======================
.. _Compiling Varnish from source: https://varnish-cache.org/docs/trunk/installation/install_source.html
generic
-------
* Compile and install varnish-cache 7.2.0 or later by the
`Compiling Varnish from source`_ documentation.
* Optionally, install the following additional prerequisites:
recommendations for optimal fellow storage performance
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.. _liburing: https://github.com/axboe/liburing.git
.. _xxhash: https://github.com/Cyan4973/xxHash
* On Linux, it is strongly recommended to add io_uring support by
installing kernel >= 5.10 (better: >= 5.13) and `liburing`_.
* For optimal performance, it is recommended to install `xxhash`_ and
later use ``xxh3_64`` or ``xxh3_128`` by setting the ``hash_obj``
and ``hash_log`` tuneables.
Note that a fellow storage using any of the `xxhash`_ hashes can
only be loaded by an instance with `xxhash`_ support compiled in.
compiling
~~~~~~~~~
* set and export the ``VARNISHSRC`` environment variable to point to
the varnish-cache source tree
* In the ``slash`` source tree, run::
./bootstrap
make check
make install
The last step will probably need to be run as root (e.g. using ``sudo``).
When installation has succeeded, continue with the `Next Steps`_.
Debian/Ubuntu
-------------
This guide was written based on:
* Debian 11 base install
* Varnish-Cache binary packages
Add the packagecloud repository, if not already done::
sudo apt-get install curl
curl -sO \
https://packagecloud.io/install/repositories/varnishcache/varnish72/script.deb.sh
# REVIEW script.deb.sh and continue only if considered safe
sudo bash script.deb.sh
Install varnish-cache dev package and other required packages::
sudo apt-get install -y \
varnish-dev \
git \
autoconf \
autoconf-archive \
automake \
libtool \
gcc \
python3-docutils \
python3-sphinx \
libpcre2-dev \
libreadline-dev \
liburing-dev \
libxxhash-dev \
libncurses-dev
Download and extract the varnish-cache source code for the installed
version, and export the ``VARNISHSRC`` environment variable to the right
directory::
v=$(/usr/sbin/varnishd -V 2>&1 | grep -Eo 'varnish-[0-9.]+')
curl -LO \
https://github.com/varnishcache/varnish-cache/archive/refs/tags/${v}.tar.gz
tar xf ${v}.tar.gz
VARNISHSRC=$(realpath varnish-cache-${v})
export VARNISHSRC
Build required components from varnish-cache::
( pushd $VARNISHSRC && \
./autogen.des && \
pushd include && \
make vcs_version.h && \
popd && pushd lib/libvarnish && \
make libvarnish.la && \
popd && pushd lib/libvsc &&
make VSC_main.c \
)
Clone this repository::
git clone http://code.uplex.de/uplex-varnish/slash.git
Enter the ``slash`` directory and call ``bootstrap``::
cd slash
./bootstrap
A summary similar to the one shown below should be output. In
particular, ``xxhash: yes`` and ``uring: yes`` should be contained::
==== slash 0.9 ====
varnish: 7.2.1
prefix: /usr
vmoddir: /usr/lib/varnish/vmods
vcldir: ${datarootdir}/varnish/vcl
pkgvcldir: ${vcldir}/${PACKAGE}
compiler: gcc
cflags: -g -O2 -fstack-protector-all
ldflags:
xxhash: yes
uring: yes
aio: no
Build, test and install SLASH/::
make check && sudo make install
Configuration options
---------------------
.. _autoconf: https://www.gnu.org/software/autoconf/
Among other things, ``bootstrap`` invokes the ``configure`` script
generated by `autoconf`_, and any command-line options given with
``bootstrap`` are passed on to ``configure``. For example,
``VARNISHSRC`` can be specified like this (since ``bootstrap`` is the
only step that requires it)::
bootstrap VARNISHSRC=/path/to/varnish-cache
CLI options can also be used, for example, to set ``CFLAGS``, select
the C compiler (with ``CC``), or specify the installation prefix.
``bootstrap --help`` (which invokes ``configure --help``) shows all of
the relevant variables and available options.
For most installations, the default values (with no CLI options, as
shown above) are sufficient.
Next Steps
----------
.. _Next Steps:
Now you should be ready to go.
Consult the :ref:`vmod_slash(3)` and :ref:`slashmap(1)` man pages for
detailed information on how to configure, use and monitor the SLASH/
storage engines.
System Setup for Optimal Performance
====================================
buddy & fellow memory cache
---------------------------
For the time being, these recommendations only apply to Linux.
The `buddy` allocator, which is also used by the memory cache of
`fellow`, will, by default, attempt to allocate memory from huge pages
and try to lock pages in RAM and thus prevent paging.
huge pages
~~~~~~~~~~
To the best of our knowledge, best performance is thus achieved by
ensuring that the system has sufficient huge pages reserved by
* either using the kernel command line, for example by adding to
``/etc/default/grub``::
GRUB_CMDLINE_LINUX="hugepagesz=1GB hugepages=300"
to configure 300GB of 1GB huge pages at boot and rebooting
* or by applying the same configuration at runtime through::
echo 300 \
>/sys/kernel/mm/hugepages/hugepages-1048576kB/nr_hugepages
to, again, configure 300GB of 1GB huge pages.
The 300GB used in these examples have to be adjusted approriately to
the desired memory cache size.
Alternatively, 2MB huge pages can be used where 1GB pages are not
available.
locked memory
~~~~~~~~~~~~~
:ref:`varnishd(1)` should be started with a limit on locked memory
higher than the configured memory size. We recommend to configure no
limit on locked memory by calling::
ulimit -l unlimited
or using::
LimitMEMLOCK=infinity
with :ref:`systemd(1)`, or whatever appropriate method to lift the
limit on locked memory.
fellow storage
--------------
`fellow` uses its own memory caching strategy, so double caching by
the operating system should be avoided. `fellow` thus tries to open
the storage path with ``O_DIRECT``, where available.
Nonetheless, to the best of our knowledge, avoiding the file system
overhead results in optimal performance. Where possible, the `fellow`
*path* should therefore point to a disk storage device. Using a mirror
or mirror/stripe (RAID1 or RAID10) is recommended for optimal
resilience.
As the IO pattern of `fellow` usually is highly random and because
access times are crucial for overall latency, using storage with the
lowest possible access times for random access is highly
recommended. Flash based storage (SSD, NVMe) usually falls into this
category.
Valid-License-Identifier: BSD-2-Clause
SPDX-URL: https://spdx.org/licenses/BSD-2-Clause.html
Usage-Guide:
To use the BSD 2-clause "Simplified" License put the following SPDX
tag/value pair into a comment according to the placement guidelines in
the licensing rules documentation:
SPDX-License-Identifier: BSD-2-Clause
License-Text:
Copyright (c) <year> <owner> . All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
This diff is collapsed.
ACLOCAL_AMFLAGS = -I m4 -I @VARNISHAPI_DATAROOTDIR@/aclocal
DISTCHECK_CONFIGURE_FLAGS = RST2MAN=:
SUBDIRS = src
dist_doc_DATA = README.rst COPYING LICENSES/BSD-2-Clause LICENSES/LGPL-2.1
EXTRA_DIST = INSTALL.rst
coverage:
$(MAKE) $(AM_MAKEFLAGS) -C src coverage
This diff is collapsed.
#!/bin/sh
set -e
set -u
WORK_DIR=$(pwd)
ROOT_DIR=$(dirname "$0")
cd "$ROOT_DIR"
if ! command -v libtoolize >/dev/null
then
echo "libtoolize: command not found, falling back to glibtoolize" >&2
alias libtoolize=glibtoolize
fi
mkdir -p m4
aclocal
libtoolize --copy --force
autoheader
automake --add-missing --copy --foreign
autoconf
cd "$WORK_DIR"
"$ROOT_DIR"/configure "$@"
AC_PREREQ([2.68])
AC_INIT([slash],[0.9])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_HEADERS([config.h])
AC_USE_SYSTEM_EXTENSIONS
AM_INIT_AUTOMAKE([1.12 -Wall -Werror foreign parallel-tests])
AM_SILENT_RULES([yes])
AM_PROG_AR
AM_PROG_CC_C_O
AX_PTHREAD(,[AC_MSG_ERROR([Could not configure pthreads support])])
LIBS="$PTHREAD_LIBS $LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
CC="$PTHREAD_CC"
LT_PREREQ([2.2.6])
LT_INIT([dlopen disable-static])
AC_ARG_WITH([rst2man],
AS_HELP_STRING(
[--with-rst2man=PATH],
[Location of rst2man (auto)]),
[RST2MAN="$withval"],
[AC_CHECK_PROGS(RST2MAN, [rst2man rst2man.py], [])])
AC_ARG_WITH([lcov],
AS_HELP_STRING(
[--with-lcov=PATH],
[Location of lcov to generate coverage data (auto)]),
[LCOV="$withval"],
[AC_CHECK_PROGS(LCOV, [lcov], [])])
AM_CONDITIONAL(HAVE_LCOV, [test -n "$LCOV"])
AC_ARG_WITH([genhtml],
AS_HELP_STRING(
[--with-genhtml=PATH],
[Location of genhtml to generate coverage reports (auto)]),
[GENHTML="$withval"],
[AC_CHECK_PROGS(GENHTML, [genhtml], [])])
AM_CONDITIONAL(HAVE_GENHTML, [test -n "$GENHTML"])
VARNISH_PREREQ([7.2.0])
VARNISH_VMODS([slash])
VARNISH_COUNTERS([slash])
VARNISH_UTILITIES([slashmap])
AC_ARG_VAR([VARNISHSRC], [path to Varnish source])
if test "x$VARNISHSRC" = x; then
AC_MSG_FAILURE([Need VARNISHSRC])
fi
VARNISHSRC_CFLAGS="$VARNISHAPI_CFLAGS \
-I$VARNISHSRC/bin/varnishd \
-I$VARNISHSRC/lib/libvsc"
AC_SUBST([VARNISHSRC_CFLAGS])
AC_CHECK_HEADERS([stdatomic.h atomic.h])
AC_CHECK_HEADERS([linux/mman.h linux/fs.h])
AC_CHECK_HEADERS([sys/dkio.h])
AC_ARG_ENABLE([uring],
[AS_HELP_STRING([--disable-uring],
[disable uring support])],
[],
[enable_uring=yes])
AS_IF([test "x$enable_uring" != xno],
[AC_CHECK_HEADERS([liburing.h])],
[ac_cv_header_liburing_h=no])
AC_ARG_ENABLE([asynch],
[AS_HELP_STRING([--disable-asynch],
[disable asynch support])],
[],
[enable_asynch=yes])
AS_IF([test "x$enable_asynch" != xno],
[AC_CHECK_HEADERS([sys/asynch.h])],
[ac_cv_header_sys_asynch_h=no])
AM_CONDITIONAL(HAVE_URING,[test "x$ac_cv_header_liburing_h" != "xno"])
AM_CONDITIONAL(HAVE_ASYNCH,[test "x$ac_cv_header_sys_asynch_h" != "xno"])
AC_CHECK_FUNCS([fallocate])
PKG_CHECK_MODULES([XXHASH], [libxxhash], [], [true])
# avoiding the fruitless RPATH debate for now
if ! echo "$pkg_cv_XXHASH_LIBS" | grep -- "-R" ; then
tmp=$(echo "$pkg_cv_XXHASH_LIBS" | grep -Po '(?<=-L)\S+')
if test -n "${tmp}" ; then
XXHASH_LIBS="${pkg_cv_XXHASH_LIBS} -R${tmp}"
fi
fi
AC_CHECK_HEADERS([xxhash.h])
## BEGIN from varnish-cache
# --enable-stack-protector XXX remove -all
AC_ARG_ENABLE(stack-protector,
AS_HELP_STRING([--enable-stack-protector],[enable stack protector (default is YES)]),
[],
[enable_stack_protector=yes])
if test "x$enable_stack_protector" != "xno"; then
AX_CHECK_COMPILE_FLAG([-fstack-protector-all],
AX_CHECK_LINK_FLAG([-fstack-protector-all],
[CFLAGS="${CFLAGS} -fstack-protector-all"], [], []),
[], [])
fi
PKG_CHECK_MODULES([CURSES], [ncursesw], [], [
PKG_CHECK_MODULES([CURSES], [ncurses], [], [
PKG_CHECK_MODULES([CURSES], [curses], [], [
AX_WITH_CURSES
if test "x$ax_cv_curses" != xyes; then
AC_MSG_ERROR([requires an X/Open-compatible Curses library])
fi
CURSES_LIBS="$CURSES_LIB"
])
])
])
AC_SUBST([CURSES_CFLAGS])
AC_SUBST([CURSES_LIBS])
save_CFLAGS="${CFLAGS}"
CFLAGS="${CFLAGS} ${CURSES_CFLAGS}"
AC_CHECK_HEADERS([ncursesw/curses.h ncursesw.h ncurses/curses.h ncurses.h curses.h])
CFLAGS="${save_CFLAGS}"
save_CFLAGS="${CFLAGS}"
CFLAGS="${CFLAGS} ${VARNISHAPI_CFLAGS}"
# varnish-cache compat with 7.2
AC_CHECK_MEMBER([struct boc.fetched_so_far],
[AC_DEFINE([BOC_FETCHED_SO_FAR], [fetched_so_far], [Name of the field])],
[AC_DEFINE([BOC_FETCHED_SO_FAR], [len_so_far], [Name of the field])],
[[#include <cache/cache.h>]])
CFLAGS="${save_CFLAGS}"
## END
AC_CONFIG_FILES([
Makefile
src/Makefile
src/slashmap.rst
])
AC_OUTPUT
AS_ECHO("
==== $PACKAGE_STRING ====
varnish: $VARNISH_VERSION
prefix: $prefix
vmoddir: $vmoddir
vcldir: $vcldir
pkgvcldir: $pkgvcldir
compiler: $CC
cflags: $CFLAGS
ldflags: $LDFLAGS
xxhash: $ac_cv_header_xxhash_h
uring: $ac_cv_header_liburing_h
aio: $ac_cv_header_sys_asynch_h
")
AM_CFLAGS = $(VARNISHAPI_CFLAGS) -fno-strict-aliasing
FREEPAGE_CFLAGS = -DFREEPAGE_WHEN
DEV_CFLAGS = -Wall -Werror
## to compile all with witness
#DEV_CFLAGS = -Wall -Werror -DBUDDY_WITNESS -DBUDDY_WITNESS_BACKTRACE
# Modules
vmod_LTLIBRARIES = \
libvmod_slash.la
# buddy libs
buddy_sources = \
buddy_witness.h \
slashmap.h \
buddy.h \
buddy_util.h \
buddy.c \
bitsof.h \
bitf.h \
tbl/mmap_flags.h \
foreign/vmb.h
noinst_LTLIBRARIES = \
libbuddy.la \
libbuddywhen.la \
libbuddywitness.la
libbuddy_la_CFLAGS = $(AM_CFLAGS) $(DEV_CFLAGS)
libbuddywhen_la_CFLAGS = $(libbuddy_la_CFLAGS) $(FREEPAGE_CFLAGS)
libbuddywitness_la_CFLAGS = $(libbuddy_la_CFLAGS) -DBUDDY_WITNESS
libbuddy_la_SOURCES = $(buddy_sources)
libbuddywhen_la_SOURCES = $(libbuddy_la_SOURCES)
libbuddywitness_la_SOURCES = $(libbuddy_la_SOURCES)
# vmod
# freepage is only used for buddy_storage, not for fellow_storage
noinst_LTLIBRARIES += \
libbuddy_storage.la
libbuddy_storage_la_CFLAGS = \
$(AM_CFLAGS) $(FREEPAGE_CFLAGS) $(VARNISHSRC_CFLAGS) $(DEV_CFLAGS)
libbuddy_storage_la_SOURCES = \
buddy_storage.c \
tbl/buddy_tunables.h \
buddy_tune.h \
buddy_tune.c
libvmod_slash_la_CFLAGS = $(AM_CFLAGS) $(VARNISHSRC_CFLAGS) $(DEV_CFLAGS)
libvmod_slash_la_LDFLAGS = $(VMOD_LDFLAGS)
libvmod_slash_la_SOURCES = \
vmod_slash.c \
vmod_slash_loadmasters.c \
fellow_storage.c \
fellow_storage_deref.h \
fellow_cache_storage.h \
fellow_stash.h \
fellow_log_storage.h
libvmod_slash_la_LIBADD = \
libbuddy_storage.la \
libbuddywhen.la \
libfellow.la
# XXX revisit
# linked to libfellow.la:
# libbuddy.la
nodist_libvmod_slash_la_SOURCES = \
vcc_slash_if.c \
vcc_slash_if.h
vmod_slash.c: vcc_slash_if.h
@BUILD_VMOD_SLASH@
# Utilities
bin_PROGRAMS = \
slashmap \
buddy_test \
buddy_test_when
slashmap_LDFLAGS = $(VARNISHAPI_LIBS) @CURSES_LIBS@
slashmap_CFLAGS = $(AM_CFLAGS) @CURSES_CFLAGS@ $(DEV_CFLAGS)
slashmap_SOURCES = \
slashmap.c \
slashmap_options.h \
slashmap.h \
pow2_units.c \
pow2_units.h \
bitsof.h \
bitf.h \
foreign/vcurses.h
buddy_test_LDFLAGS = $(VARNISHAPI_LIBS)
buddy_test_CFLAGS = \
$(AM_CFLAGS) -DDEBUG -DTEST_DRIVER $(DEV_CFLAGS)
buddy_test_SOURCES = \
$(buddy_sources)
buddy_test_witness_LDFLAGS = $(VARNISHAPI_LIBS)
buddy_test_witness_CFLAGS = \
$(AM_CFLAGS) -DDEBUG -DTEST_DRIVER -DBUDDY_WITNESS $(DEV_CFLAGS)
buddy_test_witness_SOURCES = \
$(buddy_sources)
buddy_test_when_LDFLAGS = $(VARNISHAPI_LIBS)
buddy_test_when_CFLAGS = \
$(AM_CFLAGS) -DDEBUG -DTEST_DRIVER $(FREEPAGE_CFLAGS) $(DEV_CFLAGS)
buddy_test_when_SOURCES = \
$(buddy_sources)
noinst_PROGRAMS = \
buddy_test \
buddy_test_witness \
buddy_test_when
# Test suite
AM_TESTS_ENVIRONMENT = \
PATH="$(abs_builddir):$(VARNISH_TEST_PATH):$(PATH)" \
LD_LIBRARY_PATH="$(VARNISH_LIBRARY_PATH)"
TEST_EXTENSIONS = .vtc
VTC_LOG_COMPILER = varnishtest -l -v -b 10m
AM_VTC_LOG_FLAGS = \
-D libvmod_slash="$(abs_builddir)/.libs/libvmod_slash.so" \
-p vcl_path="$(abs_top_srcdir)/vcl:$(VARNISHAPI_VCLDIR)" \
-p vmod_path="$(abs_builddir)/.libs:$(vmoddir):$(VARNISHAPI_VMODDIR)"
TESTS = \
buddy_test \
buddy_test_witness \
buddy_test_when \
vtc/buddy_vcl.vtc \
vtc/buddy_global.vtc \
vtc/buddy_edgecases.vtc \
vtc/buddy_c00062.vtc \
vtc/buddy_c00075.vtc \
vtc/buddy_c00097.vtc \
vtc/buddy_t02005.vtc \
vtc/fellow_vcl.vtc \
vtc/fellow_global.vtc \
vtc/fellow_global_shared.vtc \
vtc/fellow_coverage.vtc \
vtc/fellow_t02005.vtc \
vtc/vut_slashmap.vtc \
vtc/loadmasters.vtc
fellow_state_tables = \
tbl/fco_states.h \
tbl/fcs_states.h \
tbl/fco_transition.h \
tbl/fcs_transition.h
fellow_sources = \
pow2_units.c \
pow2_units.h \
buddy.h \
buddy_util.h \
compiler.h \
$(fellow_state_tables) \
fellow_debug.h \
fellow_io_backend.h \
fellow_io.h \
fellow_log.c \
fellow_log.h \
fellow_log_iter_out.h \
fellow_log_dle_chg.h \
fellow_regionlist.h \
fellow_sha256.h \
fellow_sha256.c \
fellow_cache.h \
fellow_cache.c \
tbl/fellow_tunables.h \
tbl/dle.h \
fellow_tune.h \
fellow_tune.c \
fellow_hash.c \
fellow_hash.h \
fellow_hashes.h \
fellow_diag.h \
fellow_errhandling.h \
fellow_task.h \
fellow_testenv.h \
fellow_testenv.c \
include/foreign/vend.h \
include/foreign/ban.h
noinst_LTLIBRARIES += \
libfellow.la \
libfellowwitness.la
libfellow_libadd = \
$(VARNISHSRC)/lib/libvarnish/libvarnish.la $(XXHASH_LIBS)
io_ioctl_sources = \
fellow_io_ioctl.c \
fellow_io_ioctl.h
fellow_sources += $(io_ioctl_sources)
if HAVE_URING
fellow_sources += fellow_io_uring.c
libfellow_libadd += -luring
else
if HAVE_ASYNCH
fellow_sources += fellow_io_aio.c
else
fellow_sources += fellow_io_threads.c
endif
endif
libfellow_la_CFLAGS = $(AM_CFLAGS) $(DEV_CFLAGS) $(XXHASH_CFLAGS)
libfellowwitness_la_CFLAGS = $(libfellow_la_CFLAGS) \
-DBUDDY_WITNESS -DDEBUG
libfellow_la_SOURCES = $(fellow_sources)
libfellowwitness_la_SOURCES = $(libfellow_la_SOURCES)
libfellow_la_LIBADD = $(libfellow_libadd) libbuddy.la
libfellowwitness_la_LIBADD = $(libfellow_libadd) libbuddywitness.la
############################################################
## log_dbg: output the log contents
fellow_log_dbg_CFLAGS = $(AM_CFLAGS) $(DEV_CFLAGS) $(XXHASH_CFLAGS) \
-DDEBUG -DFDBGL=2
fellow_log_dbg_LDADD = $(libfellow_libadd) libbuddy.la
# fellow sources without the following:
# fellow_cache.h \
# fellow_cache.c \
pow2_units.c \
pow2_units.h \
#
fellow_log_dbg_SOURCES = fellow_log_dbg.c \
buddy.h \
buddy_util.h \
$(fellow_state_tables) \
fellow_debug.h \
fellow_io_backend.h \
fellow_io.h \
fellow_log.c \
fellow_log.h \
fellow_log_iter_out.h \
fellow_log_dle_chg.h \
fellow_regionlist.h \
fellow_sha256.h \
fellow_sha256.c \
tbl/fellow_tunables.h \
tbl/dle.h \
fellow_tune.h \
fellow_tune.c \
fellow_hash.c \
fellow_hash.h \
fellow_hashes.h \
fellow_diag.h \
fellow_errhandling.h \
fellow_task.h \
fellow_testenv.h \
fellow_testenv.c \
include/foreign/vend.h
fellow_log_dbg_SOURCES += $(io_ioctl_sources)
# XXX duplication
if HAVE_URING
fellow_log_dbg_SOURCES += fellow_io_uring.c
fellow_log_dbg_LDADD += -luring
else
if HAVE_ASYNCH
fellow_log_dbg_SOURCES += fellow_io_aio.c
else
fellow_log_dbg_SOURCES += fellow_io_threads.c
endif
endif
############################################################
## test programs
fellow_log_test_ndebug_LDADD = libfellow.la
fellow_log_test_ndebug_CFLAGS = $(AM_CFLAGS) $(DEV_CFLAGS) $(XXHASH_CFLAGS) -DTEST_DRIVER
fellow_log_test_ndebug_SOURCES = fellow_log_test.c
fellow_log_test_LDFLAGS = $(fellow_log_test_ndebug_LDFLAGS)
fellow_log_test_LDADD = libfellowwitness.la
fellow_log_test_CFLAGS = $(fellow_log_test_ndebug_CFLAGS) \
-DDEBUG -DBUDDY_WITNESS
fellow_log_test_SOURCES = $(fellow_log_test_ndebug_SOURCES)
# XXX EXTRA .c FILE
fellow_cache_test_LDFLAGS = $(fellow_log_test_ndebug_LDFLAGS)
fellow_cache_test_LDADD = libfellowwitness.la
fellow_cache_test_CFLAGS = $(fellow_log_test_ndebug_CFLAGS) \
-DDEBUG -DBUDDY_WITNESS
fellow_cache_test_SOURCES = fellow_cache.c
noinst_PROGRAMS += \
fellow_log_dbg \
fellow_log_test_ndebug \
fellow_log_test \
fellow_cache_test
TESTS += \
fellow_log_test_ndebug \
fellow_log_test \
fellow_cache_test
# Code coverage
gcov: clean
$(AM_V_at)$(MAKE) $(AM_MAKEFLAGS) CC=gcc \
CFLAGS="${AM_CFLAGS} --coverage -fno-inline -g -O0" check
# Set QUIET=-q for non-verbose builds, otherwise set to empty.
QUIET_0 = -q
QUIET_ = $(QUIET_@AM_DEFAULT_V@)
QUIET = $(QUIET_@AM_V@)
coverage/lcov.info: gcov
if HAVE_LCOV
$(AM_V_at)@mkdir $(builddir)/coverage
$(AM_V_GEN) $(LCOV) $(QUIET) -c -d . -o $(builddir)/coverage/lcov.info
else
@echo "================================================="
@echo "You need lcov installed to generate coverage data"
@echo "================================================="
@false
endif
coverage: coverage/lcov.info
if HAVE_GENHTML
$(AM_V_GEN) $(GENHTML) $(QUIET) $(builddir)/coverage/lcov.info \
-o $(builddir)/coverage
else
@echo "======================================================="
@echo "You need genhtml installed to generate coverage reports"
@echo "======================================================="
@false
endif
CLEANFILES = \
$(builddir)/*.gcda \
$(builddir)/*.gcno
clean-local:
@rm -rf $(builddir)/coverage
# VSC
.vsc.c:
$(VSCTOOL) -c $<
.vsc.h:
$(VSCTOOL) -h $<
.vsc.rst:
$(VSCTOOL) -r $< >$@.tmp
@cat $@.tmp >$@
@rm -f $@.tmp
EXTRA_DIST = \
VSC_buddy.vsc \
VSC_fellow.vsc
VSC_SOURCES = \
VSC_buddy.c \
VSC_buddy.h \
VSC_fellow.c \
VSC_fellow.h
VSC_RST = \
VSC_buddy.rst \
VSC_fellow.rst
slash-counters.7: $(VSC_RST)
nodist_libvmod_slash_la_SOURCES += $(VSC_SOURCES)
buddy_storage.c: VSC_buddy.h
fellow_storage.c: VSC_fellow.h
# DOT
fcs_states.dot: $(fellow_state_tables)
# cat instead of mv: graphviz does not update for new file
.doth.dot:
@rm -f $@.h
@ln $< $@.h || cp $< $@.h
$(AM_V_GEN) ( \
$(CPP) -I$(srcdir) $@.h | sed '/^#/ d; s:\\n *:\
:g') >$@.tmp
@rm -f $@.h
@cat $@.tmp >$@
@rm -f $@.tmp
# Documentation
dist_doc_DATA = \
vmod_slash.vcc
dist_man_MANS = \
vmod_slash.3 \
slashmap.1 \
slash-counters.7
@GENERATE_SLASHMAP_DOCS@
.rst.1:
$(AM_V_GEN) $(RST2MAN) $< $@
.rst.7:
$(AM_V_GEN) $(RST2MAN) $< $@
.PHONY: flint
# XXX slashmap should be flexelinted when time, for now it does not matter
# XXX TODO flexelint fellow_io_*
flint:
flexelint $(VARNISHSRC_CFLAGS) -I .. flint.lnt \
`ls *.c | grep -vE 'fellow_io_aio|fellow_io_threads|fellow_log_test.c|slashmap.c'`
..
SPDX-License-Identifier: LGPL-2.1-only
Copyright 2023 UPLEX Nils Goroll Systemoptimierung. All rights reserved.
Author: Nils Goroll <nils.goroll@uplex.de>
*
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, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA Also add information on how to contact you by
electronic and paper mail.
.. varnish_vsc_begin:: buddy
:oneliner: buddy Stevedore Counters (SLASH/ stevedores)
:order: 70
.. varnish_vsc:: c_req
:type: counter
:level: info
:oneliner: Allocator requests
Number of times the storage has been asked to provide a storage segment.
.. varnish_vsc:: c_fail
:type: counter
:level: info
:oneliner: Allocator failures
Number of times the storage has failed to provide a storage segment.
.. varnish_vsc:: c_bytes
:type: counter
:level: info
:format: bytes
:oneliner: Bytes allocated
Number of total bytes allocated by this storage.
.. varnish_vsc:: c_freed
:type: counter
:level: info
:format: bytes
:oneliner: Bytes freed
Number of total bytes returned to this storage.
.. varnish_vsc:: g_alloc
:type: gauge
:level: info
:oneliner: Allocations outstanding
Number of storage allocations outstanding.
.. varnish_vsc:: g_bytes
:type: gauge
:level: info
:format: bytes
:oneliner: Bytes outstanding
Number of bytes allocated from the storage.
Note: This number is only approximate
.. varnish_vsc:: g_space
:type: gauge
:level: info
:format: bytes
:oneliner: Bytes available
Number of bytes left in the storage.
Note: This number is only approximate
.. varnish_vsc_end:: buddy
..
SPDX-License-Identifier: LGPL-2.1-only
Copyright 2023 UPLEX Nils Goroll Systemoptimierung. All rights reserved.
Author: Nils Goroll <nils.goroll@uplex.de>
*
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, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
02110-1301 USA Also add information on how to contact you by
electronic and paper mail.
.. varnish_vsc_begin:: fellow
:oneliner: fellow Stevedore Counters (SLASH/ stevedores)
:order: 70
.. varnish_vsc:: c_allocobj
:type: counter
:level: info
:oneliner: Requests to allocate an object
Number of times the storage has been asked to create an object
.. varnish_vsc:: c_allocobj_fail
:type: counter
:level: info
:oneliner: Object creation failures
Number of times the storage failed to create an object
.. varnish_vsc:: c_dsk_obj_get_present
:type: counter
:level: info
:oneliner: Access to a disk object which was already present
Number of times a memory pointer was already present for a disk object
.. varnish_vsc:: c_dsk_obj_get_fail
:type: counter
:level: info
:oneliner: Access to a disk object failed
Number of times access to a disk object failed
.. varnish_vsc:: c_dsk_obj_get
:type: counter
:level: info
:oneliner: Access to a disk object
Number of times a disk object (vampireobject) was read and turned
into a memory object (object)
.. varnish_vsc:: c_dsk_obj_get_coalesce
:type: counter
:level: info
:oneliner: Access to a disk object when already in progress
Number of times a disk object (vampireobject) was accessed and
a get operation was already in progress
.. varnish_vsc:: c_mem_obj_free
:type: counter
:level: info
:oneliner: Memory object free operations
Number of times a memory object was freed
.. varnish_vsc:: c_dsk_obj_free_thin
:type: counter
:level: info
:oneliner: Disk object free operations with thin deletion
Number of times a disk object was freed by logging a thin deletion
request to be executed with the next log rewrite.
.. varnish_vsc:: c_dsk_obj_free_get
:type: counter
:level: info
:oneliner: Disk object free operations with disk read
Number of times a disk object was freed by reading the object.
Each operation also adds one to one of the c_dsk_obj_get_*
counters.
.. varnish_vsc:: c_mem_obj_mutate
:type: counter
:level: info
:oneliner: Memory object evictions
Number of times an object was evicted from memory and turned
into a disk object (vampireobject). The term mutate was chosen
in favor of "vampirization" or similar.
.. varnish_vsc:: g_mem_bytes
:type: gauge
:level: info
:format: bytes
:oneliner: Memory Bytes outstanding
Number of bytes allocated from memory
Note: This number is only approximate
.. varnish_vsc:: g_mem_space
:type: gauge
:level: info
:format: bytes
:oneliner: Memory Bytes available
Number of bytes left in memory
Note: This number is only approximate
.. varnish_vsc:: g_dsk_bytes
:type: gauge
:level: info
:format: bytes
:oneliner: Disk Bytes outstanding
Number of bytes allocated from disk
Note: This number is only approximate
.. varnish_vsc:: g_dsk_space
:type: gauge
:level: info
:format: bytes
:oneliner: Disk Bytes available
Number of bytes left in disk
Note: This number is only approximate
.. varnish_vsc_end:: fellow
/*-
* SPDX-License-Identifier: LGPL-2.1-only
* Copyright 2022 UPLEX Nils Goroll Systemoptimierung. All rights reserved.
* Author: Nils Goroll <nils.goroll@uplex.de>
*
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA Also add information on how to contact you by
* electronic and paper mail.
*/
#include <stdint.h>
#include <unistd.h>
#include <string.h>
#include <assert.h>
#include "bitsof.h"
/*
* bitf_index() / (struct bitf).idxoff:
*
* We accelerate lookup in large bitfields with an index which has a bit set IFF
* a word is non-zero
*
* As each index is recursively indexed also, we effectively reduce lookup time
* to log(size), equaling that of a btree without the memory overhead
*
* idxoff is relative to the address of the bitfield itself to support
* relocation
*/
struct bitf {
unsigned magic;
#define BITF_MAGIC 0x91ebd5ff
size_t nbits;
size_t nset; // count of set bits
size_t idxoff; // distance to next index or 0 if none
void *extra;
bitf_word_t bits[];
};
#define wsz sizeof(bitf_word_t)
#define wbits (wsz * 8)
#define index_thr (wbits * 8)
#define bitf_words(bits) ((((bits + 7) / 8) + wsz - 1) / wsz)
#define bitf_sz1(bits) (sizeof(struct bitf) + bitf_words(bits) * wsz)
static inline size_t
bitf_sz(size_t bits)
{
size_t sz;
sz = bitf_sz1(bits);
while (bits > index_thr) {
bits /= wbits;
bits++;
sz += bitf_sz1(bits);
}
return (sz);
}
// pointer to word from bits
#define bitf_word(bitf, bit) \
(assert((bitf)->magic == BITF_MAGIC), \
assert((bit) < (bitf)->nbits), \
&(bitf)->bits[bit / wbits])
// set bit in word
#define bitf_bit(bit) ((bitf_word_t)1 << (bit % wbits))
static inline struct bitf *
bitf_init(void *p, size_t bits, size_t space)
{
struct bitf *bitf;
size_t sz = bitf_sz1(bits);
char *pp;
assert(space >= sz);
memset(p, 0, sz);
bitf = p;
bitf->magic = BITF_MAGIC;
bitf->nbits = bits;
if (bits > index_thr) {
bits /= wbits;
bits++;
pp = p;
pp += sz;
space -= sz;
bitf->idxoff = sz;
p = bitf_init(pp, bits, space);
assert(p);
}
return (bitf);
}
static inline struct bitf *
bitf_indexl(struct bitf *bitf)
{
assert(bitf->idxoff);
//lint --e(826)
return ((struct bitf *)((char *)bitf + bitf->idxoff));
}
static inline const struct bitf *
bitf_indexr(const struct bitf *bitf)
{
assert(bitf->idxoff);
//lint --e(826)
return ((const struct bitf *)((const char *)bitf + bitf->idxoff));
}
// return if bit was set (1: was zero, 0: was already one)
static inline unsigned
bitf_set(struct bitf *bitf, size_t bit)
{
bitf_word_t *w = bitf_word(bitf, bit);
const bitf_word_t b = bitf_bit(bit);
unsigned c, o;
if (bitf->idxoff && !*w) {
c = bitf_set(bitf_indexl(bitf), bit / wbits);
assert(c);
}
o = !(*w & b);
*w |= b;
bitf->nset += o;
return (o);
}
// number of bits set
static inline size_t
bitf_nset(const struct bitf *bitf)
{
CHECK_OBJ_NOTNULL(bitf, BITF_MAGIC);
return (bitf->nset);
}
// number of bit set
static inline size_t
bitf_nbits(const struct bitf *bitf)
{
CHECK_OBJ_NOTNULL(bitf, BITF_MAGIC);
return (bitf->nbits);
}
// return if bit was cleared (1: was one, 0: was already zero)
static inline unsigned
bitf_clr(struct bitf *bitf, size_t bit)
{
bitf_word_t *w = bitf_word(bitf, bit);
const bitf_word_t b = bitf_bit(bit);
unsigned c, o;
o = !!(*w & b);
*w &= ~b;
bitf->nset -= o;
if (bitf->idxoff && !*w && o) {
c = bitf_clr(bitf_indexl(bitf), bit / wbits);
assert(c);
}
return (o);
}
static inline int
bitf_get(const struct bitf *bitf, size_t bit)
{
const bitf_word_t *w = bitf_word(bitf, bit);
return !!(*w & bitf_bit(bit));
}
/* return bit number PLUS ONE or 0 if none set */
static inline size_t
bitf_ffs(const struct bitf *bitf)
{
const bitf_word_t *w = bitf->bits;
const size_t l = bitf_words(bitf->nbits);
size_t u = 0;
int t;
if (bitf->idxoff) {
u = bitf_ffs(bitf_indexr(bitf));
if (u == 0)
return (0);
u--;
}
for (w += u; u < l; u++, w++) {
if (*w == 0)
continue;
t = ffsszt(*w);
assert(t > 0);
return (u * wbits + (unsigned)t);
}
return (0);
}
/* return bit number PLUS ONE or 0 if none set
* at or after a start bit position
*
* should work approximately correct for dirty/unlocked/concurrent
* reads
*/
static inline size_t
bitf_ffs_from(const struct bitf *bitf, size_t start)
{
const size_t l = bitf_words(bitf->nbits);
size_t s, u, b;
int t;
const bitf_word_t *w = bitf->bits;
bitf_word_t ww;
s = start / wbits;
b = start % wbits;
if (bitf->idxoff) {
u = bitf_ffs_from(bitf_indexr(bitf), s);
if (u == 0)
return (0);
u--;
if (u > s) {
s = u;
b = 0;
} else
assert(u == s);
}
for (u = s, w += u; u < l; u++, w++) {
ww = *w;
if (ww == 0)
continue;
t = ffsszt(ww);
// DIRTY assert(t > 0);
if (u != s || (t > 0 && (unsigned)t > b))
return (u * wbits + (unsigned)t);
/* in our word, the first set bit is before the start
* we clear all bits bits before the start and check
* if another one is set
*/
AN(b);
ww &= ~(((bitf_word_t)1 << b) - 1);
t = ffsszt(ww);
if (t > 0)
return (u * wbits + (unsigned)t);
}
return (0);
}
/*
* unless *cache is reset to SIZE_MAX, must be called with increasing start
* values only
*/
static inline size_t
bitf_ffs_from_cached(const struct bitf *bitf, size_t *cache, size_t start)
{
size_t b;
AN(cache);
b = *cache;
if (b == 0 || (b > start && b < SIZE_MAX))
return (b);
b = bitf_ffs_from(bitf, start);
*cache = b;
return (b);
}
/*-
* SPDX-License-Identifier: LGPL-2.1-only
* Copyright 2022 UPLEX Nils Goroll Systemoptimierung. All rights reserved.
* Author: Nils Goroll <nils.goroll@uplex.de>
*
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA Also add information on how to contact you by
* electronic and paper mail.
*/
#ifndef BITSOF_H
#define BITSOF_H
// XXX autoconf to check for builtin, else use ffsl ffsll
#if SIZE_MAX == 0xffffffffffffffff
#define clzszt(v) __builtin_clzll(v)
#define ffsszt(v) __builtin_ffsll(v)
typedef unsigned long long bitf_word_t;
#elif SIZE_MAX == 0xffffffff
#define clzszt(v) __builtin_clzl(v)
#define ffsszt(v) __builtin_ffsl(v)
typedef unsigned long bitf_word_t;
#else
#error unsupported size_t
#endif
#define bitsof(v) (sizeof(v) * 8 - (unsigned)clzszt(v))
#endif
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
/*-
* SPDX-License-Identifier: LGPL-2.1-only
* Copyright 2022,2023 UPLEX Nils Goroll Systemoptimierung. All rights reserved.
* Author: Nils Goroll <nils.goroll@uplex.de>
*
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA Also add information on how to contact you by
* electronic and paper mail.
*/
struct stevedore *
sbu_new(const char *id, size_t *sz, size_t *min);
void sbu_fini(struct stevedore **);
struct stvbu_tune;
void
sbu_tune_get(const struct stevedore *stv, struct stvbu_tune *tune);
const char *
sbu_tune_apply(const struct stevedore *stv, const struct stvbu_tune *tuna);
int sbu_is(VCL_STEVEDORE);
void sbu_as_transient(struct stevedore *);
/*-
* SPDX-License-Identifier: LGPL-2.1-only
* Copyright 2023 UPLEX Nils Goroll Systemoptimierung. All rights reserved.
* Author: Nils Goroll <nils.goroll@uplex.de>
*
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA Also add information on how to contact you by
* electronic and paper mail.
*/
#include "config.h"
#include <assert.h>
#include <string.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include "miniobj.h"
#include "buddy_tune.h"
#include "buddy_util.h"
/* initialize with sane defaults */
const char *
stvbu_tune_init(struct stvbu_tune *tune, size_t sz)
{
INIT_OBJ(tune, STVBU_TUNE_MAGIC);
//lint -e773,
#define TUNE(t, n, d, min, max) \
tune->n = (d)
#include "tbl/buddy_tunables.h"
//lint +e773,
tune->sz = sz;
return (stvbu_tune_check(tune));
}
// XXX VSL for warnigs
const char *
stvbu_tune_check(struct stvbu_tune *tune)
{
unsigned l;
size_t sz;
l = log2down(tune->sz) - 4;
if (tune->chunk_exponent > l) {
fprintf(stderr,"buddy: chunk_exponent limited to %u "
"(less than 1/16 of memory size)\n", l);
tune->reserve_chunks <<= (tune->chunk_exponent - l);
tune->chunk_exponent = l;
}
sz = tune->sz >> (tune->chunk_exponent - 1);
assert(sz <= UINT_MAX);
l = (unsigned)sz;
if (tune->reserve_chunks > l) {
fprintf(stderr,"buddy: reserve_chunks limited to %u "
"(less than 1/8 of memory size)\n", l);
tune->reserve_chunks = l;
}
//lint --e{685,568} misc const comparisons
#define TUNE(t, n, d, min, max) \
if (tune->n < (min)) \
return ("Value of " #n " is too small, minimum is " #min); \
if (tune->n > (max)) \
return ("Value of " #n " is too big, maximum is " #max); \
#include "tbl/buddy_tunables.h"
return (NULL);
}
/*-
* SPDX-License-Identifier: LGPL-2.1-only
* Copyright 2023 UPLEX Nils Goroll Systemoptimierung. All rights reserved.
* Author: Nils Goroll <nils.goroll@uplex.de>
*
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA Also add information on how to contact you by
* electronic and paper mail.
*/
struct stvbu_tune {
unsigned magic;
#define STVBU_TUNE_MAGIC 0x65755427
#define TUNE(t, n, d, min, max) \
t n
#include "tbl/buddy_tunables.h"
size_t sz;
};
const char *
stvbu_tune_init(struct stvbu_tune *tune, size_t sz);
const char *
stvbu_tune_check(struct stvbu_tune *tune);
/*-
* SPDX-License-Identifier: LGPL-2.1-only
* Copyright 2022 UPLEX Nils Goroll Systemoptimierung. All rights reserved.
* Author: Nils Goroll <nils.goroll@uplex.de>
*
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA Also add information on how to contact you by
* electronic and paper mail.
*/
#include "bitsof.h"
/*
* min is the number of bits of the minimum allocation
*/
static inline size_t
rup_min(size_t size, unsigned minbits)
{
size_t min;
min = (size_t)1 << minbits;
min--;
size += min;
size &= ~min;
return (size);
}
static inline size_t
rdown_min(size_t size, unsigned minbits)
{
size_t min;
min = (size_t)1 << minbits;
min--;
return (size & ~min);
}
/* next log 2 of sz */
static inline unsigned
log2up(size_t sz)
{
sz--;
sz = bitsof(sz);
assert(sz > 0);
assert(sz <= UINT_MAX);
return ((unsigned) sz);
}
/* prev log 2 of sz */
static inline unsigned
log2down(size_t sz)
{
sz = bitsof(sz) - 1;
assert(sz <= UINT_MAX);
return ((unsigned) sz);
}
This diff is collapsed.
// from linux
#define likely(x) __builtin_expect(!!(x), 1)
//#define unlikely(x) __builtin_expect(!!(x), 0)
/*-
* SPDX-License-Identifier: LGPL-2.1-only
* Copyright 2022 UPLEX Nils Goroll Systemoptimierung. All rights reserved.
* Author: Nils Goroll <nils.goroll@uplex.de>
*
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA Also add information on how to contact you by
* electronic and paper mail.
*/
#ifdef DEBUG
#include <stdio.h>
#define _DBG(f, x, ...) fprintf(stderr, "dbg %s " x "\n", __func__, __VA_ARGS__)
#define DBG(x, ...) _DBG(__func__, x,__VA_ARGS__)
#else
#define DBG(x, ...) (void)0
#endif
/* -*- c -*- */
#define FCS(x) FCS_ ## x
#define FCO(x) FCO_ ## x
#define FCOSD(x, s, c, lru, fdb, mem, dsk) \
x ## _ ## s
//x ## _ ## s [label=#x + "_" + #s + "\l" + c]\n
digraph fco_fcs_state {
subgraph xcluster_fco {
#include "tbl/fco_states.h"
#define FCOT(f, t, c) \
FCO_ ## f -> FCO_ ## t
//FCO_ ## f -> FCO_ ## t [label=c]
#include "tbl/fco_transition.h"
}
subgraph xcluster_fcs {
#include "tbl/fcs_states.h"
#define FCST(f, t, c) \
FCS_ ## f -> FCS_ ## t
//FCS_ ## f -> FCS_ ## t [label=c]
#include "tbl/fcs_transition.h"
}
}
This diff is collapsed.
This diff is collapsed.
/*-
* SPDX-License-Identifier: LGPL-2.1-only
* Copyright 2022,2023 UPLEX Nils Goroll Systemoptimierung. All rights reserved.
* Author: Nils Goroll <nils.goroll@uplex.de>
*
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA Also add information on how to contact you by
* electronic and paper mail.
*/
void fellow_cache_obj_evict_mutate(struct fellow_cache *fc,
struct fellow_cache_obj *fco);
void stvfe_oc_log_removed(struct objcore *oc);
void stvfe_oc_log_submitted(struct objcore *oc);
void stvfe_oc_dle_obj(struct objcore *oc, struct fellow_dle *e);
int stvfe_mutate(struct worker *wrk, struct objcore *oc);
void stvfe_sumstat(struct worker *wrk); // wraps Pool_Sumstat(wrk);
This diff is collapsed.
/*-
* SPDX-License-Identifier: LGPL-2.1-only
* Copyright 2022 UPLEX Nils Goroll Systemoptimierung. All rights reserved.
* Author: Nils Goroll <nils.goroll@uplex.de>
*
* 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, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301 USA Also add information on how to contact you by
* electronic and paper mail.
*/
// v_printfike
#if __GNUC_PREREQ__(2, 95) || defined(__INTEL_COMPILER)
# define fe_printflike_(f,a) __attribute__((format(printf, f, a)))
#else
# define fe_printflike_(f,a)
#endif
typedef void fellow_diag_f(const char *fmt, ...) fe_printflike_(1, 2);
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment