Unverified Commit 735f0ab7 authored by openeuler-ci-bot's avatar openeuler-ci-bot Committed by Gitee
Browse files

!7482 v2 perf parse-events: Make legacy events lower priority than sysfs/JSON

Merge Pull Request from: @ci-robot 
 
PR sync from: Junhao He <hejunhao3@huawei.com>
https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/M5W3BXKXRQQKHCKRUUYCTUH2OREREYW5/ 
Make legacy events lower priority than sysfs/JSON

Ian Rogers (2):
  perf parse-events: Make legacy events lower priority than sysfs/JSON
  perf x86 test: Update hybrid expectations


-- 
2.33.0
 
https://gitee.com/openeuler/kernel/issues/I9Q2KV
https://gitee.com/openeuler/kernel/issues/I8BOB3 
 
Link:https://gitee.com/openeuler/kernel/pulls/7482

 

Reviewed-by: default avatarYe Weihua <yeweihua4@huawei.com>
Signed-off-by: default avatarZhang Peng <zhangpeng362@huawei.com>
parents 0c2a6021 5129d246
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -47,7 +47,7 @@ static int test__hybrid_hw_group_event(struct evlist *evlist)
	evsel = evsel__next(evsel);
	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
	TEST_ASSERT_VAL("wrong hybrid type", test_hybrid_type(evsel, PERF_TYPE_RAW));
	TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_INSTRUCTIONS));
	TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_BRANCH_INSTRUCTIONS));
	TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader));
	return TEST_OK;
}
@@ -102,7 +102,7 @@ static int test__hybrid_group_modifier1(struct evlist *evlist)
	evsel = evsel__next(evsel);
	TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
	TEST_ASSERT_VAL("wrong hybrid type", test_hybrid_type(evsel, PERF_TYPE_RAW));
	TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_INSTRUCTIONS));
	TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_BRANCH_INSTRUCTIONS));
	TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader));
	TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
	TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
@@ -171,27 +171,27 @@ struct evlist_test {

static const struct evlist_test test__hybrid_events[] = {
	{
		.name  = "cpu_core/cpu-cycles/",
		.name  = "cpu_core/cycles/",
		.check = test__hybrid_hw_event_with_pmu,
		/* 0 */
	},
	{
		.name  = "{cpu_core/cpu-cycles/,cpu_core/instructions/}",
		.name  = "{cpu_core/cycles/,cpu_core/branches/}",
		.check = test__hybrid_hw_group_event,
		/* 1 */
	},
	{
		.name  = "{cpu-clock,cpu_core/cpu-cycles/}",
		.name  = "{cpu-clock,cpu_core/cycles/}",
		.check = test__hybrid_sw_hw_group_event,
		/* 2 */
	},
	{
		.name  = "{cpu_core/cpu-cycles/,cpu-clock}",
		.name  = "{cpu_core/cycles/,cpu-clock}",
		.check = test__hybrid_hw_sw_group_event,
		/* 3 */
	},
	{
		.name  = "{cpu_core/cpu-cycles/k,cpu_core/instructions/u}",
		.name  = "{cpu_core/cycles/k,cpu_core/branches/u}",
		.check = test__hybrid_group_modifier1,
		/* 4 */
	},
+185 −71
Original line number Diff line number Diff line
@@ -162,6 +162,22 @@ static int test__checkevent_numeric(struct evlist *evlist)
	return TEST_OK;
}


static int assert_hw(struct perf_evsel *evsel, enum perf_hw_id id, const char *name)
{
	struct perf_pmu *pmu;

	if (evsel->attr.type == PERF_TYPE_HARDWARE) {
		TEST_ASSERT_VAL("wrong config", test_perf_config(evsel, id));
		return 0;
	}
	pmu = perf_pmus__find_by_type(evsel->attr.type);

	TEST_ASSERT_VAL("unexpected PMU type", pmu);
	TEST_ASSERT_VAL("PMU missing event", perf_pmu__have_event(pmu, name));
	return 0;
}

static int test__checkevent_symbolic_name(struct evlist *evlist)
{
	struct perf_evsel *evsel;
@@ -169,10 +185,12 @@ static int test__checkevent_symbolic_name(struct evlist *evlist)
	TEST_ASSERT_VAL("wrong number of entries", 0 != evlist->core.nr_entries);

	perf_evlist__for_each_evsel(&evlist->core, evsel) {
		TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
		TEST_ASSERT_VAL("wrong config",
				test_perf_config(evsel, PERF_COUNT_HW_INSTRUCTIONS));
		int ret = assert_hw(evsel, PERF_COUNT_HW_INSTRUCTIONS, "instructions");

		if (ret)
			return ret;
	}

	return TEST_OK;
}

@@ -183,8 +201,10 @@ static int test__checkevent_symbolic_name_config(struct evlist *evlist)
	TEST_ASSERT_VAL("wrong number of entries", 0 != evlist->core.nr_entries);

	perf_evlist__for_each_evsel(&evlist->core, evsel) {
		TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->attr.type);
		TEST_ASSERT_VAL("wrong config", test_perf_config(evsel, PERF_COUNT_HW_CPU_CYCLES));
		int ret = assert_hw(evsel, PERF_COUNT_HW_CPU_CYCLES, "cycles");

		if (ret)
			return ret;
		/*
		 * The period value gets configured within evlist__config,
		 * while this test executes only parse events method.
@@ -861,10 +881,14 @@ static int test__group1(struct evlist *evlist)
			evlist__nr_groups(evlist) == num_core_entries());

	for (int i = 0; i < num_core_entries(); i++) {
		int ret;

		/* instructions:k */
		evsel = leader = (i == 0 ? evlist__first(evlist) : evsel__next(evsel));
		TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
		TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_INSTRUCTIONS));
		ret = assert_hw(&evsel->core, PERF_COUNT_HW_INSTRUCTIONS, "instructions");
		if (ret)
			return ret;

		TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
		TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
		TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
