tools/perf/arch/x86/tests/hybrid.c

Source file repositories/reference/linux-study-clean/tools/perf/arch/x86/tests/hybrid.c

File Facts

System
Linux kernel
Corpus path
tools/perf/arch/x86/tests/hybrid.c
Extension
.c
Size
9904 bytes
Lines
311
Domain
Support Tooling And Documentation
Bucket
tools
Inferred role
Support Tooling And Documentation: implementation source
Status
source implementation candidate

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

struct evlist_test {
	const char *name;
	bool (*valid)(void);
	int (*check)(struct evlist *evlist);
};

static const struct evlist_test test__hybrid_events[] = {
	{
		.name  = "cpu_core/cycles/",
		.check = test__hybrid_hw_event_with_pmu,
		/* 0 */
	},
	{
		.name  = "{cpu_core/cycles/,cpu_core/branches/}",
		.check = test__hybrid_hw_group_event,
		/* 1 */
	},
	{
		.name  = "{cpu-clock,cpu_core/cycles/}",
		.check = test__hybrid_sw_hw_group_event,
		/* 2 */
	},
	{
		.name  = "{cpu_core/cycles/,cpu-clock}",
		.check = test__hybrid_hw_sw_group_event,
		/* 3 */
	},
	{
		.name  = "{cpu_core/cycles/k,cpu_core/branches/u}",
		.check = test__hybrid_group_modifier1,
		/* 4 */
	},
	{
		.name  = "r1a",
		.check = test__hybrid_raw1,
		/* 5 */
	},
	{
		.name  = "cpu_core/r1a/",
		.check = test__hybrid_raw2,
		/* 6 */
	},
	{
		.name  = "cpu_core/config=10,config1,config2=3,period=1000/u",
		.check = test__checkevent_pmu,
		/* 7 */
	},
	{
		.name  = "cpu_core/LLC-loads/",
		.check = test__hybrid_cache_event,
		/* 8 */
	},
	{
		.name  = "{cpu_core/cycles/,cpu_core/cpu-cycles/}",
		.check = test__hybrid_hw_group_event_2,
		/* 9 */
	},
};

static int test_event(const struct evlist_test *e)
{
	struct parse_events_error err;
	struct evlist *evlist;
	int ret;

	if (e->valid && !e->valid()) {
		pr_debug("... SKIP\n");
		return TEST_OK;
	}

	evlist = evlist__new();
	if (evlist == NULL) {
		pr_err("Failed allocation");
		return TEST_FAIL;
	}
	parse_events_error__init(&err);
	ret = parse_events(evlist, e->name, &err);
	if (ret) {
		pr_debug("failed to parse event '%s', err %d\n", e->name, ret);
		parse_events_error__print(&err, e->name);
		ret = TEST_FAIL;
		if (parse_events_error__contains(&err, "can't access trace events"))
			ret = TEST_SKIP;
	} else {
		ret = e->check(evlist);
	}
	parse_events_error__exit(&err);
	evlist__delete(evlist);

	return ret;

Annotation

Implementation Notes