Commit 0b65bb47 authored by Michal Berger's avatar Michal Berger Committed by Konrad Sztyber
Browse files

test/scheduler: Account for multiple cpus in the affinity mask



get_proc_cpu_affinity() can return an actual list, depending on how
the affinity is set for given thread. To make sure this check doesn't
suddenly fail, iterate over the entire list.

Change-Id: I83c176445992e0495ef5ada56679d7316cb2ff9b
Signed-off-by: default avatarMichal Berger <michal.berger@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/25405


Reviewed-by: default avatarKonrad Sztyber <konrad.sztyber@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <jim.harris@samsung.com>
Community-CI: Broadcom CI <spdk-ci.pdl@broadcom.com>
Community-CI: Community CI Samsung <spdk.community.ci.samsung@gmail.com>
parent a9668509
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -765,12 +765,16 @@ get_spdk_proc_time() {
	local interval=$1 cpu=$2
	local thread thread_to_time stats
	local _time time _stime stime _utime utime
	local thread_cpu_list

	[[ -e /proc/$spdk_pid/status ]] || return 1

	# Find SPDK thread pinned to given cpu
	for thread in "/proc/$spdk_pid/task/"*; do
		((cpu == $(get_proc_cpu_affinity "$thread/status"))) && thread_to_time=$thread && break
		thread_cpu_list=($(get_proc_cpu_affinity "$thread/status"))
		# we aim at reactor threads and these should be bound to a single cpu
		((${#thread_cpu_list[@]} > 1)) && continue
		((thread_cpu_list[0] == cpu)) && thread_to_time=$thread && break
	done

	[[ -e $thread_to_time/stat ]] || return 1