tools/perf/arch/x86/util/evlist.c

Source file repositories/reference/linux-study-clean/tools/perf/arch/x86/util/evlist.c

File Facts

System
Linux kernel
Corpus path
tools/perf/arch/x86/util/evlist.c
Extension
.c
Size
3663 bytes
Lines
108
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

if (lhs->core.leader != rhs->core.leader) {
			bool lhs_topdown = arch_is_topdown_metrics(lhs);
			bool rhs_topdown = arch_is_topdown_metrics(rhs);

			if (lhs_topdown && !rhs_topdown)
				return -1;
			if (!lhs_topdown && rhs_topdown)
				return 1;
		}
	}

	/* Retire latency event should not be group leader*/
	if (lhs->retire_lat && !rhs->retire_lat)
		return 1;
	if (!lhs->retire_lat && rhs->retire_lat)
		return -1;

	/* Default ordering by insertion index. */
	return lhs->core.idx - rhs->core.idx;
}

int arch_evlist__add_required_events(struct list_head *list)
{
	struct evsel *pos, *metric_event = NULL;
	int idx = 0;

	if (!topdown_sys_has_perf_metrics())
		return 0;

	list_for_each_entry(pos, list, core.node) {
		if (arch_is_topdown_slots(pos)) {
			/* Slots event already present, nothing to do. */
			return 0;
		}
		if (metric_event == NULL && arch_is_topdown_metrics(pos))
			metric_event = pos;
		idx++;
	}
	if (metric_event == NULL) {
		/* No topdown metric events, nothing to do. */
		return 0;
	}
	return topdown_insert_slots_event(list, idx + 1, metric_event);
}

Annotation

Implementation Notes