@@ -878,8 +902,10 @@ static int test__group1(struct evlist *evlist)

		/* cycles:upp */
		evsel = evsel__next(evsel);
		TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
		TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES));
		ret = assert_hw(&evsel->core, PERF_COUNT_HW_CPU_CYCLES, "cycles");
		if (ret)
			return ret;

		TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
		TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
		TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
@@ -907,6 +933,8 @@ static int test__group2(struct evlist *evlist)
	TEST_ASSERT_VAL("wrong number of groups", 1 == evlist__nr_groups(evlist));

	evlist__for_each_entry(evlist, evsel) {
		int ret;

		if (evsel->core.attr.type == PERF_TYPE_SOFTWARE) {
			/* faults + :ku modifier */
			leader = evsel;
@@ -939,8 +967,10 @@ static int test__group2(struct evlist *evlist)
			continue;
		}
		/* cycles:k */
		TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
		TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES));
		ret = assert_hw(&evsel->core, PERF_COUNT_HW_CPU_CYCLES, "cycles");
		if (ret)
			return ret;

		TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
		TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
		TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
@@ -957,6 +987,7 @@ static int test__group2(struct evlist *evlist)
static int test__group3(struct evlist *evlist __maybe_unused)
{
	struct evsel *evsel, *group1_leader = NULL, *group2_leader = NULL;
	int ret;

	TEST_ASSERT_VAL("wrong number of entries",
			evlist->core.nr_entries == (3 * perf_pmus__num_core_pmus() + 2));
@@ -1045,8 +1076,10 @@ static int test__group3(struct evlist *evlist __maybe_unused)
			continue;
		}
		/* instructions:u */
		TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
		TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_INSTRUCTIONS));
		ret = assert_hw(&evsel->core, PERF_COUNT_HW_INSTRUCTIONS, "instructions");
		if (ret)
			return ret;

		TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
		TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
		TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
@@ -1070,10 +1103,14 @@ static int test__group4(struct evlist *evlist __maybe_unused)
			num_core_entries() == evlist__nr_groups(evlist));

	for (int i = 0; i < num_core_entries(); i++) {
		int ret;

		/* cycles:u + p */
		evsel = leader = (i == 0 ? evlist__first(evlist) : evsel__next(evsel));
		TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
		TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES));
		ret = assert_hw(&evsel->core, PERF_COUNT_HW_CPU_CYCLES, "cycles");
		if (ret)
			return ret;

		TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
		TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
		TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
@@ -1089,8 +1126,10 @@ static int test__group4(struct evlist *evlist __maybe_unused)

		/* instructions:kp + p */
		evsel = evsel__next(evsel);
		TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
		TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_INSTRUCTIONS));
		ret = assert_hw(&evsel->core, PERF_COUNT_HW_INSTRUCTIONS, "instructions");
		if (ret)
			return ret;

		TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
		TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
		TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
