-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CPC probes can specify modes: all, user, and kernel. These tests check "all" against "perf stat" results. They check "user" and "kernel" by using workloads that are known to be user-space- or kernel-intensive. An extra utility is added to support these tests: * cpc_get_events.sh composes a list of events to test on the current system Signed-off-by: Eugene Loh <eugene.loh@oracle.com> Reviewed-by: Kris Van Hees <kris.van.hees@oracle.com>
- Loading branch information
Showing
4 changed files
with
155 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/bin/bash | ||
# | ||
# Oracle Linux DTrace. | ||
# Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. | ||
# Licensed under the Universal Permissive License v 1.0 as shown at | ||
# http://oss.oracle.com/licenses/upl. | ||
|
||
# Test CPC provider with modes (all, user, kernel) with a | ||
# kernel-space-intensive workload. | ||
|
||
# @@reinvoke-failure: 2 | ||
|
||
utils=`pwd`/test/utils | ||
|
||
dtrace=$1 | ||
tmpfile=$tmpdir/tst.mode_kernel.$$ | ||
mkdir $tmpfile | ||
cd $tmpfile | ||
|
||
target=workload_kernel | ||
|
||
# run tests | ||
declare -A actual | ||
status=0 | ||
for eventname in `$utils/cpc_get_events.sh`; do | ||
|
||
# the DTrace CPC provider needs '-' turned into '_' | ||
Deventname=`echo $eventname | tr '-' '_'` | ||
|
||
# determine number of iterations for target number of seconds | ||
nsecs=1 | ||
niters=`$utils/workload_get_iterations.sh $target $nsecs` | ||
if [ $niters -lt 0 ]; then | ||
echo "workload_get_iterations.sh failed with $target" | ||
exit 1 | ||
fi | ||
|
||
# determine expected count | ||
expect=`$utils/perf_count_event.sh $eventname $target $niters` | ||
|
||
# sample events (with DTrace) | ||
period=$(($expect / 20)) | ||
echo $niters iterations for $Deventname with period $period | ||
for mode in all user kernel; do | ||
$dtrace $dt_flags -qn $Deventname-$mode-$period' | ||
/pid == $target/ | ||
{ | ||
@ = sum('$period'); | ||
}' -c "$utils/$target $niters" > tmp.txt | ||
if [[ $? -ne 0 ]]; then | ||
echo ERROR running DTrace for $Deventname-$mode-$period | ||
cat tmp.txt | ||
exit 1 | ||
fi | ||
actual[$mode]=`cat tmp.txt` | ||
if [ -z ${actual[$mode]} ]; then | ||
actual[$mode]=0 | ||
fi | ||
done | ||
|
||
# report | ||
margin=$(($expect / 4)) | ||
$utils/check_result.sh ${actual[all]} $expect $margin; status=$(($status + $?)) | ||
$utils/check_result.sh ${actual[user]} 0 $margin; status=$(($status + $?)) | ||
$utils/check_result.sh ${actual[kernel]} $expect $margin; status=$(($status + $?)) | ||
done | ||
|
||
exit $status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
#!/bin/bash | ||
# | ||
# Oracle Linux DTrace. | ||
# Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. | ||
# Licensed under the Universal Permissive License v 1.0 as shown at | ||
# http://oss.oracle.com/licenses/upl. | ||
|
||
# Test CPC provider with modes (all, user, kernel) with a | ||
# user-space-intensive workload. | ||
|
||
# @@reinvoke-failure: 2 | ||
|
||
utils=`pwd`/test/utils | ||
|
||
dtrace=$1 | ||
tmpfile=$tmpdir/tst.mode_user.$$ | ||
mkdir $tmpfile | ||
cd $tmpfile | ||
|
||
target=workload_user | ||
|
||
# run tests | ||
declare -A actual | ||
status=0 | ||
for eventname in `$utils/cpc_get_events.sh`; do | ||
|
||
# the DTrace CPC provider needs '-' turned into '_' | ||
Deventname=`echo $eventname | tr '-' '_'` | ||
|
||
# determine number of iterations for target number of seconds | ||
nsecs=1 | ||
niters=`$utils/workload_get_iterations.sh $target $nsecs` | ||
if [ $niters -lt 0 ]; then | ||
echo "workload_get_iterations.sh failed with $target" | ||
exit 1 | ||
fi | ||
|
||
# determine expected count | ||
expect=`$utils/perf_count_event.sh $eventname $target $niters` | ||
|
||
# sample events (with DTrace) | ||
period=$(($expect / 20)) | ||
echo $niters iterations for $Deventname with period $period | ||
for mode in all user kernel; do | ||
$dtrace $dt_flags -qn $Deventname-$mode-$period' | ||
/pid == $target/ | ||
{ | ||
@ = sum('$period'); | ||
}' -c "$utils/$target $niters" > tmp.txt | ||
if [[ $? -ne 0 ]]; then | ||
echo ERROR running DTrace for $Deventname-$mode-$period | ||
cat tmp.txt | ||
exit 1 | ||
fi | ||
actual[$mode]=`cat tmp.txt` | ||
if [ -z ${actual[$mode]} ]; then | ||
actual[$mode]=0 | ||
fi | ||
done | ||
|
||
# report | ||
margin=$(($expect / 4)) | ||
$utils/check_result.sh ${actual[all]} $expect $margin; status=$(($status + $?)) | ||
$utils/check_result.sh ${actual[user]} $expect $margin; status=$(($status + $?)) | ||
$utils/check_result.sh ${actual[kernel]} 0 $margin; status=$(($status + $?)) | ||
done | ||
|
||
exit $status |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
# | ||
# Oracle Linux DTrace. | ||
# Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved. | ||
# Licensed under the Universal Permissive License v 1.0 as shown at | ||
# http://oss.oracle.com/licenses/upl. | ||
|
||
# Form a list of events to test on this system. | ||
# Use at least cpu-clock but also try "perf list" for some others. | ||
|
||
eventnamelist="cpu-clock" | ||
for eventname in branches instructions; do | ||
if perf list hw | grep -qw $eventname; then | ||
eventnamelist="$eventnamelist $eventname" | ||
fi | ||
done | ||
|
||
echo $eventnamelist |