]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blame - include/linux/mm_types.h
mm/mmu_gather: track page size with mmu gather and force flush if page size change
[mirror_ubuntu-zesty-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/rbtree.h>
10#include <linux/rwsem.h>
11#include <linux/completion.h>
cddb8a5c 12#include <linux/cpumask.h>
d4b3b638 13#include <linux/uprobes.h>
bbeae5b0 14#include <linux/page-flags-layout.h>
ec8d7c14 15#include <linux/workqueue.h>
c92ff1bd
MS
16#include <asm/page.h>
17#include <asm/mmu.h>
5b99cd0e 18
4f9a58d7
OH
19#ifndef AT_VECTOR_SIZE_ARCH
20#define AT_VECTOR_SIZE_ARCH 0
21#endif
22#define AT_VECTOR_SIZE (2*(AT_VECTOR_SIZE_ARCH + AT_VECTOR_SIZE_BASE + 1))
23
5b99cd0e 24struct address_space;
1306a85a 25struct mem_cgroup;
5b99cd0e 26
57c1ffce 27#define USE_SPLIT_PTE_PTLOCKS (NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS)
e009bb30
KS
28#define USE_SPLIT_PMD_PTLOCKS (USE_SPLIT_PTE_PTLOCKS && \
29 IS_ENABLED(CONFIG_ARCH_ENABLE_SPLIT_PMD_PTLOCK))
597d795a 30#define ALLOC_SPLIT_PTLOCKS (SPINLOCK_SIZE > BITS_PER_LONG/8)
f7d0b926 31
5b99cd0e
HC
32/*
33 * Each physical page in the system has a struct page associated with
34 * it to keep track of whatever it is we are using the page for at the
35 * moment. Note that we have no way to track which tasks are using
36 * a page, though if it is a pagecache page, rmap structures can tell us
37 * who is mapping it.
fc9bb8c7
CL
38 *
39 * The objects in struct page are organized in double word blocks in
40 * order to allows us to use atomic double word operations on portions
41 * of struct page. That is currently only used by slub but the arrangement
42 * allows the use of atomic double word operations on the flags/mapping
43 * and lru list pointers also.
5b99cd0e
HC
44 */
45struct page {
fc9bb8c7 46 /* First double word block */
5b99cd0e
HC
47 unsigned long flags; /* Atomic flags, some possibly
48 * updated asynchronously */
8456a648
JK
49 union {
50 struct address_space *mapping; /* If low bit clear, points to
51 * inode address_space, or NULL.
52 * If page mapped as anonymous
53 * memory, low bit is set, and
54 * it points to anon_vma object:
55 * see PAGE_MAPPING_ANON below.
56 */
57 void *s_mem; /* slab first object */
53f9263b 58 atomic_t compound_mapcount; /* first tail page */
9a982250 59 /* page_deferred_list().next -- second tail page */
8456a648
JK
60 };
61
fc9bb8c7 62 /* Second double word */
013e8963
CL
63 struct {
64 union {
fc9bb8c7 65 pgoff_t index; /* Our offset within mapping. */
8456a648 66 void *freelist; /* sl[aou]b first free object */
9a982250 67 /* page_deferred_list().prev -- second tail page */
013e8963
CL
68 };
69
70 union {
abca7c49
PS
71#if defined(CONFIG_HAVE_CMPXCHG_DOUBLE) && \
72 defined(CONFIG_HAVE_ALIGNED_STRUCT_PAGE)
013e8963
CL
73 /* Used for cmpxchg_double in slub */
74 unsigned long counters;
abca7c49
PS
75#else
76 /*
0139aa7b
JK
77 * Keep _refcount separate from slub cmpxchg_double
78 * data. As the rest of the double word is protected by
79 * slab_lock but _refcount is not.
abca7c49
PS
80 */
81 unsigned counters;
82#endif
013e8963
CL
83
84 struct {
85
86 union {
70b50f94 87 /*
ddc58f27
KS
88 * Count of ptes mapped in mms, to show
89 * when page is mapped & limit reverse
90 * map searches.
70b50f94
AA
91 */
92 atomic_t _mapcount;
fc9bb8c7 93
b8c24c4a 94 struct { /* SLUB */
013e8963
CL
95 unsigned inuse:16;
96 unsigned objects:15;
97 unsigned frozen:1;
98 };
b8c24c4a 99 int units; /* SLOB */
3adf004d 100 };
0139aa7b
JK
101 /*
102 * Usage count, *USE WRAPPER FUNCTION*
103 * when manual accounting. See page_ref.h
104 */
105 atomic_t _refcount;
fc9bb8c7 106 };
8456a648 107 unsigned int active; /* SLAB */
39b26464 108 };
81819f0f 109 };
fc9bb8c7 110
1d798ca3
KS
111 /*
112 * Third double word block
113 *
114 * WARNING: bit 0 of the first word encode PageTail(). That means
115 * the rest users of the storage space MUST NOT use the bit to
116 * avoid collision and false-positive PageTail().
117 */
49e22585
CL
118 union {
119 struct list_head lru; /* Pageout list, eg. active_list
fc9bb8c7 120 * protected by zone->lru_lock !
34bf6ef9
DH
121 * Can be used as a generic list
122 * by the page owner.
fc9bb8c7 123 */
5c2c2587
DW
124 struct dev_pagemap *pgmap; /* ZONE_DEVICE pages are never on an
125 * lru or handled by a slab
126 * allocator, this points to the
127 * hosting device page map.
128 */
49e22585
CL
129 struct { /* slub per cpu partial pages */
130 struct page *next; /* Next partial slab */
131#ifdef CONFIG_64BIT
132 int pages; /* Nr of partial slabs left */
133 int pobjects; /* Approximate # of objects */
134#else
135 short int pages;
136 short int pobjects;
137#endif
138 };
b8c24c4a 139
68126702
JK
140 struct rcu_head rcu_head; /* Used by SLAB
141 * when destroying via RCU
142 */
1d798ca3 143 /* Tail pages of compound page */
e4b294c2 144 struct {
1d798ca3
KS
145 unsigned long compound_head; /* If bit zero is set */
146
147 /* First tail page only */
1965c8b7
KS
148#ifdef CONFIG_64BIT
149 /*
150 * On 64 bit system we have enough space in struct page
151 * to encode compound_dtor and compound_order with
152 * unsigned int. It can help compiler generate better or
153 * smaller code on some archtectures.
154 */
155 unsigned int compound_dtor;
156 unsigned int compound_order;
157#else
f1e61557
KS
158 unsigned short int compound_dtor;
159 unsigned short int compound_order;
1965c8b7 160#endif
e4b294c2
KS
161 };
162
7aa555bf 163#if defined(CONFIG_TRANSPARENT_HUGEPAGE) && USE_SPLIT_PMD_PTLOCKS
1d798ca3
KS
164 struct {
165 unsigned long __pad; /* do not overlay pmd_huge_pte
166 * with compound_head to avoid
167 * possible bit 0 collision.
168 */
169 pgtable_t pmd_huge_pte; /* protected by page->ptl */
170 };
7aa555bf 171#endif
49e22585 172 };
fc9bb8c7
CL
173
174 /* Remainder is not double word aligned */
5b99cd0e 175 union {
5b99cd0e
HC
176 unsigned long private; /* Mapping-private opaque data:
177 * usually used for buffer_heads
178 * if PagePrivate set; used for
179 * swp_entry_t if PageSwapCache;
180 * indicates order in the buddy
181 * system if PG_buddy is set.
182 */
57c1ffce 183#if USE_SPLIT_PTE_PTLOCKS
597d795a 184#if ALLOC_SPLIT_PTLOCKS
539edb58
PZ
185 spinlock_t *ptl;
186#else
187 spinlock_t ptl;
188#endif
5b99cd0e 189#endif
1b4f59e3 190 struct kmem_cache *slab_cache; /* SL[AU]B: Pointer to slab */
81819f0f 191 };
fc9bb8c7 192
1306a85a
JW
193#ifdef CONFIG_MEMCG
194 struct mem_cgroup *mem_cgroup;
195#endif
196
5b99cd0e
HC
197 /*
198 * On machines where all RAM is mapped into kernel address space,
199 * we can simply calculate the virtual address. On machines with
200 * highmem some memory is mapped into kernel virtual memory
201 * dynamically, so we need a place to store that address.
202 * Note that this field could be 16 bits on x86 ... ;)
203 *
204 * Architectures with slow multiplication can define
205 * WANT_PAGE_VIRTUAL in asm/page.h
206 */
207#if defined(WANT_PAGE_VIRTUAL)
208 void *virtual; /* Kernel virtual address (NULL if
209 not kmapped, ie. highmem) */
210#endif /* WANT_PAGE_VIRTUAL */
dfec072e
VN
211
212#ifdef CONFIG_KMEMCHECK
213 /*
214 * kmemcheck wants to track the status of each byte in a page; this
215 * is a pointer to such a status block. NULL if not tracked.
216 */
217 void *shadow;
218#endif
57e0a030 219
90572890
PZ
220#ifdef LAST_CPUPID_NOT_IN_PAGE_FLAGS
221 int _last_cpupid;
57e0a030 222#endif
fc9bb8c7
CL
223}
224/*
43570fd2
HC
225 * The struct page can be forced to be double word aligned so that atomic ops
226 * on double words work. The SLUB allocator can make use of such a feature.
fc9bb8c7 227 */
43570fd2
HC
228#ifdef CONFIG_HAVE_ALIGNED_STRUCT_PAGE
229 __aligned(2 * sizeof(unsigned long))
fc9bb8c7
CL
230#endif
231;
5b99cd0e 232
30d3c128
IC
233struct page_frag {
234 struct page *page;
235#if (BITS_PER_LONG > 32) || (PAGE_SIZE >= 65536)
236 __u32 offset;
237 __u32 size;
238#else
239 __u16 offset;
240 __u16 size;
241#endif
242};
243
b63ae8ca
AD
244#define PAGE_FRAG_CACHE_MAX_SIZE __ALIGN_MASK(32768, ~PAGE_MASK)
245#define PAGE_FRAG_CACHE_MAX_ORDER get_order(PAGE_FRAG_CACHE_MAX_SIZE)
246
247struct page_frag_cache {
248 void * va;
249#if (PAGE_SIZE < PAGE_FRAG_CACHE_MAX_SIZE)
250 __u16 offset;
251 __u16 size;
252#else
253 __u32 offset;
254#endif
255 /* we maintain a pagecount bias, so that we dont dirty cache line
0139aa7b 256 * containing page->_refcount every time we allocate a fragment.
b63ae8ca
AD
257 */
258 unsigned int pagecnt_bias;
259 bool pfmemalloc;
260};
261
64b990d2 262typedef unsigned long vm_flags_t;
ca16d140 263
8feae131
DH
264/*
265 * A region containing a mapping of a non-memory backed file under NOMMU
266 * conditions. These are held in a global tree and are pinned by the VMAs that
267 * map parts of them.
268 */
269struct vm_region {
270 struct rb_node vm_rb; /* link in global region tree */
ca16d140 271 vm_flags_t vm_flags; /* VMA vm_flags */
8feae131
DH
272 unsigned long vm_start; /* start address of region */
273 unsigned long vm_end; /* region initialised to here */
dd8632a1 274 unsigned long vm_top; /* region allocated to here */
8feae131
DH
275 unsigned long vm_pgoff; /* the offset in vm_file corresponding to vm_start */
276 struct file *vm_file; /* the backing file or NULL */
277
1e2ae599 278 int vm_usage; /* region usage count (access under nommu_region_sem) */
cfe79c00
MF
279 bool vm_icache_flushed : 1; /* true if the icache has been flushed for
280 * this region */
8feae131
DH
281};
282
745f234b
AA
283#ifdef CONFIG_USERFAULTFD
284#define NULL_VM_UFFD_CTX ((struct vm_userfaultfd_ctx) { NULL, })
285struct vm_userfaultfd_ctx {
286 struct userfaultfd_ctx *ctx;
287};
288#else /* CONFIG_USERFAULTFD */
289#define NULL_VM_UFFD_CTX ((struct vm_userfaultfd_ctx) {})
290struct vm_userfaultfd_ctx {};
291#endif /* CONFIG_USERFAULTFD */
292
c92ff1bd
MS
293/*
294 * This struct defines a memory VMM memory area. There is one of these
295 * per VM-area/task. A VM area is any part of the process virtual memory
296 * space that has a special rule for the page-fault handlers (ie a shared
297 * library, the executable area etc).
298 */
299struct vm_area_struct {
e4c6bfd2
RR
300 /* The first cache line has the info for VMA tree walking. */
301
c92ff1bd
MS
302 unsigned long vm_start; /* Our start address within vm_mm. */
303 unsigned long vm_end; /* The first byte after our end address
304 within vm_mm. */
305
306 /* linked list of VM areas per task, sorted by address */
297c5eee 307 struct vm_area_struct *vm_next, *vm_prev;
c92ff1bd 308
c92ff1bd
MS
309 struct rb_node vm_rb;
310
d3737187
ML
311 /*
312 * Largest free memory gap in bytes to the left of this VMA.
313 * Either between this VMA and vma->vm_prev, or between one of the
314 * VMAs below us in the VMA rbtree and its ->vm_prev. This helps
315 * get_unmapped_area find a free area of the right size.
316 */
317 unsigned long rb_subtree_gap;
318
e4c6bfd2
RR
319 /* Second cache line starts here. */
320
321 struct mm_struct *vm_mm; /* The address space we belong to. */
322 pgprot_t vm_page_prot; /* Access permissions of this VMA. */
323 unsigned long vm_flags; /* Flags, see mm.h. */
324
c92ff1bd
MS
325 /*
326 * For areas with an address space and backing store,
27ba0644 327 * linkage into the address_space->i_mmap interval tree.
c92ff1bd 328 */
ac51b934
KS
329 struct {
330 struct rb_node rb;
331 unsigned long rb_subtree_last;
c92ff1bd
MS
332 } shared;
333
334 /*
335 * A file's MAP_PRIVATE vma can be in both i_mmap tree and anon_vma
336 * list, after a COW of one of the file pages. A MAP_SHARED vma
337 * can only be in the i_mmap tree. An anonymous MAP_PRIVATE, stack
338 * or brk vma (with NULL file) can only be in an anon_vma list.
339 */
5beb4930
RR
340 struct list_head anon_vma_chain; /* Serialized by mmap_sem &
341 * page_table_lock */
c92ff1bd
MS
342 struct anon_vma *anon_vma; /* Serialized by page_table_lock */
343
344 /* Function pointers to deal with this struct. */
f0f37e2f 345 const struct vm_operations_struct *vm_ops;
c92ff1bd
MS
346
347 /* Information about our backing store: */
348 unsigned long vm_pgoff; /* Offset (within vm_file) in PAGE_SIZE
ea1754a0 349 units */
c92ff1bd
MS
350 struct file * vm_file; /* File we map to (can be NULL). */
351 void * vm_private_data; /* was vm_pte (shared mem) */
c92ff1bd
MS
352
353#ifndef CONFIG_MMU
8feae131 354 struct vm_region *vm_region; /* NOMMU mapping region */
c92ff1bd
MS
355#endif
356#ifdef CONFIG_NUMA
357 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
358#endif
745f234b 359 struct vm_userfaultfd_ctx vm_userfaultfd_ctx;
c92ff1bd
MS
360};
361
b564daf8
ON
362struct core_thread {
363 struct task_struct *task;
364 struct core_thread *next;
365};
366
32ecb1f2 367struct core_state {
c5f1cc8c 368 atomic_t nr_threads;
b564daf8 369 struct core_thread dumper;
32ecb1f2
ON
370 struct completion startup;
371};
372
d559db08 373enum {
eca56ff9
JM
374 MM_FILEPAGES, /* Resident file mapping pages */
375 MM_ANONPAGES, /* Resident anonymous pages */
376 MM_SWAPENTS, /* Anonymous swap entries */
377 MM_SHMEMPAGES, /* Resident shared memory pages */
d559db08
KH
378 NR_MM_COUNTERS
379};
380
57c1ffce 381#if USE_SPLIT_PTE_PTLOCKS && defined(CONFIG_MMU)
34e55232 382#define SPLIT_RSS_COUNTING
34e55232
KH
383/* per-thread cached information, */
384struct task_rss_stat {
385 int events; /* for synchronization threshold */
386 int count[NR_MM_COUNTERS];
387};
57c1ffce 388#endif /* USE_SPLIT_PTE_PTLOCKS */
172703b0 389
d559db08 390struct mm_rss_stat {
172703b0 391 atomic_long_t count[NR_MM_COUNTERS];
d559db08 392};
d559db08 393
db446a08 394struct kioctx_table;
c92ff1bd 395struct mm_struct {
615d6e87 396 struct vm_area_struct *mmap; /* list of VMAs */
c92ff1bd 397 struct rb_root mm_rb;
615d6e87 398 u32 vmacache_seqnum; /* per-thread vmacache */
efc1a3b1 399#ifdef CONFIG_MMU
c92ff1bd
MS
400 unsigned long (*get_unmapped_area) (struct file *filp,
401 unsigned long addr, unsigned long len,
402 unsigned long pgoff, unsigned long flags);
efc1a3b1 403#endif
c92ff1bd 404 unsigned long mmap_base; /* base of mmap area */
41aacc1e 405 unsigned long mmap_legacy_base; /* base of mmap area in bottom-up allocations */
c92ff1bd 406 unsigned long task_size; /* size of task vm space */
d3737187 407 unsigned long highest_vm_end; /* highest vma end address */
c92ff1bd
MS
408 pgd_t * pgd;
409 atomic_t mm_users; /* How many users with user space? */
410 atomic_t mm_count; /* How many references to "struct mm_struct" (users count as 1) */
dc6c9a35 411 atomic_long_t nr_ptes; /* PTE page table pages */
5a3fbef3 412#if CONFIG_PGTABLE_LEVELS > 2
dc6c9a35 413 atomic_long_t nr_pmds; /* PMD page table pages */
5a3fbef3 414#endif
c92ff1bd 415 int map_count; /* number of VMAs */
481b4bb5 416
c92ff1bd 417 spinlock_t page_table_lock; /* Protects page tables and some counters */
481b4bb5 418 struct rw_semaphore mmap_sem;
c92ff1bd
MS
419
420 struct list_head mmlist; /* List of maybe swapped mm's. These are globally strung
421 * together off init_mm.mmlist, and are protected
422 * by mmlist_lock
423 */
424
c92ff1bd
MS
425
426 unsigned long hiwater_rss; /* High-watermark of RSS usage */
427 unsigned long hiwater_vm; /* High-water virtual memory usage */
428
e10d59f2
CL
429 unsigned long total_vm; /* Total pages mapped */
430 unsigned long locked_vm; /* Pages that have PG_mlocked set */
431 unsigned long pinned_vm; /* Refcount permanently increased */
30bdbb78
KK
432 unsigned long data_vm; /* VM_WRITE & ~VM_SHARED & ~VM_STACK */
433 unsigned long exec_vm; /* VM_EXEC & ~VM_WRITE & ~VM_STACK */
434 unsigned long stack_vm; /* VM_STACK */
e10d59f2 435 unsigned long def_flags;
c92ff1bd
MS
436 unsigned long start_code, end_code, start_data, end_data;
437 unsigned long start_brk, brk, start_stack;
438 unsigned long arg_start, arg_end, env_start, env_end;
439
440 unsigned long saved_auxv[AT_VECTOR_SIZE]; /* for /proc/PID/auxv */
441
d559db08
KH
442 /*
443 * Special counters, in some configurations protected by the
444 * page_table_lock, in other configurations by being atomic.
445 */
446 struct mm_rss_stat rss_stat;
447
801460d0
HS
448 struct linux_binfmt *binfmt;
449
6345d24d
LT
450 cpumask_var_t cpu_vm_mask_var;
451
c92ff1bd
MS
452 /* Architecture-specific MM context */
453 mm_context_t context;
454
c92ff1bd
MS
455 unsigned long flags; /* Must use atomic bitops to access the bits */
456
a94e2d40 457 struct core_state *core_state; /* coredumping support */
858f0993 458#ifdef CONFIG_AIO
db446a08
BL
459 spinlock_t ioctx_lock;
460 struct kioctx_table __rcu *ioctx_table;
858f0993 461#endif
f98bafa0 462#ifdef CONFIG_MEMCG
4cd1a8fc
KM
463 /*
464 * "owner" points to a task that is regarded as the canonical
465 * user/owner of this mm. All of the following must be true in
466 * order for it to be changed:
467 *
468 * current == mm->owner
469 * current->mm != mm
470 * new_owner->mm == mm
471 * new_owner->alloc_lock is held
472 */
4d2deb40 473 struct task_struct __rcu *owner;
78fb7466 474#endif
925d1c40 475
925d1c40 476 /* store ref to file /proc/<pid>/exe symlink points to */
90f31d0e 477 struct file __rcu *exe_file;
cddb8a5c
AA
478#ifdef CONFIG_MMU_NOTIFIER
479 struct mmu_notifier_mm *mmu_notifier_mm;
e7a00c45 480#endif
e009bb30 481#if defined(CONFIG_TRANSPARENT_HUGEPAGE) && !USE_SPLIT_PMD_PTLOCKS
e7a00c45 482 pgtable_t pmd_huge_pte; /* protected by page_table_lock */
cddb8a5c 483#endif
6345d24d
LT
484#ifdef CONFIG_CPUMASK_OFFSTACK
485 struct cpumask cpumask_allocation;
cbee9f88
PZ
486#endif
487#ifdef CONFIG_NUMA_BALANCING
488 /*
34f0315a
MG
489 * numa_next_scan is the next time that the PTEs will be marked
490 * pte_numa. NUMA hinting faults will gather statistics and migrate
491 * pages to new nodes if necessary.
cbee9f88
PZ
492 */
493 unsigned long numa_next_scan;
494
6e5fb223
PZ
495 /* Restart point for scanning and setting pte_numa */
496 unsigned long numa_scan_offset;
497
cbee9f88
PZ
498 /* numa_scan_seq prevents two threads setting pte_numa */
499 int numa_scan_seq;
20841405
RR
500#endif
501#if defined(CONFIG_NUMA_BALANCING) || defined(CONFIG_COMPACTION)
502 /*
503 * An operation with batched TLB flushing is going on. Anything that
504 * can move process memory needs to flush the TLB when moving a
505 * PROT_NONE or PROT_NUMA mapped page.
506 */
507 bool tlb_flush_pending;
6345d24d 508#endif
d4b3b638 509 struct uprobes_state uprobes_state;
fe3d197f
DH
510#ifdef CONFIG_X86_INTEL_MPX
511 /* address of the bounds directory */
512 void __user *bd_addr;
513#endif
5d317b2b
NH
514#ifdef CONFIG_HUGETLB_PAGE
515 atomic_long_t hugetlb_usage;
516#endif
7ef949d7 517#ifdef CONFIG_MMU
ec8d7c14 518 struct work_struct async_put_work;
7ef949d7 519#endif
c92ff1bd
MS
520};
521
6345d24d
LT
522static inline void mm_init_cpumask(struct mm_struct *mm)
523{
524#ifdef CONFIG_CPUMASK_OFFSTACK
525 mm->cpu_vm_mask_var = &mm->cpumask_allocation;
526#endif
41f727fd 527 cpumask_clear(mm->cpu_vm_mask_var);
6345d24d
LT
528}
529
45e575ab 530/* Future-safe accessor for struct mm_struct's cpu_vm_mask. */
de03c72c
KM
531static inline cpumask_t *mm_cpumask(struct mm_struct *mm)
532{
533 return mm->cpu_vm_mask_var;
534}
45e575ab 535
20841405
RR
536#if defined(CONFIG_NUMA_BALANCING) || defined(CONFIG_COMPACTION)
537/*
538 * Memory barriers to keep this state in sync are graciously provided by
539 * the page table locks, outside of which no page table modifications happen.
540 * The barriers below prevent the compiler from re-ordering the instructions
541 * around the memory barriers that are already present in the code.
542 */
543static inline bool mm_tlb_flush_pending(struct mm_struct *mm)
544{
545 barrier();
546 return mm->tlb_flush_pending;
547}
548static inline void set_tlb_flush_pending(struct mm_struct *mm)
549{
550 mm->tlb_flush_pending = true;
af2c1401
MG
551
552 /*
553 * Guarantee that the tlb_flush_pending store does not leak into the
554 * critical section updating the page tables
555 */
556 smp_mb__before_spinlock();
20841405
RR
557}
558/* Clearing is done after a TLB flush, which also provides a barrier. */
559static inline void clear_tlb_flush_pending(struct mm_struct *mm)
560{
561 barrier();
562 mm->tlb_flush_pending = false;
563}
564#else
565static inline bool mm_tlb_flush_pending(struct mm_struct *mm)
566{
567 return false;
568}
569static inline void set_tlb_flush_pending(struct mm_struct *mm)
570{
571}
572static inline void clear_tlb_flush_pending(struct mm_struct *mm)
573{
574}
575#endif
576
f872f540
AL
577struct vm_fault;
578
579struct vm_special_mapping {
580 const char *name; /* The name, e.g. "[vdso]". */
581
582 /*
583 * If .fault is not provided, this points to a
584 * NULL-terminated array of pages that back the special mapping.
585 *
586 * This must not be NULL unless .fault is provided.
587 */
a62c34bd 588 struct page **pages;
f872f540
AL
589
590 /*
591 * If non-NULL, then this is called to resolve page faults
592 * on the special mapping. If used, .pages is not checked.
593 */
594 int (*fault)(const struct vm_special_mapping *sm,
595 struct vm_area_struct *vma,
596 struct vm_fault *vmf);
b059a453
DS
597
598 int (*mremap)(const struct vm_special_mapping *sm,
599 struct vm_area_struct *new_vma);
a62c34bd
AL
600};
601
d17d8f9d
DH
602enum tlb_flush_reason {
603 TLB_FLUSH_ON_TASK_SWITCH,
604 TLB_REMOTE_SHOOTDOWN,
605 TLB_LOCAL_SHOOTDOWN,
606 TLB_LOCAL_MM_SHOOTDOWN,
5b74283a 607 TLB_REMOTE_SEND_IPI,
d17d8f9d
DH
608 NR_TLB_FLUSH_REASONS,
609};
610
bd6dace7
TH
611 /*
612 * A swap entry has to fit into a "unsigned long", as the entry is hidden
613 * in the "index" field of the swapper address space.
614 */
615typedef struct {
616 unsigned long val;
617} swp_entry_t;
618
5b99cd0e 619#endif /* _LINUX_MM_TYPES_H */