~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/include/linux/huge_mm.h

Version: ~ [ linux-5.5-rc7 ] ~ [ linux-5.4.13 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.97 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.166 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.210 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.210 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.140 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.81 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 #ifndef _LINUX_HUGE_MM_H
  2 #define _LINUX_HUGE_MM_H
  3 
  4 extern int do_huge_pmd_anonymous_page(struct mm_struct *mm,
  5                                       struct vm_area_struct *vma,
  6                                       unsigned long address, pmd_t *pmd,
  7                                       unsigned int flags);
  8 extern int copy_huge_pmd(struct mm_struct *dst_mm, struct mm_struct *src_mm,
  9                          pmd_t *dst_pmd, pmd_t *src_pmd, unsigned long addr,
 10                          struct vm_area_struct *vma);
 11 extern int do_huge_pmd_wp_page(struct mm_struct *mm, struct vm_area_struct *vma,
 12                                unsigned long address, pmd_t *pmd,
 13                                pmd_t orig_pmd);
 14 extern pgtable_t get_pmd_huge_pte(struct mm_struct *mm);
 15 extern struct page *follow_trans_huge_pmd(struct mm_struct *mm,
 16                                           unsigned long addr,
 17                                           pmd_t *pmd,
 18                                           unsigned int flags);
 19 extern int zap_huge_pmd(struct mmu_gather *tlb,
 20                         struct vm_area_struct *vma,
 21                         pmd_t *pmd, unsigned long addr);
 22 extern int mincore_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd,
 23                         unsigned long addr, unsigned long end,
 24                         unsigned char *vec);
 25 extern int move_huge_pmd(struct vm_area_struct *vma,
 26                          struct vm_area_struct *new_vma,
 27                          unsigned long old_addr,
 28                          unsigned long new_addr, unsigned long old_end,
 29                          pmd_t *old_pmd, pmd_t *new_pmd);
 30 extern int change_huge_pmd(struct vm_area_struct *vma, pmd_t *pmd,
 31                         unsigned long addr, pgprot_t newprot);
 32 
 33 enum transparent_hugepage_flag {
 34         TRANSPARENT_HUGEPAGE_FLAG,
 35         TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG,
 36         TRANSPARENT_HUGEPAGE_DEFRAG_FLAG,
 37         TRANSPARENT_HUGEPAGE_DEFRAG_REQ_MADV_FLAG,
 38         TRANSPARENT_HUGEPAGE_DEFRAG_KHUGEPAGED_FLAG,
 39 #ifdef CONFIG_DEBUG_VM
 40         TRANSPARENT_HUGEPAGE_DEBUG_COW_FLAG,
 41 #endif
 42 };
 43 
 44 enum page_check_address_pmd_flag {
 45         PAGE_CHECK_ADDRESS_PMD_FLAG,
 46         PAGE_CHECK_ADDRESS_PMD_NOTSPLITTING_FLAG,
 47         PAGE_CHECK_ADDRESS_PMD_SPLITTING_FLAG,
 48 };
 49 extern pmd_t *page_check_address_pmd(struct page *page,
 50                                      struct mm_struct *mm,
 51                                      unsigned long address,
 52                                      enum page_check_address_pmd_flag flag);
 53 
 54 #define HPAGE_PMD_ORDER (HPAGE_PMD_SHIFT-PAGE_SHIFT)
 55 #define HPAGE_PMD_NR (1<<HPAGE_PMD_ORDER)
 56 
 57 #ifdef CONFIG_TRANSPARENT_HUGEPAGE
 58 #define HPAGE_PMD_SHIFT HPAGE_SHIFT
 59 #define HPAGE_PMD_MASK HPAGE_MASK
 60 #define HPAGE_PMD_SIZE HPAGE_SIZE
 61 
 62 extern bool is_vma_temporary_stack(struct vm_area_struct *vma);
 63 
 64 #define transparent_hugepage_enabled(__vma)                             \
 65         ((transparent_hugepage_flags &                                  \
 66           (1<<TRANSPARENT_HUGEPAGE_FLAG) ||                             \
 67           (transparent_hugepage_flags &                                 \
 68            (1<<TRANSPARENT_HUGEPAGE_REQ_MADV_FLAG) &&                   \
 69            ((__vma)->vm_flags & VM_HUGEPAGE))) &&                       \
 70          !((__vma)->vm_flags & VM_NOHUGEPAGE) &&                        \
 71          !is_vma_temporary_stack(__vma))
 72 #define transparent_hugepage_defrag(__vma)                              \
 73         ((transparent_hugepage_flags &                                  \
 74           (1<<TRANSPARENT_HUGEPAGE_DEFRAG_FLAG)) ||                     \
 75          (transparent_hugepage_flags &                                  \
 76           (1<<TRANSPARENT_HUGEPAGE_DEFRAG_REQ_MADV_FLAG) &&             \
 77           (__vma)->vm_flags & VM_HUGEPAGE))
 78 #ifdef CONFIG_DEBUG_VM
 79 #define transparent_hugepage_debug_cow()                                \
 80         (transparent_hugepage_flags &                                   \
 81          (1<<TRANSPARENT_HUGEPAGE_DEBUG_COW_FLAG))
 82 #else /* CONFIG_DEBUG_VM */
 83 #define transparent_hugepage_debug_cow() 0
 84 #endif /* CONFIG_DEBUG_VM */
 85 
 86 extern unsigned long transparent_hugepage_flags;
 87 extern int copy_pte_range(struct mm_struct *dst_mm, struct mm_struct *src_mm,
 88                           pmd_t *dst_pmd, pmd_t *src_pmd,
 89                           struct vm_area_struct *vma,
 90                           unsigned long addr, unsigned long end);
 91 extern int handle_pte_fault(struct mm_struct *mm,
 92                             struct vm_area_struct *vma, unsigned long address,
 93                             pte_t *pte, pmd_t *pmd, unsigned int flags);
 94 extern int split_huge_page(struct page *page);
 95 extern void __split_huge_page_pmd(struct mm_struct *mm, pmd_t *pmd);
 96 #define split_huge_page_pmd(__mm, __pmd)                                \
 97         do {                                                            \
 98                 pmd_t *____pmd = (__pmd);                               \
 99                 if (unlikely(pmd_trans_huge(*____pmd)))                 \
100                         __split_huge_page_pmd(__mm, ____pmd);           \
101         }  while (0)
102 #define wait_split_huge_page(__anon_vma, __pmd)                         \
103         do {                                                            \
104                 pmd_t *____pmd = (__pmd);                               \
105                 anon_vma_lock(__anon_vma);                              \
106                 anon_vma_unlock(__anon_vma);                            \
107                 BUG_ON(pmd_trans_splitting(*____pmd) ||                 \
108                        pmd_trans_huge(*____pmd));                       \
109         } while (0)
110 #if HPAGE_PMD_ORDER > MAX_ORDER
111 #error "hugepages can't be allocated by the buddy allocator"
112 #endif
113 extern int hugepage_madvise(struct vm_area_struct *vma,
114                             unsigned long *vm_flags, int advice);
115 extern void __vma_adjust_trans_huge(struct vm_area_struct *vma,
116                                     unsigned long start,
117                                     unsigned long end,
118                                     long adjust_next);
119 extern int __pmd_trans_huge_lock(pmd_t *pmd,
120                                  struct vm_area_struct *vma);
121 /* mmap_sem must be held on entry */
122 static inline int pmd_trans_huge_lock(pmd_t *pmd,
123                                       struct vm_area_struct *vma)
124 {
125         VM_BUG_ON(!rwsem_is_locked(&vma->vm_mm->mmap_sem));
126         if (pmd_trans_huge(*pmd))
127                 return __pmd_trans_huge_lock(pmd, vma);
128         else
129                 return 0;
130 }
131 static inline void vma_adjust_trans_huge(struct vm_area_struct *vma,
132                                          unsigned long start,
133                                          unsigned long end,
134                                          long adjust_next)
135 {
136         if (!vma->anon_vma || vma->vm_ops)
137                 return;
138         __vma_adjust_trans_huge(vma, start, end, adjust_next);
139 }
140 static inline int hpage_nr_pages(struct page *page)
141 {
142         if (unlikely(PageTransHuge(page)))
143                 return HPAGE_PMD_NR;
144         return 1;
145 }
146 static inline struct page *compound_trans_head(struct page *page)
147 {
148         if (PageTail(page)) {
149                 struct page *head;
150                 head = page->first_page;
151                 smp_rmb();
152                 /*
153                  * head may be a dangling pointer.
154                  * __split_huge_page_refcount clears PageTail before
155                  * overwriting first_page, so if PageTail is still
156                  * there it means the head pointer isn't dangling.
157                  */
158                 if (PageTail(page))
159                         return head;
160         }
161         return page;
162 }
163 #else /* CONFIG_TRANSPARENT_HUGEPAGE */
164 #define HPAGE_PMD_SHIFT ({ BUILD_BUG(); 0; })
165 #define HPAGE_PMD_MASK ({ BUILD_BUG(); 0; })
166 #define HPAGE_PMD_SIZE ({ BUILD_BUG(); 0; })
167 
168 #define hpage_nr_pages(x) 1
169 
170 #define transparent_hugepage_enabled(__vma) 0
171 
172 #define transparent_hugepage_flags 0UL
173 static inline int split_huge_page(struct page *page)
174 {
175         return 0;
176 }
177 #define split_huge_page_pmd(__mm, __pmd)        \
178         do { } while (0)
179 #define wait_split_huge_page(__anon_vma, __pmd) \
180         do { } while (0)
181 #define compound_trans_head(page) compound_head(page)
182 static inline int hugepage_madvise(struct vm_area_struct *vma,
183                                    unsigned long *vm_flags, int advice)
184 {
185         BUG();
186         return 0;
187 }
188 static inline void vma_adjust_trans_huge(struct vm_area_struct *vma,
189                                          unsigned long start,
190                                          unsigned long end,
191                                          long adjust_next)
192 {
193 }
194 static inline int pmd_trans_huge_lock(pmd_t *pmd,
195                                       struct vm_area_struct *vma)
196 {
197         return 0;
198 }
199 #endif /* CONFIG_TRANSPARENT_HUGEPAGE */
200 
201 #endif /* _LINUX_HUGE_MM_H */
202 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp