linux-yocto/tools/perf/tests/shell/pipe_test.sh
Ian Rogers 64eed019f3 perf inject: Lazy build-id mmap2 event insertion
Add -B option that lazily inserts mmap2 events thereby dropping all
mmap events without samples. This is similar to the behavior of -b
where only build_id events are inserted when a dso is accessed in a
sample.

File size savings can be significant in system-wide mode, consider:

  $ perf record -g -a -o perf.data sleep 1
  $ perf inject -B -i perf.data -o perf.new.data
  $ ls -al perf.data perf.new.data
           5147049 perf.data
           2248493 perf.new.data

Give test coverage of the new option in pipe test.

Signed-off-by: Ian Rogers <irogers@google.com>
Acked-by: Namhyung Kim <namhyung@kernel.org>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Anne Macedo <retpolanne@posteo.net>
Cc: Casey Chen <cachen@purestorage.com>
Cc: Colin Ian King <colin.i.king@gmail.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Sun Haiyong <sunhaiyong@loongson.cn>
Link: https://lore.kernel.org/r/20240909203740.143492-4-irogers@google.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
2024-09-10 17:32:47 -03:00

127 lines
3.2 KiB
Bash
Executable File

#!/bin/bash
# perf pipe recording and injection test
# SPDX-License-Identifier: GPL-2.0
shelldir=$(dirname "$0")
# shellcheck source=lib/perf_has_symbol.sh
. "${shelldir}"/lib/perf_has_symbol.sh
sym="noploop"
skip_test_missing_symbol ${sym}
data=$(mktemp /tmp/perf.data.XXXXXX)
data2=$(mktemp /tmp/perf.data2.XXXXXX)
prog="perf test -w noploop"
err=0
set -e
cleanup() {
rm -rf "${data}"
rm -rf "${data}".old
rm -rf "${data2}"
rm -rf "${data2}".old
trap - EXIT TERM INT
}
trap_cleanup() {
echo "Unexpected signal in ${FUNCNAME[1]}"
cleanup
exit 1
}
trap trap_cleanup EXIT TERM INT
test_record_report() {
echo
echo "Record+report pipe test"
task="perf"
if ! perf record -e task-clock:u -o - ${prog} | perf report -i - --task | grep -q ${task}
then
echo "Record+report pipe test [Failed - cannot find the test file in the perf report #1]"
err=1
return
fi
if ! perf record -g -e task-clock:u -o - ${prog} | perf report -i - --task | grep -q ${task}
then
echo "Record+report pipe test [Failed - cannot find the test file in the perf report #2]"
err=1
return
fi
perf record -g -e task-clock:u -o - ${prog} > ${data}
if ! perf report -i ${data} --task | grep -q ${task}
then
echo "Record+report pipe test [Failed - cannot find the test file in the perf report #3]"
err=1
return
fi
echo "Record+report pipe test [Success]"
}
test_inject_bids() {
inject_opt=$1
echo
echo "Inject ${inject_opt} build-ids test"
if ! perf record -e task-clock:u -o - ${prog} | perf inject ${inject_opt}| perf report -i - | grep -q ${sym}
then
echo "Inject build-ids test [Failed - cannot find noploop function in pipe #1]"
err=1
return
fi
if ! perf record -g -e task-clock:u -o - ${prog} | perf inject ${inject_opt} | perf report -i - | grep -q ${sym}
then
echo "Inject ${inject_opt} build-ids test [Failed - cannot find noploop function in pipe #2]"
err=1
return
fi
perf record -e task-clock:u -o - ${prog} | perf inject ${inject_opt} -o ${data}
if ! perf report -i ${data} | grep -q ${sym}; then
echo "Inject ${inject_opt} build-ids test [Failed - cannot find noploop function in pipe #3]"
err=1
return
fi
perf record -e task-clock:u -o ${data} ${prog}
if ! perf inject ${inject_opt} -i ${data} | perf report -i - | grep -q ${sym}; then
echo "Inject ${inject_opt} build-ids test [Failed - cannot find noploop function in pipe #4]"
err=1
return
fi
perf record -e task-clock:u -o - ${prog} > ${data}
if ! perf inject ${inject_opt} -i ${data} | perf report -i - | grep -q ${sym}; then
echo "Inject ${inject_opt} build-ids test [Failed - cannot find noploop function in pipe #5]"
err=1
return
fi
perf record -e task-clock:u -o - ${prog} > ${data}
perf inject ${inject_opt} -i ${data} -o ${data2}
if ! perf report -i ${data2} | grep -q ${sym}; then
echo "Inject ${inject_opt} build-ids test [Failed - cannot find noploop function in pipe #6]"
err=1
return
fi
echo "Inject ${inject_opt} build-ids test [Success]"
}
test_record_report
test_inject_bids -B
test_inject_bids -b
test_inject_bids --buildid-all
test_inject_bids --mmap2-buildid-all
cleanup
exit $err