kernel/rcu/srcutiny.c
Source file repositories/reference/linux-study-clean/kernel/rcu/srcutiny.c
File Facts
- System
- Linux kernel
- Corpus path
kernel/rcu/srcutiny.c- Extension
.c- Size
- 9631 bytes
- Lines
- 334
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/export.hlinux/irq_work.hlinux/mutex.hlinux/preempt.hlinux/rcupdate_wait.hlinux/sched.hlinux/delay.hlinux/srcu.hlinux/rcu_node_tree.hrcu_segcblist.hrcu.h
Detected Declarations
function init_srcu_struct_fieldsfunction __init_srcu_structfunction init_srcu_structfunction init_srcu_structfunction __srcu_read_unlockfunction srcu_drive_gpfunction schedule_workfunction srcu_gp_start_if_neededfunction call_srcufunction synchronize_srcufunction get_state_synchronize_srcufunction get_state_synchronize_srcufunction poll_state_synchronize_srcufunction rcu_scheduler_startingfunction srcu_initexport __init_srcu_structexport init_srcu_structexport cleanup_srcu_structexport __srcu_read_unlockexport srcu_drive_gpexport srcu_tiny_irq_workexport call_srcuexport synchronize_srcuexport get_state_synchronize_srcuexport start_poll_synchronize_srcuexport poll_state_synchronize_srcu
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
/*
* Sleepable Read-Copy Update mechanism for mutual exclusion,
* tiny version for non-preemptible single-CPU use.
*
* Copyright (C) IBM Corporation, 2017
*
* Author: Paul McKenney <paulmck@linux.ibm.com>
*/
#include <linux/export.h>
#include <linux/irq_work.h>
#include <linux/mutex.h>
#include <linux/preempt.h>
#include <linux/rcupdate_wait.h>
#include <linux/sched.h>
#include <linux/delay.h>
#include <linux/srcu.h>
#include <linux/rcu_node_tree.h>
#include "rcu_segcblist.h"
#include "rcu.h"
#ifndef CONFIG_TREE_RCU
int rcu_scheduler_active __read_mostly;
#else // #ifndef CONFIG_TREE_RCU
extern int rcu_scheduler_active;
#endif // #else // #ifndef CONFIG_TREE_RCU
static LIST_HEAD(srcu_boot_list);
static bool srcu_init_done;
static int init_srcu_struct_fields(struct srcu_struct *ssp)
{
ssp->srcu_lock_nesting[0] = 0;
ssp->srcu_lock_nesting[1] = 0;
init_swait_queue_head(&ssp->srcu_wq);
ssp->srcu_cb_head = NULL;
ssp->srcu_cb_tail = &ssp->srcu_cb_head;
ssp->srcu_gp_running = false;
ssp->srcu_gp_waiting = false;
ssp->srcu_idx = 0;
ssp->srcu_idx_max = 0;
INIT_WORK(&ssp->srcu_work, srcu_drive_gp);
INIT_LIST_HEAD(&ssp->srcu_work.entry);
init_irq_work(&ssp->srcu_irq_work, srcu_tiny_irq_work);
return 0;
}
#ifdef CONFIG_DEBUG_LOCK_ALLOC
int __init_srcu_struct(struct srcu_struct *ssp, const char *name,
struct lock_class_key *key)
{
/* Don't re-initialize a lock while it is held. */
debug_check_no_locks_freed((void *)ssp, sizeof(*ssp));
lockdep_init_map(&ssp->dep_map, name, key, 0);
return init_srcu_struct_fields(ssp);
}
EXPORT_SYMBOL_GPL(__init_srcu_struct);
#else /* #ifdef CONFIG_DEBUG_LOCK_ALLOC */
/*
* init_srcu_struct - initialize a sleep-RCU structure
* @ssp: structure to initialize.
*
* Must invoke this on a given srcu_struct before passing that srcu_struct
* to any other function. Each srcu_struct represents a separate domain
* of SRCU protection.
*/
int init_srcu_struct(struct srcu_struct *ssp)
{
return init_srcu_struct_fields(ssp);
}
EXPORT_SYMBOL_GPL(init_srcu_struct);
#endif /* #else #ifdef CONFIG_DEBUG_LOCK_ALLOC */
/*
* cleanup_srcu_struct - deconstruct a sleep-RCU structure
* @ssp: structure to clean up.
*
* Must invoke this after you are finished using a given srcu_struct that
* was initialized via init_srcu_struct(), else you leak memory.
*/
void cleanup_srcu_struct(struct srcu_struct *ssp)
{
WARN_ON(ssp->srcu_lock_nesting[0] || ssp->srcu_lock_nesting[1]);
irq_work_sync(&ssp->srcu_irq_work);
flush_work(&ssp->srcu_work);
Annotation
- Immediate include surface: `linux/export.h`, `linux/irq_work.h`, `linux/mutex.h`, `linux/preempt.h`, `linux/rcupdate_wait.h`, `linux/sched.h`, `linux/delay.h`, `linux/srcu.h`.
- Detected declarations: `function init_srcu_struct_fields`, `function __init_srcu_struct`, `function init_srcu_struct`, `function init_srcu_struct`, `function __srcu_read_unlock`, `function srcu_drive_gp`, `function schedule_work`, `function srcu_gp_start_if_needed`, `function call_srcu`, `function synchronize_srcu`.
- Atlas domain: Core OS / Scheduler, Processes, Timers, Sync, And Syscalls.
- Implementation status: integration implementation candidate.
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.