diff options
Diffstat (limited to 'include/linux/mm.h')
-rw-r--r-- | include/linux/mm.h | 70 |
1 files changed, 66 insertions, 4 deletions
diff --git a/include/linux/mm.h b/include/linux/mm.h index 520238cbae5d..89d7c691b93a 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h | |||
@@ -33,6 +33,8 @@ extern int sysctl_legacy_va_layout; | |||
33 | #define sysctl_legacy_va_layout 0 | 33 | #define sysctl_legacy_va_layout 0 |
34 | #endif | 34 | #endif |
35 | 35 | ||
36 | extern unsigned long mmap_min_addr; | ||
37 | |||
36 | #include <asm/page.h> | 38 | #include <asm/page.h> |
37 | #include <asm/pgtable.h> | 39 | #include <asm/pgtable.h> |
38 | #include <asm/processor.h> | 40 | #include <asm/processor.h> |
@@ -225,10 +227,22 @@ static inline int put_page_testzero(struct page *page) | |||
225 | */ | 227 | */ |
226 | static inline int get_page_unless_zero(struct page *page) | 228 | static inline int get_page_unless_zero(struct page *page) |
227 | { | 229 | { |
228 | VM_BUG_ON(PageCompound(page)); | 230 | VM_BUG_ON(PageTail(page)); |
229 | return atomic_inc_not_zero(&page->_count); | 231 | return atomic_inc_not_zero(&page->_count); |
230 | } | 232 | } |
231 | 233 | ||
234 | /* Support for virtually mapped pages */ | ||
235 | struct page *vmalloc_to_page(const void *addr); | ||
236 | unsigned long vmalloc_to_pfn(const void *addr); | ||
237 | |||
238 | /* Determine if an address is within the vmalloc range */ | ||
239 | static inline int is_vmalloc_addr(const void *x) | ||
240 | { | ||
241 | unsigned long addr = (unsigned long)x; | ||
242 | |||
243 | return addr >= VMALLOC_START && addr < VMALLOC_END; | ||
244 | } | ||
245 | |||
232 | static inline struct page *compound_head(struct page *page) | 246 | static inline struct page *compound_head(struct page *page) |
233 | { | 247 | { |
234 | if (unlikely(PageTail(page))) | 248 | if (unlikely(PageTail(page))) |
@@ -513,6 +527,21 @@ static inline void set_page_links(struct page *page, enum zone_type zone, | |||
513 | } | 527 | } |
514 | 528 | ||
515 | /* | 529 | /* |
530 | * If a hint addr is less than mmap_min_addr change hint to be as | ||
531 | * low as possible but still greater than mmap_min_addr | ||
532 | */ | ||
533 | static inline unsigned long round_hint_to_min(unsigned long hint) | ||
534 | { | ||
535 | #ifdef CONFIG_SECURITY | ||
536 | hint &= PAGE_MASK; | ||
537 | if (((void *)hint != NULL) && | ||
538 | (hint < mmap_min_addr)) | ||
539 | return PAGE_ALIGN(mmap_min_addr); | ||
540 | #endif | ||
541 | return hint; | ||
542 | } | ||
543 | |||
544 | /* | ||
516 | * Some inline functions in vmstat.h depend on page_zone() | 545 | * Some inline functions in vmstat.h depend on page_zone() |
517 | */ | 546 | */ |
518 | #include <linux/vmstat.h> | 547 | #include <linux/vmstat.h> |
@@ -689,6 +718,28 @@ unsigned long unmap_vmas(struct mmu_gather **tlb, | |||
689 | struct vm_area_struct *start_vma, unsigned long start_addr, | 718 | struct vm_area_struct *start_vma, unsigned long start_addr, |
690 | unsigned long end_addr, unsigned long *nr_accounted, | 719 | unsigned long end_addr, unsigned long *nr_accounted, |
691 | struct zap_details *); | 720 | struct zap_details *); |
721 | |||
722 | /** | ||
723 | * mm_walk - callbacks for walk_page_range | ||
724 | * @pgd_entry: if set, called for each non-empty PGD (top-level) entry | ||
725 | * @pud_entry: if set, called for each non-empty PUD (2nd-level) entry | ||
726 | * @pmd_entry: if set, called for each non-empty PMD (3rd-level) entry | ||
727 | * @pte_entry: if set, called for each non-empty PTE (4th-level) entry | ||
728 | * @pte_hole: if set, called for each hole at all levels | ||
729 | * | ||
730 | * (see walk_page_range for more details) | ||
731 | */ | ||
732 | struct mm_walk { | ||
733 | int (*pgd_entry)(pgd_t *, unsigned long, unsigned long, void *); | ||
734 | int (*pud_entry)(pud_t *, unsigned long, unsigned long, void *); | ||
735 | int (*pmd_entry)(pmd_t *, unsigned long, unsigned long, void *); | ||
736 | int (*pte_entry)(pte_t *, unsigned long, unsigned long, void *); | ||
737 | int (*pte_hole)(unsigned long, unsigned long, void *); | ||
738 | }; | ||
739 | |||
740 | int walk_page_range(const struct mm_struct *, unsigned long addr, | ||
741 | unsigned long end, const struct mm_walk *walk, | ||
742 | void *private); | ||
692 | void free_pgd_range(struct mmu_gather **tlb, unsigned long addr, | 743 | void free_pgd_range(struct mmu_gather **tlb, unsigned long addr, |
693 | unsigned long end, unsigned long floor, unsigned long ceiling); | 744 | unsigned long end, unsigned long floor, unsigned long ceiling); |
694 | void free_pgtables(struct mmu_gather **tlb, struct vm_area_struct *start_vma, | 745 | void free_pgtables(struct mmu_gather **tlb, struct vm_area_struct *start_vma, |
@@ -1072,8 +1123,6 @@ static inline unsigned long vma_pages(struct vm_area_struct *vma) | |||
1072 | 1123 | ||
1073 | pgprot_t vm_get_page_prot(unsigned long vm_flags); | 1124 | pgprot_t vm_get_page_prot(unsigned long vm_flags); |
1074 | struct vm_area_struct *find_extend_vma(struct mm_struct *, unsigned long addr); | 1125 | struct vm_area_struct *find_extend_vma(struct mm_struct *, unsigned long addr); |
1075 | struct page *vmalloc_to_page(void *addr); | ||
1076 | unsigned long vmalloc_to_pfn(void *addr); | ||
1077 | int remap_pfn_range(struct vm_area_struct *, unsigned long addr, | 1126 | int remap_pfn_range(struct vm_area_struct *, unsigned long addr, |
1078 | unsigned long pfn, unsigned long size, pgprot_t); | 1127 | unsigned long pfn, unsigned long size, pgprot_t); |
1079 | int vm_insert_page(struct vm_area_struct *, unsigned long addr, struct page *); | 1128 | int vm_insert_page(struct vm_area_struct *, unsigned long addr, struct page *); |
@@ -1101,9 +1150,21 @@ static inline void vm_stat_account(struct mm_struct *mm, | |||
1101 | } | 1150 | } |
1102 | #endif /* CONFIG_PROC_FS */ | 1151 | #endif /* CONFIG_PROC_FS */ |
1103 | 1152 | ||
1104 | #ifndef CONFIG_DEBUG_PAGEALLOC | 1153 | #ifdef CONFIG_DEBUG_PAGEALLOC |
1154 | extern int debug_pagealloc_enabled; | ||
1155 | |||
1156 | extern void kernel_map_pages(struct page *page, int numpages, int enable); | ||
1157 | |||
1158 | static inline void enable_debug_pagealloc(void) | ||
1159 | { | ||
1160 | debug_pagealloc_enabled = 1; | ||
1161 | } | ||
1162 | #else | ||
1105 | static inline void | 1163 | static inline void |
1106 | kernel_map_pages(struct page *page, int numpages, int enable) {} | 1164 | kernel_map_pages(struct page *page, int numpages, int enable) {} |
1165 | static inline void enable_debug_pagealloc(void) | ||
1166 | { | ||
1167 | } | ||
1107 | #endif | 1168 | #endif |
1108 | 1169 | ||
1109 | extern struct vm_area_struct *get_gate_vma(struct task_struct *tsk); | 1170 | extern struct vm_area_struct *get_gate_vma(struct task_struct *tsk); |
@@ -1129,6 +1190,7 @@ extern int randomize_va_space; | |||
1129 | #endif | 1190 | #endif |
1130 | 1191 | ||
1131 | const char * arch_vma_name(struct vm_area_struct *vma); | 1192 | const char * arch_vma_name(struct vm_area_struct *vma); |
1193 | void print_vma_addr(char *prefix, unsigned long rip); | ||
1132 | 1194 | ||
1133 | struct page *sparse_mem_map_populate(unsigned long pnum, int nid); | 1195 | struct page *sparse_mem_map_populate(unsigned long pnum, int nid); |
1134 | pgd_t *vmemmap_pgd_populate(unsigned long addr, int node); | 1196 | pgd_t *vmemmap_pgd_populate(unsigned long addr, int node); |