mm/list_lru.c
Source file repositories/reference/linux-study-clean/mm/list_lru.c
File Facts
- System
- Linux kernel
- Corpus path
mm/list_lru.c- Extension
.c- Size
- 16619 bytes
- Lines
- 709
- Domain
- Core OS
- Bucket
- Memory Management
- 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/kernel.hlinux/module.hlinux/mm.hlinux/list_lru.hlinux/slab.hlinux/mutex.hlinux/memcontrol.hslab.hinternal.h
Detected Declarations
function Copyrightfunction unlock_list_lrufunction list_lru_memcg_awarefunction list_lru_registerfunction list_lru_unregisterfunction lru_shrinker_idfunction list_lru_from_memcg_idxfunction lock_list_lru_of_memcgfunction list_lru_registerfunction list_lru_memcg_awarefunction list_lru_from_memcg_idxfunction lock_list_lru_of_memcgfunction list_lru_unlockfunction list_lru_unlock_irqfunction list_lru_unlock_irqrestorefunction __list_lru_addfunction __list_lru_delfunction list_lru_addfunction list_lru_add_irqfunction list_lru_add_objfunction list_lru_delfunction list_lru_del_objfunction list_lru_isolatefunction list_lru_isolate_movefunction list_lru_count_onefunction list_lru_count_nodefunction __list_lru_walk_onefunction list_lru_walk_onefunction list_lru_walk_one_irqfunction list_lru_walk_nodefunction xa_for_eachfunction init_one_lrufunction memcg_init_list_lrufunction memcg_destroy_list_lrufunction memcg_reparent_list_lru_onefunction memcg_reparent_list_lrusfunction memcg_list_lru_allocatedfunction __memcg_list_lru_allocfunction memcg_list_lru_allocfunction folio_memcg_list_lru_allocfunction memcg_init_list_lrufunction list_lru_destroyexport list_lru_addexport list_lru_add_objexport list_lru_del_objexport list_lru_isolateexport list_lru_isolate_moveexport list_lru_count_one
Annotated Snippet
if (likely(READ_ONCE(l->nr_items) != LONG_MIN)) {
rcu_read_unlock();
return l;
}
unlock_list_lru(l, irq, irq_flags);
}
/*
* Caller may simply bail out if raced with reparenting or
* may iterate through the list_lru and expect empty slots.
*/
if (skip_empty) {
rcu_read_unlock();
return NULL;
}
VM_WARN_ON(!css_is_dying(&(*memcg)->css));
*memcg = parent_mem_cgroup(*memcg);
goto again;
}
#else
static void list_lru_register(struct list_lru *lru)
{
}
static void list_lru_unregister(struct list_lru *lru)
{
}
static int lru_shrinker_id(struct list_lru *lru)
{
return -1;
}
static inline bool list_lru_memcg_aware(struct list_lru *lru)
{
return false;
}
static inline struct list_lru_one *
list_lru_from_memcg_idx(struct list_lru *lru, int nid, int idx)
{
return &lru->node[nid].lru;
}
static inline struct list_lru_one *
lock_list_lru_of_memcg(struct list_lru *lru, int nid,
struct mem_cgroup **memcg, bool irq,
unsigned long *irq_flags, bool skip_empty)
{
struct list_lru_one *l = &lru->node[nid].lru;
lock_list_lru(l, irq, irq_flags);
return l;
}
#endif /* CONFIG_MEMCG */
struct list_lru_one *list_lru_lock(struct list_lru *lru, int nid,
struct mem_cgroup **memcg)
{
return lock_list_lru_of_memcg(lru, nid, memcg, /*irq=*/false,
/*irq_flags=*/NULL, /*skip_empty=*/false);
}
void list_lru_unlock(struct list_lru_one *l)
{
unlock_list_lru(l, /*irq_off=*/false, /*irq_flags=*/NULL);
}
struct list_lru_one *list_lru_lock_irq(struct list_lru *lru, int nid,
struct mem_cgroup **memcg)
{
return lock_list_lru_of_memcg(lru, nid, memcg, /*irq=*/true,
/*irq_flags=*/NULL, /*skip_empty=*/false);
}
void list_lru_unlock_irq(struct list_lru_one *l)
{
unlock_list_lru(l, /*irq_off=*/true, /*irq_flags=*/NULL);
}
struct list_lru_one *list_lru_lock_irqsave(struct list_lru *lru, int nid,
struct mem_cgroup **memcg,
unsigned long *flags)
{
return lock_list_lru_of_memcg(lru, nid, memcg, /*irq=*/true,
/*irq_flags=*/flags, /*skip_empty=*/false);
}
void list_lru_unlock_irqrestore(struct list_lru_one *l, unsigned long *flags)
{
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/module.h`, `linux/mm.h`, `linux/list_lru.h`, `linux/slab.h`, `linux/mutex.h`, `linux/memcontrol.h`, `slab.h`.
- Detected declarations: `function Copyright`, `function unlock_list_lru`, `function list_lru_memcg_aware`, `function list_lru_register`, `function list_lru_unregister`, `function lru_shrinker_id`, `function list_lru_from_memcg_idx`, `function lock_list_lru_of_memcg`, `function list_lru_register`, `function list_lru_memcg_aware`.
- Atlas domain: Core OS / Memory Management.
- 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.