internal.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666
  1. /* SPDX-License-Identifier: GPL-2.0-or-later */
  2. /* internal.h: mm/ internal definitions
  3. *
  4. * Copyright (C) 2004 Red Hat, Inc. All Rights Reserved.
  5. * Written by David Howells (dhowells@redhat.com)
  6. */
  7. #ifndef __MM_INTERNAL_H
  8. #define __MM_INTERNAL_H
  9. #include <linux/fs.h>
  10. #include <linux/mm.h>
  11. #include <linux/pagemap.h>
  12. #include <linux/tracepoint-defs.h>
  13. /*
  14. * The set of flags that only affect watermark checking and reclaim
  15. * behaviour. This is used by the MM to obey the caller constraints
  16. * about IO, FS and watermark checking while ignoring placement
  17. * hints such as HIGHMEM usage.
  18. */
  19. #define GFP_RECLAIM_MASK (__GFP_RECLAIM|__GFP_HIGH|__GFP_IO|__GFP_FS|\
  20. __GFP_NOWARN|__GFP_RETRY_MAYFAIL|__GFP_NOFAIL|\
  21. __GFP_NORETRY|__GFP_MEMALLOC|__GFP_NOMEMALLOC|\
  22. __GFP_ATOMIC)
  23. /* The GFP flags allowed during early boot */
  24. #define GFP_BOOT_MASK (__GFP_BITS_MASK & ~(__GFP_RECLAIM|__GFP_IO|__GFP_FS))
  25. /* Control allocation cpuset and node placement constraints */
  26. #define GFP_CONSTRAINT_MASK (__GFP_HARDWALL|__GFP_THISNODE)
  27. /* Do not use these with a slab allocator */
  28. #define GFP_SLAB_BUG_MASK (__GFP_DMA32|__GFP_HIGHMEM|~__GFP_BITS_MASK)
  29. void page_writeback_init(void);
  30. vm_fault_t do_swap_page(struct vm_fault *vmf);
  31. #ifdef CONFIG_SPECULATIVE_PAGE_FAULT
  32. extern struct vm_area_struct *get_vma(struct mm_struct *mm,
  33. unsigned long addr);
  34. extern void put_vma(struct vm_area_struct *vma);
  35. static inline bool vma_has_changed(struct vm_fault *vmf)
  36. {
  37. int ret = RB_EMPTY_NODE(&vmf->vma->vm_rb);
  38. unsigned int seq = READ_ONCE(vmf->vma->vm_sequence.sequence);
  39. /*
  40. * Matches both the wmb in write_seqlock_{begin,end}() and
  41. * the wmb in vma_rb_erase().
  42. */
  43. smp_rmb();
  44. return ret || seq != vmf->sequence;
  45. }
  46. #endif /* CONFIG_SPECULATIVE_PAGE_FAULT */
  47. void free_pgtables(struct mmu_gather *tlb, struct vm_area_struct *start_vma,
  48. unsigned long floor, unsigned long ceiling);
  49. static inline bool can_madv_lru_vma(struct vm_area_struct *vma)
  50. {
  51. return !(vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP));
  52. }
  53. void unmap_page_range(struct mmu_gather *tlb,
  54. struct vm_area_struct *vma,
  55. unsigned long addr, unsigned long end,
  56. struct zap_details *details);
  57. void do_page_cache_ra(struct readahead_control *, unsigned long nr_to_read,
  58. unsigned long lookahead_size);
  59. void force_page_cache_ra(struct readahead_control *, struct file_ra_state *,
  60. unsigned long nr);
  61. static inline void force_page_cache_readahead(struct address_space *mapping,
  62. struct file *file, pgoff_t index, unsigned long nr_to_read)
  63. {
  64. DEFINE_READAHEAD(ractl, file, mapping, index);
  65. force_page_cache_ra(&ractl, &file->f_ra, nr_to_read);
  66. }
  67. struct page *find_get_entry(struct address_space *mapping, pgoff_t index);
  68. struct page *find_lock_entry(struct address_space *mapping, pgoff_t index);
  69. /**
  70. * page_evictable - test whether a page is evictable
  71. * @page: the page to test
  72. *
  73. * Test whether page is evictable--i.e., should be placed on active/inactive
  74. * lists vs unevictable list.
  75. *
  76. * Reasons page might not be evictable:
  77. * (1) page's mapping marked unevictable
  78. * (2) page is part of an mlocked VMA
  79. *
  80. */
  81. static inline bool page_evictable(struct page *page)
  82. {
  83. bool ret;
  84. /* Prevent address_space of inode and swap cache from being freed */
  85. rcu_read_lock();
  86. ret = !mapping_unevictable(page_mapping(page)) && !PageMlocked(page);
  87. rcu_read_unlock();
  88. return ret;
  89. }
  90. /*
  91. * Turn a non-refcounted page (->_refcount == 0) into refcounted with
  92. * a count of one.
  93. */
  94. static inline void set_page_refcounted(struct page *page)
  95. {
  96. VM_BUG_ON_PAGE(PageTail(page), page);
  97. VM_BUG_ON_PAGE(page_ref_count(page), page);
  98. set_page_count(page, 1);
  99. }
  100. extern unsigned long highest_memmap_pfn;
  101. /*
  102. * Maximum number of reclaim retries without progress before the OOM
  103. * killer is consider the only way forward.
  104. */
  105. #define MAX_RECLAIM_RETRIES 16
  106. /*
  107. * in mm/vmscan.c:
  108. */
  109. extern int isolate_lru_page(struct page *page);
  110. extern void putback_lru_page(struct page *page);
  111. /*
  112. * in mm/rmap.c:
  113. */
  114. extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
  115. /*
  116. * in mm/page_alloc.c
  117. */
  118. /*
  119. * Structure for holding the mostly immutable allocation parameters passed
  120. * between functions involved in allocations, including the alloc_pages*
  121. * family of functions.
  122. *
  123. * nodemask, migratetype and highest_zoneidx are initialized only once in
  124. * __alloc_pages_nodemask() and then never change.
  125. *
  126. * zonelist, preferred_zone and highest_zoneidx are set first in
  127. * __alloc_pages_nodemask() for the fast path, and might be later changed
  128. * in __alloc_pages_slowpath(). All other functions pass the whole structure
  129. * by a const pointer.
  130. */
  131. struct alloc_context {
  132. struct zonelist *zonelist;
  133. nodemask_t *nodemask;
  134. struct zoneref *preferred_zoneref;
  135. int migratetype;
  136. /*
  137. * highest_zoneidx represents highest usable zone index of
  138. * the allocation request. Due to the nature of the zone,
  139. * memory on lower zone than the highest_zoneidx will be
  140. * protected by lowmem_reserve[highest_zoneidx].
  141. *
  142. * highest_zoneidx is also used by reclaim/compaction to limit
  143. * the target zone since higher zone than this index cannot be
  144. * usable for this allocation request.
  145. */
  146. enum zone_type highest_zoneidx;
  147. bool spread_dirty_pages;
  148. };
  149. /*
  150. * Locate the struct page for both the matching buddy in our
  151. * pair (buddy1) and the combined O(n+1) page they form (page).
  152. *
  153. * 1) Any buddy B1 will have an order O twin B2 which satisfies
  154. * the following equation:
  155. * B2 = B1 ^ (1 << O)
  156. * For example, if the starting buddy (buddy2) is #8 its order
  157. * 1 buddy is #10:
  158. * B2 = 8 ^ (1 << 1) = 8 ^ 2 = 10
  159. *
  160. * 2) Any buddy B will have an order O+1 parent P which
  161. * satisfies the following equation:
  162. * P = B & ~(1 << O)
  163. *
  164. * Assumption: *_mem_map is contiguous at least up to MAX_ORDER
  165. */
  166. static inline unsigned long
  167. __find_buddy_pfn(unsigned long page_pfn, unsigned int order)
  168. {
  169. return page_pfn ^ (1 << order);
  170. }
  171. extern struct page *__pageblock_pfn_to_page(unsigned long start_pfn,
  172. unsigned long end_pfn, struct zone *zone);
  173. static inline struct page *pageblock_pfn_to_page(unsigned long start_pfn,
  174. unsigned long end_pfn, struct zone *zone)
  175. {
  176. if (zone->contiguous)
  177. return pfn_to_page(start_pfn);
  178. return __pageblock_pfn_to_page(start_pfn, end_pfn, zone);
  179. }
  180. extern int __isolate_free_page(struct page *page, unsigned int order);
  181. extern void __putback_isolated_page(struct page *page, unsigned int order,
  182. int mt);
  183. extern void memblock_free_pages(struct page *page, unsigned long pfn,
  184. unsigned int order);
  185. extern void __free_pages_core(struct page *page, unsigned int order);
  186. extern void prep_compound_page(struct page *page, unsigned int order);
  187. extern void post_alloc_hook(struct page *page, unsigned int order,
  188. gfp_t gfp_flags);
  189. extern int user_min_free_kbytes;
  190. extern void zone_pcp_update(struct zone *zone);
  191. extern void zone_pcp_reset(struct zone *zone);
  192. #if defined CONFIG_COMPACTION || defined CONFIG_CMA
  193. /*
  194. * in mm/compaction.c
  195. */
  196. /*
  197. * compact_control is used to track pages being migrated and the free pages
  198. * they are being migrated to during memory compaction. The free_pfn starts
  199. * at the end of a zone and migrate_pfn begins at the start. Movable pages
  200. * are moved to the end of a zone during a compaction run and the run
  201. * completes when free_pfn <= migrate_pfn
  202. */
  203. struct compact_control {
  204. struct list_head freepages; /* List of free pages to migrate to */
  205. struct list_head migratepages; /* List of pages being migrated */
  206. unsigned int nr_freepages; /* Number of isolated free pages */
  207. unsigned int nr_migratepages; /* Number of pages to migrate */
  208. unsigned long free_pfn; /* isolate_freepages search base */
  209. unsigned long migrate_pfn; /* isolate_migratepages search base */
  210. unsigned long fast_start_pfn; /* a pfn to start linear scan from */
  211. struct zone *zone;
  212. unsigned long total_migrate_scanned;
  213. unsigned long total_free_scanned;
  214. unsigned short fast_search_fail;/* failures to use free list searches */
  215. short search_order; /* order to start a fast search at */
  216. const gfp_t gfp_mask; /* gfp mask of a direct compactor */
  217. int order; /* order a direct compactor needs */
  218. int migratetype; /* migratetype of direct compactor */
  219. const unsigned int alloc_flags; /* alloc flags of a direct compactor */
  220. const int highest_zoneidx; /* zone index of a direct compactor */
  221. enum migrate_mode mode; /* Async or sync migration mode */
  222. bool ignore_skip_hint; /* Scan blocks even if marked skip */
  223. bool no_set_skip_hint; /* Don't mark blocks for skipping */
  224. bool ignore_block_suitable; /* Scan blocks considered unsuitable */
  225. bool direct_compaction; /* False from kcompactd or /proc/... */
  226. bool proactive_compaction; /* kcompactd proactive compaction */
  227. bool whole_zone; /* Whole zone should/has been scanned */
  228. bool contended; /* Signal lock or sched contention */
  229. bool rescan; /* Rescanning the same pageblock */
  230. bool alloc_contig; /* alloc_contig_range allocation */
  231. };
  232. /*
  233. * Used in direct compaction when a page should be taken from the freelists
  234. * immediately when one is created during the free path.
  235. */
  236. struct capture_control {
  237. struct compact_control *cc;
  238. struct page *page;
  239. };
  240. unsigned long
  241. isolate_freepages_range(struct compact_control *cc,
  242. unsigned long start_pfn, unsigned long end_pfn);
  243. unsigned long
  244. isolate_migratepages_range(struct compact_control *cc,
  245. unsigned long low_pfn, unsigned long end_pfn);
  246. int find_suitable_fallback(struct free_area *area, unsigned int order,
  247. int migratetype, bool only_stealable, bool *can_steal);
  248. #endif
  249. /*
  250. * This function returns the order of a free page in the buddy system. In
  251. * general, page_zone(page)->lock must be held by the caller to prevent the
  252. * page from being allocated in parallel and returning garbage as the order.
  253. * If a caller does not hold page_zone(page)->lock, it must guarantee that the
  254. * page cannot be allocated or merged in parallel. Alternatively, it must
  255. * handle invalid values gracefully, and use buddy_order_unsafe() below.
  256. */
  257. static inline unsigned int buddy_order(struct page *page)
  258. {
  259. /* PageBuddy() must be checked by the caller */
  260. return page_private(page);
  261. }
  262. /*
  263. * Like buddy_order(), but for callers who cannot afford to hold the zone lock.
  264. * PageBuddy() should be checked first by the caller to minimize race window,
  265. * and invalid values must be handled gracefully.
  266. *
  267. * READ_ONCE is used so that if the caller assigns the result into a local
  268. * variable and e.g. tests it for valid range before using, the compiler cannot
  269. * decide to remove the variable and inline the page_private(page) multiple
  270. * times, potentially observing different values in the tests and the actual
  271. * use of the result.
  272. */
  273. #define buddy_order_unsafe(page) READ_ONCE(page_private(page))
  274. static inline bool is_cow_mapping(vm_flags_t flags)
  275. {
  276. return (flags & (VM_SHARED | VM_MAYWRITE)) == VM_MAYWRITE;
  277. }
  278. /*
  279. * These three helpers classifies VMAs for virtual memory accounting.
  280. */
  281. /*
  282. * Executable code area - executable, not writable, not stack
  283. */
  284. static inline bool is_exec_mapping(vm_flags_t flags)
  285. {
  286. return (flags & (VM_EXEC | VM_WRITE | VM_STACK)) == VM_EXEC;
  287. }
  288. /*
  289. * Stack area - atomatically grows in one direction
  290. *
  291. * VM_GROWSUP / VM_GROWSDOWN VMAs are always private anonymous:
  292. * do_mmap() forbids all other combinations.
  293. */
  294. static inline bool is_stack_mapping(vm_flags_t flags)
  295. {
  296. return (flags & VM_STACK) == VM_STACK;
  297. }
  298. /*
  299. * Data area - private, writable, not stack
  300. */
  301. static inline bool is_data_mapping(vm_flags_t flags)
  302. {
  303. return (flags & (VM_WRITE | VM_SHARED | VM_STACK)) == VM_WRITE;
  304. }
  305. /* mm/util.c */
  306. void __vma_link_list(struct mm_struct *mm, struct vm_area_struct *vma,
  307. struct vm_area_struct *prev);
  308. void __vma_unlink_list(struct mm_struct *mm, struct vm_area_struct *vma);
  309. #ifdef CONFIG_MMU
  310. extern long populate_vma_page_range(struct vm_area_struct *vma,
  311. unsigned long start, unsigned long end, int *nonblocking);
  312. extern void munlock_vma_pages_range(struct vm_area_struct *vma,
  313. unsigned long start, unsigned long end);
  314. static inline void munlock_vma_pages_all(struct vm_area_struct *vma)
  315. {
  316. munlock_vma_pages_range(vma, vma->vm_start, vma->vm_end);
  317. }
  318. /*
  319. * must be called with vma's mmap_lock held for read or write, and page locked.
  320. */
  321. extern void mlock_vma_page(struct page *page);
  322. extern unsigned int munlock_vma_page(struct page *page);
  323. /*
  324. * Clear the page's PageMlocked(). This can be useful in a situation where
  325. * we want to unconditionally remove a page from the pagecache -- e.g.,
  326. * on truncation or freeing.
  327. *
  328. * It is legal to call this function for any page, mlocked or not.
  329. * If called for a page that is still mapped by mlocked vmas, all we do
  330. * is revert to lazy LRU behaviour -- semantics are not broken.
  331. */
  332. extern void clear_page_mlock(struct page *page);
  333. /*
  334. * mlock_migrate_page - called only from migrate_misplaced_transhuge_page()
  335. * (because that does not go through the full procedure of migration ptes):
  336. * to migrate the Mlocked page flag; update statistics.
  337. */
  338. static inline void mlock_migrate_page(struct page *newpage, struct page *page)
  339. {
  340. if (TestClearPageMlocked(page)) {
  341. int nr_pages = thp_nr_pages(page);
  342. /* Holding pmd lock, no change in irq context: __mod is safe */
  343. __mod_zone_page_state(page_zone(page), NR_MLOCK, -nr_pages);
  344. SetPageMlocked(newpage);
  345. __mod_zone_page_state(page_zone(newpage), NR_MLOCK, nr_pages);
  346. }
  347. }
  348. extern pmd_t maybe_pmd_mkwrite(pmd_t pmd, struct vm_area_struct *vma);
  349. /*
  350. * At what user virtual address is page expected in vma?
  351. * Returns -EFAULT if all of the page is outside the range of vma.
  352. * If page is a compound head, the entire compound page is considered.
  353. */
  354. static inline unsigned long
  355. vma_address(struct page *page, struct vm_area_struct *vma)
  356. {
  357. pgoff_t pgoff;
  358. unsigned long address;
  359. VM_BUG_ON_PAGE(PageKsm(page), page); /* KSM page->index unusable */
  360. pgoff = page_to_pgoff(page);
  361. if (pgoff >= vma->vm_pgoff) {
  362. address = vma->vm_start +
  363. ((pgoff - vma->vm_pgoff) << PAGE_SHIFT);
  364. /* Check for address beyond vma (or wrapped through 0?) */
  365. if (address < vma->vm_start || address >= vma->vm_end)
  366. address = -EFAULT;
  367. } else if (PageHead(page) &&
  368. pgoff + compound_nr(page) - 1 >= vma->vm_pgoff) {
  369. /* Test above avoids possibility of wrap to 0 on 32-bit */
  370. address = vma->vm_start;
  371. } else {
  372. address = -EFAULT;
  373. }
  374. return address;
  375. }
  376. /*
  377. * Then at what user virtual address will none of the page be found in vma?
  378. * Assumes that vma_address() already returned a good starting address.
  379. * If page is a compound head, the entire compound page is considered.
  380. */
  381. static inline unsigned long
  382. vma_address_end(struct page *page, struct vm_area_struct *vma)
  383. {
  384. pgoff_t pgoff;
  385. unsigned long address;
  386. VM_BUG_ON_PAGE(PageKsm(page), page); /* KSM page->index unusable */
  387. pgoff = page_to_pgoff(page) + compound_nr(page);
  388. address = vma->vm_start + ((pgoff - vma->vm_pgoff) << PAGE_SHIFT);
  389. /* Check for address beyond vma (or wrapped through 0?) */
  390. if (address < vma->vm_start || address > vma->vm_end)
  391. address = vma->vm_end;
  392. return address;
  393. }
  394. static inline struct file *maybe_unlock_mmap_for_io(struct vm_fault *vmf,
  395. struct file *fpin)
  396. {
  397. int flags = vmf->flags;
  398. if (fpin)
  399. return fpin;
  400. /*
  401. * FAULT_FLAG_RETRY_NOWAIT means we don't want to wait on page locks or
  402. * anything, so we only pin the file and drop the mmap_lock if only
  403. * FAULT_FLAG_ALLOW_RETRY is set, while this is the first attempt.
  404. */
  405. if (fault_flag_allow_retry_first(flags) &&
  406. !(flags & FAULT_FLAG_RETRY_NOWAIT)) {
  407. fpin = get_file(vmf->vma->vm_file);
  408. mmap_read_unlock(vmf->vma->vm_mm);
  409. }
  410. return fpin;
  411. }
  412. #else /* !CONFIG_MMU */
  413. static inline void clear_page_mlock(struct page *page) { }
  414. static inline void mlock_vma_page(struct page *page) { }
  415. static inline void mlock_migrate_page(struct page *new, struct page *old) { }
  416. #endif /* !CONFIG_MMU */
  417. /*
  418. * Return the mem_map entry representing the 'offset' subpage within
  419. * the maximally aligned gigantic page 'base'. Handle any discontiguity
  420. * in the mem_map at MAX_ORDER_NR_PAGES boundaries.
  421. */
  422. static inline struct page *mem_map_offset(struct page *base, int offset)
  423. {
  424. if (unlikely(offset >= MAX_ORDER_NR_PAGES))
  425. return nth_page(base, offset);
  426. return base + offset;
  427. }
  428. /*
  429. * Iterator over all subpages within the maximally aligned gigantic
  430. * page 'base'. Handle any discontiguity in the mem_map.
  431. */
  432. static inline struct page *mem_map_next(struct page *iter,
  433. struct page *base, int offset)
  434. {
  435. if (unlikely((offset & (MAX_ORDER_NR_PAGES - 1)) == 0)) {
  436. unsigned long pfn = page_to_pfn(base) + offset;
  437. if (!pfn_valid(pfn))
  438. return NULL;
  439. return pfn_to_page(pfn);
  440. }
  441. return iter + 1;
  442. }
  443. /* Memory initialisation debug and verification */
  444. enum mminit_level {
  445. MMINIT_WARNING,
  446. MMINIT_VERIFY,
  447. MMINIT_TRACE
  448. };
  449. #ifdef CONFIG_DEBUG_MEMORY_INIT
  450. extern int mminit_loglevel;
  451. #define mminit_dprintk(level, prefix, fmt, arg...) \
  452. do { \
  453. if (level < mminit_loglevel) { \
  454. if (level <= MMINIT_WARNING) \
  455. pr_warn("mminit::" prefix " " fmt, ##arg); \
  456. else \
  457. printk(KERN_DEBUG "mminit::" prefix " " fmt, ##arg); \
  458. } \
  459. } while (0)
  460. extern void mminit_verify_pageflags_layout(void);
  461. extern void mminit_verify_zonelist(void);
  462. #else
  463. static inline void mminit_dprintk(enum mminit_level level,
  464. const char *prefix, const char *fmt, ...)
  465. {
  466. }
  467. static inline void mminit_verify_pageflags_layout(void)
  468. {
  469. }
  470. static inline void mminit_verify_zonelist(void)
  471. {
  472. }
  473. #endif /* CONFIG_DEBUG_MEMORY_INIT */
  474. /* mminit_validate_memmodel_limits is independent of CONFIG_DEBUG_MEMORY_INIT */
  475. #if defined(CONFIG_SPARSEMEM)
  476. extern void mminit_validate_memmodel_limits(unsigned long *start_pfn,
  477. unsigned long *end_pfn);
  478. #else
  479. static inline void mminit_validate_memmodel_limits(unsigned long *start_pfn,
  480. unsigned long *end_pfn)
  481. {
  482. }
  483. #endif /* CONFIG_SPARSEMEM */
  484. #define NODE_RECLAIM_NOSCAN -2
  485. #define NODE_RECLAIM_FULL -1
  486. #define NODE_RECLAIM_SOME 0
  487. #define NODE_RECLAIM_SUCCESS 1
  488. #ifdef CONFIG_NUMA
  489. extern int node_reclaim(struct pglist_data *, gfp_t, unsigned int);
  490. #else
  491. static inline int node_reclaim(struct pglist_data *pgdat, gfp_t mask,
  492. unsigned int order)
  493. {
  494. return NODE_RECLAIM_NOSCAN;
  495. }
  496. #endif
  497. extern int hwpoison_filter(struct page *p);
  498. extern u32 hwpoison_filter_dev_major;
  499. extern u32 hwpoison_filter_dev_minor;
  500. extern u64 hwpoison_filter_flags_mask;
  501. extern u64 hwpoison_filter_flags_value;
  502. extern u64 hwpoison_filter_memcg;
  503. extern u32 hwpoison_filter_enable;
  504. extern unsigned long __must_check vm_mmap_pgoff(struct file *, unsigned long,
  505. unsigned long, unsigned long,
  506. unsigned long, unsigned long);
  507. extern void set_pageblock_order(void);
  508. unsigned int reclaim_clean_pages_from_list(struct zone *zone,
  509. struct list_head *page_list);
  510. /* The ALLOC_WMARK bits are used as an index to zone->watermark */
  511. #define ALLOC_WMARK_MIN WMARK_MIN
  512. #define ALLOC_WMARK_LOW WMARK_LOW
  513. #define ALLOC_WMARK_HIGH WMARK_HIGH
  514. #define ALLOC_NO_WATERMARKS 0x04 /* don't check watermarks at all */
  515. /* Mask to get the watermark bits */
  516. #define ALLOC_WMARK_MASK (ALLOC_NO_WATERMARKS-1)
  517. /*
  518. * Only MMU archs have async oom victim reclaim - aka oom_reaper so we
  519. * cannot assume a reduced access to memory reserves is sufficient for
  520. * !MMU
  521. */
  522. #ifdef CONFIG_MMU
  523. #define ALLOC_OOM 0x08
  524. #else
  525. #define ALLOC_OOM ALLOC_NO_WATERMARKS
  526. #endif
  527. #define ALLOC_HARDER 0x10 /* try to alloc harder */
  528. #define ALLOC_HIGH 0x20 /* __GFP_HIGH set */
  529. #define ALLOC_CPUSET 0x40 /* check for correct cpuset */
  530. #define ALLOC_CMA 0x80 /* allow allocations from CMA areas */
  531. #ifdef CONFIG_ZONE_DMA32
  532. #define ALLOC_NOFRAGMENT 0x100 /* avoid mixing pageblock types */
  533. #else
  534. #define ALLOC_NOFRAGMENT 0x0
  535. #endif
  536. #define ALLOC_KSWAPD 0x800 /* allow waking of kswapd, __GFP_KSWAPD_RECLAIM set */
  537. enum ttu_flags;
  538. struct tlbflush_unmap_batch;
  539. /*
  540. * only for MM internal work items which do not depend on
  541. * any allocations or locks which might depend on allocations
  542. */
  543. extern struct workqueue_struct *mm_percpu_wq;
  544. #ifdef CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH
  545. void try_to_unmap_flush(void);
  546. void try_to_unmap_flush_dirty(void);
  547. void flush_tlb_batched_pending(struct mm_struct *mm);
  548. #else
  549. static inline void try_to_unmap_flush(void)
  550. {
  551. }
  552. static inline void try_to_unmap_flush_dirty(void)
  553. {
  554. }
  555. static inline void flush_tlb_batched_pending(struct mm_struct *mm)
  556. {
  557. }
  558. #endif /* CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH */
  559. extern const struct trace_print_flags pageflag_names[];
  560. extern const struct trace_print_flags vmaflag_names[];
  561. extern const struct trace_print_flags gfpflag_names[];
  562. static inline bool is_migrate_highatomic(enum migratetype migratetype)
  563. {
  564. return migratetype == MIGRATE_HIGHATOMIC;
  565. }
  566. static inline bool is_migrate_highatomic_page(struct page *page)
  567. {
  568. return get_pageblock_migratetype(page) == MIGRATE_HIGHATOMIC;
  569. }
  570. void setup_zone_pageset(struct zone *zone);
  571. struct migration_target_control {
  572. int nid; /* preferred node id */
  573. nodemask_t *nmask;
  574. gfp_t gfp_mask;
  575. };
  576. #endif /* __MM_INTERNAL_H */