Re: [PATCH v3 14/46] perf test: Mask config then test

From: Ravi Bangoria
Date: Tue May 02 2023 - 06:44:59 EST


> @@ -87,7 +92,7 @@ static int test__checkevent_raw(struct evlist *evlist)
>
> TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
> TEST_ASSERT_VAL("wrong type", PERF_TYPE_RAW == evsel->core.attr.type);
> - TEST_ASSERT_VAL("wrong config", 0x1a == evsel->core.attr.config);
> + TEST_ASSERT_VAL("wrong config", test_config(evsel, 0x1a));

Extended 'type' via 'config' is applicable only to HW and HW_CACHE types.
I think we should not apply test_config() for other types. Even if they
are ineffective in these tests (because we are not setting upper bits),
they are semantically wrong IMO.

In fact, AMD EventSelect is 12 bits and upper 4 bits are located at 35:32
in PerfEvtSel register. So for RAW events, upper bits MUST NOT be ignored.


> @@ -139,8 +142,7 @@ static int test__checkevent_symbolic_alias(struct evlist *evlist)
>
> TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
> TEST_ASSERT_VAL("wrong type", PERF_TYPE_SOFTWARE == evsel->core.attr.type);
> - TEST_ASSERT_VAL("wrong config",
> - PERF_COUNT_SW_PAGE_FAULTS == evsel->core.attr.config);
> + TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_SW_PAGE_FAULTS));

Ditto for PERF_TYPE_SOFTWARE. We should not use test_config().


> @@ -160,7 +162,7 @@ static int test__checkevent_breakpoint(struct evlist *evlist)
>
> TEST_ASSERT_VAL("wrong number of entries", 1 == evlist->core.nr_entries);
> TEST_ASSERT_VAL("wrong type", PERF_TYPE_BREAKPOINT == evsel->core.attr.type);
> - TEST_ASSERT_VAL("wrong config", 0 == evsel->core.attr.config);
> + TEST_ASSERT_VAL("wrong config", test_config(evsel, 0));

Ditto for PERF_TYPE_BREAKPOINT.