mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-11-02 07:13:31 +01:00
perf record: Add auto counter reload parse and regression tests
Include event parsing and regression tests for auto counter reload and ratio-to-prev event term. Reviewed-by: Ian Rogers <[email protected]> Signed-off-by: Thomas Falcon <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Dapeng Mi <[email protected]> Cc: Ingo Molnar <[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]> Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
This commit is contained in:
1 parent
6b9c0261b3
commit
56be0fe5f6
2 files changed
+94
No files matched your search
@@ -1736,6 +1736,53 @@ static int test__intel_pt(struct evlist *evlist)
|
||||
return TEST_OK;
|
||||
}
|
||||
|
||||
static bool test__acr_valid(void)
|
||||
{
|
||||
struct perf_pmu *pmu = NULL;
|
||||
|
||||
while ((pmu = perf_pmus__scan_core(pmu)) != NULL) {
|
||||
if (perf_pmu__has_format(pmu, "acr_mask"))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
static int test__ratio_to_prev(struct evlist *evlist)
|
||||
{
|
||||
struct evsel *evsel;
|
||||
int ret;
|
||||
|
||||
TEST_ASSERT_VAL("wrong number of entries", 2 * perf_pmus__num_core_pmus() == evlist->core.nr_entries);
|
||||
|
||||
evlist__for_each_entry(evlist, evsel) {
|
||||
if (!perf_pmu__has_format(evsel->pmu, "acr_mask"))
|
||||
return TEST_OK;
|
||||
|
||||
if (evsel == evlist__first(evlist)) {
|
||||
TEST_ASSERT_VAL("wrong config2", 0 == evsel->core.attr.config2);
|
||||
TEST_ASSERT_VAL("wrong leader", evsel__is_group_leader(evsel));
|
||||
TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 2);
|
||||
TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 0);
|
||||
ret = assert_hw(&evsel->core, PERF_COUNT_HW_CPU_CYCLES, "cycles");
|
||||
} else {
|
||||
TEST_ASSERT_VAL("wrong config2", 0 == evsel->core.attr.config2);
|
||||
TEST_ASSERT_VAL("wrong leader", !evsel__is_group_leader(evsel));
|
||||
TEST_ASSERT_VAL("wrong core.nr_members", evsel->core.nr_members == 0);
|
||||
TEST_ASSERT_VAL("wrong group_idx", evsel__group_idx(evsel) == 1);
|
||||
ret = assert_hw(&evsel->core, PERF_COUNT_HW_INSTRUCTIONS, "instructions");
|
||||
}
|
||||
if (ret)
|
||||
return ret;
|
||||
/*
|
||||
* The period value gets configured within evlist__config,
|
||||
* while this test executes only parse events method.
|
||||
*/
|
||||
TEST_ASSERT_VAL("wrong period", 0 == evsel->core.attr.sample_period);
|
||||
}
|
||||
return TEST_OK;
|
||||
}
|
||||
|
||||
static int test__checkevent_complex_name(struct evlist *evlist)
|
||||
{
|
||||
struct evsel *evsel = evlist__first(evlist);
|
||||
@@ -2249,6 +2296,13 @@ static const struct evlist_test test__events[] = {
|
||||
.check = test__checkevent_tracepoint,
|
||||
/* 4 */
|
||||
},
|
||||
{
|
||||
.name = "{cycles,instructions/period=200000,ratio-to-prev=2.0/}",
|
||||
.valid = test__acr_valid,
|
||||
.check = test__ratio_to_prev,
|
||||
/* 5 */
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
static const struct evlist_test test__events_pmu[] = {
|
||||
|
||||
@@ -388,6 +388,45 @@ test_callgraph() {
|
||||
echo "Callgraph test [Success]"
|
||||
}
|
||||
|
||||
test_ratio_to_prev() {
|
||||
echo "ratio-to-prev test"
|
||||
if ! perf record -o /dev/null -e "{instructions, cycles/period=100000,ratio-to-prev=0.5/}" \
|
||||
true 2> /dev/null
|
||||
then
|
||||
echo "ratio-to-prev [Skipped not supported]"
|
||||
return
|
||||
fi
|
||||
if ! perf record -o /dev/null -e "instructions, cycles/period=100000,ratio-to-prev=0.5/" \
|
||||
true |& grep -q 'Invalid use of ratio-to-prev term without preceding element in group'
|
||||
then
|
||||
echo "ratio-to-prev test [Failed elements must be in same group]"
|
||||
err=1
|
||||
return
|
||||
fi
|
||||
if ! perf record -o /dev/null -e "{instructions,dummy,cycles/period=100000,ratio-to-prev=0.5/}" \
|
||||
true |& grep -q 'must have same PMU'
|
||||
then
|
||||
echo "ratio-to-prev test [Failed elements must have same PMU]"
|
||||
err=1
|
||||
return
|
||||
fi
|
||||
if ! perf record -o /dev/null -e "{instructions,cycles/ratio-to-prev=0.5/}" \
|
||||
true |& grep -q 'Event period term or count (-c) must be set when using ratio-to-prev term.'
|
||||
then
|
||||
echo "ratio-to-prev test [Failed period must be set]"
|
||||
err=1
|
||||
return
|
||||
fi
|
||||
if ! perf record -o /dev/null -e "{cycles/ratio-to-prev=0.5/}" \
|
||||
true |& grep -q 'Invalid use of ratio-to-prev term without preceding element in group'
|
||||
then
|
||||
echo "ratio-to-prev test [Failed need 2+ events]"
|
||||
err=1
|
||||
return
|
||||
fi
|
||||
echo "Basic ratio-to-prev record test [Success]"
|
||||
}
|
||||
|
||||
# raise the limit of file descriptors to minimum
|
||||
if [[ $default_fd_limit -lt $min_fd_limit ]]; then
|
||||
ulimit -Sn $min_fd_limit
|
||||
@@ -404,6 +443,7 @@ test_leader_sampling
|
||||
test_topdown_leader_sampling
|
||||
test_precise_max
|
||||
test_callgraph
|
||||
test_ratio_to_prev
|
||||
|
||||
# restore the default value
|
||||
ulimit -Sn $default_fd_limit
|
||||
|
||||
Reference in new issue
Block a user