kernel/tracepoint.c
Source file repositories/reference/linux-study-clean/kernel/tracepoint.c
File Facts
- System
- Linux kernel
- Corpus path
kernel/tracepoint.c- Extension
.c- Size
- 21127 bytes
- Lines
- 794
- Domain
- Core OS
- Bucket
- Scheduler, Processes, Timers, Sync, And Syscalls
- Inferred role
- Core OS: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/module.hlinux/mutex.hlinux/types.hlinux/jhash.hlinux/list.hlinux/rcupdate.hlinux/tracepoint.hlinux/err.hlinux/slab.hlinux/sched/signal.hlinux/sched/task.hlinux/static_key.h
Detected Declarations
struct tp_transition_snapshotstruct tp_probesenum tp_func_stateenum tp_transition_syncfunction tp_rcu_get_statefunction tp_rcu_cond_syncfunction tp_stub_funcfunction rcu_free_old_probesfunction release_probesfunction debug_print_probesfunction func_addfunction functionsfunction tracepoint_update_callfunction tracepoint_add_funcfunction smp_store_releasefunction tracepoint_remove_funcfunction tracepoint_probe_register_priofunction tracepoint_probe_register_priofunction tracepoint_probe_registerfunction tracepoint_probe_unregisterfunction for_each_tracepoint_rangefunction trace_module_has_bad_taintfunction register_tracepoint_module_notifierfunction unregister_tracepoint_module_notifierfunction tp_module_going_check_quiescentfunction tracepoint_module_comingfunction tracepoint_module_goingfunction tracepoint_module_notifyfunction init_tracepointsfunction for_each_tracepoint_in_modulefunction for_each_module_tracepointfunction for_each_kernel_tracepointfunction syscall_regfuncfunction for_each_process_threadfunction syscall_unregfuncfunction for_each_process_threadexport tracepoint_srcuexport tracepoint_probe_register_prio_may_existexport tracepoint_probe_register_prioexport tracepoint_probe_registerexport tracepoint_probe_unregisterexport register_tracepoint_module_notifierexport unregister_tracepoint_module_notifierexport for_each_kernel_tracepoint
Annotated Snippet
struct tp_transition_snapshot {
unsigned long rcu;
unsigned long srcu_gp;
bool ongoing;
};
DEFINE_SRCU_FAST(tracepoint_srcu);
EXPORT_SYMBOL_GPL(tracepoint_srcu);
/* Protected by tracepoints_mutex */
static struct tp_transition_snapshot tp_transition_snapshot[_NR_TP_TRANSITION_SYNC];
static void tp_rcu_get_state(enum tp_transition_sync sync)
{
struct tp_transition_snapshot *snapshot = &tp_transition_snapshot[sync];
/* Keep the latest get_state snapshot. */
snapshot->rcu = get_state_synchronize_rcu();
snapshot->srcu_gp = start_poll_synchronize_srcu(&tracepoint_srcu);
snapshot->ongoing = true;
}
static void tp_rcu_cond_sync(enum tp_transition_sync sync)
{
struct tp_transition_snapshot *snapshot = &tp_transition_snapshot[sync];
if (!snapshot->ongoing)
return;
cond_synchronize_rcu(snapshot->rcu);
if (!poll_state_synchronize_srcu(&tracepoint_srcu, snapshot->srcu_gp))
synchronize_srcu(&tracepoint_srcu);
snapshot->ongoing = false;
}
/* Set to 1 to enable tracepoint debug output */
static const int tracepoint_debug;
#ifdef CONFIG_MODULES
/*
* Tracepoint module list mutex protects the local module list.
*/
static DEFINE_MUTEX(tracepoint_module_list_mutex);
/* Local list of struct tp_module */
static LIST_HEAD(tracepoint_module_list);
#endif /* CONFIG_MODULES */
/*
* tracepoints_mutex protects the builtin and module tracepoints.
* tracepoints_mutex nests inside tracepoint_module_list_mutex.
*/
static DEFINE_MUTEX(tracepoints_mutex);
/*
* Note about RCU :
* It is used to delay the free of multiple probes array until a quiescent
* state is reached.
*/
struct tp_probes {
struct rcu_head rcu;
struct tracepoint_func probes[];
};
/* Called in removal of a func but failed to allocate a new tp_funcs */
static void tp_stub_func(void)
{
return;
}
static inline void *allocate_probes(int count)
{
struct tp_probes *p = kmalloc_flex(*p, probes, count);
return p == NULL ? NULL : p->probes;
}
static void rcu_free_old_probes(struct rcu_head *head)
{
kfree(container_of(head, struct tp_probes, rcu));
}
static inline void release_probes(struct tracepoint *tp, struct tracepoint_func *old)
{
if (old) {
struct tp_probes *tp_probes = container_of(old,
struct tp_probes, probes[0]);
if (tracepoint_is_faultable(tp)) {
call_rcu_tasks_trace(&tp_probes->rcu,
rcu_free_old_probes);
} else {
Annotation
- Immediate include surface: `linux/module.h`, `linux/mutex.h`, `linux/types.h`, `linux/jhash.h`, `linux/list.h`, `linux/rcupdate.h`, `linux/tracepoint.h`, `linux/err.h`.
- Detected declarations: `struct tp_transition_snapshot`, `struct tp_probes`, `enum tp_func_state`, `enum tp_transition_sync`, `function tp_rcu_get_state`, `function tp_rcu_cond_sync`, `function tp_stub_func`, `function rcu_free_old_probes`, `function release_probes`, `function debug_print_probes`.
- Atlas domain: Core OS / Scheduler, Processes, Timers, Sync, And Syscalls.
- Implementation status: integration 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.