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.

Dependency Surface

Detected Declarations

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

Implementation Notes