kernel/trace/trace_events_hist.c
Source file repositories/reference/linux-study-clean/kernel/trace/trace_events_hist.c
File Facts
- System
- Linux kernel
- Corpus path
kernel/trace/trace_events_hist.c- Extension
.c- Size
- 177037 bytes
- Lines
- 7067
- Domain
- Core OS
- Bucket
- Scheduler, Processes, Timers, Sync, And Syscalls
- Inferred role
- Core OS: operation-table or driver-model contract
- Status
- pattern implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/module.hlinux/kallsyms.hlinux/security.hlinux/seq_buf.hlinux/mutex.hlinux/slab.hlinux/stacktrace.hlinux/rculist.hlinux/tracefs.hlinux/trace_events.htrace/events/mmflags.htracing_map.htrace_synth.h
Detected Declarations
struct hist_fieldstruct hist_varstruct hist_fieldstruct var_defsstruct hist_trigger_attrsstruct field_varstruct field_var_histstruct hist_trigger_datastruct action_datastruct action_datastruct track_datastruct hist_elt_datastruct snapshot_contextstruct hist_var_datastruct hist_padstruct hist_val_statstruct hist_file_dataenum field_op_idenum hist_field_fnenum hist_field_flagsenum handler_idenum action_idfunction hist_field_constfunction hist_field_counterfunction hist_field_stringfunction hist_field_dynstringfunction hist_field_reldynstringfunction hist_field_pstringfunction hist_field_log2function hist_field_bucketfunction hist_field_plusfunction hist_field_minusfunction hist_field_divfunction div_by_power_of_twofunction div_by_not_power_of_twofunction div_by_mult_and_shiftfunction hist_field_multfunction hist_field_unary_minusfunction hist_field_get_div_fnfunction track_data_freefunction errposfunction last_cmd_setfunction hist_errfunction hist_err_clearfunction trace_synthfunction action_tracefunction hist_field_timestampfunction hist_field_cpu
Annotated Snippet
const struct file_operations event_hist_fops = {
.open = event_hist_open,
.read = seq_read,
.llseek = seq_lseek,
.release = event_hist_release,
.poll = event_hist_poll,
};
#ifdef CONFIG_HIST_TRIGGERS_DEBUG
#undef C
#define C(a, b) b
static const char * const field_funcs[] = { FIELD_FUNCS };
static void hist_field_debug_show_flags(struct seq_file *m,
unsigned long flags)
{
seq_puts(m, " flags:\n");
if (flags & HIST_FIELD_FL_KEY)
seq_puts(m, " HIST_FIELD_FL_KEY\n");
else if (flags & HIST_FIELD_FL_HITCOUNT)
seq_puts(m, " VAL: HIST_FIELD_FL_HITCOUNT\n");
else if (flags & HIST_FIELD_FL_VAR)
seq_puts(m, " HIST_FIELD_FL_VAR\n");
else if (flags & HIST_FIELD_FL_VAR_REF)
seq_puts(m, " HIST_FIELD_FL_VAR_REF\n");
else
seq_puts(m, " VAL: normal u64 value\n");
if (flags & HIST_FIELD_FL_ALIAS)
seq_puts(m, " HIST_FIELD_FL_ALIAS\n");
else if (flags & HIST_FIELD_FL_CONST)
seq_puts(m, " HIST_FIELD_FL_CONST\n");
}
static int hist_field_debug_show(struct seq_file *m,
struct hist_field *field, unsigned long flags)
{
if ((field->flags & flags) != flags) {
seq_printf(m, "ERROR: bad flags - %lx\n", flags);
return -EINVAL;
}
hist_field_debug_show_flags(m, field->flags);
if (field->field)
seq_printf(m, " ftrace_event_field name: %s\n",
field->field->name);
if (field->flags & HIST_FIELD_FL_VAR) {
seq_printf(m, " var.name: %s\n", field->var.name);
seq_printf(m, " var.idx (into tracing_map_elt.vars[]): %u\n",
field->var.idx);
}
if (field->flags & HIST_FIELD_FL_CONST)
seq_printf(m, " constant: %llu\n", field->constant);
if (field->flags & HIST_FIELD_FL_ALIAS)
seq_printf(m, " var_ref_idx (into hist_data->var_refs[]): %u\n",
field->var_ref_idx);
if (field->flags & HIST_FIELD_FL_VAR_REF) {
seq_printf(m, " name: %s\n", field->name);
seq_printf(m, " var.idx (into tracing_map_elt.vars[]): %u\n",
field->var.idx);
seq_printf(m, " var.hist_data: %p\n", field->var.hist_data);
seq_printf(m, " var_ref_idx (into hist_data->var_refs[]): %u\n",
field->var_ref_idx);
if (field->system)
seq_printf(m, " system: %s\n", field->system);
if (field->event_name)
seq_printf(m, " event_name: %s\n", field->event_name);
}
seq_printf(m, " type: %s\n", field->type);
seq_printf(m, " size: %u\n", field->size);
seq_printf(m, " is_signed: %u\n", field->is_signed);
seq_printf(m, " function: hist_field_%s()\n", field_funcs[field->fn_num]);
return 0;
}
static int field_var_debug_show(struct seq_file *m,
struct field_var *field_var, unsigned int i,
bool save_vars)
{
const char *vars_name = save_vars ? "save_vars" : "field_vars";
struct hist_field *field;
Annotation
- Immediate include surface: `linux/module.h`, `linux/kallsyms.h`, `linux/security.h`, `linux/seq_buf.h`, `linux/mutex.h`, `linux/slab.h`, `linux/stacktrace.h`, `linux/rculist.h`.
- Detected declarations: `struct hist_field`, `struct hist_var`, `struct hist_field`, `struct var_defs`, `struct hist_trigger_attrs`, `struct field_var`, `struct field_var_hist`, `struct hist_trigger_data`, `struct action_data`, `struct action_data`.
- Atlas domain: Core OS / Scheduler, Processes, Timers, Sync, And Syscalls.
- Implementation status: pattern 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.