kernel/rcu/tree.c
Source file repositories/reference/linux-study-clean/kernel/rcu/tree.c
File Facts
- System
- Linux kernel
- Corpus path
kernel/rcu/tree.c- Extension
.c- Size
- 168758 bytes
- Lines
- 4955
- 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/types.hlinux/kernel.hlinux/init.hlinux/spinlock.hlinux/smp.hlinux/rcupdate_wait.hlinux/interrupt.hlinux/sched.hlinux/sched/debug.hlinux/nmi.hlinux/atomic.hlinux/bitops.hlinux/export.hlinux/completion.hlinux/kmemleak.hlinux/moduleparam.hlinux/panic.hlinux/panic_notifier.hlinux/percpu.hlinux/notifier.hlinux/cpu.hlinux/mutex.hlinux/time.hlinux/kernel_stat.hlinux/wait.hlinux/kthread.huapi/linux/sched/types.hlinux/prefetch.hlinux/delay.hlinux/random.hlinux/trace_events.hlinux/suspend.h
Detected Declarations
function rcu_get_gpwrap_countfunction rcu_get_gp_kthreads_priofunction rcu_gp_in_progressfunction rcu_get_n_cbs_cpufunction synchronize_rcufunction rcu_watching_onlinefunction ct_rcu_watchingfunction rcu_watching_snap_stopped_sincefunction rcu_watching_zero_in_eqsfunction mightfunction rcu_is_cpu_rrupt_from_idlefunction adjust_jiffies_till_sched_qsfunction param_set_first_fqs_jiffiesfunction param_set_next_fqs_jiffiesfunction rcu_get_gp_seqfunction rcu_exp_batches_completedfunction rcutorture_get_gp_datafunction rcutorture_gather_gp_seqsfunction rcutorture_format_gp_seqsfunction late_wakeup_funcfunction rcu_irq_work_reschedfunction rcu_irq_exit_check_preemptfunction __rcu_irq_enter_check_tickfunction rcu_needs_cpufunction CPUfunction rcu_is_watchingfunction rcu_request_urgent_qs_taskfunction rcu_set_gpwrap_lagfunction rcu_gpnum_ovffunction rcu_watching_snap_savefunction rcu_watching_snap_savefunction time_afterfunction cond_reschedfunction resched_cpufunction trace_rcu_this_gpfunction rcu_start_this_gpfunction rcu_future_gp_cleanupfunction rcu_gp_kthread_wakefunction rcu_accelerate_cbsfunction rcu_accelerate_cbsfunction rcu_advance_cbsfunction rcu_advance_cbs_nowakefunction rcu_strict_gp_check_qsfunction __note_gp_changesfunction unlikelyfunction unlikelyfunction note_gp_changesfunction rcu_gp_slow_register
Annotated Snippet
* A later core_initcall() rcu_set_runtime_mode() will switch to full
* runtime RCU functionality.
*/
void rcu_scheduler_starting(void)
{
unsigned long flags;
struct rcu_node *rnp;
WARN_ON(num_online_cpus() != 1);
WARN_ON(nr_context_switches() > 0);
rcu_test_sync_prims();
// Fix up the ->gp_seq counters.
local_irq_save(flags);
rcu_for_each_node_breadth_first(rnp)
rnp->gp_seq_needed = rnp->gp_seq = rcu_state.gp_seq;
local_irq_restore(flags);
// Switch out of early boot mode.
rcu_scheduler_active = RCU_SCHEDULER_INIT;
rcu_test_sync_prims();
}
/*
* Helper function for rcu_init() that initializes the rcu_state structure.
*/
static void __init rcu_init_one(void)
{
static const char * const buf[] = RCU_NODE_NAME_INIT;
static const char * const fqs[] = RCU_FQS_NAME_INIT;
static struct lock_class_key rcu_node_class[RCU_NUM_LVLS];
static struct lock_class_key rcu_fqs_class[RCU_NUM_LVLS];
int levelspread[RCU_NUM_LVLS]; /* kids/node in each level. */
int cpustride = 1;
int i;
int j;
struct rcu_node *rnp;
BUILD_BUG_ON(RCU_NUM_LVLS > ARRAY_SIZE(buf)); /* Fix buf[] init! */
/* Silence gcc 4.8 false positive about array index out of range. */
if (rcu_num_lvls <= 0 || rcu_num_lvls > RCU_NUM_LVLS)
panic("rcu_init_one: rcu_num_lvls out of range");
/* Initialize the level-tracking arrays. */
for (i = 1; i < rcu_num_lvls; i++)
rcu_state.level[i] =
rcu_state.level[i - 1] + num_rcu_lvl[i - 1];
rcu_init_levelspread(levelspread, num_rcu_lvl);
/* Initialize the elements themselves, starting from the leaves. */
for (i = rcu_num_lvls - 1; i >= 0; i--) {
cpustride *= levelspread[i];
rnp = rcu_state.level[i];
for (j = 0; j < num_rcu_lvl[i]; j++, rnp++) {
raw_spin_lock_init(&ACCESS_PRIVATE(rnp, lock));
lockdep_set_class_and_name(&ACCESS_PRIVATE(rnp, lock),
&rcu_node_class[i], buf[i]);
raw_spin_lock_init(&rnp->fqslock);
lockdep_set_class_and_name(&rnp->fqslock,
&rcu_fqs_class[i], fqs[i]);
rnp->gp_seq = rcu_state.gp_seq;
rnp->gp_seq_needed = rcu_state.gp_seq;
rnp->completedqs = rcu_state.gp_seq;
rnp->qsmask = 0;
rnp->qsmaskinit = 0;
rnp->grplo = j * cpustride;
rnp->grphi = (j + 1) * cpustride - 1;
if (rnp->grphi >= nr_cpu_ids)
rnp->grphi = nr_cpu_ids - 1;
if (i == 0) {
rnp->grpnum = 0;
rnp->grpmask = 0;
rnp->parent = NULL;
} else {
rnp->grpnum = j % levelspread[i - 1];
rnp->grpmask = BIT(rnp->grpnum);
rnp->parent = rcu_state.level[i - 1] +
j / levelspread[i - 1];
}
rnp->level = i;
INIT_LIST_HEAD(&rnp->blkd_tasks);
rcu_init_one_nocb(rnp);
init_waitqueue_head(&rnp->exp_wq[0]);
init_waitqueue_head(&rnp->exp_wq[1]);
init_waitqueue_head(&rnp->exp_wq[2]);
init_waitqueue_head(&rnp->exp_wq[3]);
Annotation
- Immediate include surface: `linux/types.h`, `linux/kernel.h`, `linux/init.h`, `linux/spinlock.h`, `linux/smp.h`, `linux/rcupdate_wait.h`, `linux/interrupt.h`, `linux/sched.h`.
- Detected declarations: `function rcu_get_gpwrap_count`, `function rcu_get_gp_kthreads_prio`, `function rcu_gp_in_progress`, `function rcu_get_n_cbs_cpu`, `function synchronize_rcu`, `function rcu_watching_online`, `function ct_rcu_watching`, `function rcu_watching_snap_stopped_since`, `function rcu_watching_zero_in_eqs`, `function might`.
- 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.