include/linux/list.h
Source file repositories/reference/linux-study-clean/include/linux/list.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/list.h- Extension
.h- Size
- 37560 bytes
- Lines
- 1255
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/container_of.hlinux/types.hlinux/stddef.hlinux/poison.hlinux/const.hasm/barrier.h
Detected Declarations
function functionsfunction __list_addfunction __list_del_entryfunction __list_add_validfunction __list_del_entry_validfunction __list_addfunction list_addfunction list_add_tailfunction list_add_tail_releasefunction __list_delfunction WRITE_ONCEfunction __list_del_entryfunction list_delfunction list_replacefunction list_replace_initfunction list_swapfunction list_del_initfunction list_movefunction list_move_tailfunction list_bulk_move_tailfunction list_is_firstfunction list_is_lastfunction list_is_headfunction list_emptyfunction list_del_initfunction memberfunction list_rotate_leftfunction list_rotate_to_frontfunction list_is_singularfunction __list_cut_positionfunction list_cut_positionfunction list_cut_beforefunction __list_splicefunction list_splicefunction list_splice_tailfunction list_splice_initfunction list_splice_tail_initfunction list_count_nodesfunction concurrentlyfunction hlist_unhashedfunction hlist_unhashedfunction hlist_emptyfunction __hlist_delfunction hlist_del_initfunction hlist_del_initfunction hlist_add_headfunction hlist_add_beforefunction hlist_add_behind
Annotated Snippet
#ifndef _LINUX_LIST_H
#define _LINUX_LIST_H
#include <linux/container_of.h>
#include <linux/types.h>
#include <linux/stddef.h>
#include <linux/poison.h>
#include <linux/const.h>
#include <asm/barrier.h>
/*
* Circular doubly linked list implementation.
*
* Some of the internal functions ("__xxx") are useful when
* manipulating whole lists rather than single entries, as
* sometimes we already know the next/prev entries and we can
* generate better code by using them directly rather than
* using the generic single-entry routines.
*/
/**
* LIST_HEAD_INIT - initialize a &struct list_head's links to point to itself
* @name: name of the list_head
*/
#define LIST_HEAD_INIT(name) { &(name), &(name) }
/**
* LIST_HEAD - definition of a &struct list_head with initialization values
* @name: name of the list_head
*/
#define LIST_HEAD(name) \
struct list_head name = LIST_HEAD_INIT(name)
/**
* INIT_LIST_HEAD - Initialize a list_head structure
* @list: list_head structure to be initialized.
*
* Initializes the list_head to point to itself. If it is a list header,
* the result is an empty list.
*/
static inline void INIT_LIST_HEAD(struct list_head *list)
{
WRITE_ONCE(list->next, list);
WRITE_ONCE(list->prev, list);
}
#ifdef CONFIG_LIST_HARDENED
#ifdef CONFIG_DEBUG_LIST
# define __list_valid_slowpath
#else
# define __list_valid_slowpath __cold __preserve_most
#endif
/*
* Performs the full set of list corruption checks before __list_add().
* On list corruption reports a warning, and returns false.
*/
bool __list_valid_slowpath __list_add_valid_or_report(struct list_head *new,
struct list_head *prev,
struct list_head *next);
/*
* Performs list corruption checks before __list_add(). Returns false if a
* corruption is detected, true otherwise.
*
* With CONFIG_LIST_HARDENED only, performs minimal list integrity checking
* inline to catch non-faulting corruptions, and only if a corruption is
* detected calls the reporting function __list_add_valid_or_report().
*/
static __always_inline bool __list_add_valid(struct list_head *new,
struct list_head *prev,
struct list_head *next)
{
bool ret = true;
if (!IS_ENABLED(CONFIG_DEBUG_LIST)) {
/*
* With the hardening version, elide checking if next and prev
* are NULL, since the immediate dereference of them below would
* result in a fault if NULL.
*
* With the reduced set of checks, we can afford to inline the
* checks, which also gives the compiler a chance to elide some
* of them completely if they can be proven at compile-time. If
* one of the pre-conditions does not hold, the slow-path will
* show a report which pre-condition failed.
*/
if (likely(next->prev == prev && prev->next == next && new != prev && new != next))
Annotation
- Immediate include surface: `linux/container_of.h`, `linux/types.h`, `linux/stddef.h`, `linux/poison.h`, `linux/const.h`, `asm/barrier.h`.
- Detected declarations: `function functions`, `function __list_add`, `function __list_del_entry`, `function __list_add_valid`, `function __list_del_entry_valid`, `function __list_add`, `function list_add`, `function list_add_tail`, `function list_add_tail_release`, `function __list_del`.
- Atlas domain: Core OS / Core Kernel Interface.
- Implementation status: source 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.