tools/perf/util/sort.c

Source file repositories/reference/linux-study-clean/tools/perf/util/sort.c

File Facts

System
Linux kernel
Corpus path
tools/perf/util/sort.c
Extension
.c
Size
112781 bytes
Lines
4486
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 sort_dimension {
	const char		*name;
	struct sort_entry	*entry;
	int			taken;
};

static int arch_support_sort_key(const char *sort_key, struct perf_env *env)
{
	const char *arch = perf_env__arch(env);

	if (!strcmp("x86", arch) || !strcmp("powerpc", arch)) {
		if (!strcmp(sort_key, "p_stage_cyc"))
			return 1;
		if (!strcmp(sort_key, "local_p_stage_cyc"))
			return 1;
	}
	return 0;
}

static const char *arch_perf_header_entry(const char *se_header, struct perf_env *env)
{
	const char *arch = perf_env__arch(env);

	if (!strcmp("x86", arch)) {
		if (!strcmp(se_header, "Local Pipeline Stage Cycle"))
			return "Local Retire Latency";
		else if (!strcmp(se_header, "Pipeline Stage Cycle"))
			return "Retire Latency";
	} else if (!strcmp("powerpc", arch)) {
		if (!strcmp(se_header, "Local INSTR Latency"))
			return "Finish Cyc";
		else if (!strcmp(se_header, "INSTR Latency"))
			return "Global Finish_cyc";
		else if (!strcmp(se_header, "Local Pipeline Stage Cycle"))
			return "Dispatch Cyc";
		else if (!strcmp(se_header, "Pipeline Stage Cycle"))
			return "Global Dispatch_cyc";
	}
	return se_header;
}

static void sort_dimension_add_dynamic_header(struct sort_dimension *sd, struct perf_env *env)
{
	sd->entry->se_header = arch_perf_header_entry(sd->entry->se_header, env);
}

#define DIM(d, n, func) [d] = { .name = n, .entry = &(func) }

static struct sort_dimension common_sort_dimensions[] = {
	DIM(SORT_PID, "pid", sort_thread),
	DIM(SORT_TGID, "tgid", sort_tgid),
	DIM(SORT_COMM, "comm", sort_comm),
	DIM(SORT_COMM_NODIGIT, "comm_nodigit", sort_comm_nodigit),
	DIM(SORT_DSO, "dso", sort_dso),
	DIM(SORT_SYM, "symbol", sort_sym),
	DIM(SORT_PARENT, "parent", sort_parent),
	DIM(SORT_CPU, "cpu", sort_cpu),
	DIM(SORT_SOCKET, "socket", sort_socket),
	DIM(SORT_SRCLINE, "srcline", sort_srcline),
	DIM(SORT_SRCFILE, "srcfile", sort_srcfile),
	DIM(SORT_LOCAL_WEIGHT, "local_weight", sort_local_weight),
	DIM(SORT_GLOBAL_WEIGHT, "weight", sort_global_weight),
	DIM(SORT_TRANSACTION, "transaction", sort_transaction),
#ifdef HAVE_LIBTRACEEVENT
	DIM(SORT_TRACE, "trace", sort_trace),
#endif
	DIM(SORT_SYM_SIZE, "symbol_size", sort_sym_size),
	DIM(SORT_DSO_SIZE, "dso_size", sort_dso_size),
	DIM(SORT_CGROUP, "cgroup", sort_cgroup),
	DIM(SORT_CGROUP_ID, "cgroup_id", sort_cgroup_id),
	DIM(SORT_SYM_IPC_NULL, "ipc_null", sort_sym_ipc_null),
	DIM(SORT_TIME, "time", sort_time),
	DIM(SORT_CODE_PAGE_SIZE, "code_page_size", sort_code_page_size),
	DIM(SORT_LOCAL_INS_LAT, "local_ins_lat", sort_local_ins_lat),
	DIM(SORT_GLOBAL_INS_LAT, "ins_lat", sort_global_ins_lat),
	DIM(SORT_LOCAL_PIPELINE_STAGE_CYC, "local_p_stage_cyc", sort_local_p_stage_cyc),
	DIM(SORT_GLOBAL_PIPELINE_STAGE_CYC, "p_stage_cyc", sort_global_p_stage_cyc),
	DIM(SORT_ADDR, "addr", sort_addr),
	DIM(SORT_LOCAL_RETIRE_LAT, "local_retire_lat", sort_local_p_stage_cyc),
	DIM(SORT_GLOBAL_RETIRE_LAT, "retire_lat", sort_global_p_stage_cyc),
	DIM(SORT_SIMD, "simd", sort_simd),
	DIM(SORT_ANNOTATE_DATA_TYPE, "type", sort_type),
	DIM(SORT_ANNOTATE_DATA_TYPE_OFFSET, "typeoff", sort_type_offset),
	DIM(SORT_SYM_OFFSET, "symoff", sort_sym_offset),
	DIM(SORT_ANNOTATE_DATA_TYPE_CACHELINE, "typecln", sort_type_cacheline),
	DIM(SORT_PARALLELISM, "parallelism", sort_parallelism),
};

#undef DIM

Annotation

Implementation Notes