mm/memcontrol.c
Source file repositories/reference/linux-study-clean/mm/memcontrol.c
File Facts
- System
- Linux kernel
- Corpus path
mm/memcontrol.c- Extension
.c- Size
- 160768 bytes
- Lines
- 6069
- 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/cgroup-defs.hlinux/page_counter.hlinux/memcontrol.hlinux/cgroup.hlinux/cpuset.hlinux/sched/mm.hlinux/shmem_fs.hlinux/hugetlb.hlinux/pagemap.hlinux/folio_batch.hlinux/vm_event_item.hlinux/smp.hlinux/page-flags.hlinux/backing-dev.hlinux/bit_spinlock.hlinux/rcupdate.hlinux/limits.hlinux/export.hlinux/list.hlinux/mutex.hlinux/rbtree.hlinux/slab.hlinux/swapops.hlinux/spinlock.hlinux/fs.hlinux/seq_file.hlinux/vmpressure.hlinux/memremap.hlinux/mm_inline.hlinux/cpu.hlinux/oom.hlinux/lockdep.h
Detected Declarations
struct lruvec_stats_percpustruct lruvec_statsstruct memcg_vmstats_percpustruct memcg_vmstatsstruct memory_statstruct memcg_stock_pcpstruct obj_stock_pcpstruct aggregate_controlstruct uncharge_gatherfunction task_is_dyingfunction mem_cgroup_kmem_disabledfunction obj_cgroup_releasefunction reparent_state_localfunction reparent_state_localfunction reparent_unlocksfunction memcg_reparent_objcgsfunction for_each_nodefunction page_cgroup_inofunction init_memcg_statsfunction memcg_stats_indexfunction lruvec_page_statefunction lruvec_page_state_localfunction reparent_memcg_lruvec_state_localfunction for_each_nodefunction init_memcg_eventsfunction memcg_events_indexfunction memcg_vmstats_needs_flushfunction memcg_rstat_updatedfunction __mem_cgroup_flush_statsfunction mem_cgroup_flush_statsfunction mem_cgroup_flush_stats_ratelimitedfunction flush_memcg_stats_dworkfunction memcg_page_statefunction memcg_stat_item_validfunction memcg_rstat_updatedfunction mod_memcg_statefunction get_non_dying_memcg_endfunction get_non_dying_memcg_endfunction mod_memcg_statefunction memcg_page_state_localfunction reparent_memcg_state_localfunction __mod_memcg_lruvec_statefunction mod_memcg_lruvec_statefunction mod_lruvec_statefunction lruvec_stat_mod_foliofunction mod_lruvec_kmem_statefunction count_memcg_eventsfunction memcg_events
Annotated Snippet
subsys_initcall(mem_cgroup_swap_init);
#endif /* CONFIG_SWAP */
void mem_cgroup_node_filter_allowed(struct mem_cgroup *memcg, nodemask_t *mask)
{
nodemask_t allowed;
if (!memcg)
return;
/*
* Since this interface is intended for use by migration paths, and
* reclaim and migration are subject to race conditions such as changes
* in effective_mems and hot-unpluging of nodes, inaccurate allowed
* mask is acceptable.
*/
cpuset_nodes_allowed(memcg->css.cgroup, &allowed);
nodes_and(*mask, *mask, allowed);
}
void mem_cgroup_show_protected_memory(struct mem_cgroup *memcg)
{
if (mem_cgroup_disabled() || !cgroup_subsys_on_dfl(memory_cgrp_subsys))
return;
if (!memcg)
memcg = root_mem_cgroup;
pr_warn("Memory cgroup min protection %lukB -- low protection %lukB",
K(atomic_long_read(&memcg->memory.children_min_usage)),
K(atomic_long_read(&memcg->memory.children_low_usage)));
}
Annotation
- Immediate include surface: `linux/cgroup-defs.h`, `linux/page_counter.h`, `linux/memcontrol.h`, `linux/cgroup.h`, `linux/cpuset.h`, `linux/sched/mm.h`, `linux/shmem_fs.h`, `linux/hugetlb.h`.
- Detected declarations: `struct lruvec_stats_percpu`, `struct lruvec_stats`, `struct memcg_vmstats_percpu`, `struct memcg_vmstats`, `struct memory_stat`, `struct memcg_stock_pcp`, `struct obj_stock_pcp`, `struct aggregate_control`, `struct uncharge_gather`, `function task_is_dying`.
- 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.