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.
- Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
ctype.herrno.hinttypes.hregex.hstdlib.hlinux/mman.hlinux/time64.hdebug.hdso.hsort.hhist.hcacheline.hcomm.hmap.hmaps.hsymbol.hmap_symbol.hbranch.hthread.hevsel.hevlist.hsrcline.hstrlist.hstrbuf.hmem-events.hmem-info.hannotate.hannotate-data.hevent.htime-utils.hcgroup.hmachine.h
Detected Declarations
struct sort_dimensionstruct hpp_dimensionstruct hpp_sort_entrystruct hpp_dynamic_entryfunction namesfunction cmp_nullfunction sort__thread_cmpfunction hist_entry__thread_snprintffunction hist_entry__thread_filterfunction sort__tgid_cmpfunction hist_entry__tgid_snprintffunction sort__simd_cmpfunction hist_entry__simd_snprintffunction sort__comm_cmpfunction sort__comm_collapsefunction sort__comm_sortfunction hist_entry__comm_snprintffunction sort__comm_nodigit_lenfunction strcmp_nodigitfunction sort__comm_nodigit_cmpfunction sort__comm_nodigit_collapsefunction sort__comm_nodigit_sortfunction hist_entry__comm_nodigit_snprintffunction _sort__dso_cmpfunction sort__dso_cmpfunction _hist_entry__dso_snprintffunction hist_entry__dso_snprintffunction hist_entry__dso_filterfunction _sort__addr_cmpfunction _sort__sym_cmpfunction sort__sym_cmpfunction sort__sym_sortfunction _hist_entry__sym_snprintffunction hist_entry__sym_snprintffunction hist_entry__sym_filterfunction sort__symoff_cmpfunction sort__symoff_sortfunction hist_entry__symoff_snprintffunction sort__srcline_cmpfunction sort__srcline_collapsefunction sort__srcline_sortfunction sort__srcline_initfunction hist_entry__srcline_snprintffunction sort__srcline_from_cmpfunction sort__srcline_from_collapsefunction sort__srcline_from_sortfunction sort__srcline_from_initfunction hist_entry__srcline_from_snprintf
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
- Immediate include surface: `ctype.h`, `errno.h`, `inttypes.h`, `regex.h`, `stdlib.h`, `linux/mman.h`, `linux/time64.h`, `debug.h`.
- Detected declarations: `struct sort_dimension`, `struct hpp_dimension`, `struct hpp_sort_entry`, `struct hpp_dynamic_entry`, `function names`, `function cmp_null`, `function sort__thread_cmp`, `function hist_entry__thread_snprintf`, `function hist_entry__thread_filter`, `function sort__tgid_cmp`.
- Atlas domain: Support Tooling And Documentation / tools.
- Implementation status: source implementation candidate.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.