From 83945d1b88bfb8334c54115ccb9fd354a0155081 Mon Sep 17 00:00:00 2001 From: Alan Maguire Date: Tue, 22 Aug 2023 16:17:02 +0100 Subject: [PATCH 1/2] bpftune: rename tcp_cong_tuner -> tcp_conn_tuner we will implement alternate per-connection strategy --- README.md | 4 ++-- docs/Makefile | 2 +- docs/{bpftune-tcp-cong.rst => bpftune-tcp-conn.rst} | 8 ++++---- src/Makefile | 2 +- src/probe.bpf.c | 2 +- src/{tcp_cong_tuner.bpf.c => tcp_conn_tuner.bpf.c} | 2 +- src/{tcp_cong_tuner.c => tcp_conn_tuner.c} | 12 ++++++------ src/{tcp_cong_tuner.h => tcp_conn_tuner.h} | 0 8 files changed, 16 insertions(+), 16 deletions(-) rename docs/{bpftune-tcp-cong.rst => bpftune-tcp-conn.rst} (90%) rename src/{tcp_cong_tuner.bpf.c => tcp_conn_tuner.bpf.c} (99%) rename src/{tcp_cong_tuner.c => tcp_conn_tuner.c} (94%) rename src/{tcp_cong_tuner.h => tcp_conn_tuner.h} (100%) diff --git a/README.md b/README.md index 712b9fa..1420bab 100644 --- a/README.md +++ b/README.md @@ -147,8 +147,8 @@ The key components are ## Supported tuners -- congestion tuner: auto-tune choice of congestion control algorithm. - See bpftune-tcp-cong (8). +- TCP connection tuner: auto-tune choice of congestion control algorithm. + See bpftune-tcp-conn (8). - neighbour table tuner: auto-tune neighbour table sizes by growing tables when approaching full. See bpftune-neigh (8). - route table tuner: auto-tune route table size by growing tables diff --git a/docs/Makefile b/docs/Makefile index 4038651..2c08807 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -34,7 +34,7 @@ installprefix = $(DESTDIR)/$(prefix) mandir ?= $(prefix)/man man8dir = $(mandir)/man8 -MAN8_RST = bpftune.rst bpftune-sysctl.rst bpftune-tcp-cong.rst \ +MAN8_RST = bpftune.rst bpftune-sysctl.rst bpftune-tcp-conn.rst \ bpftune-neigh.rst bpftune-tcp-buffer.rst bpftune-netns.rst \ bpftune-net-buffer.rst diff --git a/docs/bpftune-tcp-cong.rst b/docs/bpftune-tcp-conn.rst similarity index 90% rename from docs/bpftune-tcp-cong.rst rename to docs/bpftune-tcp-conn.rst index e028eac..b22d633 100644 --- a/docs/bpftune-tcp-cong.rst +++ b/docs/bpftune-tcp-conn.rst @@ -1,16 +1,16 @@ ================ BPFTUNE-TCP-CONG ================ -------------------------------------------------------------------------------- -Congestion bpftune plugin for auto-selection of congestion control algorithm -------------------------------------------------------------------------------- +-------------------------------------------------------------------------------- +TCP connection bpftune plugin for auto-selection of congestion control algorithm +-------------------------------------------------------------------------------- :Manual section: 8 DESCRIPTION =========== - The congestion algorithm tuner sets congestion control algorithm on + The TCP connection algorithm tuner sets congestion control algorithm on TCP sockets. Linux uses cubic by default, and it works well in a wide range of settings, however it can under-perform in lossy networks. diff --git a/src/Makefile b/src/Makefile index 0ba4acd..3f1a071 100644 --- a/src/Makefile +++ b/src/Makefile @@ -84,7 +84,7 @@ submake_extras := feature_display=0 endif TUNERS = tcp_buffer_tuner route_table_tuner neigh_table_tuner sysctl_tuner \ - tcp_cong_tuner netns_tuner net_buffer_tuner + tcp_conn_tuner netns_tuner net_buffer_tuner TUNER_OBJS = $(patsubst %,%.o,$(TUNERS)) TUNER_SRCS = $(patsubst %,%.c,$(TUNERS)) diff --git a/src/probe.bpf.c b/src/probe.bpf.c index 39a452a..91493e7 100644 --- a/src/probe.bpf.c +++ b/src/probe.bpf.c @@ -19,7 +19,7 @@ #include #include "netns_tuner.h" -#include "tcp_cong_tuner.h" +#include "tcp_conn_tuner.h" /* probe hash map */ BPF_MAP_DEF(probe_hash_map, BPF_MAP_TYPE_HASH, __u64, __u64, 65536); diff --git a/src/tcp_cong_tuner.bpf.c b/src/tcp_conn_tuner.bpf.c similarity index 99% rename from src/tcp_cong_tuner.bpf.c rename to src/tcp_conn_tuner.bpf.c index 95b066c..74eeb30 100644 --- a/src/tcp_cong_tuner.bpf.c +++ b/src/tcp_conn_tuner.bpf.c @@ -19,7 +19,7 @@ #include -#include "tcp_cong_tuner.h" +#include "tcp_conn_tuner.h" const char bbr[4] = { 'b', 'b', 'r', '\0' }; diff --git a/src/tcp_cong_tuner.c b/src/tcp_conn_tuner.c similarity index 94% rename from src/tcp_cong_tuner.c rename to src/tcp_conn_tuner.c index 79e5046..47562f1 100644 --- a/src/tcp_cong_tuner.c +++ b/src/tcp_conn_tuner.c @@ -18,10 +18,10 @@ */ #include -#include "tcp_cong_tuner.h" -#include "tcp_cong_tuner.skel.h" -#include "tcp_cong_tuner.skel.legacy.h" -#include "tcp_cong_tuner.skel.nobtf.h" +#include "tcp_conn_tuner.h" +#include "tcp_conn_tuner.skel.h" +#include "tcp_conn_tuner.skel.legacy.h" +#include "tcp_conn_tuner.skel.nobtf.h" #include #include @@ -40,7 +40,7 @@ static struct bpftunable_scenario scenarios[] = { "Because loss rate has exceeded 1 percent for a connection, use bbr congestion control algorithm instead of default" }, }; -struct tcp_cong_tuner_bpf *skel; +struct tcp_conn_tuner_bpf *skel; int tcp_iter_fd; @@ -56,7 +56,7 @@ int init(struct bpftuner *tuner) bpftune_log(LOG_DEBUG, "could not load tcp_bbr module: %s\n", strerror(-err)); - err = bpftuner_bpf_init(tcp_cong, tuner, NULL); + err = bpftuner_bpf_init(tcp_conn, tuner, NULL); if (err) return err; diff --git a/src/tcp_cong_tuner.h b/src/tcp_conn_tuner.h similarity index 100% rename from src/tcp_cong_tuner.h rename to src/tcp_conn_tuner.h From ce23d20dc282b6d496ccde07d29fcc95de8f6fbd Mon Sep 17 00:00:00 2001 From: Alan Maguire Date: Tue, 22 Aug 2023 17:38:10 +0100 Subject: [PATCH 2/2] make strategy evaluation return "long double" this allows us to compute more complex strategy evaluations --- include/bpftune/bpftune.h | 2 +- src/libbpftune.c | 2 +- test/strategy/strategy_tuner.c | 12 ++++++------ 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/include/bpftune/bpftune.h b/include/bpftune/bpftune.h index f70c5a5..fc4ae68 100644 --- a/include/bpftune/bpftune.h +++ b/include/bpftune/bpftune.h @@ -144,7 +144,7 @@ struct bpftuner_strategy { const char *name; const char *description; /* return a number to compare with other strategies */ - int (*evaluate)(struct bpftuner *tuner, struct bpftuner_strategy *strategy); + long double (*evaluate)(struct bpftuner *tuner, struct bpftuner_strategy *strategy); unsigned long timeout; /* time in seconds until evaluation */ const char **bpf_progs; /* programs to load in BPF skeleton for this * strategy; if NULL, all */ diff --git a/src/libbpftune.c b/src/libbpftune.c index fa41afa..9e43858 100644 --- a/src/libbpftune.c +++ b/src/libbpftune.c @@ -1534,7 +1534,7 @@ int bpftune_module_unload(const char *name) static void bpftuner_strategy_update(struct bpftuner *tuner) { struct bpftuner_strategy *strategy, *max_strategy = NULL; - int curr, max = 0; + long double curr, max = 0; if (!tuner->strategies) return; diff --git a/test/strategy/strategy_tuner.c b/test/strategy/strategy_tuner.c index 532b0f2..72044b4 100644 --- a/test/strategy/strategy_tuner.c +++ b/test/strategy/strategy_tuner.c @@ -23,12 +23,12 @@ #include "strategy_tuner.skel.legacy.h" #include "strategy_tuner.skel.nobtf.h" -static int evaluate_A(struct bpftuner *tuner, struct bpftuner_strategy *strategy) +static long double evaluate_A(struct bpftuner *tuner, struct bpftuner_strategy *strategy) { if (tuner->strategy == strategy) - return 0; + return (long double)0; else - return 1; + return (long double)1; } const char *progs_A[] = { "entry__proc_dostring_coredump", NULL }; @@ -41,12 +41,12 @@ struct bpftuner_strategy strategy_A = { .bpf_progs = progs_A, }; -static int evaluate_B(struct bpftuner *tuner, struct bpftuner_strategy *strategy) +static long double evaluate_B(struct bpftuner *tuner, struct bpftuner_strategy *strategy) { if (tuner->strategy == strategy) - return 0; + return (long double)0; else - return 1; + return (long double)1; } const char *progs_B[] = { "entry__proc_dostring", NULL };