Skip to content

Commit 0996e67

Browse files
SSapkalshuahkh
authored andcommitted
selftests/amd-pstate: Added option to provide perf binary path
In selftests/amd-pstate, distro `perf` is used to capture `perf stat` while running microbenchmarks. Distro `perf` is not working with upstream kernel. Fix this by providing an option to give the perf binary path. Reviewed-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Swapnil Sapkal <swapnil.sapkal@amd.com> Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
1 parent 27aabb2 commit 0996e67

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

tools/testing/selftests/amd-pstate/gitsource.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ run_gitsource()
8888
BACKUP_DIR=$(pwd)
8989
pushd $BACKUP_DIR > /dev/null 2>&1
9090
cd $SCRIPTDIR/$git_name
91-
perf stat -a --per-socket -I 1000 -e power/energy-pkg/ /usr/bin/time -o $BACKUP_DIR/$OUTFILE_GIT.time-gitsource-$1-$2.log make test -j$MAKE_CPUS > $BACKUP_DIR/$OUTFILE_GIT-perf-$1-$2.log 2>&1
91+
$PERF stat -a --per-socket -I 1000 -e power/energy-pkg/ /usr/bin/time -o $BACKUP_DIR/$OUTFILE_GIT.time-gitsource-$1-$2.log make test -j$MAKE_CPUS > $BACKUP_DIR/$OUTFILE_GIT-perf-$1-$2.log 2>&1
9292
popd > /dev/null 2>&1
9393

9494
for job in `jobs -p`

tools/testing/selftests/amd-pstate/run.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ OUTFILE=selftest
2525
OUTFILE_TBENCH="$OUTFILE.tbench"
2626
OUTFILE_GIT="$OUTFILE.gitsource"
2727

28+
PERF=/usr/bin/perf
2829
SYSFS=
2930
CPUROOT=
3031
CPUFREQROOT=
@@ -154,14 +155,15 @@ help()
154155
[-p <tbench process number>]
155156
[-l <loop times for tbench>]
156157
[-i <amd tracer interval>]
158+
[-b <perf binary>]
157159
[-m <comparative test: acpi-cpufreq>]
158160
\n"
159161
exit 2
160162
}
161163

162164
parse_arguments()
163165
{
164-
while getopts ho:c:t:p:l:i:m: arg
166+
while getopts ho:c:t:p:l:i:b:m: arg
165167
do
166168
case $arg in
167169
h) # --help
@@ -192,6 +194,10 @@ parse_arguments()
192194
TRACER_INTERVAL=$OPTARG
193195
;;
194196

197+
b) # --perf-binary
198+
PERF=`realpath $OPTARG`
199+
;;
200+
195201
m) # --comparative-test
196202
COMPARATIVE_TEST=$OPTARG
197203
;;
@@ -205,8 +211,8 @@ parse_arguments()
205211

206212
command_perf()
207213
{
208-
if ! command -v perf > /dev/null; then
209-
echo $msg please install perf. >&2
214+
if ! $PERF -v; then
215+
echo $msg please install perf or provide perf binary path as argument >&2
210216
exit $ksft_skip
211217
fi
212218
}

tools/testing/selftests/amd-pstate/tbench.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ run_tbench()
6868

6969
printf "Test tbench for $1 #$2 time_limit: $TIME_LIMIT procs_num: $PROCESS_NUM\n"
7070
tbench_srv > /dev/null 2>&1 &
71-
perf stat -a --per-socket -I 1000 -e power/energy-pkg/ tbench -t $TIME_LIMIT $PROCESS_NUM > $OUTFILE_TBENCH-perf-$1-$2.log 2>&1
71+
$PERF stat -a --per-socket -I 1000 -e power/energy-pkg/ tbench -t $TIME_LIMIT $PROCESS_NUM > $OUTFILE_TBENCH-perf-$1-$2.log 2>&1
7272

7373
pid=`pidof tbench_srv`
7474
kill $pid

0 commit comments

Comments
 (0)