From b94b559058929fecb347bc78a86143ed670891d5 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Tue, 19 Dec 2023 17:21:01 -0800 Subject: [PATCH 1/5] scripts/check-config: don't check MEMCG_SWAP on newer kernels Kernel commit e55b9f96860f (which made its way into Linux v6.1-rc1) removes CONFIG_MEMCG_SWAP entirely, so there's no sense to check for in on newer kernels. Make the check conditional. Signed-off-by: Kir Kolyshkin --- script/check-config.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/script/check-config.sh b/script/check-config.sh index acc5547cf..2de94d292 100755 --- a/script/check-config.sh +++ b/script/check-config.sh @@ -255,8 +255,9 @@ echo 'Optional Features:' check_flags SECCOMP_FILTER check_flags CGROUP_PIDS - check_flags MEMCG_SWAP - + if kernel_lt 6 1; then + check_flags MEMCG_SWAP + fi if kernel_lt 5 8; then check_flags MEMCG_SWAP_ENABLED if is_set MEMCG_SWAP && ! is_set MEMCG_SWAP_ENABLED; then From 6aa4c1a13ee173b689654b528cf3c83820ceb1d5 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Tue, 19 Dec 2023 17:26:35 -0800 Subject: [PATCH 2/5] script/check-config: disable colors ...when the stdout is not a terminal, and also when NO_COLOR environment variable is set to any non-empty value (as per no-color.org). Co-authored-by: Akihiro Suda Signed-off-by: Kir Kolyshkin --- script/check-config.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/script/check-config.sh b/script/check-config.sh index 2de94d292..9c26152ea 100755 --- a/script/check-config.sh +++ b/script/check-config.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash set -e -u +[ -t 1 ] || NO_COLOR=1 + # bits of this were adapted from check_config.sh in docker # see also https://github.com/docker/docker/blob/master/contrib/check-config.sh @@ -43,6 +45,8 @@ is_set_as_module() { } color() { + [ -n "${NO_COLOR:-}" ] && return + local codes=() if [ "$1" = 'bold' ]; then codes=("${codes[@]-}" '1') From 7f65cc75c7ffa5d6cd5f94b2a046a807c246578e Mon Sep 17 00:00:00 2001 From: Akihiro Suda Date: Fri, 15 Dec 2023 11:33:17 +0900 Subject: [PATCH 3/5] script/check-config.sh: check CONFIG_CHECKPOINT_RESTORE Signed-off-by: Akihiro Suda --- script/check-config.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/script/check-config.sh b/script/check-config.sh index 9c26152ea..642ff33a1 100755 --- a/script/check-config.sh +++ b/script/check-config.sh @@ -302,5 +302,6 @@ flags=( IP_VS_RR SECURITY_SELINUX SECURITY_APPARMOR + CHECKPOINT_RESTORE ) check_flags "${flags[@]}" From d87366f0195e72616fe2e5323ca89862b9714ca6 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Tue, 19 Dec 2023 19:24:09 -0800 Subject: [PATCH 4/5] scripts/check-config: fix kernel version checks Looking at the code, I found out that kernel_lt function was actually doing le ("less than or equal") rather than lt ("less than") operation. Let's fix this and do exactly what the name says. A bigger issue is, the function use was not consistent (some uses implied "less than or equal"). To fix the usage, find out all relevant kernel commits and kernel versions that have them (the latter is done using "git describe --contains $sha"), and fix the wrong cases. While at it, add references to all these kernel commits for the future generations of check-config.sh hackers. Also, add kernel_ge function which is the opposite of kernel_lt, and document both. Signed-off-by: Kir Kolyshkin --- script/check-config.sh | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/script/check-config.sh b/script/check-config.sh index 642ff33a1..c749c6015 100755 --- a/script/check-config.sh +++ b/script/check-config.sh @@ -29,9 +29,19 @@ kernelMajor="${kernelVersion%%.*}" kernelMinor="${kernelVersion#"$kernelMajor".}" kernelMinor="${kernelMinor%%.*}" +# Usage: to check if kernel version is < 4.8, use +# kernel_lt 4 8 +# (here "lt" stands for "less than"). kernel_lt() { [ "$kernelMajor" -lt "$1" ] && return - [ "$kernelMajor" -eq "$1" ] && [ "$kernelMinor" -le "$2" ] + [ "$kernelMajor" -eq "$1" ] && [ "$kernelMinor" -lt "$2" ] +} + +# Usage: to check if kernel version is >= 6.1, use +# kernel_ge 6 1 +# (here "ge" stands for "greater or equal"). +kernel_ge() { + ! kernel_lt "$1" "$2" } is_set() { @@ -234,16 +244,17 @@ flags=( ) check_flags "${flags[@]}" -if ! kernel_lt 4 14; then - if [ $cgroup = "v2" ]; then - check_flags CGROUP_BPF - fi +# Linux kernel commit 3007098494be. +if kernel_ge 4 10 && [ $cgroup = "v2" ]; then + check_flags CGROUP_BPF fi +# Linux kernel commit 3bf195ae6037. if kernel_lt 5 1; then check_flags NF_NAT_IPV4 fi +# Linux kernel commit 4806e975729f99c7. if kernel_lt 5 2; then check_flags NF_NAT_NEEDED fi @@ -259,9 +270,11 @@ echo 'Optional Features:' check_flags SECCOMP_FILTER check_flags CGROUP_PIDS + # Linux kernel commit e55b9f96860f. if kernel_lt 6 1; then check_flags MEMCG_SWAP fi + # Linux kernel commit 2d1c498072de. if kernel_lt 5 8; then check_flags MEMCG_SWAP_ENABLED if is_set MEMCG_SWAP && ! is_set MEMCG_SWAP_ENABLED; then @@ -270,20 +283,24 @@ echo 'Optional Features:' fi } +# Linux kernel commit d886f4e483ce. if kernel_lt 4 5; then check_flags MEMCG_KMEM fi -if kernel_lt 3 18; then +# Linux kernel commit 5b1efc027c0b. +if kernel_lt 3 19; then check_flags RESOURCE_COUNTERS fi -if kernel_lt 3 13; then +# Linux kernel commit 86f8515f9721. +if kernel_lt 3 14; then netprio=NETPRIO_CGROUP else netprio=CGROUP_NET_PRIO fi +# Linux kernel commit f382fb0bcef4. if kernel_lt 5 0; then check_flags IOSCHED_CFQ CFQ_GROUP_IOSCHED fi From 5a4f52178d80bcb0c4f240a4377755a2e667bcf1 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Fri, 15 Dec 2023 12:37:33 +0900 Subject: [PATCH 5/5] script/check-config.sh: check CONFIG_BLK_CGROUP_IOCOST For `io.weight` Co-authored-by: Akihiro Suda Signed-off-by: Kir Kolyshkin --- script/check-config.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/script/check-config.sh b/script/check-config.sh index c749c6015..d54055023 100755 --- a/script/check-config.sh +++ b/script/check-config.sh @@ -305,6 +305,11 @@ if kernel_lt 5 0; then check_flags IOSCHED_CFQ CFQ_GROUP_IOSCHED fi +# Linux kernel commit 7caa47151ab2. +if kernel_ge 5 4; then + check_flags BLK_CGROUP_IOCOST +fi + flags=( BLK_CGROUP BLK_DEV_THROTTLING CGROUP_PERF