tools/perf/builtin-kwork.c
Source file repositories/reference/linux-study-clean/tools/perf/builtin-kwork.c
File Facts
- System
- Linux kernel
- Corpus path
tools/perf/builtin-kwork.c- Extension
.c- Size
- 65155 bytes
- Lines
- 2547
- 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
builtin.hperf.hutil/data.hutil/evlist.hutil/evsel.hutil/header.hutil/kwork.hutil/debug.hutil/session.hutil/symbol.hutil/thread.hutil/string2.hutil/callchain.hutil/evsel_fprintf.hutil/util.hsubcmd/pager.hsubcmd/parse-options.hevent-parse.herrno.hinttypes.hsignal.hlinux/err.hlinux/time64.hlinux/zalloc.h
Detected Declarations
struct sort_dimensionfunction id_cmpfunction count_cmpfunction runtime_cmpfunction max_runtime_cmpfunction avg_latency_cmpfunction max_latency_cmpfunction cpu_usage_cmpfunction id_or_cpu_r_cmpfunction sort_dimension__addfunction setup_sortingfunction list_for_each_entryfunction atom_freefunction atom_delfunction work_cmpfunction list_for_each_entryfunction work_insertfunction profile_update_timespanfunction profile_name_matchfunction profile_event_matchfunction work_push_atomfunction list_for_each_entryfunction report_update_exit_eventfunction report_entry_eventfunction report_exit_eventfunction latency_update_entry_eventfunction latency_raise_eventfunction latency_entry_eventfunction timehist_save_callchainfunction timehist_print_eventfunction timehist_raise_eventfunction timehist_entry_eventfunction timehist_exit_eventfunction top_update_runtimefunction top_entry_eventfunction top_exit_eventfunction top_sched_switch_eventfunction process_irq_handler_entry_eventfunction process_irq_handler_exit_eventfunction irq_class_initfunction irq_work_initfunction irq_work_namefunction process_softirq_raise_eventfunction process_softirq_entry_eventfunction process_softirq_exit_eventfunction softirq_class_initfunction softirq_work_initfunction softirq_work_name
Annotated Snippet
struct sort_dimension {
const char *name;
int (*cmp)(struct kwork_work *l, struct kwork_work *r);
struct list_head list;
};
static int id_cmp(struct kwork_work *l, struct kwork_work *r)
{
if (l->cpu > r->cpu)
return 1;
if (l->cpu < r->cpu)
return -1;
if (l->id > r->id)
return 1;
if (l->id < r->id)
return -1;
return 0;
}
static int count_cmp(struct kwork_work *l, struct kwork_work *r)
{
if (l->nr_atoms > r->nr_atoms)
return 1;
if (l->nr_atoms < r->nr_atoms)
return -1;
return 0;
}
static int runtime_cmp(struct kwork_work *l, struct kwork_work *r)
{
if (l->total_runtime > r->total_runtime)
return 1;
if (l->total_runtime < r->total_runtime)
return -1;
return 0;
}
static int max_runtime_cmp(struct kwork_work *l, struct kwork_work *r)
{
if (l->max_runtime > r->max_runtime)
return 1;
if (l->max_runtime < r->max_runtime)
return -1;
return 0;
}
static int avg_latency_cmp(struct kwork_work *l, struct kwork_work *r)
{
u64 avgl, avgr;
if (!r->nr_atoms)
return 1;
if (!l->nr_atoms)
return -1;
avgl = l->total_latency / l->nr_atoms;
avgr = r->total_latency / r->nr_atoms;
if (avgl > avgr)
return 1;
if (avgl < avgr)
return -1;
return 0;
}
static int max_latency_cmp(struct kwork_work *l, struct kwork_work *r)
{
if (l->max_latency > r->max_latency)
return 1;
if (l->max_latency < r->max_latency)
return -1;
return 0;
}
static int cpu_usage_cmp(struct kwork_work *l, struct kwork_work *r)
{
if (l->cpu_usage > r->cpu_usage)
return 1;
if (l->cpu_usage < r->cpu_usage)
return -1;
return 0;
}
Annotation
- Immediate include surface: `builtin.h`, `perf.h`, `util/data.h`, `util/evlist.h`, `util/evsel.h`, `util/header.h`, `util/kwork.h`, `util/debug.h`.
- Detected declarations: `struct sort_dimension`, `function id_cmp`, `function count_cmp`, `function runtime_cmp`, `function max_runtime_cmp`, `function avg_latency_cmp`, `function max_latency_cmp`, `function cpu_usage_cmp`, `function id_or_cpu_r_cmp`, `function sort_dimension__add`.
- 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.