@@ -1108,6 +1147,7 @@ static int test__group4(struct evlist *evlist __maybe_unused)
static int test__group5(struct evlist *evlist __maybe_unused)
{
	struct evsel *evsel = NULL, *leader;
	int ret;

	TEST_ASSERT_VAL("wrong number of entries",
			evlist->core.nr_entries == (5 * num_core_entries()));
@@ -1117,8 +1157,10 @@ static int test__group5(struct evlist *evlist __maybe_unused)
	for (int i = 0; i < num_core_entries(); i++) {
		/* cycles + G */
		evsel = leader = (i == 0 ? evlist__first(evlist) : evsel__next(evsel));
		TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
		TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES));
		ret = assert_hw(&evsel->core, PERF_COUNT_HW_CPU_CYCLES, "cycles");
		if (ret)
			return ret;

		TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
		TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
		TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
@@ -1133,8 +1175,10 @@ static int test__group5(struct evlist *evlist __maybe_unused)

		/* instructions + G */
		evsel = evsel__next(evsel);
		TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
		TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_INSTRUCTIONS));
		ret = assert_hw(&evsel->core, PERF_COUNT_HW_INSTRUCTIONS, "instructions");
		if (ret)
			return ret;

		TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
		TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
		TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
@@ -1148,8 +1192,10 @@ static int test__group5(struct evlist *evlist __maybe_unused)
	for (int i = 0; i < num_core_entries(); i++) {
		/* cycles:G */
		evsel = leader = evsel__next(evsel);
		TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
		TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES));
		ret = assert_hw(&evsel->core, PERF_COUNT_HW_CPU_CYCLES, "cycles");
		if (ret)
			return ret;

		TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
		TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
		TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
@@ -1164,8 +1210,10 @@ static int test__group5(struct evlist *evlist __maybe_unused)

		/* instructions:G */
		evsel = evsel__next(evsel);
		TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
		TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_INSTRUCTIONS));
		ret = assert_hw(&evsel->core, PERF_COUNT_HW_INSTRUCTIONS, "instructions");
		if (ret)
			return ret;

		TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
		TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
		TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
@@ -1178,8 +1226,10 @@ static int test__group5(struct evlist *evlist __maybe_unused)
	for (int i = 0; i < num_core_entries(); i++) {
		/* cycles */
		evsel = evsel__next(evsel);
		TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
		TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES));
		ret = assert_hw(&evsel->core, PERF_COUNT_HW_CPU_CYCLES, "cycles");
		if (ret)
			return ret;

		TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
		TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
		TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
@@ -1201,10 +1251,14 @@ static int test__group_gh1(struct evlist *evlist)
			evlist__nr_groups(evlist) == num_core_entries());

	for (int i = 0; i < num_core_entries(); i++) {
		int ret;

		/* cycles + :H group modifier */
		evsel = leader = (i == 0 ? evlist__first(evlist) : evsel__next(evsel));
		TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
		TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES));
		ret = assert_hw(&evsel->core, PERF_COUNT_HW_CPU_CYCLES, "cycles");
		if (ret)
			return ret;

		TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
		TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
		TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
@@ -1218,8 +1272,10 @@ static int test__group_gh1(struct evlist *evlist)

		/* cache-misses:G + :H group modifier */
		evsel = evsel__next(evsel);
		TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
		TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CACHE_MISSES));
		ret = assert_hw(&evsel->core, PERF_COUNT_HW_CACHE_MISSES, "cache-misses");
		if (ret)
			return ret;

		TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
		TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
		TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
@@ -1242,10 +1298,14 @@ static int test__group_gh2(struct evlist *evlist)
			evlist__nr_groups(evlist) == num_core_entries());

	for (int i = 0; i < num_core_entries(); i++) {
		int ret;

		/* cycles + :G group modifier */
		evsel = leader = (i == 0 ? evlist__first(evlist) : evsel__next(evsel));
		TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
		TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES));
		ret = assert_hw(&evsel->core, PERF_COUNT_HW_CPU_CYCLES, "cycles");
		if (ret)
			return ret;

		TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
		TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
		TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
