1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _LINUX_MM_TYPES_H
3 #define _LINUX_MM_TYPES_H
5 #include <linux/mm_types_task.h>
7 #include <linux/auxvec.h>
8 #include <linux/kref.h>
9 #include <linux/list.h>
10 #include <linux/spinlock.h>
11 #include <linux/rbtree.h>
12 #include <linux/rwsem.h>
13 #include <linux/completion.h>
14 #include <linux/cpumask.h>
15 #include <linux/uprobes.h>
16 #include <linux/rcupdate.h>
17 #include <linux/page-flags-layout.h>
18 #include <linux/workqueue.h>
19 #include <linux/seqlock.h>
23 #ifndef AT_VECTOR_SIZE_ARCH
24 #define AT_VECTOR_SIZE_ARCH 0
26 #define AT_VECTOR_SIZE (2*(AT_VECTOR_SIZE_ARCH + AT_VECTOR_SIZE_BASE + 1))
34 * Each physical page in the system has a struct page associated with
35 * it to keep track of whatever it is we are using the page for at the
36 * moment. Note that we have no way to track which tasks are using
37 * a page, though if it is a pagecache page, rmap structures can tell us
40 * If you allocate the page using alloc_pages(), you can use some of the
41 * space in struct page for your own purposes. The five words in the main
42 * union are available, except for bit 0 of the first word which must be
43 * kept clear. Many users use this word to store a pointer to an object
44 * which is guaranteed to be aligned. If you use the same storage as
45 * page->mapping, you must restore it to NULL before freeing the page.
47 * If your page will not be mapped to userspace, you can also use the four
48 * bytes in the mapcount union, but you must call page_mapcount_reset()
51 * If you want to use the refcount field, it must be used in such a way
52 * that other CPUs temporarily incrementing and then decrementing the
53 * refcount does not cause problems. On receiving the page from
54 * alloc_pages(), the refcount will be positive.
56 * If you allocate pages of order > 0, you can use some of the fields
57 * in each subpage, but you may need to restore some of their values
60 * SLUB uses cmpxchg_double() to atomically update its freelist and counters.
61 * That requires that freelist & counters in struct slab be adjacent and
62 * double-word aligned. Because struct slab currently just reinterprets the
63 * bits of struct page, we align all struct pages to double-word boundaries,
64 * and ensure that 'freelist' is aligned within struct slab.
66 #ifdef CONFIG_HAVE_ALIGNED_STRUCT_PAGE
67 #define _struct_page_alignment __aligned(2 * sizeof(unsigned long))
69 #define _struct_page_alignment
73 unsigned long flags; /* Atomic flags, some possibly
74 * updated asynchronously */
76 * Five words (20/40 bytes) are available in this union.
77 * WARNING: bit 0 of the first word is used for PageTail(). That
78 * means the other users of this union MUST NOT use the bit to
79 * avoid collision and false-positive PageTail().
82 struct { /* Page cache and anonymous pages */
84 * @lru: Pageout list, eg. active_list protected by
85 * lruvec->lru_lock. Sometimes used as a generic list
89 /* See page-flags.h for PAGE_MAPPING_FLAGS */
90 struct address_space *mapping;
91 pgoff_t index; /* Our offset within mapping. */
93 * @private: Mapping-private opaque data.
94 * Usually used for buffer_heads if PagePrivate.
95 * Used for swp_entry_t if PageSwapCache.
96 * Indicates order in the buddy system if PageBuddy.
98 unsigned long private;
100 struct { /* page_pool used by netstack */
102 * @pp_magic: magic value to avoid recycling non
103 * page_pool allocated pages.
105 unsigned long pp_magic;
106 struct page_pool *pp;
107 unsigned long _pp_mapping_pad;
108 unsigned long dma_addr;
111 * dma_addr_upper: might require a 64-bit
112 * value on 32-bit architectures.
114 unsigned long dma_addr_upper;
116 * For frag page support, not supported in
117 * 32-bit architectures with 64-bit DMA.
119 atomic_long_t pp_frag_count;
122 struct { /* slab, slob and slub */
124 struct list_head slab_list;
125 struct { /* Partial pages */
128 int pages; /* Nr of pages left */
134 struct kmem_cache *slab_cache; /* not slob */
135 /* Double-word boundary */
136 void *freelist; /* first free object */
138 void *s_mem; /* slab: first object */
139 unsigned long counters; /* SLUB */
147 struct { /* Tail pages of compound page */
148 unsigned long compound_head; /* Bit zero is set */
150 /* First tail page only */
151 unsigned char compound_dtor;
152 unsigned char compound_order;
153 atomic_t compound_mapcount;
154 unsigned int compound_nr; /* 1 << compound_order */
156 struct { /* Second tail page of compound page */
157 unsigned long _compound_pad_1; /* compound_head */
158 atomic_t hpage_pinned_refcount;
159 /* For both global and memcg */
160 struct list_head deferred_list;
162 struct { /* Page table pages */
163 unsigned long _pt_pad_1; /* compound_head */
164 pgtable_t pmd_huge_pte; /* protected by page->ptl */
165 unsigned long _pt_pad_2; /* mapping */
167 struct mm_struct *pt_mm; /* x86 pgds only */
168 atomic_t pt_frag_refcount; /* powerpc */
170 #if ALLOC_SPLIT_PTLOCKS
176 struct { /* ZONE_DEVICE pages */
177 /** @pgmap: Points to the hosting device page map. */
178 struct dev_pagemap *pgmap;
179 void *zone_device_data;
181 * ZONE_DEVICE private pages are counted as being
182 * mapped so the next 3 words hold the mapping, index,
183 * and private fields from the source anonymous or
184 * page cache page while the page is migrated to device
186 * ZONE_DEVICE MEMORY_DEVICE_FS_DAX pages also
187 * use the mapping, index, and private fields when
188 * pmem backed DAX files are mapped.
192 /** @rcu_head: You can use this to free a page by RCU. */
193 struct rcu_head rcu_head;
196 union { /* This union is 4 bytes in size. */
198 * If the page can be mapped to userspace, encodes the number
199 * of times this page is referenced by a page table.
204 * If the page is neither PageSlab nor mappable to userspace,
205 * the value stored here may help determine what this page
206 * is used for. See page-flags.h for a list of page types
207 * which are currently stored here.
209 unsigned int page_type;
211 unsigned int active; /* SLAB */
212 int units; /* SLOB */
215 /* Usage count. *DO NOT USE DIRECTLY*. See page_ref.h */
219 unsigned long memcg_data;
223 * On machines where all RAM is mapped into kernel address space,
224 * we can simply calculate the virtual address. On machines with
225 * highmem some memory is mapped into kernel virtual memory
226 * dynamically, so we need a place to store that address.
227 * Note that this field could be 16 bits on x86 ... ;)
229 * Architectures with slow multiplication can define
230 * WANT_PAGE_VIRTUAL in asm/page.h
232 #if defined(WANT_PAGE_VIRTUAL)
233 void *virtual; /* Kernel virtual address (NULL if
234 not kmapped, ie. highmem) */
235 #endif /* WANT_PAGE_VIRTUAL */
237 #ifdef LAST_CPUPID_NOT_IN_PAGE_FLAGS
240 } _struct_page_alignment;
243 * struct folio - Represents a contiguous set of bytes.
244 * @flags: Identical to the page flags.
245 * @lru: Least Recently Used list; tracks how recently this folio was used.
246 * @mapping: The file this page belongs to, or refers to the anon_vma for
248 * @index: Offset within the file, in units of pages. For anonymous memory,
249 * this is the index from the beginning of the mmap.
250 * @private: Filesystem per-folio data (see folio_attach_private()).
251 * Used for swp_entry_t if folio_test_swapcache().
252 * @_mapcount: Do not access this member directly. Use folio_mapcount() to
253 * find out how many times this folio is mapped by userspace.
254 * @_refcount: Do not access this member directly. Use folio_ref_count()
255 * to find how many references there are to this folio.
256 * @memcg_data: Memory Control Group data.
258 * A folio is a physically, virtually and logically contiguous set
259 * of bytes. It is a power-of-two in size, and it is aligned to that
260 * same power-of-two. It is at least as large as %PAGE_SIZE. If it is
261 * in the page cache, it is at a file offset which is a multiple of that
262 * power-of-two. It may be mapped into userspace at an address which is
263 * at an arbitrary page offset, but its kernel virtual address is aligned
267 /* private: don't document the anon union */
272 struct list_head lru;
273 struct address_space *mapping;
279 unsigned long memcg_data;
281 /* private: the union with struct page is transitional */
287 static_assert(sizeof(struct page) == sizeof(struct folio));
288 #define FOLIO_MATCH(pg, fl) \
289 static_assert(offsetof(struct page, pg) == offsetof(struct folio, fl))
290 FOLIO_MATCH(flags, flags);
291 FOLIO_MATCH(lru, lru);
292 FOLIO_MATCH(compound_head, lru);
293 FOLIO_MATCH(index, index);
294 FOLIO_MATCH(private, private);
295 FOLIO_MATCH(_mapcount, _mapcount);
296 FOLIO_MATCH(_refcount, _refcount);
298 FOLIO_MATCH(memcg_data, memcg_data);
302 static inline atomic_t *folio_mapcount_ptr(struct folio *folio)
304 struct page *tail = &folio->page + 1;
305 return &tail->compound_mapcount;
308 static inline atomic_t *compound_mapcount_ptr(struct page *page)
310 return &page[1].compound_mapcount;
313 static inline atomic_t *compound_pincount_ptr(struct page *page)
315 return &page[2].hpage_pinned_refcount;
319 * Used for sizing the vmemmap region on some architectures
321 #define STRUCT_PAGE_MAX_SHIFT (order_base_2(sizeof(struct page)))
323 #define PAGE_FRAG_CACHE_MAX_SIZE __ALIGN_MASK(32768, ~PAGE_MASK)
324 #define PAGE_FRAG_CACHE_MAX_ORDER get_order(PAGE_FRAG_CACHE_MAX_SIZE)
327 * page_private can be used on tail pages. However, PagePrivate is only
328 * checked by the VM on the head page. So page_private on the tail pages
329 * should be used for data that's ancillary to the head page (eg attaching
330 * buffer heads to tail pages after attaching buffer heads to the head page)
332 #define page_private(page) ((page)->private)
334 static inline void set_page_private(struct page *page, unsigned long private)
336 page->private = private;
339 static inline void *folio_get_private(struct folio *folio)
341 return folio->private;
344 struct page_frag_cache {
346 #if (PAGE_SIZE < PAGE_FRAG_CACHE_MAX_SIZE)
352 /* we maintain a pagecount bias, so that we dont dirty cache line
353 * containing page->_refcount every time we allocate a fragment.
355 unsigned int pagecnt_bias;
359 typedef unsigned long vm_flags_t;
362 * A region containing a mapping of a non-memory backed file under NOMMU
363 * conditions. These are held in a global tree and are pinned by the VMAs that
367 struct rb_node vm_rb; /* link in global region tree */
368 vm_flags_t vm_flags; /* VMA vm_flags */
369 unsigned long vm_start; /* start address of region */
370 unsigned long vm_end; /* region initialised to here */
371 unsigned long vm_top; /* region allocated to here */
372 unsigned long vm_pgoff; /* the offset in vm_file corresponding to vm_start */
373 struct file *vm_file; /* the backing file or NULL */
375 int vm_usage; /* region usage count (access under nommu_region_sem) */
376 bool vm_icache_flushed : 1; /* true if the icache has been flushed for
380 #ifdef CONFIG_USERFAULTFD
381 #define NULL_VM_UFFD_CTX ((struct vm_userfaultfd_ctx) { NULL, })
382 struct vm_userfaultfd_ctx {
383 struct userfaultfd_ctx *ctx;
385 #else /* CONFIG_USERFAULTFD */
386 #define NULL_VM_UFFD_CTX ((struct vm_userfaultfd_ctx) {})
387 struct vm_userfaultfd_ctx {};
388 #endif /* CONFIG_USERFAULTFD */
390 struct anon_vma_name {
392 /* The name needs to be at the end because it is dynamically sized. */
397 * This struct describes a virtual memory area. There is one of these
398 * per VM-area/task. A VM area is any part of the process virtual memory
399 * space that has a special rule for the page-fault handlers (ie a shared
400 * library, the executable area etc).
402 struct vm_area_struct {
403 /* The first cache line has the info for VMA tree walking. */
405 unsigned long vm_start; /* Our start address within vm_mm. */
406 unsigned long vm_end; /* The first byte after our end address
409 /* linked list of VM areas per task, sorted by address */
410 struct vm_area_struct *vm_next, *vm_prev;
412 struct rb_node vm_rb;
415 * Largest free memory gap in bytes to the left of this VMA.
416 * Either between this VMA and vma->vm_prev, or between one of the
417 * VMAs below us in the VMA rbtree and its ->vm_prev. This helps
418 * get_unmapped_area find a free area of the right size.
420 unsigned long rb_subtree_gap;
422 /* Second cache line starts here. */
424 struct mm_struct *vm_mm; /* The address space we belong to. */
427 * Access permissions of this VMA.
428 * See vmf_insert_mixed_prot() for discussion.
430 pgprot_t vm_page_prot;
431 unsigned long vm_flags; /* Flags, see mm.h. */
434 * For areas with an address space and backing store,
435 * linkage into the address_space->i_mmap interval tree.
437 * For private anonymous mappings, a pointer to a null terminated string
438 * containing the name given to the vma, or NULL if unnamed.
444 unsigned long rb_subtree_last;
446 /* Serialized by mmap_sem. */
447 struct anon_vma_name *anon_name;
451 * A file's MAP_PRIVATE vma can be in both i_mmap tree and anon_vma
452 * list, after a COW of one of the file pages. A MAP_SHARED vma
453 * can only be in the i_mmap tree. An anonymous MAP_PRIVATE, stack
454 * or brk vma (with NULL file) can only be in an anon_vma list.
456 struct list_head anon_vma_chain; /* Serialized by mmap_lock &
458 struct anon_vma *anon_vma; /* Serialized by page_table_lock */
460 /* Function pointers to deal with this struct. */
461 const struct vm_operations_struct *vm_ops;
463 /* Information about our backing store: */
464 unsigned long vm_pgoff; /* Offset (within vm_file) in PAGE_SIZE
466 struct file * vm_file; /* File we map to (can be NULL). */
467 void * vm_private_data; /* was vm_pte (shared mem) */
470 atomic_long_t swap_readahead_info;
473 struct vm_region *vm_region; /* NOMMU mapping region */
476 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
478 struct vm_userfaultfd_ctx vm_userfaultfd_ctx;
479 } __randomize_layout;
484 struct vm_area_struct *mmap; /* list of VMAs */
485 struct rb_root mm_rb;
486 u64 vmacache_seqnum; /* per-thread vmacache */
488 unsigned long (*get_unmapped_area) (struct file *filp,
489 unsigned long addr, unsigned long len,
490 unsigned long pgoff, unsigned long flags);
492 unsigned long mmap_base; /* base of mmap area */
493 unsigned long mmap_legacy_base; /* base of mmap area in bottom-up allocations */
494 #ifdef CONFIG_HAVE_ARCH_COMPAT_MMAP_BASES
495 /* Base addresses for compatible mmap() */
496 unsigned long mmap_compat_base;
497 unsigned long mmap_compat_legacy_base;
499 unsigned long task_size; /* size of task vm space */
500 unsigned long highest_vm_end; /* highest vma end address */
503 #ifdef CONFIG_MEMBARRIER
505 * @membarrier_state: Flags controlling membarrier behavior.
507 * This field is close to @pgd to hopefully fit in the same
508 * cache-line, which needs to be touched by switch_mm().
510 atomic_t membarrier_state;
514 * @mm_users: The number of users including userspace.
516 * Use mmget()/mmget_not_zero()/mmput() to modify. When this
517 * drops to 0 (i.e. when the task exits and there are no other
518 * temporary reference holders), we also release a reference on
519 * @mm_count (which may then free the &struct mm_struct if
520 * @mm_count also drops to 0).
525 * @mm_count: The number of references to &struct mm_struct
526 * (@mm_users count as 1).
528 * Use mmgrab()/mmdrop() to modify. When this drops to 0, the
529 * &struct mm_struct is freed.
534 atomic_long_t pgtables_bytes; /* PTE page table pages */
536 int map_count; /* number of VMAs */
538 spinlock_t page_table_lock; /* Protects page tables and some
542 * With some kernel config, the current mmap_lock's offset
543 * inside 'mm_struct' is at 0x120, which is very optimal, as
544 * its two hot fields 'count' and 'owner' sit in 2 different
545 * cachelines, and when mmap_lock is highly contended, both
546 * of the 2 fields will be accessed frequently, current layout
547 * will help to reduce cache bouncing.
549 * So please be careful with adding new fields before
550 * mmap_lock, which can easily push the 2 fields into one
553 struct rw_semaphore mmap_lock;
555 struct list_head mmlist; /* List of maybe swapped mm's. These
556 * are globally strung together off
557 * init_mm.mmlist, and are protected
562 unsigned long hiwater_rss; /* High-watermark of RSS usage */
563 unsigned long hiwater_vm; /* High-water virtual memory usage */
565 unsigned long total_vm; /* Total pages mapped */
566 unsigned long locked_vm; /* Pages that have PG_mlocked set */
567 atomic64_t pinned_vm; /* Refcount permanently increased */
568 unsigned long data_vm; /* VM_WRITE & ~VM_SHARED & ~VM_STACK */
569 unsigned long exec_vm; /* VM_EXEC & ~VM_WRITE & ~VM_STACK */
570 unsigned long stack_vm; /* VM_STACK */
571 unsigned long def_flags;
574 * @write_protect_seq: Locked when any thread is write
575 * protecting pages mapped by this mm to enforce a later COW,
576 * for instance during page table copying for fork().
578 seqcount_t write_protect_seq;
580 spinlock_t arg_lock; /* protect the below fields */
582 unsigned long start_code, end_code, start_data, end_data;
583 unsigned long start_brk, brk, start_stack;
584 unsigned long arg_start, arg_end, env_start, env_end;
586 unsigned long saved_auxv[AT_VECTOR_SIZE]; /* for /proc/PID/auxv */
589 * Special counters, in some configurations protected by the
590 * page_table_lock, in other configurations by being atomic.
592 struct mm_rss_stat rss_stat;
594 struct linux_binfmt *binfmt;
596 /* Architecture-specific MM context */
597 mm_context_t context;
599 unsigned long flags; /* Must use atomic bitops to access */
602 spinlock_t ioctx_lock;
603 struct kioctx_table __rcu *ioctx_table;
607 * "owner" points to a task that is regarded as the canonical
608 * user/owner of this mm. All of the following must be true in
609 * order for it to be changed:
611 * current == mm->owner
613 * new_owner->mm == mm
614 * new_owner->alloc_lock is held
616 struct task_struct __rcu *owner;
618 struct user_namespace *user_ns;
620 /* store ref to file /proc/<pid>/exe symlink points to */
621 struct file __rcu *exe_file;
622 #ifdef CONFIG_MMU_NOTIFIER
623 struct mmu_notifier_subscriptions *notifier_subscriptions;
625 #if defined(CONFIG_TRANSPARENT_HUGEPAGE) && !USE_SPLIT_PMD_PTLOCKS
626 pgtable_t pmd_huge_pte; /* protected by page_table_lock */
628 #ifdef CONFIG_NUMA_BALANCING
630 * numa_next_scan is the next time that the PTEs will be marked
631 * pte_numa. NUMA hinting faults will gather statistics and
632 * migrate pages to new nodes if necessary.
634 unsigned long numa_next_scan;
636 /* Restart point for scanning and setting pte_numa */
637 unsigned long numa_scan_offset;
639 /* numa_scan_seq prevents two threads setting pte_numa */
643 * An operation with batched TLB flushing is going on. Anything
644 * that can move process memory needs to flush the TLB when
645 * moving a PROT_NONE or PROT_NUMA mapped page.
647 atomic_t tlb_flush_pending;
648 #ifdef CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH
649 /* See flush_tlb_batched_pending() */
650 atomic_t tlb_flush_batched;
652 struct uprobes_state uprobes_state;
653 #ifdef CONFIG_PREEMPT_RT
654 struct rcu_head delayed_drop;
656 #ifdef CONFIG_HUGETLB_PAGE
657 atomic_long_t hugetlb_usage;
659 struct work_struct async_put_work;
661 #ifdef CONFIG_IOMMU_SUPPORT
664 } __randomize_layout;
667 * The mm_cpumask needs to be at the end of mm_struct, because it
668 * is dynamically sized based on nr_cpu_ids.
670 unsigned long cpu_bitmap[];
673 extern struct mm_struct init_mm;
675 /* Pointer magic because the dynamic array size confuses some compilers. */
676 static inline void mm_init_cpumask(struct mm_struct *mm)
678 unsigned long cpu_bitmap = (unsigned long)mm;
680 cpu_bitmap += offsetof(struct mm_struct, cpu_bitmap);
681 cpumask_clear((struct cpumask *)cpu_bitmap);
684 /* Future-safe accessor for struct mm_struct's cpu_vm_mask. */
685 static inline cpumask_t *mm_cpumask(struct mm_struct *mm)
687 return (struct cpumask *)&mm->cpu_bitmap;
691 extern void tlb_gather_mmu(struct mmu_gather *tlb, struct mm_struct *mm);
692 extern void tlb_gather_mmu_fullmm(struct mmu_gather *tlb, struct mm_struct *mm);
693 extern void tlb_finish_mmu(struct mmu_gather *tlb);
698 * typedef vm_fault_t - Return type for page fault handlers.
700 * Page fault handlers return a bitmask of %VM_FAULT values.
702 typedef __bitwise unsigned int vm_fault_t;
705 * enum vm_fault_reason - Page fault handlers return a bitmask of
706 * these values to tell the core VM what happened when handling the
707 * fault. Used to decide whether a process gets delivered SIGBUS or
708 * just gets major/minor fault counters bumped up.
710 * @VM_FAULT_OOM: Out Of Memory
711 * @VM_FAULT_SIGBUS: Bad access
712 * @VM_FAULT_MAJOR: Page read from storage
713 * @VM_FAULT_WRITE: Special case for get_user_pages
714 * @VM_FAULT_HWPOISON: Hit poisoned small page
715 * @VM_FAULT_HWPOISON_LARGE: Hit poisoned large page. Index encoded
717 * @VM_FAULT_SIGSEGV: segmentation fault
718 * @VM_FAULT_NOPAGE: ->fault installed the pte, not return page
719 * @VM_FAULT_LOCKED: ->fault locked the returned page
720 * @VM_FAULT_RETRY: ->fault blocked, must retry
721 * @VM_FAULT_FALLBACK: huge page fault failed, fall back to small
722 * @VM_FAULT_DONE_COW: ->fault has fully handled COW
723 * @VM_FAULT_NEEDDSYNC: ->fault did not modify page tables and needs
724 * fsync() to complete (for synchronous page faults
726 * @VM_FAULT_HINDEX_MASK: mask HINDEX value
729 enum vm_fault_reason {
730 VM_FAULT_OOM = (__force vm_fault_t)0x000001,
731 VM_FAULT_SIGBUS = (__force vm_fault_t)0x000002,
732 VM_FAULT_MAJOR = (__force vm_fault_t)0x000004,
733 VM_FAULT_WRITE = (__force vm_fault_t)0x000008,
734 VM_FAULT_HWPOISON = (__force vm_fault_t)0x000010,
735 VM_FAULT_HWPOISON_LARGE = (__force vm_fault_t)0x000020,
736 VM_FAULT_SIGSEGV = (__force vm_fault_t)0x000040,
737 VM_FAULT_NOPAGE = (__force vm_fault_t)0x000100,
738 VM_FAULT_LOCKED = (__force vm_fault_t)0x000200,
739 VM_FAULT_RETRY = (__force vm_fault_t)0x000400,
740 VM_FAULT_FALLBACK = (__force vm_fault_t)0x000800,
741 VM_FAULT_DONE_COW = (__force vm_fault_t)0x001000,
742 VM_FAULT_NEEDDSYNC = (__force vm_fault_t)0x002000,
743 VM_FAULT_HINDEX_MASK = (__force vm_fault_t)0x0f0000,
746 /* Encode hstate index for a hwpoisoned large page */
747 #define VM_FAULT_SET_HINDEX(x) ((__force vm_fault_t)((x) << 16))
748 #define VM_FAULT_GET_HINDEX(x) (((__force unsigned int)(x) >> 16) & 0xf)
750 #define VM_FAULT_ERROR (VM_FAULT_OOM | VM_FAULT_SIGBUS | \
751 VM_FAULT_SIGSEGV | VM_FAULT_HWPOISON | \
752 VM_FAULT_HWPOISON_LARGE | VM_FAULT_FALLBACK)
754 #define VM_FAULT_RESULT_TRACE \
755 { VM_FAULT_OOM, "OOM" }, \
756 { VM_FAULT_SIGBUS, "SIGBUS" }, \
757 { VM_FAULT_MAJOR, "MAJOR" }, \
758 { VM_FAULT_WRITE, "WRITE" }, \
759 { VM_FAULT_HWPOISON, "HWPOISON" }, \
760 { VM_FAULT_HWPOISON_LARGE, "HWPOISON_LARGE" }, \
761 { VM_FAULT_SIGSEGV, "SIGSEGV" }, \
762 { VM_FAULT_NOPAGE, "NOPAGE" }, \
763 { VM_FAULT_LOCKED, "LOCKED" }, \
764 { VM_FAULT_RETRY, "RETRY" }, \
765 { VM_FAULT_FALLBACK, "FALLBACK" }, \
766 { VM_FAULT_DONE_COW, "DONE_COW" }, \
767 { VM_FAULT_NEEDDSYNC, "NEEDDSYNC" }
769 struct vm_special_mapping {
770 const char *name; /* The name, e.g. "[vdso]". */
773 * If .fault is not provided, this points to a
774 * NULL-terminated array of pages that back the special mapping.
776 * This must not be NULL unless .fault is provided.
781 * If non-NULL, then this is called to resolve page faults
782 * on the special mapping. If used, .pages is not checked.
784 vm_fault_t (*fault)(const struct vm_special_mapping *sm,
785 struct vm_area_struct *vma,
786 struct vm_fault *vmf);
788 int (*mremap)(const struct vm_special_mapping *sm,
789 struct vm_area_struct *new_vma);
792 enum tlb_flush_reason {
793 TLB_FLUSH_ON_TASK_SWITCH,
794 TLB_REMOTE_SHOOTDOWN,
796 TLB_LOCAL_MM_SHOOTDOWN,
798 NR_TLB_FLUSH_REASONS,
802 * A swap entry has to fit into a "unsigned long", as the entry is hidden
803 * in the "index" field of the swapper address space.
810 * enum fault_flag - Fault flag definitions.
811 * @FAULT_FLAG_WRITE: Fault was a write fault.
812 * @FAULT_FLAG_MKWRITE: Fault was mkwrite of existing PTE.
813 * @FAULT_FLAG_ALLOW_RETRY: Allow to retry the fault if blocked.
814 * @FAULT_FLAG_RETRY_NOWAIT: Don't drop mmap_lock and wait when retrying.
815 * @FAULT_FLAG_KILLABLE: The fault task is in SIGKILL killable region.
816 * @FAULT_FLAG_TRIED: The fault has been tried once.
817 * @FAULT_FLAG_USER: The fault originated in userspace.
818 * @FAULT_FLAG_REMOTE: The fault is not for current task/mm.
819 * @FAULT_FLAG_INSTRUCTION: The fault was during an instruction fetch.
820 * @FAULT_FLAG_INTERRUPTIBLE: The fault can be interrupted by non-fatal signals.
822 * About @FAULT_FLAG_ALLOW_RETRY and @FAULT_FLAG_TRIED: we can specify
823 * whether we would allow page faults to retry by specifying these two
824 * fault flags correctly. Currently there can be three legal combinations:
826 * (a) ALLOW_RETRY and !TRIED: this means the page fault allows retry, and
827 * this is the first try
829 * (b) ALLOW_RETRY and TRIED: this means the page fault allows retry, and
830 * we've already tried at least once
832 * (c) !ALLOW_RETRY and !TRIED: this means the page fault does not allow retry
834 * The unlisted combination (!ALLOW_RETRY && TRIED) is illegal and should never
835 * be used. Note that page faults can be allowed to retry for multiple times,
836 * in which case we'll have an initial fault with flags (a) then later on
837 * continuous faults with flags (b). We should always try to detect pending
838 * signals before a retry to make sure the continuous page faults can still be
839 * interrupted if necessary.
842 FAULT_FLAG_WRITE = 1 << 0,
843 FAULT_FLAG_MKWRITE = 1 << 1,
844 FAULT_FLAG_ALLOW_RETRY = 1 << 2,
845 FAULT_FLAG_RETRY_NOWAIT = 1 << 3,
846 FAULT_FLAG_KILLABLE = 1 << 4,
847 FAULT_FLAG_TRIED = 1 << 5,
848 FAULT_FLAG_USER = 1 << 6,
849 FAULT_FLAG_REMOTE = 1 << 7,
850 FAULT_FLAG_INSTRUCTION = 1 << 8,
851 FAULT_FLAG_INTERRUPTIBLE = 1 << 9,
854 #endif /* _LINUX_MM_TYPES_H */