kernel/trace/trace_events_trigger.c
Source file repositories/reference/linux-study-clean/kernel/trace/trace_events_trigger.c
File Facts
- System
- Linux kernel
- Corpus path
kernel/trace/trace_events_trigger.c- Extension
.c- Size
- 53067 bytes
- Lines
- 1984
- 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.
- 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/security.hlinux/kthread.hlinux/module.hlinux/ctype.hlinux/mutex.hlinux/slab.hlinux/rculist.htrace.h
Detected Declarations
function trigger_create_kthread_lockedfunction trigger_data_free_queued_lockedfunction trigger_kthread_fnfunction trigger_data_freefunction trigger_data_free_initfunction data_ops_triggerfunction handlersfunction list_for_each_entry_rcufunction __trace_trigger_soft_disabledfunction handlersfunction list_for_each_entry_rcufunction check_user_triggerfunction list_for_each_entry_rcufunction trigger_stopfunction trigger_showfunction event_trigger_regex_openfunction list_for_each_entryfunction trigger_process_regexfunction list_for_each_entryfunction event_trigger_regex_writefunction event_trigger_regex_releasefunction event_trigger_writefunction event_trigger_openfunction event_trigger_releasefunction register_event_commandfunction list_for_each_entryfunction unregister_event_commandfunction list_for_each_entry_safefunction event_trigger_countfunction event_trigger_printfunction event_trigger_initfunction event_trigger_freefunction trace_event_trigger_enable_disablefunction trace_event_trigger_enable_disablefunction list_for_each_entryfunction list_for_each_entry_safefunction update_cond_flagfunction list_for_each_entryfunction register_triggerfunction list_for_each_entryfunction try_unregister_triggerfunction list_for_each_entryfunction unregister_triggerfunction commandfunction event_trigger_empty_paramfunction event_trigger_separate_filterfunction trigger_data_freefunction event_trigger_parse_num
Annotated Snippet
const struct file_operations event_trigger_fops = {
.open = event_trigger_open,
.read = seq_read,
.write = event_trigger_write,
.llseek = tracing_lseek,
.release = event_trigger_release,
};
/*
* Currently we only register event commands from __init, so mark this
* __init too.
*/
__init int register_event_command(struct event_command *cmd)
{
struct event_command *p;
guard(mutex)(&trigger_cmd_mutex);
list_for_each_entry(p, &trigger_commands, list) {
if (strcmp(cmd->name, p->name) == 0)
return -EBUSY;
}
list_add(&cmd->list, &trigger_commands);
return 0;
}
/*
* Currently we only unregister event commands from __init, so mark
* this __init too.
*/
__init int unregister_event_command(struct event_command *cmd)
{
struct event_command *p, *n;
guard(mutex)(&trigger_cmd_mutex);
list_for_each_entry_safe(p, n, &trigger_commands, list) {
if (strcmp(cmd->name, p->name) == 0) {
list_del_init(&p->list);
return 0;
}
}
return -ENODEV;
}
/**
* event_trigger_count - Optional count function for event triggers
* @data: Trigger-specific data
* @buffer: The ring buffer that the event is being written to
* @rec: The trace entry for the event, NULL for unconditional invocation
* @event: The event meta data in the ring buffer
*
* For triggers that can take a count parameter that doesn't do anything
* special, they can use this function to assign to their .count_func
* field.
*
* This simply does a count down of the @data->count field.
*
* If the @data->count is greater than zero, it will decrement it.
*
* Returns false if @data->count is zero, otherwise true.
*/
bool event_trigger_count(struct event_trigger_data *data,
struct trace_buffer *buffer, void *rec,
struct ring_buffer_event *event)
{
if (!data->count)
return false;
if (data->count != -1)
(data->count)--;
return true;
}
/**
* event_trigger_print - Generic event_command @print implementation
* @name: The name of the event trigger
* @m: The seq_file being printed to
* @data: Trigger-specific data
* @filter_str: filter_str to print, if present
*
* Common implementation for event triggers to print themselves.
*
* Usually wrapped by a function that simply sets the @name of the
* trigger command and then invokes this.
*
* Return: 0 on success, errno otherwise
Annotation
- Immediate include surface: `linux/security.h`, `linux/kthread.h`, `linux/module.h`, `linux/ctype.h`, `linux/mutex.h`, `linux/slab.h`, `linux/rculist.h`, `trace.h`.
- Detected declarations: `function trigger_create_kthread_locked`, `function trigger_data_free_queued_locked`, `function trigger_kthread_fn`, `function trigger_data_free`, `function trigger_data_free_init`, `function data_ops_trigger`, `function handlers`, `function list_for_each_entry_rcu`, `function __trace_trigger_soft_disabled`, `function handlers`.
- Atlas domain: Core OS / Scheduler, Processes, Timers, Sync, And Syscalls.
- Implementation status: pattern implementation candidate.
- 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.