@@ -1259,8 +1319,10 @@ static int test__group_gh2(struct evlist *evlist)

		/* cache-misses:H + :G group modifier */
		evsel = evsel__next(evsel);
		TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
		TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CACHE_MISSES));
		ret = assert_hw(&evsel->core, PERF_COUNT_HW_CACHE_MISSES, "cache-misses");
		if (ret)
			return ret;

		TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
		TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
		TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
@@ -1283,10 +1345,14 @@ static int test__group_gh3(struct evlist *evlist)
			evlist__nr_groups(evlist) == num_core_entries());

	for (int i = 0; i < num_core_entries(); i++) {
		int ret;

		/* cycles:G + :u group modifier */
		evsel = leader = (i == 0 ? evlist__first(evlist) : evsel__next(evsel));
		TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
		TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES));
		ret = assert_hw(&evsel->core, PERF_COUNT_HW_CPU_CYCLES, "cycles");
		if (ret)
			return ret;

		TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
		TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
		TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
@@ -1300,8 +1366,10 @@ static int test__group_gh3(struct evlist *evlist)

		/* cache-misses:H + :u group modifier */
		evsel = evsel__next(evsel);
		TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
		TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CACHE_MISSES));
		ret = assert_hw(&evsel->core, PERF_COUNT_HW_CACHE_MISSES, "cache-misses");
		if (ret)
			return ret;

		TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
		TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
		TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
@@ -1324,10 +1392,14 @@ static int test__group_gh4(struct evlist *evlist)
			evlist__nr_groups(evlist) == num_core_entries());

	for (int i = 0; i < num_core_entries(); i++) {
		int ret;

		/* cycles:G + :uG group modifier */
		evsel = leader = (i == 0 ? evlist__first(evlist) : evsel__next(evsel));
		TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
		TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES));
		ret = assert_hw(&evsel->core, PERF_COUNT_HW_CPU_CYCLES, "cycles");
		if (ret)
			return ret;

		TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
		TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
		TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
@@ -1341,8 +1413,10 @@ static int test__group_gh4(struct evlist *evlist)

		/* cache-misses:H + :uG group modifier */
		evsel = evsel__next(evsel);
		TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
		TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CACHE_MISSES));
		ret = assert_hw(&evsel->core, PERF_COUNT_HW_CACHE_MISSES, "cache-misses");
		if (ret)
			return ret;

		TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
		TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
		TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
@@ -1363,10 +1437,14 @@ static int test__leader_sample1(struct evlist *evlist)
			evlist->core.nr_entries == (3 * num_core_entries()));

	for (int i = 0; i < num_core_entries(); i++) {
		int ret;

		/* cycles - sampling group leader */
		evsel = leader = (i == 0 ? evlist__first(evlist) : evsel__next(evsel));
		TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
		TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES));
		ret = assert_hw(&evsel->core, PERF_COUNT_HW_CPU_CYCLES, "cycles");
		if (ret)
			return ret;

		TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
		TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
		TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
@@ -1379,8 +1457,10 @@ static int test__leader_sample1(struct evlist *evlist)

		/* cache-misses - not sampling */
		evsel = evsel__next(evsel);
		TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
		TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CACHE_MISSES));
		ret = assert_hw(&evsel->core, PERF_COUNT_HW_CACHE_MISSES, "cache-misses");
		if (ret)
			return ret;

		TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
		TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
		TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
@@ -1392,8 +1472,10 @@ static int test__leader_sample1(struct evlist *evlist)

		/* branch-misses - not sampling */
		evsel = evsel__next(evsel);
		TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
		TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_BRANCH_MISSES));
		ret = assert_hw(&evsel->core, PERF_COUNT_HW_BRANCH_MISSES, "branch-misses");
		if (ret)
			return ret;

		TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
		TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
		TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
@@ -1415,10 +1497,14 @@ static int test__leader_sample2(struct evlist *evlist __maybe_unused)
			evlist->core.nr_entries == (2 * num_core_entries()));

	for (int i = 0; i < num_core_entries(); i++) {
		int ret;

		/* instructions - sampling group leader */
		evsel = leader = (i == 0 ? evlist__first(evlist) : evsel__next(evsel));
		TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
		TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_INSTRUCTIONS));
		ret = assert_hw(&evsel->core, PERF_COUNT_HW_INSTRUCTIONS, "instructions");
		if (ret)
			return ret;

		TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
		TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
		TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
