about summary refs log tree commit diff
path: root/modules/system/kernel/bfq/default.nix
blob: a4b593ee5b8e4064236aa20236259804a5031697 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
{ config, lib, ... }:

let
  inherit (config.boot.kernelPackages.kernel) version;
  inherit (lib) optionalString versionAtLeast versionOlder;
in {
  options.vuizvui.system.kernel.bfq = {
    enable = lib.mkEnableOption "Enable the BFQ scheduler by default";
  };

  config = lib.mkIf config.vuizvui.system.kernel.bfq.enable {
    boot.kernelPatches = lib.singleton {
      name = "bfq";
      patch =
        if      versionAtLeast version "5.4"  then ./bfq-by-default-5.4.patch
        else if versionAtLeast version "4.18" then ./bfq-by-default-4.18.patch
        else if versionAtLeast version "4.15" then ./bfq-by-default-4.15.patch
        else ./bfq-by-default.patch;
      extraConfig = ''
        SCSI_MQ_DEFAULT? y
        DM_MQ_DEFAULT? y
        IOSCHED_BFQ y
        BFQ_GROUP_IOSCHED y
      '';
    };

    vuizvui.requiresTests = lib.singleton ["vuizvui" "system" "kernel" "bfq"];

    assertions = lib.singleton {
      assertion = versionAtLeast version "4.12";

      message = "The BFQ scheduler in conjunction with blk-mq requires "
              + "at least kernel 4.12.";
    };
  };
}