Blame view
include/linux/mempolicy.h
7.19 KB
b24413180 License cleanup: ... |
1 |
/* SPDX-License-Identifier: GPL-2.0 */ |
1da177e4c Linux-2.6.12-rc2 |
2 3 4 5 |
/* * NUMA memory policies for Linux. * Copyright 2003,2004 Andi Kleen SuSE Labs */ |
607ca46e9 UAPI: (Scripted) ... |
6 7 |
#ifndef _LINUX_MEMPOLICY_H #define _LINUX_MEMPOLICY_H 1 |
1da177e4c Linux-2.6.12-rc2 |
8 |
|
8ca39e687 mm/hugetlb: add m... |
9 |
#include <linux/sched.h> |
1da177e4c Linux-2.6.12-rc2 |
10 |
#include <linux/mmzone.h> |
c1ef8e2c0 mm: disable numa ... |
11 |
#include <linux/dax.h> |
1da177e4c Linux-2.6.12-rc2 |
12 13 14 |
#include <linux/slab.h> #include <linux/rbtree.h> #include <linux/spinlock.h> |
dfcd3c0dc [PATCH] Convert m... |
15 |
#include <linux/nodemask.h> |
83d1674a9 mm: make CONFIG_M... |
16 |
#include <linux/pagemap.h> |
607ca46e9 UAPI: (Scripted) ... |
17 |
#include <uapi/linux/mempolicy.h> |
1da177e4c Linux-2.6.12-rc2 |
18 |
|
45b35a5ce [PATCH] Fix mempo... |
19 |
struct mm_struct; |
1da177e4c Linux-2.6.12-rc2 |
20 21 22 23 24 25 26 27 28 29 30 |
#ifdef CONFIG_NUMA /* * Describe a memory policy. * * A mempolicy can be either associated with a process or with a VMA. * For VMA related allocations the VMA policy is preferred, otherwise * the process policy is used. Interrupts ignore the memory policy * of the current process. * |
f3f3416c2 include/linux/mem... |
31 |
* Locking policy for interleave: |
1da177e4c Linux-2.6.12-rc2 |
32 33 |
* In process context there is no locking because only the process accesses * its own state. All vma manipulation is somewhat protected by a down_read on |
c1e8d7c6a mmap locking API:... |
34 |
* mmap_lock. |
1da177e4c Linux-2.6.12-rc2 |
35 36 |
* * Freeing policy: |
19770b326 mm: filter based ... |
37 |
* Mempolicy objects are reference counted. A mempolicy will be freed when |
f0be3d32b mempolicy: rename... |
38 |
* mpol_put() decrements the reference count to zero. |
1da177e4c Linux-2.6.12-rc2 |
39 |
* |
846a16bf0 mempolicy: rename... |
40 41 |
* Duplicating policy objects: * mpol_dup() allocates a new mempolicy and copies the specified mempolicy |
19770b326 mm: filter based ... |
42 |
* to the new storage. The reference count of the new object is initialized |
846a16bf0 mempolicy: rename... |
43 |
* to 1, representing the caller of mpol_dup(). |
1da177e4c Linux-2.6.12-rc2 |
44 45 46 |
*/ struct mempolicy { atomic_t refcnt; |
45c4745af mempolicy: rename... |
47 |
unsigned short mode; /* See MPOL_* above */ |
028fec414 mempolicy: suppor... |
48 |
unsigned short flags; /* See set_mempolicy() MPOL_F_* above */ |
1da177e4c Linux-2.6.12-rc2 |
49 |
union { |
1da177e4c Linux-2.6.12-rc2 |
50 |
short preferred_node; /* preferred */ |
19770b326 mm: filter based ... |
51 |
nodemask_t nodes; /* interleave/bind */ |
1da177e4c Linux-2.6.12-rc2 |
52 53 |
/* undefined for default */ } v; |
f5b087b52 mempolicy: add MP... |
54 55 56 57 |
union { nodemask_t cpuset_mems_allowed; /* relative to these nodes */ nodemask_t user_nodemask; /* nodemask passed by user */ } w; |
1da177e4c Linux-2.6.12-rc2 |
58 59 60 61 62 63 |
}; /* * Support for managing mempolicy data objects (clone, copy, destroy) * The default fast path of a NULL MPOL_DEFAULT policy is always inlined. */ |
f0be3d32b mempolicy: rename... |
64 65 |
extern void __mpol_put(struct mempolicy *pol); static inline void mpol_put(struct mempolicy *pol) |
1da177e4c Linux-2.6.12-rc2 |
66 67 |
{ if (pol) |
f0be3d32b mempolicy: rename... |
68 |
__mpol_put(pol); |
1da177e4c Linux-2.6.12-rc2 |
69 |
} |
52cd3b074 mempolicy: rework... |
70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
/* * 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); } |
846a16bf0 mempolicy: rename... |
84 85 |
extern struct mempolicy *__mpol_dup(struct mempolicy *pol); static inline struct mempolicy *mpol_dup(struct mempolicy *pol) |
1da177e4c Linux-2.6.12-rc2 |
86 87 |
{ if (pol) |
846a16bf0 mempolicy: rename... |
88 |
pol = __mpol_dup(pol); |
1da177e4c Linux-2.6.12-rc2 |
89 90 91 92 |
return pol; } #define vma_policy(vma) ((vma)->vm_policy) |
1da177e4c Linux-2.6.12-rc2 |
93 94 95 96 97 98 |
static inline void mpol_get(struct mempolicy *pol) { if (pol) atomic_inc(&pol->refcnt); } |
fcfb4dcc9 mm/mempolicy.c: m... |
99 100 |
extern bool __mpol_equal(struct mempolicy *a, struct mempolicy *b); static inline bool mpol_equal(struct mempolicy *a, struct mempolicy *b) |
1da177e4c Linux-2.6.12-rc2 |
101 102 |
{ if (a == b) |
fcfb4dcc9 mm/mempolicy.c: m... |
103 |
return true; |
1da177e4c Linux-2.6.12-rc2 |
104 105 |
return __mpol_equal(a, b); } |
1da177e4c Linux-2.6.12-rc2 |
106 |
|
1da177e4c Linux-2.6.12-rc2 |
107 |
/* |
1da177e4c Linux-2.6.12-rc2 |
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
* Tree of shared policies for a shared memory region. * Maintain the policies in a pseudo mm that contains vmas. The vmas * carry the policy. As a special twist the pseudo mm is indexed in pages, not * bytes, so that we can work with shared memory segments bigger than * unsigned long. */ struct sp_node { struct rb_node nd; unsigned long start, end; struct mempolicy *policy; }; struct shared_policy { struct rb_root root; |
4a8c7bb59 mm/mempolicy.c: c... |
123 |
rwlock_t lock; |
1da177e4c Linux-2.6.12-rc2 |
124 |
}; |
ef0855d33 mm: mempolicy: tu... |
125 |
int vma_dup_policy(struct vm_area_struct *src, struct vm_area_struct *dst); |
71fe804b6 mempolicy: use st... |
126 |
void mpol_shared_policy_init(struct shared_policy *sp, struct mempolicy *mpol); |
1da177e4c Linux-2.6.12-rc2 |
127 128 129 130 131 132 |
int mpol_set_shared_policy(struct shared_policy *info, struct vm_area_struct *vma, struct mempolicy *new); void mpol_free_shared_policy(struct shared_policy *p); struct mempolicy *mpol_shared_policy_lookup(struct shared_policy *sp, unsigned long idx); |
74d2c3a05 mempolicy: introd... |
133 134 135 |
struct mempolicy *get_task_policy(struct task_struct *p); struct mempolicy *__get_vma_policy(struct vm_area_struct *vma, unsigned long addr); |
6b6482bbf mempolicy: remove... |
136 |
bool vma_policy_mof(struct vm_area_struct *vma); |
d98f6cb67 mm: export get_vm... |
137 |
|
1da177e4c Linux-2.6.12-rc2 |
138 139 |
extern void numa_default_policy(void); extern void numa_policy_init(void); |
213980c0f mm, mempolicy: si... |
140 |
extern void mpol_rebind_task(struct task_struct *tsk, const nodemask_t *new); |
4225399a6 [PATCH] cpuset: r... |
141 |
extern void mpol_rebind_mm(struct mm_struct *mm, nodemask_t *new); |
4225399a6 [PATCH] cpuset: r... |
142 |
|
04ec6264f mm, page_alloc: p... |
143 |
extern int huge_node(struct vm_area_struct *vma, |
19770b326 mm: filter based ... |
144 145 |
unsigned long addr, gfp_t gfp_flags, struct mempolicy **mpol, nodemask_t **nodemask); |
06808b082 hugetlb: derive h... |
146 |
extern bool init_nodemask_of_mempolicy(nodemask_t *mask); |
6f48d0ebd oom: select task ... |
147 148 |
extern bool mempolicy_nodemask_intersects(struct task_struct *tsk, const nodemask_t *mask); |
8ca39e687 mm/hugetlb: add m... |
149 150 151 152 153 154 155 156 |
extern nodemask_t *policy_nodemask(gfp_t gfp, struct mempolicy *policy); static inline nodemask_t *policy_nodemask_current(gfp_t gfp) { struct mempolicy *mpol = get_task_policy(current); return policy_nodemask(gfp, mpol); } |
2a389610a mm, mempolicy: re... |
157 |
extern unsigned int mempolicy_slab_node(void); |
1da177e4c Linux-2.6.12-rc2 |
158 |
|
2f6726e54 [PATCH] Apply typ... |
159 |
extern enum zone_type policy_zone; |
4be38e351 [PATCH] mm: move ... |
160 |
|
2f6726e54 [PATCH] Apply typ... |
161 |
static inline void check_highest_zone(enum zone_type k) |
4be38e351 [PATCH] mm: move ... |
162 |
{ |
b377fd398 Apply memory poli... |
163 |
if (k > policy_zone && k != ZONE_MOVABLE) |
4be38e351 [PATCH] mm: move ... |
164 165 |
policy_zone = k; } |
0ce72d4f7 mm: do_migrate_pa... |
166 167 |
int do_migrate_pages(struct mm_struct *mm, const nodemask_t *from, const nodemask_t *to, int flags); |
39743889a [PATCH] Swap Migr... |
168 |
|
095f1fc4e mempolicy: rework... |
169 170 |
#ifdef CONFIG_TMPFS |
a7a88b237 mempolicy: remove... |
171 |
extern int mpol_parse_str(char *str, struct mempolicy **mpol); |
13057efb0 mm: declare mpol_... |
172 |
#endif |
095f1fc4e mempolicy: rework... |
173 |
|
948927ee9 mm, mempolicy: ma... |
174 |
extern void mpol_to_str(char *buffer, int maxlen, struct mempolicy *pol); |
83d1674a9 mm: make CONFIG_M... |
175 176 |
/* Check if a vma is migratable */ |
20ca87f22 mm/mempolicy: che... |
177 |
extern bool vma_migratable(struct vm_area_struct *vma); |
83d1674a9 mm: make CONFIG_M... |
178 |
|
771fb4d80 mm: mempolicy: Ch... |
179 |
extern int mpol_misplaced(struct page *, struct vm_area_struct *, unsigned long); |
c11600e4f mm, mempolicy: ta... |
180 |
extern void mpol_put_task_policy(struct task_struct *); |
771fb4d80 mm: mempolicy: Ch... |
181 |
|
1da177e4c Linux-2.6.12-rc2 |
182 183 184 |
#else struct mempolicy {}; |
fcfb4dcc9 mm/mempolicy.c: m... |
185 |
static inline bool mpol_equal(struct mempolicy *a, struct mempolicy *b) |
1da177e4c Linux-2.6.12-rc2 |
186 |
{ |
fcfb4dcc9 mm/mempolicy.c: m... |
187 |
return true; |
1da177e4c Linux-2.6.12-rc2 |
188 |
} |
1da177e4c Linux-2.6.12-rc2 |
189 |
|
f0be3d32b mempolicy: rename... |
190 |
static inline void mpol_put(struct mempolicy *p) |
1da177e4c Linux-2.6.12-rc2 |
191 192 |
{ } |
52cd3b074 mempolicy: rework... |
193 194 195 |
static inline void mpol_cond_put(struct mempolicy *pol) { } |
1da177e4c Linux-2.6.12-rc2 |
196 197 198 |
static inline void mpol_get(struct mempolicy *pol) { } |
1da177e4c Linux-2.6.12-rc2 |
199 |
struct shared_policy {}; |
71fe804b6 mempolicy: use st... |
200 201 |
static inline void mpol_shared_policy_init(struct shared_policy *sp, struct mempolicy *mpol) |
1da177e4c Linux-2.6.12-rc2 |
202 203 204 205 206 207 |
{ } static inline void mpol_free_shared_policy(struct shared_policy *p) { } |
75edd345e tmpfs: preliminar... |
208 209 210 211 212 |
static inline struct mempolicy * mpol_shared_policy_lookup(struct shared_policy *sp, unsigned long idx) { return NULL; } |
1da177e4c Linux-2.6.12-rc2 |
213 |
#define vma_policy(vma) NULL |
ef0855d33 mm: mempolicy: tu... |
214 215 216 217 218 219 |
static inline int vma_dup_policy(struct vm_area_struct *src, struct vm_area_struct *dst) { return 0; } |
1da177e4c Linux-2.6.12-rc2 |
220 221 222 223 224 225 226 227 |
static inline void numa_policy_init(void) { } static inline void numa_default_policy(void) { } |
74cb21553 [PATCH] cpuset: n... |
228 |
static inline void mpol_rebind_task(struct task_struct *tsk, |
213980c0f mm, mempolicy: si... |
229 |
const nodemask_t *new) |
68860ec10 [PATCH] cpusets: ... |
230 231 |
{ } |
4225399a6 [PATCH] cpuset: r... |
232 233 234 |
static inline void mpol_rebind_mm(struct mm_struct *mm, nodemask_t *new) { } |
04ec6264f mm, page_alloc: p... |
235 |
static inline int huge_node(struct vm_area_struct *vma, |
19770b326 mm: filter based ... |
236 237 |
unsigned long addr, gfp_t gfp_flags, struct mempolicy **mpol, nodemask_t **nodemask) |
5da7ca860 [PATCH] Add NUMA ... |
238 |
{ |
19770b326 mm: filter based ... |
239 240 |
*mpol = NULL; *nodemask = NULL; |
04ec6264f mm, page_alloc: p... |
241 |
return 0; |
5da7ca860 [PATCH] Add NUMA ... |
242 |
} |
6f48d0ebd oom: select task ... |
243 244 245 246 |
static inline bool init_nodemask_of_mempolicy(nodemask_t *m) { return false; } |
0ce72d4f7 mm: do_migrate_pa... |
247 248 |
static inline int do_migrate_pages(struct mm_struct *mm, const nodemask_t *from, const nodemask_t *to, int flags) |
45b07ef31 [PATCH] cpusets: ... |
249 250 251 |
{ return 0; } |
4be38e351 [PATCH] mm: move ... |
252 253 254 |
static inline void check_highest_zone(int k) { } |
095f1fc4e mempolicy: rework... |
255 256 |
#ifdef CONFIG_TMPFS |
a7a88b237 mempolicy: remove... |
257 |
static inline int mpol_parse_str(char *str, struct mempolicy **mpol) |
095f1fc4e mempolicy: rework... |
258 |
{ |
71fe804b6 mempolicy: use st... |
259 |
return 1; /* error */ |
095f1fc4e mempolicy: rework... |
260 |
} |
13057efb0 mm: declare mpol_... |
261 |
#endif |
095f1fc4e mempolicy: rework... |
262 |
|
771fb4d80 mm: mempolicy: Ch... |
263 264 265 266 267 |
static inline int mpol_misplaced(struct page *page, struct vm_area_struct *vma, unsigned long address) { return -1; /* no node preference */ } |
c11600e4f mm, mempolicy: ta... |
268 269 270 |
static inline void mpol_put_task_policy(struct task_struct *task) { } |
8ca39e687 mm/hugetlb: add m... |
271 272 273 274 275 |
static inline nodemask_t *policy_nodemask_current(gfp_t gfp) { return NULL; } |
1da177e4c Linux-2.6.12-rc2 |
276 |
#endif /* CONFIG_NUMA */ |
1da177e4c Linux-2.6.12-rc2 |
277 |
#endif |