@@ -1431,8 +1517,10 @@ static int test__leader_sample2(struct evlist *evlist __maybe_unused)

		/* branch-misses - not sampling */
		evsel = evsel__next(evsel);
		TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
		TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_BRANCH_MISSES));
		ret = assert_hw(&evsel->core, PERF_COUNT_HW_BRANCH_MISSES, "branch-misses");
		if (ret)
			return ret;

		TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
		TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
		TEST_ASSERT_VAL("wrong exclude_hv", evsel->core.attr.exclude_hv);
@@ -1472,10 +1560,14 @@ static int test__pinned_group(struct evlist *evlist)
			evlist->core.nr_entries == (3 * num_core_entries()));

	for (int i = 0; i < num_core_entries(); i++) {
		int ret;

		/* cycles - group leader */
		evsel = leader = (i == 0 ? evlist__first(evlist) : evsel__next(evsel));
		TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
		TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES));
		ret = assert_hw(&evsel->core, PERF_COUNT_HW_CPU_CYCLES, "cycles");
		if (ret)
			return ret;

		TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
		TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader));
		/* TODO: The group modifier is not copied to the split group leader. */
@@ -1484,13 +1576,18 @@ static int test__pinned_group(struct evlist *evlist)

		/* cache-misses - can not be pinned, but will go on with the leader */
		evsel = evsel__next(evsel);
		TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
		TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CACHE_MISSES));
		ret = assert_hw(&evsel->core, PERF_COUNT_HW_CACHE_MISSES, "cache-misses");
		if (ret)
			return ret;

		TEST_ASSERT_VAL("wrong pinned", !evsel->core.attr.pinned);

		/* branch-misses - ditto */
		evsel = evsel__next(evsel);
		TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_BRANCH_MISSES));
		ret = assert_hw(&evsel->core, PERF_COUNT_HW_BRANCH_MISSES, "branch-misses");
		if (ret)
			return ret;

		TEST_ASSERT_VAL("wrong pinned", !evsel->core.attr.pinned);
	}
	return TEST_OK;
@@ -1517,10 +1614,14 @@ static int test__exclusive_group(struct evlist *evlist)
			evlist->core.nr_entries == 3 * num_core_entries());

	for (int i = 0; i < num_core_entries(); i++) {
		int ret;

		/* cycles - group leader */
		evsel = leader = (i == 0 ? evlist__first(evlist) : evsel__next(evsel));
		TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
		TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES));
		ret = assert_hw(&evsel->core, PERF_COUNT_HW_CPU_CYCLES, "cycles");
		if (ret)
			return ret;

		TEST_ASSERT_VAL("wrong group name", !evsel->group_name);
		TEST_ASSERT_VAL("wrong leader", evsel__has_leader(evsel, leader));
		/* TODO: The group modifier is not copied to the split group leader. */
@@ -1529,13 +1630,18 @@ static int test__exclusive_group(struct evlist *evlist)

		/* cache-misses - can not be pinned, but will go on with the leader */
		evsel = evsel__next(evsel);
		TEST_ASSERT_VAL("wrong type", PERF_TYPE_HARDWARE == evsel->core.attr.type);
		TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CACHE_MISSES));
		ret = assert_hw(&evsel->core, PERF_COUNT_HW_CACHE_MISSES, "cache-misses");
		if (ret)
			return ret;

		TEST_ASSERT_VAL("wrong exclusive", !evsel->core.attr.exclusive);

		/* branch-misses - ditto */
		evsel = evsel__next(evsel);
		TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_BRANCH_MISSES));
		ret = assert_hw(&evsel->core, PERF_COUNT_HW_BRANCH_MISSES, "branch-misses");
		if (ret)
			return ret;

		TEST_ASSERT_VAL("wrong exclusive", !evsel->core.attr.exclusive);
	}
	return TEST_OK;
