Skip to content

Commit 3eb5c49

Browse files
captain5050acmel
authored andcommitted
perf test: Hybrid improvements for metric value validation test
On my alderlake I currently see for the "perf metrics value validation" test: ``` Total Test Count: 142 Passed Test Count: 139 [ Metric Relationship Error: The collected value of metric ['tma_fetch_latency', 'tma_fetch_bandwidth', 'tma_frontend_bound'] is [31.137028] in workload(s): ['perf bench futex hash -r 2 -s'] but expected value range is [tma_frontend_bound, tma_frontend_bound] Relationship rule description: 'Sum of the level 2 children should equal level 1 parent', Metric Relationship Error: The collected value of metric ['tma_memory_bound', 'tma_core_bound', 'tma_backend_bound'] is [6.564442] in workload(s): ['perf bench futex hash -r 2 -s'] but expected value range is [tma_backend_bound, tma_backend_bound] Relationship rule description: 'Sum of the level 2 children should equal level 1 parent', Metric Relationship Error: The collected value of metric ['tma_light_operations', 'tma_heavy_operations', 'tma_retiring'] is [57.806179] in workload(s): ['perf bench futex hash -r 2 -s'] but expected value range is [tma_retiring, tma_retiring] Relationship rule description: 'Sum of the level 2 children should equal level 1 parent'] Metric validation return with erros. Please check metrics reported with errors. ``` I suspect it is due to two metrics for different CPU types being enabled. Add a -cputype option to avoid this. The test still fails with: ``` Total Test Count: 115 Passed Test Count: 114 [ Wrong Metric Value Error: The collected value of metric ['tma_l2_hit_latency'] is [117.947088] in workload(s): ['perf bench futex hash -r 2 -s'] but expected value range is [0, 100]] Metric validation return with errors. Please check metrics reported with errors. ``` which is a reproducible genuine error and likely requires a metric fix. Signed-off-by: Ian Rogers <[email protected]> Tested-by: Thomas Falcon <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: James Clark <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Kan Liang <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Weilin Wang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 7f84f67 commit 3eb5c49

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

tools/perf/tests/shell/lib/perf_metric_validation.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,16 @@ def __repr__(self) -> str:
3535

3636

3737
class Validator:
38-
def __init__(self, rulefname, reportfname='', t=5, debug=False, datafname='', fullrulefname='', workload='true', metrics=''):
38+
def __init__(self, rulefname, reportfname='', t=5, debug=False, datafname='', fullrulefname='',
39+
workload='true', metrics='', cputype='cpu'):
3940
self.rulefname = rulefname
4041
self.reportfname = reportfname
4142
self.rules = None
4243
self.collectlist: str = metrics
4344
self.metrics = self.__set_metrics(metrics)
4445
self.skiplist = set()
4546
self.tolerance = t
47+
self.cputype = cputype
4648

4749
self.workloads = [x for x in workload.split(",") if x]
4850
self.wlidx = 0 # idx of current workloads
@@ -377,7 +379,7 @@ def convert(self, data: list, metricvalues: dict):
377379

378380
def _run_perf(self, metric, workload: str):
379381
tool = 'perf'
380-
command = [tool, 'stat', '-j', '-M', f"{metric}", "-a"]
382+
command = [tool, 'stat', '--cputype', self.cputype, '-j', '-M', f"{metric}", "-a"]
381383
wl = workload.split()
382384
command.extend(wl)
383385
print(" ".join(command))
@@ -443,6 +445,8 @@ def parse_perf_metrics(self):
443445
if 'MetricName' not in m:
444446
print("Warning: no metric name")
445447
continue
448+
if 'Unit' in m and m['Unit'] != self.cputype:
449+
continue
446450
name = m['MetricName'].lower()
447451
self.metrics.add(name)
448452
if 'ScaleUnit' in m and (m['ScaleUnit'] == '1%' or m['ScaleUnit'] == '100%'):
@@ -578,6 +582,8 @@ def main() -> None:
578582
parser.add_argument(
579583
"-wl", help="Workload to run while data collection", default="true")
580584
parser.add_argument("-m", help="Metric list to validate", default="")
585+
parser.add_argument("-cputype", help="Only test metrics for the given CPU/PMU type",
586+
default="cpu")
581587
args = parser.parse_args()
582588
outpath = Path(args.output_dir)
583589
reportf = Path.joinpath(outpath, 'perf_report.json')
@@ -586,7 +592,7 @@ def main() -> None:
586592

587593
validator = Validator(args.rule, reportf, debug=args.debug,
588594
datafname=datafile, fullrulefname=fullrule, workload=args.wl,
589-
metrics=args.m)
595+
metrics=args.m, cputype=args.cputype)
590596
ret = validator.test()
591597

592598
return ret

tools/perf/tests/shell/stat_metrics_values.sh

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,16 @@ workload="perf bench futex hash -r 2 -s"
1616
# Add -debug, save data file and full rule file
1717
echo "Launch python validation script $pythonvalidator"
1818
echo "Output will be stored in: $tmpdir"
19-
$PYTHON $pythonvalidator -rule $rulefile -output_dir $tmpdir -wl "${workload}"
20-
ret=$?
21-
rm -rf $tmpdir
22-
if [ $ret -ne 0 ]; then
23-
echo "Metric validation return with erros. Please check metrics reported with errors."
24-
fi
19+
for cputype in /sys/bus/event_source/devices/cpu_*; do
20+
cputype=$(basename "$cputype")
21+
echo "Testing metrics for: $cputype"
22+
$PYTHON $pythonvalidator -rule $rulefile -output_dir $tmpdir -wl "${workload}" \
23+
-cputype "${cputype}"
24+
ret=$?
25+
rm -rf $tmpdir
26+
if [ $ret -ne 0 ]; then
27+
echo "Metric validation return with errors. Please check metrics reported with errors."
28+
fi
29+
done
2530
exit $ret
2631

0 commit comments

Comments
 (0)