Skip to content

Commit

Permalink
tests/int: fix "cpu burst" failure on new kernels
Browse files Browse the repository at this point in the history
A kernel bug which resulted in cpu.max.burst value read which is 1000
times smaller than it should be has recently been fixed (see [1]).

Adapt the test so it works with either broken or fixed kernel.

[1]: https://lore.kernel.org/all/[email protected]/

Signed-off-by: Kir Kolyshkin <[email protected]>
  • Loading branch information
kolyshkin committed Aug 14, 2024
1 parent b437ed3 commit a7c8d86
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions tests/integration/helpers.bash
Original file line number Diff line number Diff line change
Expand Up @@ -260,14 +260,15 @@ function get_cgroup_value() {
cat "$cgroup/$1"
}

# Check if a value in a cgroup file $1 matches $2.
# Check if a value in a cgroup file $1 matches $2 or $3 (if specified).
function check_cgroup_value() {
local got
got="$(get_cgroup_value "$1")"
local want=$2
local want2="${3:-}"

echo "$1: got $got, want $want"
[ "$got" = "$want" ]
echo "$1: got $got, want $want $want2"
[ "$got" = "$want" ] || [[ -n "$want2" && "$got" = "$want2" ]]
}

# Check if a value of systemd unit property $1 matches $2 or $3 (if specified).
Expand Down Expand Up @@ -316,8 +317,10 @@ function check_cpu_quota() {
function check_cpu_burst() {
local burst=$1
if [ -v CGROUP_V2 ]; then
burst=$((burst / 1000))
check_cgroup_value "cpu.max.burst" "$burst"
# Due to a kernel bug (fixed by commit 49217ea147df, see
# https://lore.kernel.org/all/[email protected]/),
# older kernels printed value divided by 1000. Check for both.
check_cgroup_value "cpu.max.burst" "$burst" "$((burst / 1000))"
else
check_cgroup_value "cpu.cfs_burst_us" "$burst"
fi
Expand Down

0 comments on commit a7c8d86

Please sign in to comment.