include/linux/hugetlb_cgroup.h
Source file repositories/reference/linux-study-clean/include/linux/hugetlb_cgroup.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/hugetlb_cgroup.h- Extension
.h- Size
- 6938 bytes
- Lines
- 272
- 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.
- 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/mmdebug.h
Detected Declarations
struct hugetlb_cgroupstruct resv_mapstruct file_regionstruct hugetlb_cgroup_per_nodestruct hugetlb_cgroupenum hugetlb_memory_eventfunction __hugetlb_cgroup_from_foliofunction hugetlb_cgroup_from_folio_rsvdfunction __set_hugetlb_cgroupfunction set_hugetlb_cgroupfunction set_hugetlb_cgroup_rsvdfunction hugetlb_cgroup_disabledfunction hugetlb_cgroup_put_rsvd_cgroupfunction resv_map_dup_hugetlb_cgroup_uncharge_infofunction resv_map_put_hugetlb_cgroup_uncharge_infofunction hugetlb_cgroup_uncharge_file_regionfunction hugetlb_cgroup_from_folio_rsvdfunction set_hugetlb_cgroupfunction hugetlb_cgroup_put_rsvd_cgroupfunction hugetlb_cgroup_charge_cgroup_rsvdfunction hugetlb_cgroup_commit_charge
Annotated Snippet
struct hugetlb_cgroup_per_node {
/* hugetlb usage in pages over all hstates. */
unsigned long usage[HUGE_MAX_HSTATE];
};
struct hugetlb_cgroup {
struct cgroup_subsys_state css;
/*
* the counter to account for hugepages from hugetlb.
*/
struct page_counter hugepage[HUGE_MAX_HSTATE];
/*
* the counter to account for hugepage reservations from hugetlb.
*/
struct page_counter rsvd_hugepage[HUGE_MAX_HSTATE];
atomic_long_t events[HUGE_MAX_HSTATE][HUGETLB_NR_MEMORY_EVENTS];
atomic_long_t events_local[HUGE_MAX_HSTATE][HUGETLB_NR_MEMORY_EVENTS];
/* Handle for "hugetlb.events" */
struct cgroup_file events_file[HUGE_MAX_HSTATE];
/* Handle for "hugetlb.events.local" */
struct cgroup_file events_local_file[HUGE_MAX_HSTATE];
struct hugetlb_cgroup_per_node *nodeinfo[];
};
static inline struct hugetlb_cgroup *
__hugetlb_cgroup_from_folio(struct folio *folio, bool rsvd)
{
VM_BUG_ON_FOLIO(!folio_test_hugetlb(folio), folio);
if (rsvd)
return folio->_hugetlb_cgroup_rsvd;
else
return folio->_hugetlb_cgroup;
}
static inline struct hugetlb_cgroup *hugetlb_cgroup_from_folio(struct folio *folio)
{
return __hugetlb_cgroup_from_folio(folio, false);
}
static inline struct hugetlb_cgroup *
hugetlb_cgroup_from_folio_rsvd(struct folio *folio)
{
return __hugetlb_cgroup_from_folio(folio, true);
}
static inline void __set_hugetlb_cgroup(struct folio *folio,
struct hugetlb_cgroup *h_cg, bool rsvd)
{
VM_BUG_ON_FOLIO(!folio_test_hugetlb(folio), folio);
if (rsvd)
folio->_hugetlb_cgroup_rsvd = h_cg;
else
folio->_hugetlb_cgroup = h_cg;
}
static inline void set_hugetlb_cgroup(struct folio *folio,
struct hugetlb_cgroup *h_cg)
{
__set_hugetlb_cgroup(folio, h_cg, false);
}
static inline void set_hugetlb_cgroup_rsvd(struct folio *folio,
struct hugetlb_cgroup *h_cg)
{
__set_hugetlb_cgroup(folio, h_cg, true);
}
static inline bool hugetlb_cgroup_disabled(void)
{
return !cgroup_subsys_enabled(hugetlb_cgrp_subsys);
}
static inline void hugetlb_cgroup_put_rsvd_cgroup(struct hugetlb_cgroup *h_cg)
{
css_put(&h_cg->css);
}
static inline void resv_map_dup_hugetlb_cgroup_uncharge_info(
struct resv_map *resv_map)
{
if (resv_map->css)
css_get(resv_map->css);
}
Annotation
- Immediate include surface: `linux/mmdebug.h`.
- Detected declarations: `struct hugetlb_cgroup`, `struct resv_map`, `struct file_region`, `struct hugetlb_cgroup_per_node`, `struct hugetlb_cgroup`, `enum hugetlb_memory_event`, `function __hugetlb_cgroup_from_folio`, `function hugetlb_cgroup_from_folio_rsvd`, `function __set_hugetlb_cgroup`, `function set_hugetlb_cgroup`.
- Atlas domain: Core OS / Core Kernel Interface.
- 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.