kernel/rcu/rcu_segcblist.c
Source file repositories/reference/linux-study-clean/kernel/rcu/rcu_segcblist.c
File Facts
- System
- Linux kernel
- Corpus path
kernel/rcu/rcu_segcblist.c- Extension
.c- Size
- 20178 bytes
- Lines
- 623
- Domain
- Core OS
- Bucket
- Scheduler, Processes, Timers, Sync, And Syscalls
- Inferred role
- Core OS: implementation source
- Status
- source 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.
- 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/cpu.hlinux/interrupt.hlinux/kernel.hlinux/types.hrcu_segcblist.h
Detected Declarations
function rcu_cblist_initfunction rcu_cblist_enqueuefunction rcu_cblist_flush_enqueuefunction rcu_segcblist_set_lenfunction rcu_segcblist_get_seglenfunction rcu_segcblist_n_segment_cbsfunction rcu_segcblist_set_seglenfunction rcu_segcblist_add_seglenfunction rcu_segcblist_move_seglenfunction rcu_segcblist_inc_seglenfunction rcu_barrierfunction rcu_segcblist_inc_lenfunction rcu_segcblist_initfunction rcu_segcblist_disablefunction rcu_segcblist_ready_cbsfunction rcu_segcblist_pend_cbsfunction rcu_segcblist_nextgpfunction rcu_barrierfunction rcu_barrierfunction rcu_segcblist_extract_done_cbsfunction pendingfunction rcu_segcblist_insert_countfunction rcu_segcblist_insert_done_cbsfunction rcu_segcblist_insert_pend_cbsfunction rcu_segcblist_advancefunction rcu_segcblist_acceleratefunction rcu_segcblist_merge
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0+
/*
* RCU segmented callback lists, function definitions
*
* Copyright IBM Corporation, 2017
*
* Authors: Paul E. McKenney <paulmck@linux.ibm.com>
*/
#include <linux/cpu.h>
#include <linux/interrupt.h>
#include <linux/kernel.h>
#include <linux/types.h>
#include "rcu_segcblist.h"
/* Initialize simple callback list. */
void rcu_cblist_init(struct rcu_cblist *rclp)
{
rclp->head = NULL;
rclp->tail = &rclp->head;
rclp->len = 0;
}
/*
* Enqueue an rcu_head structure onto the specified callback list.
*/
void rcu_cblist_enqueue(struct rcu_cblist *rclp, struct rcu_head *rhp)
{
*rclp->tail = rhp;
rclp->tail = &rhp->next;
WRITE_ONCE(rclp->len, rclp->len + 1);
}
/*
* Flush the second rcu_cblist structure onto the first one, obliterating
* any contents of the first. If rhp is non-NULL, enqueue it as the sole
* element of the second rcu_cblist structure, but ensuring that the second
* rcu_cblist structure, if initially non-empty, always appears non-empty
* throughout the process. If rdp is NULL, the second rcu_cblist structure
* is instead initialized to empty.
*/
void rcu_cblist_flush_enqueue(struct rcu_cblist *drclp,
struct rcu_cblist *srclp,
struct rcu_head *rhp)
{
drclp->head = srclp->head;
if (drclp->head)
drclp->tail = srclp->tail;
else
drclp->tail = &drclp->head;
drclp->len = srclp->len;
if (!rhp) {
rcu_cblist_init(srclp);
} else {
rhp->next = NULL;
srclp->head = rhp;
srclp->tail = &rhp->next;
WRITE_ONCE(srclp->len, 1);
}
}
/*
* Dequeue the oldest rcu_head structure from the specified callback
* list.
*/
struct rcu_head *rcu_cblist_dequeue(struct rcu_cblist *rclp)
{
struct rcu_head *rhp;
rhp = rclp->head;
if (!rhp)
return NULL;
rclp->len--;
rclp->head = rhp->next;
if (!rclp->head)
rclp->tail = &rclp->head;
return rhp;
}
/* Set the length of an rcu_segcblist structure. */
static void rcu_segcblist_set_len(struct rcu_segcblist *rsclp, long v)
{
#ifdef CONFIG_RCU_NOCB_CPU
atomic_long_set(&rsclp->len, v);
#else
WRITE_ONCE(rsclp->len, v);
#endif
}
Annotation
- Immediate include surface: `linux/cpu.h`, `linux/interrupt.h`, `linux/kernel.h`, `linux/types.h`, `rcu_segcblist.h`.
- Detected declarations: `function rcu_cblist_init`, `function rcu_cblist_enqueue`, `function rcu_cblist_flush_enqueue`, `function rcu_segcblist_set_len`, `function rcu_segcblist_get_seglen`, `function rcu_segcblist_n_segment_cbs`, `function rcu_segcblist_set_seglen`, `function rcu_segcblist_add_seglen`, `function rcu_segcblist_move_seglen`, `function rcu_segcblist_inc_seglen`.
- Atlas domain: Core OS / Scheduler, Processes, Timers, Sync, And Syscalls.
- Implementation status: source 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.