diff options
Diffstat (limited to 'include/linux/mm.h')
-rw-r--r-- | include/linux/mm.h | 52 |
1 files changed, 48 insertions, 4 deletions
diff --git a/include/linux/mm.h b/include/linux/mm.h index 1bba6789a50a..e8abb3814209 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h | |||
@@ -227,10 +227,22 @@ static inline int put_page_testzero(struct page *page) | |||
227 | */ | 227 | */ |
228 | static inline int get_page_unless_zero(struct page *page) | 228 | static inline int get_page_unless_zero(struct page *page) |
229 | { | 229 | { |
230 | VM_BUG_ON(PageCompound(page)); | 230 | VM_BUG_ON(PageTail(page)); |
231 | return atomic_inc_not_zero(&page->_count); | 231 | return atomic_inc_not_zero(&page->_count); |
232 | } | 232 | } |
233 | 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 | |||
234 | static inline struct page *compound_head(struct page *page) | 246 | static inline struct page *compound_head(struct page *page) |
235 | { | 247 | { |
236 | if (unlikely(PageTail(page))) | 248 | if (unlikely(PageTail(page))) |
@@ -706,6 +718,28 @@ unsigned long unmap_vmas(struct mmu_gather **tlb, | |||
706 | struct vm_area_struct *start_vma, unsigned long start_addr, | 718 | struct vm_area_struct *start_vma, unsigned long start_addr, |
707 | unsigned long end_addr, unsigned long *nr_accounted, | 719 | unsigned long end_addr, unsigned long *nr_accounted, |
708 | 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); | ||
709 | void free_pgd_range(struct mmu_gather **tlb, unsigned long addr, | 743 | void free_pgd_range(struct mmu_gather **tlb, unsigned long addr, |
710 | unsigned long end, unsigned long floor, unsigned long ceiling); | 744 | unsigned long end, unsigned long floor, unsigned long ceiling); |
711 | 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, |
@@ -860,6 +894,18 @@ static inline pmd_t *pmd_alloc(struct mm_struct *mm, pud_t *pud, unsigned long a | |||
860 | #define pte_lockptr(mm, pmd) ({(void)(pmd); &(mm)->page_table_lock;}) | 894 | #define pte_lockptr(mm, pmd) ({(void)(pmd); &(mm)->page_table_lock;}) |
861 | #endif /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */ | 895 | #endif /* NR_CPUS < CONFIG_SPLIT_PTLOCK_CPUS */ |
862 | 896 | ||
897 | static inline void pgtable_page_ctor(struct page *page) | ||
898 | { | ||
899 | pte_lock_init(page); | ||
900 | inc_zone_page_state(page, NR_PAGETABLE); | ||
901 | } | ||
902 | |||
903 | static inline void pgtable_page_dtor(struct page *page) | ||
904 | { | ||
905 | pte_lock_deinit(page); | ||
906 | dec_zone_page_state(page, NR_PAGETABLE); | ||
907 | } | ||
908 | |||
863 | #define pte_offset_map_lock(mm, pmd, address, ptlp) \ | 909 | #define pte_offset_map_lock(mm, pmd, address, ptlp) \ |
864 | ({ \ | 910 | ({ \ |
865 | spinlock_t *__ptl = pte_lockptr(mm, pmd); \ | 911 | spinlock_t *__ptl = pte_lockptr(mm, pmd); \ |
@@ -1089,8 +1135,6 @@ static inline unsigned long vma_pages(struct vm_area_struct *vma) | |||
1089 | 1135 | ||
1090 | pgprot_t vm_get_page_prot(unsigned long vm_flags); | 1136 | pgprot_t vm_get_page_prot(unsigned long vm_flags); |
1091 | struct vm_area_struct *find_extend_vma(struct mm_struct *, unsigned long addr); | 1137 | struct vm_area_struct *find_extend_vma(struct mm_struct *, unsigned long addr); |
1092 | struct page *vmalloc_to_page(void *addr); | ||
1093 | unsigned long vmalloc_to_pfn(void *addr); | ||
1094 | int remap_pfn_range(struct vm_area_struct *, unsigned long addr, | 1138 | int remap_pfn_range(struct vm_area_struct *, unsigned long addr, |
1095 | unsigned long pfn, unsigned long size, pgprot_t); | 1139 | unsigned long pfn, unsigned long size, pgprot_t); |
1096 | int vm_insert_page(struct vm_area_struct *, unsigned long addr, struct page *); | 1140 | int vm_insert_page(struct vm_area_struct *, unsigned long addr, struct page *); |
@@ -1104,7 +1148,7 @@ struct page *follow_page(struct vm_area_struct *, unsigned long address, | |||
1104 | #define FOLL_GET 0x04 /* do get_page on page */ | 1148 | #define FOLL_GET 0x04 /* do get_page on page */ |
1105 | #define FOLL_ANON 0x08 /* give ZERO_PAGE if no pgtable */ | 1149 | #define FOLL_ANON 0x08 /* give ZERO_PAGE if no pgtable */ |
1106 | 1150 | ||
1107 | typedef int (*pte_fn_t)(pte_t *pte, struct page *pmd_page, unsigned long addr, | 1151 | typedef int (*pte_fn_t)(pte_t *pte, pgtable_t token, unsigned long addr, |
1108 | void *data); | 1152 | void *data); |
1109 | extern int apply_to_page_range(struct mm_struct *mm, unsigned long address, | 1153 | extern int apply_to_page_range(struct mm_struct *mm, unsigned long address, |
1110 | unsigned long size, pte_fn_t fn, void *data); | 1154 | unsigned long size, pte_fn_t fn, void *data); |