Merge pull request #240452 from NickCao/bpftune

This commit is contained in:
Sandro 2023-07-18 12:43:02 +02:00 committed by GitHub
commit 065fd18e5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 119 additions and 0 deletions

View File

@ -1142,6 +1142,7 @@
./services/security/vaultwarden/default.nix
./services/security/yubikey-agent.nix
./services/system/automatic-timezoned.nix
./services/system/bpftune.nix
./services/system/cachix-agent/default.nix
./services/system/cachix-watch-store.nix
./services/system/cloud-init.nix

View File

@ -0,0 +1,22 @@
{ config, lib, pkgs, ... }:
let
cfg = config.services.bpftune;
in
{
meta = {
maintainers = with lib.maintainers; [ nickcao ];
};
options = {
services.bpftune = {
enable = lib.mkEnableOption (lib.mdDoc "bpftune BPF driven auto-tuning");
package = lib.mkPackageOptionMD pkgs "bpftune" { };
};
};
config = lib.mkIf cfg.enable {
systemd.packages = [ cfg.package ];
systemd.services.bpftune.wantedBy = [ "multi-user.target" ];
};
}

View File

@ -138,6 +138,7 @@ in {
borgbackup = handleTest ./borgbackup.nix {};
botamusique = handleTest ./botamusique.nix {};
bpf = handleTestOn ["x86_64-linux" "aarch64-linux"] ./bpf.nix {};
bpftune = handleTest ./bpftune.nix {};
breitbandmessung = handleTest ./breitbandmessung.nix {};
brscan5 = handleTest ./brscan5.nix {};
btrbk = handleTest ./btrbk.nix {};

20
nixos/tests/bpftune.nix Normal file
View File

@ -0,0 +1,20 @@
import ./make-test-python.nix ({ lib, pkgs, ... }: {
name = "bpftune";
meta = {
maintainers = with lib.maintainers; [ nickcao ];
};
nodes = {
machine = { pkgs, ... }: {
services.bpftune.enable = true;
};
};
testScript = ''
machine.wait_for_unit("bpftune.service")
machine.wait_for_console_text("bpftune works")
'';
})

View File

@ -0,0 +1,73 @@
{ lib
, stdenv
, fetchFromGitHub
, clang
, bpftools
, docutils
, libbpf
, libcap
, libnl
, nixosTests
}:
stdenv.mkDerivation rec {
pname = "bpftune";
version = "unstable-2023-07-14";
src = fetchFromGitHub {
owner = "oracle-samples";
repo = "bpftune";
rev = "66620152bf8c37ab592e9273fe87e567126801c2";
hash = "sha256-U0O+F1DBF1xiaUKklwpZORBwF1T9wHM0SPQKUNaxKZk=";
};
postPatch = ''
# otherwise shrink rpath would drop $out/lib from rpath
substituteInPlace src/Makefile \
--replace /lib64 /lib \
--replace /sbin /bin \
--replace ldconfig true
substituteInPlace src/bpftune.service \
--replace /usr/sbin/bpftune "$out/bin/bpftune"
substituteInPlace include/bpftune/libbpftune.h \
--replace /usr/lib64/bpftune/ "$out/lib/bpftune/" \
--replace /usr/local/lib64/bpftune/ "$out/lib/bpftune/"
'';
nativeBuildInputs = [
clang
bpftools
docutils # rst2man
];
buildInputs = [
libbpf
libcap
libnl
];
makeFlags = [
"prefix=${placeholder "out"}"
"confprefix=${placeholder "out"}/etc"
"BPFTUNE_VERSION=${version}"
"BPF_INCLUDE=${lib.getDev libbpf}/include"
"NL_INCLUDE=${lib.getDev libnl}/include/libnl3"
];
hardeningDisable = [
"stackprotector"
];
passthru.tests = {
inherit (nixosTests) bpftune;
};
enableParallelBuilding = true;
meta = with lib; {
description = "BPF-based auto-tuning of Linux system parameters";
homepage = "https://github.com/oracle-samples/bpftune";
license = licenses.gpl2Only;
maintainers = with maintainers; [ nickcao ];
};
}

View File

@ -27226,6 +27226,8 @@ with pkgs;
bpf-linker = callPackage ../development/tools/bpf-linker { };
bpftune = callPackage ../os-specific/linux/bpftune { };
bpfmon = callPackage ../os-specific/linux/bpfmon { };
bridge-utils = callPackage ../os-specific/linux/bridge-utils { };