kernel/trace/trace_events_user.c
Source file repositories/reference/linux-study-clean/kernel/trace/trace_events_user.c
File Facts
- System
- Linux kernel
- Corpus path
kernel/trace/trace_events_user.c- Extension
.c- Size
- 68478 bytes
- Lines
- 2934
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- 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/bitmap.hlinux/cdev.hlinux/hashtable.hlinux/list.hlinux/io.hlinux/uio.hlinux/ioctl.hlinux/jhash.hlinux/refcount.hlinux/trace_events.hlinux/tracefs.hlinux/types.hlinux/uaccess.hlinux/highmem.hlinux/init.hlinux/user_events.htrace_dynevent.htrace_output.htrace.h
Detected Declarations
struct user_event_groupstruct user_eventstruct user_event_enablerstruct user_event_enabler_faultstruct user_event_refsstruct user_event_file_infostruct user_event_validatorfunction align_addr_bitfunction user_event_keyfunction user_event_capablefunction delayed_destroy_user_eventfunction user_event_putfunction find_user_eventfunction user_event_group_destroyfunction user_event_enabler_destroyfunction user_event_mm_fault_infunction user_event_enabler_fault_fixupfunction user_event_enabler_queue_faultfunction user_event_enabler_writefunction user_event_enabler_existsfunction list_for_each_entryfunction user_event_enabler_updatefunction list_for_each_entryfunction user_event_enabler_dupfunction list_for_each_entry_rcufunction user_event_mm_attachfunction user_event_mm_destroyfunction user_event_mm_putfunction delayed_user_event_mm_putfunction user_event_mm_removefunction user_event_mm_dupfunction list_for_each_entry_rcufunction current_user_event_enabler_existsfunction execfunction user_event_last_reffunction copy_nofaultfunction user_event_parse_cmdfunction user_field_array_sizefunction user_field_sizefunction user_event_destroy_validatorsfunction list_for_each_entry_safefunction user_event_destroy_fieldsfunction list_for_each_entry_safefunction user_event_add_fieldfunction user_event_parse_fieldfunction user_event_parse_fieldsfunction user_field_is_dyn_stringfunction user_dyn_field_set_string
Annotated Snippet
static const struct file_operations user_data_fops = {
.open = user_events_open,
.write = user_events_write,
.write_iter = user_events_write_iter,
.unlocked_ioctl = user_events_ioctl,
.release = user_events_release,
};
static void *user_seq_start(struct seq_file *m, loff_t *pos)
{
if (*pos)
return NULL;
return (void *)1;
}
static void *user_seq_next(struct seq_file *m, void *p, loff_t *pos)
{
++*pos;
return NULL;
}
static void user_seq_stop(struct seq_file *m, void *p)
{
}
static int user_seq_show(struct seq_file *m, void *p)
{
struct user_event_group *group = m->private;
struct user_event *user;
char status;
int i, active = 0, busy = 0;
if (!group)
return -EINVAL;
mutex_lock(&group->reg_mutex);
hash_for_each(group->register_table, i, user, node) {
status = user->status;
seq_printf(m, "%s", EVENT_TP_NAME(user));
if (status != 0) {
seq_puts(m, " # Used by");
if (status & EVENT_STATUS_FTRACE)
seq_puts(m, " ftrace");
if (status & EVENT_STATUS_PERF)
seq_puts(m, " perf");
if (status & EVENT_STATUS_OTHER)
seq_puts(m, " other");
busy++;
}
seq_puts(m, "\n");
active++;
}
mutex_unlock(&group->reg_mutex);
seq_puts(m, "\n");
seq_printf(m, "Active: %d\n", active);
seq_printf(m, "Busy: %d\n", busy);
return 0;
}
static const struct seq_operations user_seq_ops = {
.start = user_seq_start,
.next = user_seq_next,
.stop = user_seq_stop,
.show = user_seq_show,
};
static int user_status_open(struct inode *node, struct file *file)
{
struct user_event_group *group;
int ret;
group = current_user_event_group();
if (!group)
return -ENOENT;
ret = seq_open(file, &user_seq_ops);
if (!ret) {
/* Chain group to seq_file */
struct seq_file *m = file->private_data;
Annotation
- Immediate include surface: `linux/bitmap.h`, `linux/cdev.h`, `linux/hashtable.h`, `linux/list.h`, `linux/io.h`, `linux/uio.h`, `linux/ioctl.h`, `linux/jhash.h`.
- Detected declarations: `struct user_event_group`, `struct user_event`, `struct user_event_enabler`, `struct user_event_enabler_fault`, `struct user_event_refs`, `struct user_event_file_info`, `struct user_event_validator`, `function align_addr_bit`, `function user_event_key`, `function user_event_capable`.
- Atlas domain: Core OS / Scheduler, Processes, Timers, Sync, And Syscalls.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
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.