@@ -1677,9 +1783,11 @@ static int test__checkevent_raw_pmu(struct evlist *evlist)
static int test__sym_event_slash(struct evlist *evlist)
{
	struct evsel *evsel = evlist__first(evlist);
	int ret = assert_hw(&evsel->core, PERF_COUNT_HW_CPU_CYCLES, "cycles");

	if (ret)
		return ret;

	TEST_ASSERT_VAL("wrong type", evsel->core.attr.type == PERF_TYPE_HARDWARE);
	TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES));
	TEST_ASSERT_VAL("wrong exclude_kernel", evsel->core.attr.exclude_kernel);
	return TEST_OK;
}
@@ -1687,9 +1795,11 @@ static int test__sym_event_slash(struct evlist *evlist)
static int test__sym_event_dc(struct evlist *evlist)
{
	struct evsel *evsel = evlist__first(evlist);
	int ret = assert_hw(&evsel->core, PERF_COUNT_HW_CPU_CYCLES, "cycles");

	if (ret)
		return ret;

	TEST_ASSERT_VAL("wrong type", evsel->core.attr.type == PERF_TYPE_HARDWARE);
	TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES));
	TEST_ASSERT_VAL("wrong exclude_user", evsel->core.attr.exclude_user);
	return TEST_OK;
}
@@ -1697,9 +1807,11 @@ static int test__sym_event_dc(struct evlist *evlist)
static int test__term_equal_term(struct evlist *evlist)
{
	struct evsel *evsel = evlist__first(evlist);
	int ret = assert_hw(&evsel->core, PERF_COUNT_HW_CPU_CYCLES, "cycles");

	if (ret)
		return ret;

	TEST_ASSERT_VAL("wrong type", evsel->core.attr.type == PERF_TYPE_HARDWARE);
	TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES));
	TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "name") == 0);
	return TEST_OK;
}
@@ -1707,9 +1819,11 @@ static int test__term_equal_term(struct evlist *evlist)
static int test__term_equal_legacy(struct evlist *evlist)
{
	struct evsel *evsel = evlist__first(evlist);
	int ret = assert_hw(&evsel->core, PERF_COUNT_HW_CPU_CYCLES, "cycles");

	if (ret)
		return ret;

	TEST_ASSERT_VAL("wrong type", evsel->core.attr.type == PERF_TYPE_HARDWARE);
	TEST_ASSERT_VAL("wrong config", test_config(evsel, PERF_COUNT_HW_CPU_CYCLES));
	TEST_ASSERT_VAL("wrong name setting", strcmp(evsel->name, "l1d") == 0);
	return TEST_OK;
}
+36 −14

File changed.

Preview size limit exceeded, changes collapsed.

+6 −2
Original line number Diff line number Diff line
@@ -1498,12 +1498,14 @@ static int check_info_data(struct perf_pmu *pmu,
 * defined for the alias
 */
int perf_pmu__check_alias(struct perf_pmu *pmu, struct list_head *head_terms,
			  struct perf_pmu_info *info, struct parse_events_error *err)
			  struct perf_pmu_info *info, bool *rewrote_terms,
			  struct parse_events_error *err)
{
	struct parse_events_term *term, *h;
	struct perf_pmu_alias *alias;
	int ret;

	*rewrote_terms = false;
	info->per_pkg = false;

	/*
@@ -1525,7 +1527,7 @@ int perf_pmu__check_alias(struct perf_pmu *pmu, struct list_head *head_terms,
						NULL);
			return ret;
		}

		*rewrote_terms = true;
		ret = check_info_data(pmu, alias, info, err, term->err_term);
		if (ret)
			return ret;
@@ -1619,6 +1621,8 @@ bool perf_pmu__auto_merge_stats(const struct perf_pmu *pmu)

bool perf_pmu__have_event(struct perf_pmu *pmu, const char *name)
{
	if (!name)
		return false;
	if (perf_pmu__find_alias(pmu, name, /*load=*/ true) != NULL)
		return true;
	if (pmu->cpu_aliases_added || !pmu->events_table)
+2 −1
Original line number Diff line number Diff line
@@ -202,7 +202,8 @@ int perf_pmu__config_terms(struct perf_pmu *pmu,
__u64 perf_pmu__format_bits(struct perf_pmu *pmu, const char *name);
int perf_pmu__format_type(struct perf_pmu *pmu, const char *name);
int perf_pmu__check_alias(struct perf_pmu *pmu, struct list_head *head_terms,
			  struct perf_pmu_info *info, struct parse_events_error *err);
			  struct perf_pmu_info *info, bool *rewrote_terms,
			  struct parse_events_error *err);
int perf_pmu__find_event(struct perf_pmu *pmu, const char *event, void *state, pmu_event_callback cb);

int perf_pmu__format_parse(struct perf_pmu *pmu, int dirfd, bool eager_load);