include/linux/mempolicy.h
Source file repositories/reference/linux-study-clean/include/linux/mempolicy.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/mempolicy.h- Extension
.h- Size
- 7570 bytes
- Lines
- 308
- 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.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/sched.hlinux/mmzone.hlinux/slab.hlinux/rbtree.hlinux/spinlock.hlinux/node.hlinux/nodemask.hlinux/pagemap.huapi/linux/mempolicy.h
Detected Declarations
struct mm_structstruct mempolicystruct shared_policystruct sp_nodestruct mempolicystruct shared_policyfunction mpol_putfunction mpol_needs_cond_reffunction mpol_cond_putfunction mpol_getfunction mpol_equalfunction check_highest_zonefunction mpol_is_preferred_manyfunction mpol_equalfunction mpol_putfunction mpol_shared_policy_initfunction vma_dup_policyfunction numa_policy_initfunction init_nodemask_of_mempolicyfunction do_migrate_pagesfunction check_highest_zonefunction mpol_misplacedfunction mpol_put_task_policy
Annotated Snippet
struct mempolicy {
atomic_t refcnt;
unsigned short mode; /* See MPOL_* above */
unsigned short flags; /* See set_mempolicy() MPOL_F_* above */
nodemask_t nodes; /* interleave/bind/preferred/etc */
int home_node; /* Home node to use for MPOL_BIND and MPOL_PREFERRED_MANY */
union {
nodemask_t cpuset_mems_allowed; /* relative to these nodes */
nodemask_t user_nodemask; /* nodemask passed by user */
} w;
struct rcu_head rcu;
};
/*
* Support for managing mempolicy data objects (clone, copy, destroy)
* The default fast path of a NULL MPOL_DEFAULT policy is always inlined.
*/
extern void __mpol_put(struct mempolicy *pol);
static inline void mpol_put(struct mempolicy *pol)
{
if (pol)
__mpol_put(pol);
}
/*
* Does mempolicy pol need explicit unref after use?
* Currently only needed for shared policies.
*/
static inline int mpol_needs_cond_ref(struct mempolicy *pol)
{
return (pol && (pol->flags & MPOL_F_SHARED));
}
static inline void mpol_cond_put(struct mempolicy *pol)
{
if (mpol_needs_cond_ref(pol))
__mpol_put(pol);
}
extern struct mempolicy *__mpol_dup(struct mempolicy *pol);
static inline struct mempolicy *mpol_dup(struct mempolicy *pol)
{
if (pol)
pol = __mpol_dup(pol);
return pol;
}
static inline void mpol_get(struct mempolicy *pol)
{
if (pol)
atomic_inc(&pol->refcnt);
}
extern bool __mpol_equal(struct mempolicy *a, struct mempolicy *b);
static inline bool mpol_equal(struct mempolicy *a, struct mempolicy *b)
{
if (a == b)
return true;
return __mpol_equal(a, b);
}
/*
* Tree of shared policies for a shared memory region.
*/
struct shared_policy {
struct rb_root root;
rwlock_t lock;
};
struct sp_node {
struct rb_node nd;
pgoff_t start, end;
struct mempolicy *policy;
};
int vma_dup_policy(struct vm_area_struct *src, struct vm_area_struct *dst);
void mpol_shared_policy_init(struct shared_policy *sp, struct mempolicy *mpol);
int mpol_set_shared_policy(struct shared_policy *sp,
struct vm_area_struct *vma, struct mempolicy *mpol);
void mpol_free_shared_policy(struct shared_policy *sp);
struct mempolicy *mpol_shared_policy_lookup(struct shared_policy *sp,
pgoff_t idx);
struct mempolicy *get_task_policy(struct task_struct *p);
struct mempolicy *__get_vma_policy(struct vm_area_struct *vma,
unsigned long addr, pgoff_t *ilx);
struct mempolicy *get_vma_policy(struct vm_area_struct *vma,
unsigned long addr, int order, pgoff_t *ilx);
bool vma_policy_mof(struct vm_area_struct *vma);
Annotation
- Immediate include surface: `linux/sched.h`, `linux/mmzone.h`, `linux/slab.h`, `linux/rbtree.h`, `linux/spinlock.h`, `linux/node.h`, `linux/nodemask.h`, `linux/pagemap.h`.
- Detected declarations: `struct mm_struct`, `struct mempolicy`, `struct shared_policy`, `struct sp_node`, `struct mempolicy`, `struct shared_policy`, `function mpol_put`, `function mpol_needs_cond_ref`, `function mpol_cond_put`, `function mpol_get`.
- 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.