]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - include/linux/mm_types.h
slub: Move page->frozen handling near where the page->freelist handling occurs
[mirror_ubuntu-bionic-kernel.git] / include / linux / mm_types.h
CommitLineData
5b99cd0e
HC
1#ifndef _LINUX_MM_TYPES_H
2#define _LINUX_MM_TYPES_H
3
4f9a58d7 4#include <linux/auxvec.h>
5b99cd0e
HC
5#include <linux/types.h>
6#include <linux/threads.h>
7#include <linux/list.h>
8#include <linux/spinlock.h>
c92ff1bd
MS
9#include <linux/prio_tree.h>
10#include <linux/rbtree.h>
11#include <linux/rwsem.h>
12#include <linux/completion.h>
cddb8a5c 13#include <linux/cpumask.h>
6a11f75b 14#include <linux/page-debug-flags.h>
c92ff1bd
MS
15#include <asm/page.h>
16#include <asm/mmu.h>
5b99cd0e 17
4f9a58d7
OH
18#ifndef AT_VECTOR_SIZE_ARCH
19#define AT_VECTOR_SIZE_ARCH 0
20#endif
21#define AT_VECTOR_SIZE (2*(AT_VECTOR_SIZE_ARCH + AT_VECTOR_SIZE_BASE + 1))
22
5b99cd0e
HC
23struct address_space;
24
f7d0b926
JF
25#define USE_SPLIT_PTLOCKS (NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS)
26
5b99cd0e
HC
27/*
28 * Each physical page in the system has a struct page associated with
29 * it to keep track of whatever it is we are using the page for at the
30 * moment. Note that we have no way to track which tasks are using
31 * a page, though if it is a pagecache page, rmap structures can tell us
32 * who is mapping it.
33 */
34struct page {
35 unsigned long flags; /* Atomic flags, some possibly
36 * updated asynchronously */
37 atomic_t _count; /* Usage count, see below. */
81819f0f
CL
38 union {
39 atomic_t _mapcount; /* Count of ptes mapped in mms,
5b99cd0e
HC
40 * to show when page is mapped
41 * & limit reverse map searches.
42 */
39b26464 43 struct { /* SLUB */
50d5c41c
CL
44 unsigned inuse:16;
45 unsigned objects:15;
46 unsigned frozen:1;
39b26464 47 };
81819f0f 48 };
5b99cd0e
HC
49 union {
50 struct {
51 unsigned long private; /* Mapping-private opaque data:
52 * usually used for buffer_heads
53 * if PagePrivate set; used for
54 * swp_entry_t if PageSwapCache;
55 * indicates order in the buddy
56 * system if PG_buddy is set.
57 */
58 struct address_space *mapping; /* If low bit clear, points to
59 * inode address_space, or NULL.
60 * If page mapped as anonymous
61 * memory, low bit is set, and
62 * it points to anon_vma object:
63 * see PAGE_MAPPING_ANON below.
64 */
65 };
f7d0b926 66#if USE_SPLIT_PTLOCKS
5b99cd0e
HC
67 spinlock_t ptl;
68#endif
a973e9dd 69 struct kmem_cache *slab; /* SLUB: Pointer to slab */
8e65d24c 70 struct page *first_page; /* Compound tail pages */
81819f0f
CL
71 };
72 union {
73 pgoff_t index; /* Our offset within mapping. */
894b8788 74 void *freelist; /* SLUB: freelist req. slab lock */
5b99cd0e 75 };
5b99cd0e
HC
76 struct list_head lru; /* Pageout list, eg. active_list
77 * protected by zone->lru_lock !
78 */
79 /*
80 * On machines where all RAM is mapped into kernel address space,
81 * we can simply calculate the virtual address. On machines with
82 * highmem some memory is mapped into kernel virtual memory
83 * dynamically, so we need a place to store that address.
84 * Note that this field could be 16 bits on x86 ... ;)
85 *
86 * Architectures with slow multiplication can define
87 * WANT_PAGE_VIRTUAL in asm/page.h
88 */
89#if defined(WANT_PAGE_VIRTUAL)
90 void *virtual; /* Kernel virtual address (NULL if
91 not kmapped, ie. highmem) */
92#endif /* WANT_PAGE_VIRTUAL */
ee3b4290
AM
93#ifdef CONFIG_WANT_PAGE_DEBUG_FLAGS
94 unsigned long debug_flags; /* Use atomic bitops on this */
95#endif
dfec072e
VN
96
97#ifdef CONFIG_KMEMCHECK
98 /*
99 * kmemcheck wants to track the status of each byte in a page; this
100 * is a pointer to such a status block. NULL if not tracked.
101 */
102 void *shadow;
103#endif
5b99cd0e
HC
104};
105
ca16d140
KM
106typedef unsigned long __nocast vm_flags_t;
107
8feae131
DH
108/*
109 * A region containing a mapping of a non-memory backed file under NOMMU
110 * conditions. These are held in a global tree and are pinned by the VMAs that
111 * map parts of them.
112 */
113struct vm_region {
114 struct rb_node vm_rb; /* link in global region tree */
ca16d140 115 vm_flags_t vm_flags; /* VMA vm_flags */
8feae131
DH
116 unsigned long vm_start; /* start address of region */
117 unsigned long vm_end; /* region initialised to here */
dd8632a1 118 unsigned long vm_top; /* region allocated to here */
8feae131
DH
119 unsigned long vm_pgoff; /* the offset in vm_file corresponding to vm_start */
120 struct file *vm_file; /* the backing file or NULL */
121
1e2ae599 122 int vm_usage; /* region usage count (access under nommu_region_sem) */
cfe79c00
MF
123 bool vm_icache_flushed : 1; /* true if the icache has been flushed for
124 * this region */
8feae131
DH
125};
126
c92ff1bd
MS
127/*
128 * This struct defines a memory VMM memory area. There is one of these
129 * per VM-area/task. A VM area is any part of the process virtual memory
130 * space that has a special rule for the page-fault handlers (ie a shared
131 * library, the executable area etc).
132 */
133struct vm_area_struct {
134 struct mm_struct * vm_mm; /* The address space we belong to. */
135 unsigned long vm_start; /* Our start address within vm_mm. */
136 unsigned long vm_end; /* The first byte after our end address
137 within vm_mm. */
138
139 /* linked list of VM areas per task, sorted by address */
297c5eee 140 struct vm_area_struct *vm_next, *vm_prev;
c92ff1bd
MS
141
142 pgprot_t vm_page_prot; /* Access permissions of this VMA. */
605d9288 143 unsigned long vm_flags; /* Flags, see mm.h. */
c92ff1bd
MS
144
145 struct rb_node vm_rb;
146
147 /*
148 * For areas with an address space and backing store,
149 * linkage into the address_space->i_mmap prio tree, or
150 * linkage to the list of like vmas hanging off its node, or
151 * linkage of vma in the address_space->i_mmap_nonlinear list.
152 */
153 union {
154 struct {
155 struct list_head list;
156 void *parent; /* aligns with prio_tree_node parent */
157 struct vm_area_struct *head;
158 } vm_set;
159
160 struct raw_prio_tree_node prio_tree_node;
161 } shared;
162
163 /*
164 * A file's MAP_PRIVATE vma can be in both i_mmap tree and anon_vma
165 * list, after a COW of one of the file pages. A MAP_SHARED vma
166 * can only be in the i_mmap tree. An anonymous MAP_PRIVATE, stack
167 * or brk vma (with NULL file) can only be in an anon_vma list.
168 */
5beb4930
RR
169 struct list_head anon_vma_chain; /* Serialized by mmap_sem &
170 * page_table_lock */
c92ff1bd
MS
171 struct anon_vma *anon_vma; /* Serialized by page_table_lock */
172
173 /* Function pointers to deal with this struct. */
f0f37e2f 174 const struct vm_operations_struct *vm_ops;
c92ff1bd
MS
175
176 /* Information about our backing store: */
177 unsigned long vm_pgoff; /* Offset (within vm_file) in PAGE_SIZE
178 units, *not* PAGE_CACHE_SIZE */
179 struct file * vm_file; /* File we map to (can be NULL). */
180 void * vm_private_data; /* was vm_pte (shared mem) */
c92ff1bd
MS
181
182#ifndef CONFIG_MMU
8feae131 183 struct vm_region *vm_region; /* NOMMU mapping region */
c92ff1bd
MS
184#endif
185#ifdef CONFIG_NUMA
186 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
187#endif
188};
189
b564daf8
ON
190struct core_thread {
191 struct task_struct *task;
192 struct core_thread *next;
193};
194
32ecb1f2 195struct core_state {
c5f1cc8c 196 atomic_t nr_threads;
b564daf8 197 struct core_thread dumper;
32ecb1f2
ON
198 struct completion startup;
199};
200
d559db08
KH
201enum {
202 MM_FILEPAGES,
203 MM_ANONPAGES,
b084d435 204 MM_SWAPENTS,
d559db08
KH
205 NR_MM_COUNTERS
206};
207
53bddb4e 208#if USE_SPLIT_PTLOCKS && defined(CONFIG_MMU)
34e55232 209#define SPLIT_RSS_COUNTING
34e55232
KH
210/* per-thread cached information, */
211struct task_rss_stat {
212 int events; /* for synchronization threshold */
213 int count[NR_MM_COUNTERS];
214};
172703b0
MF
215#endif /* USE_SPLIT_PTLOCKS */
216
d559db08 217struct mm_rss_stat {
172703b0 218 atomic_long_t count[NR_MM_COUNTERS];
d559db08 219};
d559db08 220
c92ff1bd
MS
221struct mm_struct {
222 struct vm_area_struct * mmap; /* list of VMAs */
223 struct rb_root mm_rb;
224 struct vm_area_struct * mmap_cache; /* last find_vma result */
efc1a3b1 225#ifdef CONFIG_MMU
c92ff1bd
MS
226 unsigned long (*get_unmapped_area) (struct file *filp,
227 unsigned long addr, unsigned long len,
228 unsigned long pgoff, unsigned long flags);
229 void (*unmap_area) (struct mm_struct *mm, unsigned long addr);
efc1a3b1 230#endif
c92ff1bd
MS
231 unsigned long mmap_base; /* base of mmap area */
232 unsigned long task_size; /* size of task vm space */
233 unsigned long cached_hole_size; /* if non-zero, the largest hole below free_area_cache */
234 unsigned long free_area_cache; /* first hole of size cached_hole_size or larger */
235 pgd_t * pgd;
236 atomic_t mm_users; /* How many users with user space? */
237 atomic_t mm_count; /* How many references to "struct mm_struct" (users count as 1) */
238 int map_count; /* number of VMAs */
481b4bb5 239
c92ff1bd 240 spinlock_t page_table_lock; /* Protects page tables and some counters */
481b4bb5 241 struct rw_semaphore mmap_sem;
c92ff1bd
MS
242
243 struct list_head mmlist; /* List of maybe swapped mm's. These are globally strung
244 * together off init_mm.mmlist, and are protected
245 * by mmlist_lock
246 */
247
c92ff1bd
MS
248
249 unsigned long hiwater_rss; /* High-watermark of RSS usage */
250 unsigned long hiwater_vm; /* High-water virtual memory usage */
251
252 unsigned long total_vm, locked_vm, shared_vm, exec_vm;
253 unsigned long stack_vm, reserved_vm, def_flags, nr_ptes;
254 unsigned long start_code, end_code, start_data, end_data;
255 unsigned long start_brk, brk, start_stack;
256 unsigned long arg_start, arg_end, env_start, env_end;
257
258 unsigned long saved_auxv[AT_VECTOR_SIZE]; /* for /proc/PID/auxv */
259
d559db08
KH
260 /*
261 * Special counters, in some configurations protected by the
262 * page_table_lock, in other configurations by being atomic.
263 */
264 struct mm_rss_stat rss_stat;
265
801460d0
HS
266 struct linux_binfmt *binfmt;
267
6345d24d
LT
268 cpumask_var_t cpu_vm_mask_var;
269
c92ff1bd
MS
270 /* Architecture-specific MM context */
271 mm_context_t context;
272
273 /* Swap token stuff */
274 /*
275 * Last value of global fault stamp as seen by this process.
276 * In other words, this value gives an indication of how long
277 * it has been since this task got the token.
278 * Look at mm/thrash.c
279 */
280 unsigned int faultstamp;
281 unsigned int token_priority;
282 unsigned int last_interval;
283
481b4bb5
RK
284 /* How many tasks sharing this mm are OOM_DISABLE */
285 atomic_t oom_disable_count;
286
c92ff1bd
MS
287 unsigned long flags; /* Must use atomic bitops to access the bits */
288
a94e2d40 289 struct core_state *core_state; /* coredumping support */
858f0993 290#ifdef CONFIG_AIO
abf137dd
JA
291 spinlock_t ioctx_lock;
292 struct hlist_head ioctx_list;
858f0993 293#endif
cf475ad2 294#ifdef CONFIG_MM_OWNER
4cd1a8fc
KM
295 /*
296 * "owner" points to a task that is regarded as the canonical
297 * user/owner of this mm. All of the following must be true in
298 * order for it to be changed:
299 *
300 * current == mm->owner
301 * current->mm != mm
302 * new_owner->mm == mm
303 * new_owner->alloc_lock is held
304 */
4d2deb40 305 struct task_struct __rcu *owner;
78fb7466 306#endif
925d1c40 307
925d1c40
MH
308 /* store ref to file /proc/<pid>/exe symlink points to */
309 struct file *exe_file;
310 unsigned long num_exe_file_vmas;
cddb8a5c
AA
311#ifdef CONFIG_MMU_NOTIFIER
312 struct mmu_notifier_mm *mmu_notifier_mm;
e7a00c45
AA
313#endif
314#ifdef CONFIG_TRANSPARENT_HUGEPAGE
315 pgtable_t pmd_huge_pte; /* protected by page_table_lock */
cddb8a5c 316#endif
6345d24d
LT
317#ifdef CONFIG_CPUMASK_OFFSTACK
318 struct cpumask cpumask_allocation;
319#endif
c92ff1bd
MS
320};
321
6345d24d
LT
322static inline void mm_init_cpumask(struct mm_struct *mm)
323{
324#ifdef CONFIG_CPUMASK_OFFSTACK
325 mm->cpu_vm_mask_var = &mm->cpumask_allocation;
326#endif
327}
328
45e575ab 329/* Future-safe accessor for struct mm_struct's cpu_vm_mask. */
de03c72c
KM
330static inline cpumask_t *mm_cpumask(struct mm_struct *mm)
331{
332 return mm->cpu_vm_mask_var;
333}
45e575ab 334
5b99cd0e 335#endif /* _LINUX_MM_TYPES_H */