Spdk/test/scheduler/isolate_cores.sh
Michal Berger 977a53573f test/scheduler: Use separete cgroup for the tests
Two cgroups are created prior running the scheduler tests:
  - /cpuset/spdk
  - /cpuset/all

/cpuset/spdk is the cgroup dedicated for the tests, i.e., the SPDK
processes executed along the way. The resources consist of the cpus
that are initially picked up by isolate_cores.sh.

/cpuset/all is the "dummy" cgroup that holds most of the remaining
processes that run on the target system - "most" since not every
process (especially kernel threads) can be migrated between cgroups.
This cgroup's resources include all the online cpus except those
selected for the /cpuset/spdk.

This should allow for lowering the noise on the target SPDK's cpus
and make sure that load on each cpu is generated exclusively by the
SPDK.

Fixes issue #1950

Signed-off-by: Michal Berger <michalx.berger@intel.com>
Change-Id: Ic45149f55052ff03bead0b9bea086f95c87ea75d
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/10584
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Reviewed-by: Konrad Sztyber <konrad.sztyber@intel.com>
Reviewed-by: Tomasz Zawadzki <tomasz.zawadzki@intel.com>
2021-12-23 08:33:15 +00:00

68 lines
1.9 KiB
Bash

# Select cores for the test
xtrace_disable
source "$testdir/common.sh"
restore_cgroups() {
xtrace_disable
kill_in_cgroup "/cpuset/spdk"
remove_cgroup "/cpuset/spdk"
remove_cgroup "/cpuset/all"
remove_cpuset_cgroup
xtrace_restore
}
trap "restore_cgroups" EXIT
# Number of cpus to include in the mask
NUM_CPUS=${NUM_CPUS:-8}
init_cpuset_cgroup
map_cpus
# Build core mask. Avoid all CPUs that may be offline and skip cpu0
# (and all its potential thread siblings) as it's already doing an
# extra work for the kernel.
denied_list $(get_cpus "${cpu_node_map[0]}" "${cpu_core_map[0]}")
# If there are any isolated cpus (as defined on the kernel cmdline
# with isolcpus) they take the priority. We fill up the list up to
# NUM_CPUS, applying filtering as per the denied list. All cpus are
# taken from node0.
allowed_list "$NUM_CPUS" 0
# Assign proper resources to the cpuset/spdk
spdk_cpus=("${allowed[@]}")
spdk_cpus_csv=$(fold_array_onto_string "${spdk_cpus[@]}")
spdk_cpumask=$(mask_cpus "${spdk_cpus[@]}")
spdk_main_core=${spdk_cpus[0]}
spdk_cpus_mems=0
# Build list of remaining cpus for posterity
denied_list "${spdk_cpus[@]}"
fold_list_onto_array allowed "${cpus[@]}"
filter_allowed_list
all_cpus=("${allowed[@]}")
all_cpus_csv=$(fold_array_onto_string "${all_cpus[@]}")
all_cpumask=$(mask_cpus "${all_cpus[@]}")
all_cpus_mems=0
# Pin spdk cores to a new cgroup
create_cgroup "/cpuset/spdk"
create_cgroup "/cpuset/all"
set_cgroup_attr "/cpuset/spdk" cpuset.cpus "$spdk_cpus_csv"
set_cgroup_attr "/cpuset/spdk" cpuset.mems "$spdk_cpus_mems"
set_cgroup_attr "/cpuset/all" cpuset.cpus "$all_cpus_csv"
set_cgroup_attr "/cpuset/all" cpuset.mems "$all_cpus_mems"
move_cgroup_procs "/cpuset" "/cpuset/all"
export \
"spdk_cpumask=$spdk_cpumask" \
"spdk_cpus_csv=$spdk_cpus_csv" \
"spdk_cpus_no=${#spdk_cpus[@]}" \
"spdk_main_core=$spdk_main_core" \
"all_cpumask=$all_cpumask" \
"all_cpus_csv=$all_cpus_csv"
xtrace_restore