blob: 8d37e26a1007c6493990093e7ce8a03f2b201419 [file] [log] [blame]
Heiko Carstens5b99cd02006-09-27 01:50:01 -07001#ifndef _LINUX_MM_TYPES_H
2#define _LINUX_MM_TYPES_H
3
Olaf Hering4f9a58d2007-10-16 23:30:12 -07004#include <linux/auxvec.h>
Heiko Carstens5b99cd02006-09-27 01:50:01 -07005#include <linux/types.h>
6#include <linux/threads.h>
7#include <linux/list.h>
8#include <linux/spinlock.h>
Martin Schwidefskyc92ff1b2007-10-16 01:24:43 -07009#include <linux/rbtree.h>
10#include <linux/rwsem.h>
11#include <linux/completion.h>
Andrea Arcangelicddb8a52008-07-28 15:46:29 -070012#include <linux/cpumask.h>
Srikar Dronamrajud4b3b632012-03-30 23:56:31 +053013#include <linux/uprobes.h>
Peter Zijlstrabbeae5b2013-02-22 16:34:30 -080014#include <linux/page-flags-layout.h>
Martin Schwidefskyc92ff1b2007-10-16 01:24:43 -070015#include <asm/page.h>
16#include <asm/mmu.h>
Heiko Carstens5b99cd02006-09-27 01:50:01 -070017
Olaf Hering4f9a58d2007-10-16 23:30:12 -070018#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
Heiko Carstens5b99cd02006-09-27 01:50:01 -070023struct address_space;
Johannes Weiner1306a852014-12-10 15:44:52 -080024struct mem_cgroup;
Heiko Carstens5b99cd02006-09-27 01:50:01 -070025
Kirill A. Shutemov57c1ffc2013-11-14 14:30:45 -080026#define USE_SPLIT_PTE_PTLOCKS (NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS)
Kirill A. Shutemove009bb32013-11-14 14:31:07 -080027#define USE_SPLIT_PMD_PTLOCKS (USE_SPLIT_PTE_PTLOCKS && \
28 IS_ENABLED(CONFIG_ARCH_ENABLE_SPLIT_PMD_PTLOCK))
Kirill A. Shutemov597d7952013-12-20 13:35:58 +020029#define ALLOC_SPLIT_PTLOCKS (SPINLOCK_SIZE > BITS_PER_LONG/8)
Jeremy Fitzhardingef7d0b922008-09-09 15:43:22 -070030
Kirill A. Shutemove4b294c2015-02-11 15:24:46 -080031typedef void compound_page_dtor(struct page *);
32
Heiko Carstens5b99cd02006-09-27 01:50:01 -070033/*
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
38 * who is mapping it.
Christoph Lameterfc9bb8c2011-06-01 12:25:48 -050039 *
40 * The objects in struct page are organized in double word blocks in
41 * order to allows us to use atomic double word operations on portions
42 * of struct page. That is currently only used by slub but the arrangement
43 * allows the use of atomic double word operations on the flags/mapping
44 * and lru list pointers also.
Heiko Carstens5b99cd02006-09-27 01:50:01 -070045 */
46struct page {
Christoph Lameterfc9bb8c2011-06-01 12:25:48 -050047 /* First double word block */
Heiko Carstens5b99cd02006-09-27 01:50:01 -070048 unsigned long flags; /* Atomic flags, some possibly
49 * updated asynchronously */
Joonsoo Kim8456a642013-10-24 10:07:49 +090050 union {
51 struct address_space *mapping; /* If low bit clear, points to
52 * inode address_space, or NULL.
53 * If page mapped as anonymous
54 * memory, low bit is set, and
55 * it points to anon_vma object:
56 * see PAGE_MAPPING_ANON below.
57 */
58 void *s_mem; /* slab first object */
59 };
60
Christoph Lameterfc9bb8c2011-06-01 12:25:48 -050061 /* Second double word */
Christoph Lameter013e8962011-07-14 12:48:14 -050062 struct {
63 union {
Christoph Lameterfc9bb8c2011-06-01 12:25:48 -050064 pgoff_t index; /* Our offset within mapping. */
Joonsoo Kim8456a642013-10-24 10:07:49 +090065 void *freelist; /* sl[aou]b first free object */
Mel Gorman072bb0a2012-07-31 16:43:58 -070066 bool pfmemalloc; /* If set by the page allocator,
Mel Gormanb37f1dd2012-07-31 16:44:03 -070067 * ALLOC_NO_WATERMARKS was set
Mel Gorman072bb0a2012-07-31 16:43:58 -070068 * and the low watermark was not
69 * met implying that the system
70 * is under some pressure. The
71 * caller should try ensure
72 * this page is only used to
73 * free other pages.
74 */
Christoph Lameter013e8962011-07-14 12:48:14 -050075 };
76
77 union {
Pravin B Shelarabca7c42012-06-20 12:52:56 -070078#if defined(CONFIG_HAVE_CMPXCHG_DOUBLE) && \
79 defined(CONFIG_HAVE_ALIGNED_STRUCT_PAGE)
Christoph Lameter013e8962011-07-14 12:48:14 -050080 /* Used for cmpxchg_double in slub */
81 unsigned long counters;
Pravin B Shelarabca7c42012-06-20 12:52:56 -070082#else
83 /*
84 * Keep _count separate from slub cmpxchg_double data.
85 * As the rest of the double word is protected by
86 * slab_lock but _count is not.
87 */
88 unsigned counters;
89#endif
Christoph Lameter013e8962011-07-14 12:48:14 -050090
91 struct {
92
93 union {
Andrea Arcangeli70b50f92011-11-02 13:36:59 -070094 /*
95 * Count of ptes mapped in
96 * mms, to show when page is
97 * mapped & limit reverse map
98 * searches.
99 *
100 * Used also for tail pages
101 * refcounting instead of
102 * _count. Tail pages cannot
103 * be mapped and keeping the
104 * tail page _count zero at
105 * all times guarantees
106 * get_page_unless_zero() will
107 * never succeed on tail
108 * pages.
109 */
110 atomic_t _mapcount;
Christoph Lameterfc9bb8c2011-06-01 12:25:48 -0500111
Christoph Lameterb8c24c42012-06-13 10:24:52 -0500112 struct { /* SLUB */
Christoph Lameter013e8962011-07-14 12:48:14 -0500113 unsigned inuse:16;
114 unsigned objects:15;
115 unsigned frozen:1;
116 };
Christoph Lameterb8c24c42012-06-13 10:24:52 -0500117 int units; /* SLOB */
Pekka Enberg3adf0042011-07-18 15:16:55 +0300118 };
Christoph Lameter013e8962011-07-14 12:48:14 -0500119 atomic_t _count; /* Usage count, see below. */
Christoph Lameterfc9bb8c2011-06-01 12:25:48 -0500120 };
Joonsoo Kim8456a642013-10-24 10:07:49 +0900121 unsigned int active; /* SLAB */
Christoph Lameter39b26462008-04-14 19:11:30 +0300122 };
Christoph Lameter81819f02007-05-06 14:49:36 -0700123 };
Christoph Lameterfc9bb8c2011-06-01 12:25:48 -0500124
125 /* Third double word block */
Christoph Lameter49e22582011-08-09 16:12:27 -0500126 union {
127 struct list_head lru; /* Pageout list, eg. active_list
Christoph Lameterfc9bb8c2011-06-01 12:25:48 -0500128 * protected by zone->lru_lock !
Dave Hansen34bf6ef2014-04-08 13:44:27 -0700129 * Can be used as a generic list
130 * by the page owner.
Christoph Lameterfc9bb8c2011-06-01 12:25:48 -0500131 */
Christoph Lameter49e22582011-08-09 16:12:27 -0500132 struct { /* slub per cpu partial pages */
133 struct page *next; /* Next partial slab */
134#ifdef CONFIG_64BIT
135 int pages; /* Nr of partial slabs left */
136 int pobjects; /* Approximate # of objects */
137#else
138 short int pages;
139 short int pobjects;
140#endif
141 };
Christoph Lameterb8c24c42012-06-13 10:24:52 -0500142
Glauber Costa1b4f59e32012-10-22 18:05:36 +0400143 struct slab *slab_page; /* slab fields */
Joonsoo Kim68126702013-10-24 10:07:42 +0900144 struct rcu_head rcu_head; /* Used by SLAB
145 * when destroying via RCU
146 */
Kirill A. Shutemove4b294c2015-02-11 15:24:46 -0800147 /* First tail page of compound page */
148 struct {
149 compound_page_dtor *compound_dtor;
150 unsigned long compound_order;
151 };
152
Kirill A. Shutemov7aa555b2013-11-21 14:32:11 -0800153#if defined(CONFIG_TRANSPARENT_HUGEPAGE) && USE_SPLIT_PMD_PTLOCKS
154 pgtable_t pmd_huge_pte; /* protected by page->ptl */
155#endif
Christoph Lameter49e22582011-08-09 16:12:27 -0500156 };
Christoph Lameterfc9bb8c2011-06-01 12:25:48 -0500157
158 /* Remainder is not double word aligned */
Heiko Carstens5b99cd02006-09-27 01:50:01 -0700159 union {
Heiko Carstens5b99cd02006-09-27 01:50:01 -0700160 unsigned long private; /* Mapping-private opaque data:
161 * usually used for buffer_heads
162 * if PagePrivate set; used for
163 * swp_entry_t if PageSwapCache;
164 * indicates order in the buddy
165 * system if PG_buddy is set.
166 */
Kirill A. Shutemov57c1ffc2013-11-14 14:30:45 -0800167#if USE_SPLIT_PTE_PTLOCKS
Kirill A. Shutemov597d7952013-12-20 13:35:58 +0200168#if ALLOC_SPLIT_PTLOCKS
Peter Zijlstra539edb52013-11-14 14:31:52 -0800169 spinlock_t *ptl;
170#else
171 spinlock_t ptl;
172#endif
Heiko Carstens5b99cd02006-09-27 01:50:01 -0700173#endif
Glauber Costa1b4f59e32012-10-22 18:05:36 +0400174 struct kmem_cache *slab_cache; /* SL[AU]B: Pointer to slab */
Christoph Lameterfc9bb8c2011-06-01 12:25:48 -0500175 struct page *first_page; /* Compound tail pages */
Heiko Carstens5b99cd02006-09-27 01:50:01 -0700176 };
Christoph Lameterfc9bb8c2011-06-01 12:25:48 -0500177
Johannes Weiner1306a852014-12-10 15:44:52 -0800178#ifdef CONFIG_MEMCG
179 struct mem_cgroup *mem_cgroup;
180#endif
181
Heiko Carstens5b99cd02006-09-27 01:50:01 -0700182 /*
183 * On machines where all RAM is mapped into kernel address space,
184 * we can simply calculate the virtual address. On machines with
185 * highmem some memory is mapped into kernel virtual memory
186 * dynamically, so we need a place to store that address.
187 * Note that this field could be 16 bits on x86 ... ;)
188 *
189 * Architectures with slow multiplication can define
190 * WANT_PAGE_VIRTUAL in asm/page.h
191 */
192#if defined(WANT_PAGE_VIRTUAL)
193 void *virtual; /* Kernel virtual address (NULL if
194 not kmapped, ie. highmem) */
195#endif /* WANT_PAGE_VIRTUAL */
Vegard Nossumdfec0722008-04-04 00:51:41 +0200196
197#ifdef CONFIG_KMEMCHECK
198 /*
199 * kmemcheck wants to track the status of each byte in a page; this
200 * is a pointer to such a status block. NULL if not tracked.
201 */
202 void *shadow;
203#endif
Mel Gorman57e0a032012-11-12 09:06:20 +0000204
Peter Zijlstra90572892013-10-07 11:29:20 +0100205#ifdef LAST_CPUPID_NOT_IN_PAGE_FLAGS
206 int _last_cpupid;
Mel Gorman57e0a032012-11-12 09:06:20 +0000207#endif
Christoph Lameterfc9bb8c2011-06-01 12:25:48 -0500208}
209/*
Heiko Carstens43570fd2012-01-12 17:17:27 -0800210 * The struct page can be forced to be double word aligned so that atomic ops
211 * on double words work. The SLUB allocator can make use of such a feature.
Christoph Lameterfc9bb8c2011-06-01 12:25:48 -0500212 */
Heiko Carstens43570fd2012-01-12 17:17:27 -0800213#ifdef CONFIG_HAVE_ALIGNED_STRUCT_PAGE
214 __aligned(2 * sizeof(unsigned long))
Christoph Lameterfc9bb8c2011-06-01 12:25:48 -0500215#endif
216;
Heiko Carstens5b99cd02006-09-27 01:50:01 -0700217
Ian Campbell30d3c122011-10-20 04:58:32 -0400218struct page_frag {
219 struct page *page;
220#if (BITS_PER_LONG > 32) || (PAGE_SIZE >= 65536)
221 __u32 offset;
222 __u32 size;
223#else
224 __u16 offset;
225 __u16 size;
226#endif
227};
228
KOSAKI Motohiroca16d142011-05-26 19:16:19 +0900229typedef unsigned long __nocast vm_flags_t;
230
Martin Schwidefskyc92ff1b2007-10-16 01:24:43 -0700231/*
David Howells8feae132009-01-08 12:04:47 +0000232 * A region containing a mapping of a non-memory backed file under NOMMU
233 * conditions. These are held in a global tree and are pinned by the VMAs that
234 * map parts of them.
235 */
236struct vm_region {
237 struct rb_node vm_rb; /* link in global region tree */
KOSAKI Motohiroca16d142011-05-26 19:16:19 +0900238 vm_flags_t vm_flags; /* VMA vm_flags */
David Howells8feae132009-01-08 12:04:47 +0000239 unsigned long vm_start; /* start address of region */
240 unsigned long vm_end; /* region initialised to here */
Paul Mundtdd8632a2009-01-08 12:04:47 +0000241 unsigned long vm_top; /* region allocated to here */
David Howells8feae132009-01-08 12:04:47 +0000242 unsigned long vm_pgoff; /* the offset in vm_file corresponding to vm_start */
243 struct file *vm_file; /* the backing file or NULL */
244
David Howells1e2ae592010-01-15 17:01:33 -0800245 int vm_usage; /* region usage count (access under nommu_region_sem) */
Mike Frysingercfe79c02010-01-06 17:23:23 +0000246 bool vm_icache_flushed : 1; /* true if the icache has been flushed for
247 * this region */
David Howells8feae132009-01-08 12:04:47 +0000248};
249
250/*
Martin Schwidefskyc92ff1b2007-10-16 01:24:43 -0700251 * This struct defines a memory VMM memory area. There is one of these
252 * per VM-area/task. A VM area is any part of the process virtual memory
253 * space that has a special rule for the page-fault handlers (ie a shared
254 * library, the executable area etc).
255 */
256struct vm_area_struct {
Rik van Riele4c6bfd2012-12-11 16:01:44 -0800257 /* The first cache line has the info for VMA tree walking. */
258
Martin Schwidefskyc92ff1b2007-10-16 01:24:43 -0700259 unsigned long vm_start; /* Our start address within vm_mm. */
260 unsigned long vm_end; /* The first byte after our end address
261 within vm_mm. */
262
263 /* linked list of VM areas per task, sorted by address */
Linus Torvalds297c5ee2010-08-20 16:24:55 -0700264 struct vm_area_struct *vm_next, *vm_prev;
Martin Schwidefskyc92ff1b2007-10-16 01:24:43 -0700265
Martin Schwidefskyc92ff1b2007-10-16 01:24:43 -0700266 struct rb_node vm_rb;
267
268 /*
Michel Lespinassed3737182012-12-11 16:01:38 -0800269 * Largest free memory gap in bytes to the left of this VMA.
270 * Either between this VMA and vma->vm_prev, or between one of the
271 * VMAs below us in the VMA rbtree and its ->vm_prev. This helps
272 * get_unmapped_area find a free area of the right size.
273 */
274 unsigned long rb_subtree_gap;
275
Rik van Riele4c6bfd2012-12-11 16:01:44 -0800276 /* Second cache line starts here. */
277
278 struct mm_struct *vm_mm; /* The address space we belong to. */
279 pgprot_t vm_page_prot; /* Access permissions of this VMA. */
280 unsigned long vm_flags; /* Flags, see mm.h. */
281
Michel Lespinassed3737182012-12-11 16:01:38 -0800282 /*
Martin Schwidefskyc92ff1b2007-10-16 01:24:43 -0700283 * For areas with an address space and backing store,
Kirill A. Shutemov27ba0642015-02-10 14:09:59 -0800284 * linkage into the address_space->i_mmap interval tree.
Martin Schwidefskyc92ff1b2007-10-16 01:24:43 -0700285 */
Kirill A. Shutemovac51b932015-02-10 14:10:02 -0800286 struct {
287 struct rb_node rb;
288 unsigned long rb_subtree_last;
Martin Schwidefskyc92ff1b2007-10-16 01:24:43 -0700289 } shared;
290
291 /*
292 * A file's MAP_PRIVATE vma can be in both i_mmap tree and anon_vma
293 * list, after a COW of one of the file pages. A MAP_SHARED vma
294 * can only be in the i_mmap tree. An anonymous MAP_PRIVATE, stack
295 * or brk vma (with NULL file) can only be in an anon_vma list.
296 */
Rik van Riel5beb4932010-03-05 13:42:07 -0800297 struct list_head anon_vma_chain; /* Serialized by mmap_sem &
298 * page_table_lock */
Martin Schwidefskyc92ff1b2007-10-16 01:24:43 -0700299 struct anon_vma *anon_vma; /* Serialized by page_table_lock */
300
301 /* Function pointers to deal with this struct. */
Alexey Dobriyanf0f37e22009-09-27 22:29:37 +0400302 const struct vm_operations_struct *vm_ops;
Martin Schwidefskyc92ff1b2007-10-16 01:24:43 -0700303
304 /* Information about our backing store: */
305 unsigned long vm_pgoff; /* Offset (within vm_file) in PAGE_SIZE
306 units, *not* PAGE_CACHE_SIZE */
307 struct file * vm_file; /* File we map to (can be NULL). */
308 void * vm_private_data; /* was vm_pte (shared mem) */
Martin Schwidefskyc92ff1b2007-10-16 01:24:43 -0700309
310#ifndef CONFIG_MMU
David Howells8feae132009-01-08 12:04:47 +0000311 struct vm_region *vm_region; /* NOMMU mapping region */
Martin Schwidefskyc92ff1b2007-10-16 01:24:43 -0700312#endif
313#ifdef CONFIG_NUMA
314 struct mempolicy *vm_policy; /* NUMA policy for the VMA */
315#endif
316};
317
Oleg Nesterovb564daf2008-07-25 01:47:44 -0700318struct core_thread {
319 struct task_struct *task;
320 struct core_thread *next;
321};
322
Oleg Nesterov32ecb1f2008-07-25 01:47:41 -0700323struct core_state {
Oleg Nesterovc5f1cc82008-07-25 01:47:42 -0700324 atomic_t nr_threads;
Oleg Nesterovb564daf2008-07-25 01:47:44 -0700325 struct core_thread dumper;
Oleg Nesterov32ecb1f2008-07-25 01:47:41 -0700326 struct completion startup;
327};
328
KAMEZAWA Hiroyukid559db02010-03-05 13:41:39 -0800329enum {
330 MM_FILEPAGES,
331 MM_ANONPAGES,
KAMEZAWA Hiroyukib084d432010-03-05 13:41:42 -0800332 MM_SWAPENTS,
KAMEZAWA Hiroyukid559db02010-03-05 13:41:39 -0800333 NR_MM_COUNTERS
334};
335
Kirill A. Shutemov57c1ffc2013-11-14 14:30:45 -0800336#if USE_SPLIT_PTE_PTLOCKS && defined(CONFIG_MMU)
KAMEZAWA Hiroyuki34e55232010-03-05 13:41:40 -0800337#define SPLIT_RSS_COUNTING
KAMEZAWA Hiroyuki34e55232010-03-05 13:41:40 -0800338/* per-thread cached information, */
339struct task_rss_stat {
340 int events; /* for synchronization threshold */
341 int count[NR_MM_COUNTERS];
342};
Kirill A. Shutemov57c1ffc2013-11-14 14:30:45 -0800343#endif /* USE_SPLIT_PTE_PTLOCKS */
Matt Fleming172703b2011-05-24 17:12:36 -0700344
KAMEZAWA Hiroyukid559db02010-03-05 13:41:39 -0800345struct mm_rss_stat {
Matt Fleming172703b2011-05-24 17:12:36 -0700346 atomic_long_t count[NR_MM_COUNTERS];
KAMEZAWA Hiroyukid559db02010-03-05 13:41:39 -0800347};
KAMEZAWA Hiroyukid559db02010-03-05 13:41:39 -0800348
Benjamin LaHaisedb446a02013-07-30 12:54:40 -0400349struct kioctx_table;
Martin Schwidefskyc92ff1b2007-10-16 01:24:43 -0700350struct mm_struct {
Davidlohr Bueso615d6e82014-04-07 15:37:25 -0700351 struct vm_area_struct *mmap; /* list of VMAs */
Martin Schwidefskyc92ff1b2007-10-16 01:24:43 -0700352 struct rb_root mm_rb;
Davidlohr Bueso615d6e82014-04-07 15:37:25 -0700353 u32 vmacache_seqnum; /* per-thread vmacache */
David Howellsefc1a3b2010-01-15 17:01:35 -0800354#ifdef CONFIG_MMU
Martin Schwidefskyc92ff1b2007-10-16 01:24:43 -0700355 unsigned long (*get_unmapped_area) (struct file *filp,
356 unsigned long addr, unsigned long len,
357 unsigned long pgoff, unsigned long flags);
David Howellsefc1a3b2010-01-15 17:01:35 -0800358#endif
Martin Schwidefskyc92ff1b2007-10-16 01:24:43 -0700359 unsigned long mmap_base; /* base of mmap area */
Radu Caragea41aacc12013-08-21 20:55:59 +0300360 unsigned long mmap_legacy_base; /* base of mmap area in bottom-up allocations */
Martin Schwidefskyc92ff1b2007-10-16 01:24:43 -0700361 unsigned long task_size; /* size of task vm space */
Michel Lespinassed3737182012-12-11 16:01:38 -0800362 unsigned long highest_vm_end; /* highest vma end address */
Martin Schwidefskyc92ff1b2007-10-16 01:24:43 -0700363 pgd_t * pgd;
364 atomic_t mm_users; /* How many users with user space? */
365 atomic_t mm_count; /* How many references to "struct mm_struct" (users count as 1) */
Kirill A. Shutemovdc6c9a32015-02-11 15:26:50 -0800366 atomic_long_t nr_ptes; /* PTE page table pages */
Kirill A. Shutemov5a3fbef2015-04-14 15:46:21 -0700367#if CONFIG_PGTABLE_LEVELS > 2
Kirill A. Shutemovdc6c9a32015-02-11 15:26:50 -0800368 atomic_long_t nr_pmds; /* PMD page table pages */
Kirill A. Shutemov5a3fbef2015-04-14 15:46:21 -0700369#endif
Martin Schwidefskyc92ff1b2007-10-16 01:24:43 -0700370 int map_count; /* number of VMAs */
Richard Kennedy481b4bb2011-03-22 16:32:50 -0700371
Martin Schwidefskyc92ff1b2007-10-16 01:24:43 -0700372 spinlock_t page_table_lock; /* Protects page tables and some counters */
Richard Kennedy481b4bb2011-03-22 16:32:50 -0700373 struct rw_semaphore mmap_sem;
Martin Schwidefskyc92ff1b2007-10-16 01:24:43 -0700374
375 struct list_head mmlist; /* List of maybe swapped mm's. These are globally strung
376 * together off init_mm.mmlist, and are protected
377 * by mmlist_lock
378 */
379
Martin Schwidefskyc92ff1b2007-10-16 01:24:43 -0700380
381 unsigned long hiwater_rss; /* High-watermark of RSS usage */
382 unsigned long hiwater_vm; /* High-water virtual memory usage */
383
Christoph Lametere10d59f2011-10-31 17:07:34 -0700384 unsigned long total_vm; /* Total pages mapped */
385 unsigned long locked_vm; /* Pages that have PG_mlocked set */
386 unsigned long pinned_vm; /* Refcount permanently increased */
387 unsigned long shared_vm; /* Shared pages (files) */
388 unsigned long exec_vm; /* VM_EXEC & ~VM_WRITE */
389 unsigned long stack_vm; /* VM_GROWSUP/DOWN */
Christoph Lametere10d59f2011-10-31 17:07:34 -0700390 unsigned long def_flags;
Martin Schwidefskyc92ff1b2007-10-16 01:24:43 -0700391 unsigned long start_code, end_code, start_data, end_data;
392 unsigned long start_brk, brk, start_stack;
393 unsigned long arg_start, arg_end, env_start, env_end;
394
395 unsigned long saved_auxv[AT_VECTOR_SIZE]; /* for /proc/PID/auxv */
396
KAMEZAWA Hiroyukid559db02010-03-05 13:41:39 -0800397 /*
398 * Special counters, in some configurations protected by the
399 * page_table_lock, in other configurations by being atomic.
400 */
401 struct mm_rss_stat rss_stat;
402
Hiroshi Shimamoto801460d2009-09-23 15:57:41 -0700403 struct linux_binfmt *binfmt;
404
Linus Torvalds6345d242011-05-29 11:32:28 -0700405 cpumask_var_t cpu_vm_mask_var;
406
Martin Schwidefskyc92ff1b2007-10-16 01:24:43 -0700407 /* Architecture-specific MM context */
408 mm_context_t context;
409
Martin Schwidefskyc92ff1b2007-10-16 01:24:43 -0700410 unsigned long flags; /* Must use atomic bitops to access the bits */
411
Oleg Nesterova94e2d42008-07-25 01:47:46 -0700412 struct core_state *core_state; /* coredumping support */
Alexey Dobriyan858f0992009-09-23 15:57:32 -0700413#ifdef CONFIG_AIO
Benjamin LaHaisedb446a02013-07-30 12:54:40 -0400414 spinlock_t ioctx_lock;
415 struct kioctx_table __rcu *ioctx_table;
Alexey Dobriyan858f0992009-09-23 15:57:32 -0700416#endif
Oleg Nesterovf98bafa2014-06-04 16:07:34 -0700417#ifdef CONFIG_MEMCG
KOSAKI Motohiro4cd1a8f2008-05-12 14:02:31 -0700418 /*
419 * "owner" points to a task that is regarded as the canonical
420 * user/owner of this mm. All of the following must be true in
421 * order for it to be changed:
422 *
423 * current == mm->owner
424 * current->mm != mm
425 * new_owner->mm == mm
426 * new_owner->alloc_lock is held
427 */
Arnd Bergmann4d2deb42010-02-24 20:01:56 +0100428 struct task_struct __rcu *owner;
Pavel Emelianov78fb7462008-02-07 00:13:51 -0800429#endif
Matt Helsley925d1c42008-04-29 01:01:36 -0700430
Matt Helsley925d1c42008-04-29 01:01:36 -0700431 /* store ref to file /proc/<pid>/exe symlink points to */
Konstantin Khlebnikov90f31d02015-04-16 12:47:56 -0700432 struct file __rcu *exe_file;
Andrea Arcangelicddb8a52008-07-28 15:46:29 -0700433#ifdef CONFIG_MMU_NOTIFIER
434 struct mmu_notifier_mm *mmu_notifier_mm;
435#endif
Kirill A. Shutemove009bb32013-11-14 14:31:07 -0800436#if defined(CONFIG_TRANSPARENT_HUGEPAGE) && !USE_SPLIT_PMD_PTLOCKS
Andrea Arcangelie7a00c42011-01-13 15:46:45 -0800437 pgtable_t pmd_huge_pte; /* protected by page_table_lock */
438#endif
Linus Torvalds6345d242011-05-29 11:32:28 -0700439#ifdef CONFIG_CPUMASK_OFFSTACK
440 struct cpumask cpumask_allocation;
441#endif
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200442#ifdef CONFIG_NUMA_BALANCING
443 /*
Mel Gorman34f03152013-02-22 16:34:25 -0800444 * numa_next_scan is the next time that the PTEs will be marked
445 * pte_numa. NUMA hinting faults will gather statistics and migrate
446 * pages to new nodes if necessary.
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200447 */
448 unsigned long numa_next_scan;
449
Peter Zijlstra6e5fb222012-10-25 14:16:45 +0200450 /* Restart point for scanning and setting pte_numa */
451 unsigned long numa_scan_offset;
452
Peter Zijlstracbee9f82012-10-25 14:16:43 +0200453 /* numa_scan_seq prevents two threads setting pte_numa */
454 int numa_scan_seq;
455#endif
Rik van Riel20841402013-12-18 17:08:44 -0800456#if defined(CONFIG_NUMA_BALANCING) || defined(CONFIG_COMPACTION)
457 /*
458 * An operation with batched TLB flushing is going on. Anything that
459 * can move process memory needs to flush the TLB when moving a
460 * PROT_NONE or PROT_NUMA mapped page.
461 */
462 bool tlb_flush_pending;
463#endif
Srikar Dronamrajud4b3b632012-03-30 23:56:31 +0530464 struct uprobes_state uprobes_state;
Dave Hansenfe3d1972014-11-14 07:18:29 -0800465#ifdef CONFIG_X86_INTEL_MPX
466 /* address of the bounds directory */
467 void __user *bd_addr;
468#endif
Martin Schwidefskyc92ff1b2007-10-16 01:24:43 -0700469};
470
Linus Torvalds6345d242011-05-29 11:32:28 -0700471static inline void mm_init_cpumask(struct mm_struct *mm)
472{
473#ifdef CONFIG_CPUMASK_OFFSTACK
474 mm->cpu_vm_mask_var = &mm->cpumask_allocation;
475#endif
Vladimir Davydov41f727f2014-08-08 14:21:56 -0700476 cpumask_clear(mm->cpu_vm_mask_var);
Linus Torvalds6345d242011-05-29 11:32:28 -0700477}
478
Rusty Russell45e575a2009-03-12 14:35:44 -0600479/* Future-safe accessor for struct mm_struct's cpu_vm_mask. */
KOSAKI Motohirode03c722011-05-24 17:12:15 -0700480static inline cpumask_t *mm_cpumask(struct mm_struct *mm)
481{
482 return mm->cpu_vm_mask_var;
483}
Rusty Russell45e575a2009-03-12 14:35:44 -0600484
Rik van Riel20841402013-12-18 17:08:44 -0800485#if defined(CONFIG_NUMA_BALANCING) || defined(CONFIG_COMPACTION)
486/*
487 * Memory barriers to keep this state in sync are graciously provided by
488 * the page table locks, outside of which no page table modifications happen.
489 * The barriers below prevent the compiler from re-ordering the instructions
490 * around the memory barriers that are already present in the code.
491 */
492static inline bool mm_tlb_flush_pending(struct mm_struct *mm)
493{
494 barrier();
495 return mm->tlb_flush_pending;
496}
497static inline void set_tlb_flush_pending(struct mm_struct *mm)
498{
499 mm->tlb_flush_pending = true;
Mel Gormanaf2c1402013-12-18 17:08:45 -0800500
501 /*
502 * Guarantee that the tlb_flush_pending store does not leak into the
503 * critical section updating the page tables
504 */
505 smp_mb__before_spinlock();
Rik van Riel20841402013-12-18 17:08:44 -0800506}
507/* Clearing is done after a TLB flush, which also provides a barrier. */
508static inline void clear_tlb_flush_pending(struct mm_struct *mm)
509{
510 barrier();
511 mm->tlb_flush_pending = false;
512}
513#else
514static inline bool mm_tlb_flush_pending(struct mm_struct *mm)
515{
516 return false;
517}
518static inline void set_tlb_flush_pending(struct mm_struct *mm)
519{
520}
521static inline void clear_tlb_flush_pending(struct mm_struct *mm)
522{
523}
524#endif
525
Andy Lutomirskia62c34b2014-05-19 15:58:33 -0700526struct vm_special_mapping
527{
528 const char *name;
529 struct page **pages;
530};
531
Dave Hansend17d8f92014-07-31 08:40:59 -0700532enum tlb_flush_reason {
533 TLB_FLUSH_ON_TASK_SWITCH,
534 TLB_REMOTE_SHOOTDOWN,
535 TLB_LOCAL_SHOOTDOWN,
536 TLB_LOCAL_MM_SHOOTDOWN,
537 NR_TLB_FLUSH_REASONS,
538};
539
Tejun Heobd6dace2014-12-12 16:55:35 -0800540 /*
541 * A swap entry has to fit into a "unsigned long", as the entry is hidden
542 * in the "index" field of the swapper address space.
543 */
544typedef struct {
545 unsigned long val;
546} swp_entry_t;
547
Heiko Carstens5b99cd02006-09-27 01:50:01 -0700548#endif /* _LINUX_MM_TYPES_H */