1 #ifndef _LINUX_MM_TYPES_H
2 #define _LINUX_MM_TYPES_H
4 #include <linux/auxvec.h>
5 #include <linux/types.h>
6 #include <linux/threads.h>
7 #include <linux/list.h>
8 #include <linux/spinlock.h>
9 #include <linux/prio_tree.h>
10 #include <linux/rbtree.h>
11 #include <linux/rwsem.h>
12 #include <linux/completion.h>
13 #include <linux/cpumask.h>
14 #include <linux/page-debug-flags.h>
18 #ifndef AT_VECTOR_SIZE_ARCH
19 #define AT_VECTOR_SIZE_ARCH 0
21 #define AT_VECTOR_SIZE (2*(AT_VECTOR_SIZE_ARCH + AT_VECTOR_SIZE_BASE + 1))
25 #define USE_SPLIT_PTLOCKS (NR_CPUS >= CONFIG_SPLIT_PTLOCK_CPUS)
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
35 unsigned long flags
; /* Atomic flags, some possibly
36 * updated asynchronously */
37 atomic_t _count
; /* Usage count, see below. */
39 atomic_t _mapcount
; /* Count of ptes mapped in mms,
40 * to show when page is mapped
41 * & limit reverse map searches.
50 unsigned long private; /* Mapping-private opaque data:
51 * usually used for buffer_heads
52 * if PagePrivate set; used for
53 * swp_entry_t if PageSwapCache;
54 * indicates order in the buddy
55 * system if PG_buddy is set.
57 struct address_space
*mapping
; /* If low bit clear, points to
58 * inode address_space, or NULL.
59 * If page mapped as anonymous
60 * memory, low bit is set, and
61 * it points to anon_vma object:
62 * see PAGE_MAPPING_ANON below.
68 struct kmem_cache
*slab
; /* SLUB: Pointer to slab */
69 struct page
*first_page
; /* Compound tail pages */
72 pgoff_t index
; /* Our offset within mapping. */
73 void *freelist
; /* SLUB: freelist req. slab lock */
75 struct list_head lru
; /* Pageout list, eg. active_list
76 * protected by zone->lru_lock !
79 * On machines where all RAM is mapped into kernel address space,
80 * we can simply calculate the virtual address. On machines with
81 * highmem some memory is mapped into kernel virtual memory
82 * dynamically, so we need a place to store that address.
83 * Note that this field could be 16 bits on x86 ... ;)
85 * Architectures with slow multiplication can define
86 * WANT_PAGE_VIRTUAL in asm/page.h
88 #if defined(WANT_PAGE_VIRTUAL)
89 void *virtual; /* Kernel virtual address (NULL if
90 not kmapped, ie. highmem) */
91 #endif /* WANT_PAGE_VIRTUAL */
92 #ifdef CONFIG_WANT_PAGE_DEBUG_FLAGS
93 unsigned long debug_flags
; /* Use atomic bitops on this */
96 #ifdef CONFIG_KMEMCHECK
98 * kmemcheck wants to track the status of each byte in a page; this
99 * is a pointer to such a status block. NULL if not tracked.
105 typedef unsigned long __nocast vm_flags_t
;
108 * A region containing a mapping of a non-memory backed file under NOMMU
109 * conditions. These are held in a global tree and are pinned by the VMAs that
113 struct rb_node vm_rb
; /* link in global region tree */
114 vm_flags_t vm_flags
; /* VMA vm_flags */
115 unsigned long vm_start
; /* start address of region */
116 unsigned long vm_end
; /* region initialised to here */
117 unsigned long vm_top
; /* region allocated to here */
118 unsigned long vm_pgoff
; /* the offset in vm_file corresponding to vm_start */
119 struct file
*vm_file
; /* the backing file or NULL */
121 int vm_usage
; /* region usage count (access under nommu_region_sem) */
122 bool vm_icache_flushed
: 1; /* true if the icache has been flushed for
127 * This struct defines a memory VMM memory area. There is one of these
128 * per VM-area/task. A VM area is any part of the process virtual memory
129 * space that has a special rule for the page-fault handlers (ie a shared
130 * library, the executable area etc).
132 struct vm_area_struct
{
133 struct mm_struct
* vm_mm
; /* The address space we belong to. */
134 unsigned long vm_start
; /* Our start address within vm_mm. */
135 unsigned long vm_end
; /* The first byte after our end address
138 /* linked list of VM areas per task, sorted by address */
139 struct vm_area_struct
*vm_next
, *vm_prev
;
141 pgprot_t vm_page_prot
; /* Access permissions of this VMA. */
142 unsigned long vm_flags
; /* Flags, see mm.h. */
144 struct rb_node vm_rb
;
147 * For areas with an address space and backing store,
148 * linkage into the address_space->i_mmap prio tree, or
149 * linkage to the list of like vmas hanging off its node, or
150 * linkage of vma in the address_space->i_mmap_nonlinear list.
154 struct list_head list
;
155 void *parent
; /* aligns with prio_tree_node parent */
156 struct vm_area_struct
*head
;
159 struct raw_prio_tree_node prio_tree_node
;
163 * A file's MAP_PRIVATE vma can be in both i_mmap tree and anon_vma
164 * list, after a COW of one of the file pages. A MAP_SHARED vma
165 * can only be in the i_mmap tree. An anonymous MAP_PRIVATE, stack
166 * or brk vma (with NULL file) can only be in an anon_vma list.
168 struct list_head anon_vma_chain
; /* Serialized by mmap_sem &
170 struct anon_vma
*anon_vma
; /* Serialized by page_table_lock */
172 /* Function pointers to deal with this struct. */
173 const struct vm_operations_struct
*vm_ops
;
175 /* Information about our backing store: */
176 unsigned long vm_pgoff
; /* Offset (within vm_file) in PAGE_SIZE
177 units, *not* PAGE_CACHE_SIZE */
178 struct file
* vm_file
; /* File we map to (can be NULL). */
179 void * vm_private_data
; /* was vm_pte (shared mem) */
182 struct vm_region
*vm_region
; /* NOMMU mapping region */
185 struct mempolicy
*vm_policy
; /* NUMA policy for the VMA */
190 struct task_struct
*task
;
191 struct core_thread
*next
;
196 struct core_thread dumper
;
197 struct completion startup
;
207 #if USE_SPLIT_PTLOCKS && defined(CONFIG_MMU)
208 #define SPLIT_RSS_COUNTING
209 /* per-thread cached information, */
210 struct task_rss_stat
{
211 int events
; /* for synchronization threshold */
212 int count
[NR_MM_COUNTERS
];
214 #endif /* USE_SPLIT_PTLOCKS */
217 atomic_long_t count
[NR_MM_COUNTERS
];
221 struct vm_area_struct
* mmap
; /* list of VMAs */
222 struct rb_root mm_rb
;
223 struct vm_area_struct
* mmap_cache
; /* last find_vma result */
225 unsigned long (*get_unmapped_area
) (struct file
*filp
,
226 unsigned long addr
, unsigned long len
,
227 unsigned long pgoff
, unsigned long flags
);
228 void (*unmap_area
) (struct mm_struct
*mm
, unsigned long addr
);
230 unsigned long mmap_base
; /* base of mmap area */
231 unsigned long task_size
; /* size of task vm space */
232 unsigned long cached_hole_size
; /* if non-zero, the largest hole below free_area_cache */
233 unsigned long free_area_cache
; /* first hole of size cached_hole_size or larger */
235 atomic_t mm_users
; /* How many users with user space? */
236 atomic_t mm_count
; /* How many references to "struct mm_struct" (users count as 1) */
237 int map_count
; /* number of VMAs */
239 spinlock_t page_table_lock
; /* Protects page tables and some counters */
240 struct rw_semaphore mmap_sem
;
242 struct list_head mmlist
; /* List of maybe swapped mm's. These are globally strung
243 * together off init_mm.mmlist, and are protected
248 unsigned long hiwater_rss
; /* High-watermark of RSS usage */
249 unsigned long hiwater_vm
; /* High-water virtual memory usage */
251 unsigned long total_vm
, locked_vm
, shared_vm
, exec_vm
;
252 unsigned long stack_vm
, reserved_vm
, def_flags
, nr_ptes
;
253 unsigned long start_code
, end_code
, start_data
, end_data
;
254 unsigned long start_brk
, brk
, start_stack
;
255 unsigned long arg_start
, arg_end
, env_start
, env_end
;
257 unsigned long saved_auxv
[AT_VECTOR_SIZE
]; /* for /proc/PID/auxv */
260 * Special counters, in some configurations protected by the
261 * page_table_lock, in other configurations by being atomic.
263 struct mm_rss_stat rss_stat
;
265 struct linux_binfmt
*binfmt
;
267 cpumask_var_t cpu_vm_mask_var
;
269 /* Architecture-specific MM context */
270 mm_context_t context
;
272 /* Swap token stuff */
274 * Last value of global fault stamp as seen by this process.
275 * In other words, this value gives an indication of how long
276 * it has been since this task got the token.
277 * Look at mm/thrash.c
279 unsigned int faultstamp
;
280 unsigned int token_priority
;
281 unsigned int last_interval
;
283 /* How many tasks sharing this mm are OOM_DISABLE */
284 atomic_t oom_disable_count
;
286 unsigned long flags
; /* Must use atomic bitops to access the bits */
288 struct core_state
*core_state
; /* coredumping support */
290 spinlock_t ioctx_lock
;
291 struct hlist_head ioctx_list
;
293 #ifdef CONFIG_MM_OWNER
295 * "owner" points to a task that is regarded as the canonical
296 * user/owner of this mm. All of the following must be true in
297 * order for it to be changed:
299 * current == mm->owner
301 * new_owner->mm == mm
302 * new_owner->alloc_lock is held
304 struct task_struct __rcu
*owner
;
307 /* store ref to file /proc/<pid>/exe symlink points to */
308 struct file
*exe_file
;
309 unsigned long num_exe_file_vmas
;
310 #ifdef CONFIG_MMU_NOTIFIER
311 struct mmu_notifier_mm
*mmu_notifier_mm
;
313 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
314 pgtable_t pmd_huge_pte
; /* protected by page_table_lock */
316 #ifdef CONFIG_CPUMASK_OFFSTACK
317 struct cpumask cpumask_allocation
;
321 static inline void mm_init_cpumask(struct mm_struct
*mm
)
323 #ifdef CONFIG_CPUMASK_OFFSTACK
324 mm
->cpu_vm_mask_var
= &mm
->cpumask_allocation
;
328 /* Future-safe accessor for struct mm_struct's cpu_vm_mask. */
329 static inline cpumask_t
*mm_cpumask(struct mm_struct
*mm
)
331 return mm
->cpu_vm_mask_var
;
334 #endif /* _LINUX_MM_TYPES_H */