Commit e91bb736 authored by Michal Berger's avatar Michal Berger Committed by Tomasz Zawadzki
Browse files

scripts/core-collector: Collect traces only from in-repo processes



This is a follow up to a087f7be which attempts to restore some
portion of the filtering functionality from the old collector.

Change-Id: I295bdf6d51277d0d2721447a8408ac250c95af82
Signed-off-by: default avatarMichal Berger <michal.berger@nutanix.com>
Reviewed-on: https://review.spdk.io/c/spdk/spdk/+/26437


Reviewed-by: default avatarKonrad Sztyber <ksztyber@nvidia.com>
Reviewed-by: default avatarJim Harris <jim.harris@nvidia.com>
Tested-by: default avatarSPDK Automated Test System <spdkbot@gmail.com>
parent 923d2607
Loading
Loading
Loading
Loading
+51 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
#

shopt -s nullglob
rootdir=$(readlink -f "$(dirname "$0")/../")

core_meta() {
	jq . <<- CORE
@@ -23,6 +24,54 @@ core_meta() {

bt() { hash gdb && gdb -batch -ex "thread apply all bt full" "$1" "$2" 2>&1; }

in_maps() {
	local exe_path=$1 core=$2
	local maps map

	shift 2 || return 1

	# Filter out deleted mappings (e.g. hugepages backing files)
	mapfile -t maps < <(
		gdb -batch -ex "info proc mappings" "$exe_path" "$core" 2> /dev/null | grep -v deleted
	)

	for map; do
		[[ ${maps[*]} == *"$map"* ]] && return 0
	done

	return 1
}

in_crit_bins() {
	local exe_path=$1
	local crit_binaries=() bin

	crit_binaries+=("nvme")
	crit_binaries+=("qemu-system*")
	# Add more if needed

	for bin in "${crit_binaries[@]}"; do
		# The below SC is intentional
		# shellcheck disable=SC2053
		[[ ${exe_path##*/} == $bin ]] && return 0
	done

	return 1
}

filter_process() {
	local exe_path=$1 core=$2
	# Did the process sit in our repo?
	[[ $exe_path == "$rootdir/"* ]] && return 0
	# Did the process use our plugins?
	in_maps "$exe_path" "$core" \
		"$rootdir/build/fio/spdk_nvme" \
		"$rootdir/build/fio/spdk_bdev" && return 0
	# Do we depend on it?
	in_crit_bins "$exe_path" && return 0
	return 1
}

parse_core() {
	local core=$1 _core
	local cores_dir=$2
@@ -52,6 +101,8 @@ parse_core() {
	IFS="-" read -r "${prefix[@]}" <<< "${_core%"-$exe_path"}"
	# /opt/spdk/build/bin/spdk_tgt
	exe_path=${exe_path//\!/\/}
	# If core comes from a process we don't support, skip it
	filter_process "$exe_path" "$core" || return 0
	# spdk_tgt
	exe_comm=${exe_path##*/}
	# 11 -> SEGV