kernel/rcu/tiny.c
Source file repositories/reference/linux-study-clean/kernel/rcu/tiny.c
File Facts
- System
- Linux kernel
- Corpus path
kernel/rcu/tiny.c- Extension
.c- Size
- 6839 bytes
- Lines
- 253
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/completion.hlinux/interrupt.hlinux/notifier.hlinux/rcupdate_wait.hlinux/kernel.hlinux/export.hlinux/mutex.hlinux/sched.hlinux/types.hlinux/init.hlinux/time.hlinux/cpu.hlinux/prefetch.hlinux/slab.hlinux/mm.hrcu.h
Detected Declarations
struct rcu_ctrlblkfunction rcu_barrierfunction rcu_qsfunction rcu_sched_clock_irqfunction directlyfunction rcu_process_callbacksfunction synchronize_rcufunction call_rcufunction get_completed_synchronize_rcu_fullfunction get_state_synchronize_rcufunction start_poll_synchronize_rcufunction poll_state_synchronize_rcufunction rcutorture_gather_gp_seqsfunction rcutorture_format_gp_seqsfunction rcu_initexport rcu_barrierexport synchronize_rcuexport call_rcuexport get_completed_synchronize_rcu_fullexport get_state_synchronize_rcuexport start_poll_synchronize_rcuexport poll_state_synchronize_rcuexport rcutorture_gather_gp_seqsexport rcutorture_format_gp_seqs
Annotated Snippet
struct rcu_ctrlblk {
struct rcu_head *rcucblist; /* List of pending callbacks (CBs). */
struct rcu_head **donetail; /* ->next pointer of last "done" CB. */
struct rcu_head **curtail; /* ->next pointer of last CB. */
unsigned long gp_seq; /* Grace-period counter. */
};
/* Definition for rcupdate control block. */
static struct rcu_ctrlblk rcu_ctrlblk = {
.donetail = &rcu_ctrlblk.rcucblist,
.curtail = &rcu_ctrlblk.rcucblist,
.gp_seq = 0 - 300UL,
};
void rcu_barrier(void)
{
wait_rcu_gp(call_rcu_hurry);
}
EXPORT_SYMBOL(rcu_barrier);
/* Record an rcu quiescent state. */
void rcu_qs(void)
{
unsigned long flags;
local_irq_save(flags);
if (rcu_ctrlblk.donetail != rcu_ctrlblk.curtail) {
rcu_ctrlblk.donetail = rcu_ctrlblk.curtail;
raise_softirq_irqoff(RCU_SOFTIRQ);
}
WRITE_ONCE(rcu_ctrlblk.gp_seq, rcu_ctrlblk.gp_seq + 2);
local_irq_restore(flags);
}
/*
* Check to see if the scheduling-clock interrupt came from an extended
* quiescent state, and, if so, tell RCU about it. This function must
* be called from hardirq context. It is normally called from the
* scheduling-clock interrupt.
*/
void rcu_sched_clock_irq(int user)
{
if (user)
rcu_qs();
else if (rcu_ctrlblk.donetail != rcu_ctrlblk.curtail)
set_need_resched_current();
}
/*
* Reclaim the specified callback, either by invoking it for non-kfree cases or
* freeing it directly (for kfree). Return true if kfreeing, false otherwise.
*/
static inline bool rcu_reclaim_tiny(struct rcu_head *head)
{
rcu_callback_t f;
rcu_lock_acquire(&rcu_callback_map);
trace_rcu_invoke_callback("", head);
f = head->func;
debug_rcu_head_callback(head);
WRITE_ONCE(head->func, (rcu_callback_t)0L);
f(head);
rcu_lock_release(&rcu_callback_map);
return false;
}
/* Invoke the RCU callbacks whose grace period has elapsed. */
static __latent_entropy void rcu_process_callbacks(void)
{
struct rcu_head *next, *list;
unsigned long flags;
/* Move the ready-to-invoke callbacks to a local list. */
local_irq_save(flags);
if (rcu_ctrlblk.donetail == &rcu_ctrlblk.rcucblist) {
/* No callbacks ready, so just leave. */
local_irq_restore(flags);
return;
}
list = rcu_ctrlblk.rcucblist;
rcu_ctrlblk.rcucblist = *rcu_ctrlblk.donetail;
*rcu_ctrlblk.donetail = NULL;
if (rcu_ctrlblk.curtail == rcu_ctrlblk.donetail)
rcu_ctrlblk.curtail = &rcu_ctrlblk.rcucblist;
rcu_ctrlblk.donetail = &rcu_ctrlblk.rcucblist;
local_irq_restore(flags);
/* Invoke the callbacks on the local list. */
while (list) {
Annotation
- Immediate include surface: `linux/completion.h`, `linux/interrupt.h`, `linux/notifier.h`, `linux/rcupdate_wait.h`, `linux/kernel.h`, `linux/export.h`, `linux/mutex.h`, `linux/sched.h`.
- Detected declarations: `struct rcu_ctrlblk`, `function rcu_barrier`, `function rcu_qs`, `function rcu_sched_clock_irq`, `function directly`, `function rcu_process_callbacks`, `function synchronize_rcu`, `function call_rcu`, `function get_completed_synchronize_rcu_full`, `function get_state_synchronize_rcu`.
- 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.