]> Git Repo - linux.git/blame - mm/internal.h
mm/page_alloc: remove the throttling logic from the page allocator
[linux.git] / mm / internal.h
CommitLineData
2874c5fd 1/* SPDX-License-Identifier: GPL-2.0-or-later */
1da177e4
LT
2/* internal.h: mm/ internal definitions
3 *
4 * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
5 * Written by David Howells ([email protected])
1da177e4 6 */
0f8053a5
NP
7#ifndef __MM_INTERNAL_H
8#define __MM_INTERNAL_H
9
29f175d1 10#include <linux/fs.h>
0f8053a5 11#include <linux/mm.h>
e9b61f19 12#include <linux/pagemap.h>
edf14cdb 13#include <linux/tracepoint-defs.h>
1da177e4 14
dd56b046
MG
15/*
16 * The set of flags that only affect watermark checking and reclaim
17 * behaviour. This is used by the MM to obey the caller constraints
18 * about IO, FS and watermark checking while ignoring placement
19 * hints such as HIGHMEM usage.
20 */
21#define GFP_RECLAIM_MASK (__GFP_RECLAIM|__GFP_HIGH|__GFP_IO|__GFP_FS|\
dcda9b04 22 __GFP_NOWARN|__GFP_RETRY_MAYFAIL|__GFP_NOFAIL|\
e838a45f
MG
23 __GFP_NORETRY|__GFP_MEMALLOC|__GFP_NOMEMALLOC|\
24 __GFP_ATOMIC)
dd56b046
MG
25
26/* The GFP flags allowed during early boot */
27#define GFP_BOOT_MASK (__GFP_BITS_MASK & ~(__GFP_RECLAIM|__GFP_IO|__GFP_FS))
28
29/* Control allocation cpuset and node placement constraints */
30#define GFP_CONSTRAINT_MASK (__GFP_HARDWALL|__GFP_THISNODE)
31
32/* Do not use these with a slab allocator */
33#define GFP_SLAB_BUG_MASK (__GFP_DMA32|__GFP_HIGHMEM|~__GFP_BITS_MASK)
34
62906027
NP
35void page_writeback_init(void);
36
8cd7c588
MG
37void __acct_reclaim_writeback(pg_data_t *pgdat, struct page *page,
38 int nr_throttled);
39static inline void acct_reclaim_writeback(struct page *page)
40{
41 pg_data_t *pgdat = page_pgdat(page);
42 int nr_throttled = atomic_read(&pgdat->nr_writeback_throttled);
43
44 if (nr_throttled)
45 __acct_reclaim_writeback(pgdat, page, nr_throttled);
46}
47
d818fca1
MG
48static inline void wake_throttle_isolated(pg_data_t *pgdat)
49{
50 wait_queue_head_t *wqh;
51
52 wqh = &pgdat->reclaim_wait[VMSCAN_THROTTLE_ISOLATED];
53 if (waitqueue_active(wqh))
54 wake_up(wqh);
55}
56
2b740303 57vm_fault_t do_swap_page(struct vm_fault *vmf);
8a966ed7 58
42b77728
JB
59void free_pgtables(struct mmu_gather *tlb, struct vm_area_struct *start_vma,
60 unsigned long floor, unsigned long ceiling);
03c4f204 61void pmd_install(struct mm_struct *mm, pmd_t *pmd, pgtable_t *pte);
42b77728 62
9c276cc6 63static inline bool can_madv_lru_vma(struct vm_area_struct *vma)
23519073
KS
64{
65 return !(vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP));
66}
67
aac45363
MH
68void unmap_page_range(struct mmu_gather *tlb,
69 struct vm_area_struct *vma,
70 unsigned long addr, unsigned long end,
71 struct zap_details *details);
72
7b3df3b9
DH
73void do_page_cache_ra(struct readahead_control *, unsigned long nr_to_read,
74 unsigned long lookahead_size);
fcd9ae4f 75void force_page_cache_ra(struct readahead_control *, unsigned long nr);
7b3df3b9
DH
76static inline void force_page_cache_readahead(struct address_space *mapping,
77 struct file *file, pgoff_t index, unsigned long nr_to_read)
78{
fcd9ae4f
MWO
79 DEFINE_READAHEAD(ractl, file, &file->f_ra, mapping, index);
80 force_page_cache_ra(&ractl, nr_to_read);
7b3df3b9 81}
29f175d1 82
5c211ba2
MWO
83unsigned find_lock_entries(struct address_space *mapping, pgoff_t start,
84 pgoff_t end, struct pagevec *pvec, pgoff_t *indices);
85
1eb6234e
YS
86/**
87 * page_evictable - test whether a page is evictable
88 * @page: the page to test
89 *
90 * Test whether page is evictable--i.e., should be placed on active/inactive
91 * lists vs unevictable list.
92 *
93 * Reasons page might not be evictable:
94 * (1) page's mapping marked unevictable
95 * (2) page is part of an mlocked VMA
96 *
97 */
98static inline bool page_evictable(struct page *page)
99{
100 bool ret;
101
102 /* Prevent address_space of inode and swap cache from being freed */
103 rcu_read_lock();
104 ret = !mapping_unevictable(page_mapping(page)) && !PageMlocked(page);
105 rcu_read_unlock();
106 return ret;
107}
108
7835e98b 109/*
0139aa7b 110 * Turn a non-refcounted page (->_refcount == 0) into refcounted with
7835e98b
NP
111 * a count of one.
112 */
113static inline void set_page_refcounted(struct page *page)
114{
309381fe 115 VM_BUG_ON_PAGE(PageTail(page), page);
fe896d18 116 VM_BUG_ON_PAGE(page_ref_count(page), page);
77a8a788 117 set_page_count(page, 1);
77a8a788
NP
118}
119
03f6462a
HD
120extern unsigned long highest_memmap_pfn;
121
c73322d0
JW
122/*
123 * Maximum number of reclaim retries without progress before the OOM
124 * killer is consider the only way forward.
125 */
126#define MAX_RECLAIM_RETRIES 16
127
894bc310
LS
128/*
129 * in mm/vmscan.c:
130 */
62695a84 131extern int isolate_lru_page(struct page *page);
894bc310 132extern void putback_lru_page(struct page *page);
d818fca1
MG
133extern void reclaim_throttle(pg_data_t *pgdat, enum vmscan_throttle_state reason,
134 long timeout);
62695a84 135
6219049a
BL
136/*
137 * in mm/rmap.c:
138 */
139extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
140
494c1dfe
WL
141/*
142 * in mm/memcontrol.c:
143 */
144extern bool cgroup_memory_nokmem;
145
894bc310
LS
146/*
147 * in mm/page_alloc.c
148 */
3c605096 149
1a6d53a1
VB
150/*
151 * Structure for holding the mostly immutable allocation parameters passed
152 * between functions involved in allocations, including the alloc_pages*
153 * family of functions.
154 *
97a225e6 155 * nodemask, migratetype and highest_zoneidx are initialized only once in
84172f4b 156 * __alloc_pages() and then never change.
1a6d53a1 157 *
97a225e6 158 * zonelist, preferred_zone and highest_zoneidx are set first in
84172f4b 159 * __alloc_pages() for the fast path, and might be later changed
68956ccb 160 * in __alloc_pages_slowpath(). All other functions pass the whole structure
1a6d53a1
VB
161 * by a const pointer.
162 */
163struct alloc_context {
164 struct zonelist *zonelist;
165 nodemask_t *nodemask;
c33d6c06 166 struct zoneref *preferred_zoneref;
1a6d53a1 167 int migratetype;
97a225e6
JK
168
169 /*
170 * highest_zoneidx represents highest usable zone index of
171 * the allocation request. Due to the nature of the zone,
172 * memory on lower zone than the highest_zoneidx will be
173 * protected by lowmem_reserve[highest_zoneidx].
174 *
175 * highest_zoneidx is also used by reclaim/compaction to limit
176 * the target zone since higher zone than this index cannot be
177 * usable for this allocation request.
178 */
179 enum zone_type highest_zoneidx;
c9ab0c4f 180 bool spread_dirty_pages;
1a6d53a1
VB
181};
182
3c605096
JK
183/*
184 * Locate the struct page for both the matching buddy in our
185 * pair (buddy1) and the combined O(n+1) page they form (page).
186 *
187 * 1) Any buddy B1 will have an order O twin B2 which satisfies
188 * the following equation:
189 * B2 = B1 ^ (1 << O)
190 * For example, if the starting buddy (buddy2) is #8 its order
191 * 1 buddy is #10:
192 * B2 = 8 ^ (1 << 1) = 8 ^ 2 = 10
193 *
194 * 2) Any buddy B will have an order O+1 parent P which
195 * satisfies the following equation:
196 * P = B & ~(1 << O)
197 *
198 * Assumption: *_mem_map is contiguous at least up to MAX_ORDER
199 */
200static inline unsigned long
76741e77 201__find_buddy_pfn(unsigned long page_pfn, unsigned int order)
3c605096 202{
76741e77 203 return page_pfn ^ (1 << order);
3c605096
JK
204}
205
7cf91a98
JK
206extern struct page *__pageblock_pfn_to_page(unsigned long start_pfn,
207 unsigned long end_pfn, struct zone *zone);
208
209static inline struct page *pageblock_pfn_to_page(unsigned long start_pfn,
210 unsigned long end_pfn, struct zone *zone)
211{
212 if (zone->contiguous)
213 return pfn_to_page(start_pfn);
214
215 return __pageblock_pfn_to_page(start_pfn, end_pfn, zone);
216}
217
3c605096 218extern int __isolate_free_page(struct page *page, unsigned int order);
624f58d8
AD
219extern void __putback_isolated_page(struct page *page, unsigned int order,
220 int mt);
7c2ee349 221extern void memblock_free_pages(struct page *page, unsigned long pfn,
d70ddd7a 222 unsigned int order);
a9cd410a 223extern void __free_pages_core(struct page *page, unsigned int order);
d00181b9 224extern void prep_compound_page(struct page *page, unsigned int order);
46f24fd8
JK
225extern void post_alloc_hook(struct page *page, unsigned int order,
226 gfp_t gfp_flags);
42aa83cb 227extern int user_min_free_kbytes;
20a0307c 228
44042b44 229extern void free_unref_page(struct page *page, unsigned int order);
0966aeb4
MWO
230extern void free_unref_page_list(struct list_head *list);
231
04f8cfea 232extern void zone_pcp_update(struct zone *zone, int cpu_online);
68265390 233extern void zone_pcp_reset(struct zone *zone);
ec6e8c7e
VB
234extern void zone_pcp_disable(struct zone *zone);
235extern void zone_pcp_enable(struct zone *zone);
68265390 236
c803b3c8
MR
237extern void *memmap_alloc(phys_addr_t size, phys_addr_t align,
238 phys_addr_t min_addr,
239 int nid, bool exact_nid);
240
ff9543fd
MN
241#if defined CONFIG_COMPACTION || defined CONFIG_CMA
242
243/*
244 * in mm/compaction.c
245 */
246/*
247 * compact_control is used to track pages being migrated and the free pages
248 * they are being migrated to during memory compaction. The free_pfn starts
249 * at the end of a zone and migrate_pfn begins at the start. Movable pages
250 * are moved to the end of a zone during a compaction run and the run
251 * completes when free_pfn <= migrate_pfn
252 */
253struct compact_control {
254 struct list_head freepages; /* List of free pages to migrate to */
255 struct list_head migratepages; /* List of pages being migrated */
c5fbd937
MG
256 unsigned int nr_freepages; /* Number of isolated free pages */
257 unsigned int nr_migratepages; /* Number of pages to migrate */
ff9543fd 258 unsigned long free_pfn; /* isolate_freepages search base */
c2ad7a1f
OS
259 /*
260 * Acts as an in/out parameter to page isolation for migration.
261 * isolate_migratepages uses it as a search base.
262 * isolate_migratepages_block will update the value to the next pfn
263 * after the last isolated one.
264 */
265 unsigned long migrate_pfn;
70b44595 266 unsigned long fast_start_pfn; /* a pfn to start linear scan from */
c5943b9c
MG
267 struct zone *zone;
268 unsigned long total_migrate_scanned;
269 unsigned long total_free_scanned;
dbe2d4e4
MG
270 unsigned short fast_search_fail;/* failures to use free list searches */
271 short search_order; /* order to start a fast search at */
f25ba6dc
VB
272 const gfp_t gfp_mask; /* gfp mask of a direct compactor */
273 int order; /* order a direct compactor needs */
d39773a0 274 int migratetype; /* migratetype of direct compactor */
f25ba6dc 275 const unsigned int alloc_flags; /* alloc flags of a direct compactor */
97a225e6 276 const int highest_zoneidx; /* zone index of a direct compactor */
e0b9daeb 277 enum migrate_mode mode; /* Async or sync migration mode */
bb13ffeb 278 bool ignore_skip_hint; /* Scan blocks even if marked skip */
2583d671 279 bool no_set_skip_hint; /* Don't mark blocks for skipping */
9f7e3387 280 bool ignore_block_suitable; /* Scan blocks considered unsuitable */
accf6242 281 bool direct_compaction; /* False from kcompactd or /proc/... */
facdaa91 282 bool proactive_compaction; /* kcompactd proactive compaction */
06ed2998 283 bool whole_zone; /* Whole zone should/has been scanned */
c3486f53 284 bool contended; /* Signal lock or sched contention */
804d3121 285 bool rescan; /* Rescanning the same pageblock */
b06eda09 286 bool alloc_contig; /* alloc_contig_range allocation */
ff9543fd
MN
287};
288
5e1f0f09
MG
289/*
290 * Used in direct compaction when a page should be taken from the freelists
291 * immediately when one is created during the free path.
292 */
293struct capture_control {
294 struct compact_control *cc;
295 struct page *page;
296};
297
ff9543fd 298unsigned long
bb13ffeb
MG
299isolate_freepages_range(struct compact_control *cc,
300 unsigned long start_pfn, unsigned long end_pfn);
c2ad7a1f 301int
edc2ca61
VB
302isolate_migratepages_range(struct compact_control *cc,
303 unsigned long low_pfn, unsigned long end_pfn);
ffd8f251 304#endif
2149cdae
JK
305int find_suitable_fallback(struct free_area *area, unsigned int order,
306 int migratetype, bool only_stealable, bool *can_steal);
ff9543fd 307
48f13bf3 308/*
6c14466c
MG
309 * This function returns the order of a free page in the buddy system. In
310 * general, page_zone(page)->lock must be held by the caller to prevent the
311 * page from being allocated in parallel and returning garbage as the order.
312 * If a caller does not hold page_zone(page)->lock, it must guarantee that the
99c0fd5e 313 * page cannot be allocated or merged in parallel. Alternatively, it must
ab130f91 314 * handle invalid values gracefully, and use buddy_order_unsafe() below.
48f13bf3 315 */
ab130f91 316static inline unsigned int buddy_order(struct page *page)
48f13bf3 317{
572438f9 318 /* PageBuddy() must be checked by the caller */
48f13bf3
MG
319 return page_private(page);
320}
b5a0e011 321
99c0fd5e 322/*
ab130f91 323 * Like buddy_order(), but for callers who cannot afford to hold the zone lock.
99c0fd5e
VB
324 * PageBuddy() should be checked first by the caller to minimize race window,
325 * and invalid values must be handled gracefully.
326 *
4db0c3c2 327 * READ_ONCE is used so that if the caller assigns the result into a local
99c0fd5e
VB
328 * variable and e.g. tests it for valid range before using, the compiler cannot
329 * decide to remove the variable and inline the page_private(page) multiple
330 * times, potentially observing different values in the tests and the actual
331 * use of the result.
332 */
ab130f91 333#define buddy_order_unsafe(page) READ_ONCE(page_private(page))
99c0fd5e 334
30bdbb78
KK
335/*
336 * These three helpers classifies VMAs for virtual memory accounting.
337 */
338
339/*
340 * Executable code area - executable, not writable, not stack
341 */
d977d56c
KK
342static inline bool is_exec_mapping(vm_flags_t flags)
343{
30bdbb78 344 return (flags & (VM_EXEC | VM_WRITE | VM_STACK)) == VM_EXEC;
d977d56c
KK
345}
346
30bdbb78 347/*
f0953a1b 348 * Stack area - automatically grows in one direction
30bdbb78
KK
349 *
350 * VM_GROWSUP / VM_GROWSDOWN VMAs are always private anonymous:
351 * do_mmap() forbids all other combinations.
352 */
d977d56c
KK
353static inline bool is_stack_mapping(vm_flags_t flags)
354{
30bdbb78 355 return (flags & VM_STACK) == VM_STACK;
d977d56c
KK
356}
357
30bdbb78
KK
358/*
359 * Data area - private, writable, not stack
360 */
d977d56c
KK
361static inline bool is_data_mapping(vm_flags_t flags)
362{
30bdbb78 363 return (flags & (VM_WRITE | VM_SHARED | VM_STACK)) == VM_WRITE;
d977d56c
KK
364}
365
6038def0
NK
366/* mm/util.c */
367void __vma_link_list(struct mm_struct *mm, struct vm_area_struct *vma,
aba6dfb7 368 struct vm_area_struct *prev);
1b9fc5b2 369void __vma_unlink_list(struct mm_struct *mm, struct vm_area_struct *vma);
6038def0 370
af8e3354 371#ifdef CONFIG_MMU
fc05f566 372extern long populate_vma_page_range(struct vm_area_struct *vma,
a78f1ccd 373 unsigned long start, unsigned long end, int *locked);
4ca9b385
DH
374extern long faultin_vma_page_range(struct vm_area_struct *vma,
375 unsigned long start, unsigned long end,
376 bool write, int *locked);
af8e3354
HD
377extern void munlock_vma_pages_range(struct vm_area_struct *vma,
378 unsigned long start, unsigned long end);
379static inline void munlock_vma_pages_all(struct vm_area_struct *vma)
380{
381 munlock_vma_pages_range(vma, vma->vm_start, vma->vm_end);
382}
383
b291f000 384/*
c1e8d7c6 385 * must be called with vma's mmap_lock held for read or write, and page locked.
b291f000
NP
386 */
387extern void mlock_vma_page(struct page *page);
ff6a6da6 388extern unsigned int munlock_vma_page(struct page *page);
b291f000 389
6aeb2542
MR
390extern int mlock_future_check(struct mm_struct *mm, unsigned long flags,
391 unsigned long len);
392
b291f000
NP
393/*
394 * Clear the page's PageMlocked(). This can be useful in a situation where
395 * we want to unconditionally remove a page from the pagecache -- e.g.,
396 * on truncation or freeing.
397 *
398 * It is legal to call this function for any page, mlocked or not.
399 * If called for a page that is still mapped by mlocked vmas, all we do
400 * is revert to lazy LRU behaviour -- semantics are not broken.
401 */
e6c509f8 402extern void clear_page_mlock(struct page *page);
b291f000 403
f55e1014 404extern pmd_t maybe_pmd_mkwrite(pmd_t pmd, struct vm_area_struct *vma);
b32967ff 405
e9b61f19 406/*
494334e4
HD
407 * At what user virtual address is page expected in vma?
408 * Returns -EFAULT if all of the page is outside the range of vma.
409 * If page is a compound head, the entire compound page is considered.
e9b61f19
KS
410 */
411static inline unsigned long
494334e4 412vma_address(struct page *page, struct vm_area_struct *vma)
e9b61f19 413{
494334e4
HD
414 pgoff_t pgoff;
415 unsigned long address;
416
417 VM_BUG_ON_PAGE(PageKsm(page), page); /* KSM page->index unusable */
418 pgoff = page_to_pgoff(page);
419 if (pgoff >= vma->vm_pgoff) {
420 address = vma->vm_start +
421 ((pgoff - vma->vm_pgoff) << PAGE_SHIFT);
422 /* Check for address beyond vma (or wrapped through 0?) */
423 if (address < vma->vm_start || address >= vma->vm_end)
424 address = -EFAULT;
425 } else if (PageHead(page) &&
426 pgoff + compound_nr(page) - 1 >= vma->vm_pgoff) {
427 /* Test above avoids possibility of wrap to 0 on 32-bit */
428 address = vma->vm_start;
429 } else {
430 address = -EFAULT;
431 }
432 return address;
e9b61f19
KS
433}
434
494334e4
HD
435/*
436 * Then at what user virtual address will none of the page be found in vma?
437 * Assumes that vma_address() already returned a good starting address.
438 * If page is a compound head, the entire compound page is considered.
439 */
e9b61f19 440static inline unsigned long
494334e4 441vma_address_end(struct page *page, struct vm_area_struct *vma)
e9b61f19 442{
494334e4
HD
443 pgoff_t pgoff;
444 unsigned long address;
445
446 VM_BUG_ON_PAGE(PageKsm(page), page); /* KSM page->index unusable */
447 pgoff = page_to_pgoff(page) + compound_nr(page);
448 address = vma->vm_start + ((pgoff - vma->vm_pgoff) << PAGE_SHIFT);
449 /* Check for address beyond vma (or wrapped through 0?) */
450 if (address < vma->vm_start || address > vma->vm_end)
451 address = vma->vm_end;
452 return address;
e9b61f19
KS
453}
454
89b15332
JW
455static inline struct file *maybe_unlock_mmap_for_io(struct vm_fault *vmf,
456 struct file *fpin)
457{
458 int flags = vmf->flags;
459
460 if (fpin)
461 return fpin;
462
463 /*
464 * FAULT_FLAG_RETRY_NOWAIT means we don't want to wait on page locks or
c1e8d7c6 465 * anything, so we only pin the file and drop the mmap_lock if only
4064b982 466 * FAULT_FLAG_ALLOW_RETRY is set, while this is the first attempt.
89b15332 467 */
4064b982
PX
468 if (fault_flag_allow_retry_first(flags) &&
469 !(flags & FAULT_FLAG_RETRY_NOWAIT)) {
89b15332 470 fpin = get_file(vmf->vma->vm_file);
d8ed45c5 471 mmap_read_unlock(vmf->vma->vm_mm);
89b15332
JW
472 }
473 return fpin;
474}
475
af8e3354 476#else /* !CONFIG_MMU */
b291f000
NP
477static inline void clear_page_mlock(struct page *page) { }
478static inline void mlock_vma_page(struct page *page) { }
4ad0ae8c
NP
479static inline void vunmap_range_noflush(unsigned long start, unsigned long end)
480{
481}
af8e3354 482#endif /* !CONFIG_MMU */
894bc310 483
69d177c2
AW
484/*
485 * Return the mem_map entry representing the 'offset' subpage within
486 * the maximally aligned gigantic page 'base'. Handle any discontiguity
487 * in the mem_map at MAX_ORDER_NR_PAGES boundaries.
488 */
489static inline struct page *mem_map_offset(struct page *base, int offset)
490{
491 if (unlikely(offset >= MAX_ORDER_NR_PAGES))
bc7f84c0 492 return nth_page(base, offset);
69d177c2
AW
493 return base + offset;
494}
495
496/*
25985edc 497 * Iterator over all subpages within the maximally aligned gigantic
69d177c2
AW
498 * page 'base'. Handle any discontiguity in the mem_map.
499 */
500static inline struct page *mem_map_next(struct page *iter,
501 struct page *base, int offset)
502{
503 if (unlikely((offset & (MAX_ORDER_NR_PAGES - 1)) == 0)) {
504 unsigned long pfn = page_to_pfn(base) + offset;
505 if (!pfn_valid(pfn))
506 return NULL;
507 return pfn_to_page(pfn);
508 }
509 return iter + 1;
510}
511
6b74ab97
MG
512/* Memory initialisation debug and verification */
513enum mminit_level {
514 MMINIT_WARNING,
515 MMINIT_VERIFY,
516 MMINIT_TRACE
517};
518
519#ifdef CONFIG_DEBUG_MEMORY_INIT
520
521extern int mminit_loglevel;
522
523#define mminit_dprintk(level, prefix, fmt, arg...) \
524do { \
525 if (level < mminit_loglevel) { \
fc5199d1 526 if (level <= MMINIT_WARNING) \
1170532b 527 pr_warn("mminit::" prefix " " fmt, ##arg); \
fc5199d1
RV
528 else \
529 printk(KERN_DEBUG "mminit::" prefix " " fmt, ##arg); \
6b74ab97
MG
530 } \
531} while (0)
532
708614e6 533extern void mminit_verify_pageflags_layout(void);
68ad8df4 534extern void mminit_verify_zonelist(void);
6b74ab97
MG
535#else
536
537static inline void mminit_dprintk(enum mminit_level level,
538 const char *prefix, const char *fmt, ...)
539{
540}
541
708614e6
MG
542static inline void mminit_verify_pageflags_layout(void)
543{
544}
545
68ad8df4
MG
546static inline void mminit_verify_zonelist(void)
547{
548}
6b74ab97 549#endif /* CONFIG_DEBUG_MEMORY_INIT */
2dbb51c4
MG
550
551/* mminit_validate_memmodel_limits is independent of CONFIG_DEBUG_MEMORY_INIT */
552#if defined(CONFIG_SPARSEMEM)
553extern void mminit_validate_memmodel_limits(unsigned long *start_pfn,
554 unsigned long *end_pfn);
555#else
556static inline void mminit_validate_memmodel_limits(unsigned long *start_pfn,
557 unsigned long *end_pfn)
558{
559}
560#endif /* CONFIG_SPARSEMEM */
561
a5f5f91d
MG
562#define NODE_RECLAIM_NOSCAN -2
563#define NODE_RECLAIM_FULL -1
564#define NODE_RECLAIM_SOME 0
565#define NODE_RECLAIM_SUCCESS 1
7c116f2b 566
8b09549c
WY
567#ifdef CONFIG_NUMA
568extern int node_reclaim(struct pglist_data *, gfp_t, unsigned int);
79c28a41 569extern int find_next_best_node(int node, nodemask_t *used_node_mask);
8b09549c
WY
570#else
571static inline int node_reclaim(struct pglist_data *pgdat, gfp_t mask,
572 unsigned int order)
573{
574 return NODE_RECLAIM_NOSCAN;
575}
79c28a41
DH
576static inline int find_next_best_node(int node, nodemask_t *used_node_mask)
577{
578 return NUMA_NO_NODE;
579}
8b09549c
WY
580#endif
581
31d3d348
WF
582extern int hwpoison_filter(struct page *p);
583
7c116f2b
WF
584extern u32 hwpoison_filter_dev_major;
585extern u32 hwpoison_filter_dev_minor;
478c5ffc
WF
586extern u64 hwpoison_filter_flags_mask;
587extern u64 hwpoison_filter_flags_value;
4fd466eb 588extern u64 hwpoison_filter_memcg;
1bfe5feb 589extern u32 hwpoison_filter_enable;
eb36c587 590
dc0ef0df 591extern unsigned long __must_check vm_mmap_pgoff(struct file *, unsigned long,
eb36c587 592 unsigned long, unsigned long,
9fbeb5ab 593 unsigned long, unsigned long);
ca57df79
XQ
594
595extern void set_pageblock_order(void);
730ec8c0 596unsigned int reclaim_clean_pages_from_list(struct zone *zone,
02c6de8d 597 struct list_head *page_list);
d95ea5d1
BZ
598/* The ALLOC_WMARK bits are used as an index to zone->watermark */
599#define ALLOC_WMARK_MIN WMARK_MIN
600#define ALLOC_WMARK_LOW WMARK_LOW
601#define ALLOC_WMARK_HIGH WMARK_HIGH
602#define ALLOC_NO_WATERMARKS 0x04 /* don't check watermarks at all */
603
604/* Mask to get the watermark bits */
605#define ALLOC_WMARK_MASK (ALLOC_NO_WATERMARKS-1)
606
cd04ae1e
MH
607/*
608 * Only MMU archs have async oom victim reclaim - aka oom_reaper so we
609 * cannot assume a reduced access to memory reserves is sufficient for
610 * !MMU
611 */
612#ifdef CONFIG_MMU
613#define ALLOC_OOM 0x08
614#else
615#define ALLOC_OOM ALLOC_NO_WATERMARKS
616#endif
617
6bb15450
MG
618#define ALLOC_HARDER 0x10 /* try to alloc harder */
619#define ALLOC_HIGH 0x20 /* __GFP_HIGH set */
620#define ALLOC_CPUSET 0x40 /* check for correct cpuset */
621#define ALLOC_CMA 0x80 /* allow allocations from CMA areas */
622#ifdef CONFIG_ZONE_DMA32
623#define ALLOC_NOFRAGMENT 0x100 /* avoid mixing pageblock types */
624#else
625#define ALLOC_NOFRAGMENT 0x0
626#endif
736838e9 627#define ALLOC_KSWAPD 0x800 /* allow waking of kswapd, __GFP_KSWAPD_RECLAIM set */
d95ea5d1 628
72b252ae
MG
629enum ttu_flags;
630struct tlbflush_unmap_batch;
631
ce612879
MH
632
633/*
634 * only for MM internal work items which do not depend on
635 * any allocations or locks which might depend on allocations
636 */
637extern struct workqueue_struct *mm_percpu_wq;
638
72b252ae
MG
639#ifdef CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH
640void try_to_unmap_flush(void);
d950c947 641void try_to_unmap_flush_dirty(void);
3ea27719 642void flush_tlb_batched_pending(struct mm_struct *mm);
72b252ae
MG
643#else
644static inline void try_to_unmap_flush(void)
645{
646}
d950c947
MG
647static inline void try_to_unmap_flush_dirty(void)
648{
649}
3ea27719
MG
650static inline void flush_tlb_batched_pending(struct mm_struct *mm)
651{
652}
72b252ae 653#endif /* CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH */
edf14cdb
VB
654
655extern const struct trace_print_flags pageflag_names[];
656extern const struct trace_print_flags vmaflag_names[];
657extern const struct trace_print_flags gfpflag_names[];
658
a6ffdc07
XQ
659static inline bool is_migrate_highatomic(enum migratetype migratetype)
660{
661 return migratetype == MIGRATE_HIGHATOMIC;
662}
663
664static inline bool is_migrate_highatomic_page(struct page *page)
665{
666 return get_pageblock_migratetype(page) == MIGRATE_HIGHATOMIC;
667}
668
72675e13 669void setup_zone_pageset(struct zone *zone);
19fc7bed
JK
670
671struct migration_target_control {
672 int nid; /* preferred node id */
673 nodemask_t *nmask;
674 gfp_t gfp_mask;
675};
676
b67177ec
NP
677/*
678 * mm/vmalloc.c
679 */
4ad0ae8c 680#ifdef CONFIG_MMU
b67177ec
NP
681int vmap_pages_range_noflush(unsigned long addr, unsigned long end,
682 pgprot_t prot, struct page **pages, unsigned int page_shift);
4ad0ae8c
NP
683#else
684static inline
685int vmap_pages_range_noflush(unsigned long addr, unsigned long end,
686 pgprot_t prot, struct page **pages, unsigned int page_shift)
687{
688 return -EINVAL;
689}
690#endif
691
692void vunmap_range_noflush(unsigned long start, unsigned long end);
b67177ec 693
f4c0d836
YS
694int numa_migrate_prep(struct page *page, struct vm_area_struct *vma,
695 unsigned long addr, int page_nid, int *flags);
696
db971418 697#endif /* __MM_INTERNAL_H */
This page took 1.170805 seconds and 4 git commands to generate.