123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504 |
- #ifndef __MM_INTERNAL_H
- #define __MM_INTERNAL_H
- #include <linux/fs.h>
- #include <linux/mm.h>
- #include <linux/pagemap.h>
- #include <linux/tracepoint-defs.h>
- #define GFP_RECLAIM_MASK (__GFP_RECLAIM|__GFP_HIGH|__GFP_IO|__GFP_FS|\
- __GFP_NOWARN|__GFP_REPEAT|__GFP_NOFAIL|\
- __GFP_NORETRY|__GFP_MEMALLOC|__GFP_NOMEMALLOC|\
- __GFP_ATOMIC)
- #define GFP_BOOT_MASK (__GFP_BITS_MASK & ~(__GFP_RECLAIM|__GFP_IO|__GFP_FS))
- #define GFP_CONSTRAINT_MASK (__GFP_HARDWALL|__GFP_THISNODE)
- #define GFP_SLAB_BUG_MASK (__GFP_DMA32|__GFP_HIGHMEM|~__GFP_BITS_MASK)
- void page_writeback_init(void);
- int do_swap_page(struct fault_env *fe, pte_t orig_pte);
- void free_pgtables(struct mmu_gather *tlb, struct vm_area_struct *start_vma,
- unsigned long floor, unsigned long ceiling);
- static inline bool can_madv_dontneed_vma(struct vm_area_struct *vma)
- {
- return !(vma->vm_flags & (VM_LOCKED|VM_HUGETLB|VM_PFNMAP));
- }
- void unmap_page_range(struct mmu_gather *tlb,
- struct vm_area_struct *vma,
- unsigned long addr, unsigned long end,
- struct zap_details *details);
- extern int __do_page_cache_readahead(struct address_space *mapping,
- struct file *filp, pgoff_t offset, unsigned long nr_to_read,
- unsigned long lookahead_size);
- static inline unsigned long ra_submit(struct file_ra_state *ra,
- struct address_space *mapping, struct file *filp)
- {
- return __do_page_cache_readahead(mapping, filp,
- ra->start, ra->size, ra->async_size);
- }
- static inline void set_page_refcounted(struct page *page)
- {
- VM_BUG_ON_PAGE(PageTail(page), page);
- VM_BUG_ON_PAGE(page_ref_count(page), page);
- set_page_count(page, 1);
- }
- extern unsigned long highest_memmap_pfn;
- #define MAX_RECLAIM_RETRIES 16
- extern int isolate_lru_page(struct page *page);
- extern void putback_lru_page(struct page *page);
- extern pmd_t *mm_find_pmd(struct mm_struct *mm, unsigned long address);
- struct alloc_context {
- struct zonelist *zonelist;
- nodemask_t *nodemask;
- struct zoneref *preferred_zoneref;
- int migratetype;
- enum zone_type high_zoneidx;
- bool spread_dirty_pages;
- };
- #define ac_classzone_idx(ac) zonelist_zone_idx(ac->preferred_zoneref)
- static inline unsigned long
- __find_buddy_index(unsigned long page_idx, unsigned int order)
- {
- return page_idx ^ (1 << order);
- }
- extern struct page *__pageblock_pfn_to_page(unsigned long start_pfn,
- unsigned long end_pfn, struct zone *zone);
- static inline struct page *pageblock_pfn_to_page(unsigned long start_pfn,
- unsigned long end_pfn, struct zone *zone)
- {
- if (zone->contiguous)
- return pfn_to_page(start_pfn);
- return __pageblock_pfn_to_page(start_pfn, end_pfn, zone);
- }
- extern int __isolate_free_page(struct page *page, unsigned int order);
- extern void __free_pages_bootmem(struct page *page, unsigned long pfn,
- unsigned int order);
- extern void prep_compound_page(struct page *page, unsigned int order);
- extern void post_alloc_hook(struct page *page, unsigned int order,
- gfp_t gfp_flags);
- extern int user_min_free_kbytes;
- #if defined CONFIG_COMPACTION || defined CONFIG_CMA
- struct compact_control {
- struct list_head freepages;
- struct list_head migratepages;
- unsigned long nr_freepages;
- unsigned long nr_migratepages;
- unsigned long free_pfn;
- unsigned long migrate_pfn;
- unsigned long last_migrated_pfn;
- enum migrate_mode mode;
- bool ignore_skip_hint;
- bool ignore_block_suitable;
- bool direct_compaction;
- bool whole_zone;
- int order;
- const gfp_t gfp_mask;
- const unsigned int alloc_flags;
- const int classzone_idx;
- struct zone *zone;
- bool contended;
- };
- unsigned long
- isolate_freepages_range(struct compact_control *cc,
- unsigned long start_pfn, unsigned long end_pfn);
- unsigned long
- isolate_migratepages_range(struct compact_control *cc,
- unsigned long low_pfn, unsigned long end_pfn);
- int find_suitable_fallback(struct free_area *area, unsigned int order,
- int migratetype, bool only_stealable, bool *can_steal);
- #endif
- static inline unsigned int page_order(struct page *page)
- {
-
- return page_private(page);
- }
- #define page_order_unsafe(page) READ_ONCE(page_private(page))
- static inline bool is_cow_mapping(vm_flags_t flags)
- {
- return (flags & (VM_SHARED | VM_MAYWRITE)) == VM_MAYWRITE;
- }
- static inline bool is_exec_mapping(vm_flags_t flags)
- {
- return (flags & (VM_EXEC | VM_WRITE | VM_STACK)) == VM_EXEC;
- }
- static inline bool is_stack_mapping(vm_flags_t flags)
- {
- return (flags & VM_STACK) == VM_STACK;
- }
- static inline bool is_data_mapping(vm_flags_t flags)
- {
- return (flags & (VM_WRITE | VM_SHARED | VM_STACK)) == VM_WRITE;
- }
- void __vma_link_list(struct mm_struct *mm, struct vm_area_struct *vma,
- struct vm_area_struct *prev, struct rb_node *rb_parent);
- #ifdef CONFIG_MMU
- extern long populate_vma_page_range(struct vm_area_struct *vma,
- unsigned long start, unsigned long end, int *nonblocking);
- extern void munlock_vma_pages_range(struct vm_area_struct *vma,
- unsigned long start, unsigned long end);
- static inline void munlock_vma_pages_all(struct vm_area_struct *vma)
- {
- munlock_vma_pages_range(vma, vma->vm_start, vma->vm_end);
- }
- extern void mlock_vma_page(struct page *page);
- extern unsigned int munlock_vma_page(struct page *page);
- extern void clear_page_mlock(struct page *page);
- static inline void mlock_migrate_page(struct page *newpage, struct page *page)
- {
- if (TestClearPageMlocked(page)) {
- int nr_pages = hpage_nr_pages(page);
-
- __mod_zone_page_state(page_zone(page), NR_MLOCK, -nr_pages);
- SetPageMlocked(newpage);
- __mod_zone_page_state(page_zone(newpage), NR_MLOCK, nr_pages);
- }
- }
- extern pmd_t maybe_pmd_mkwrite(pmd_t pmd, struct vm_area_struct *vma);
- static inline unsigned long
- __vma_address(struct page *page, struct vm_area_struct *vma)
- {
- pgoff_t pgoff = page_to_pgoff(page);
- return vma->vm_start + ((pgoff - vma->vm_pgoff) << PAGE_SHIFT);
- }
- static inline unsigned long
- vma_address(struct page *page, struct vm_area_struct *vma)
- {
- unsigned long address = __vma_address(page, vma);
-
- VM_BUG_ON_VMA(address < vma->vm_start || address >= vma->vm_end, vma);
- return address;
- }
- #else
- static inline void clear_page_mlock(struct page *page) { }
- static inline void mlock_vma_page(struct page *page) { }
- static inline void mlock_migrate_page(struct page *new, struct page *old) { }
- #endif
- static inline struct page *mem_map_offset(struct page *base, int offset)
- {
- if (unlikely(offset >= MAX_ORDER_NR_PAGES))
- return nth_page(base, offset);
- return base + offset;
- }
- static inline struct page *mem_map_next(struct page *iter,
- struct page *base, int offset)
- {
- if (unlikely((offset & (MAX_ORDER_NR_PAGES - 1)) == 0)) {
- unsigned long pfn = page_to_pfn(base) + offset;
- if (!pfn_valid(pfn))
- return NULL;
- return pfn_to_page(pfn);
- }
- return iter + 1;
- }
- #ifdef CONFIG_SPARSEMEM
- #define __paginginit __meminit
- #else
- #define __paginginit __init
- #endif
- enum mminit_level {
- MMINIT_WARNING,
- MMINIT_VERIFY,
- MMINIT_TRACE
- };
- #ifdef CONFIG_DEBUG_MEMORY_INIT
- extern int mminit_loglevel;
- #define mminit_dprintk(level, prefix, fmt, arg...) \
- do { \
- if (level < mminit_loglevel) { \
- if (level <= MMINIT_WARNING) \
- pr_warn("mminit::" prefix " " fmt, ##arg); \
- else \
- printk(KERN_DEBUG "mminit::" prefix " " fmt, ##arg); \
- } \
- } while (0)
- extern void mminit_verify_pageflags_layout(void);
- extern void mminit_verify_zonelist(void);
- #else
- static inline void mminit_dprintk(enum mminit_level level,
- const char *prefix, const char *fmt, ...)
- {
- }
- static inline void mminit_verify_pageflags_layout(void)
- {
- }
- static inline void mminit_verify_zonelist(void)
- {
- }
- #endif
- #if defined(CONFIG_SPARSEMEM)
- extern void mminit_validate_memmodel_limits(unsigned long *start_pfn,
- unsigned long *end_pfn);
- #else
- static inline void mminit_validate_memmodel_limits(unsigned long *start_pfn,
- unsigned long *end_pfn)
- {
- }
- #endif
- #define NODE_RECLAIM_NOSCAN -2
- #define NODE_RECLAIM_FULL -1
- #define NODE_RECLAIM_SOME 0
- #define NODE_RECLAIM_SUCCESS 1
- extern int hwpoison_filter(struct page *p);
- extern u32 hwpoison_filter_dev_major;
- extern u32 hwpoison_filter_dev_minor;
- extern u64 hwpoison_filter_flags_mask;
- extern u64 hwpoison_filter_flags_value;
- extern u64 hwpoison_filter_memcg;
- extern u32 hwpoison_filter_enable;
- extern unsigned long __must_check vm_mmap_pgoff(struct file *, unsigned long,
- unsigned long, unsigned long,
- unsigned long, unsigned long);
- extern void set_pageblock_order(void);
- unsigned long reclaim_clean_pages_from_list(struct zone *zone,
- struct list_head *page_list);
- #define ALLOC_WMARK_MIN WMARK_MIN
- #define ALLOC_WMARK_LOW WMARK_LOW
- #define ALLOC_WMARK_HIGH WMARK_HIGH
- #define ALLOC_NO_WATERMARKS 0x04
- #define ALLOC_WMARK_MASK (ALLOC_NO_WATERMARKS-1)
- #define ALLOC_HARDER 0x10
- #define ALLOC_HIGH 0x20
- #define ALLOC_CPUSET 0x40
- #define ALLOC_CMA 0x80
- enum ttu_flags;
- struct tlbflush_unmap_batch;
- #ifdef CONFIG_ARCH_WANT_BATCHED_UNMAP_TLB_FLUSH
- void try_to_unmap_flush(void);
- void try_to_unmap_flush_dirty(void);
- void flush_tlb_batched_pending(struct mm_struct *mm);
- #else
- static inline void try_to_unmap_flush(void)
- {
- }
- static inline void try_to_unmap_flush_dirty(void)
- {
- }
- static inline void flush_tlb_batched_pending(struct mm_struct *mm)
- {
- }
- #endif
- extern const struct trace_print_flags pageflag_names[];
- extern const struct trace_print_flags vmaflag_names[];
- extern const struct trace_print_flags gfpflag_names[];
- #endif
|