diff options
author | Andrea Arcangeli <aarcange@redhat.com> | 2011-01-13 18:47:20 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-01-13 20:32:48 -0500 |
commit | 22e5c47ee238abe636655c3862ed28d6eb084ad4 (patch) | |
tree | 4a4e7d330cbef6c99a8914de482eb0e8daba2485 /include/linux/huge_mm.h | |
parent | 29ad768cfc08611a4c1070d0f13f82eeea2bac7b (diff) |
thp: add compound_trans_head() helper
Cleanup some code with common compound_trans_head helper.
Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: Johannes Weiner <jweiner@redhat.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Avi Kivity <avi@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include/linux/huge_mm.h')
-rw-r--r-- | include/linux/huge_mm.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/include/linux/huge_mm.h b/include/linux/huge_mm.h index bddfba1d7b85..8e6c8c42bc3c 100644 --- a/include/linux/huge_mm.h +++ b/include/linux/huge_mm.h | |||
@@ -126,6 +126,23 @@ static inline int hpage_nr_pages(struct page *page) | |||
126 | return HPAGE_PMD_NR; | 126 | return HPAGE_PMD_NR; |
127 | return 1; | 127 | return 1; |
128 | } | 128 | } |
129 | static inline struct page *compound_trans_head(struct page *page) | ||
130 | { | ||
131 | if (PageTail(page)) { | ||
132 | struct page *head; | ||
133 | head = page->first_page; | ||
134 | smp_rmb(); | ||
135 | /* | ||
136 | * head may be a dangling pointer. | ||
137 | * __split_huge_page_refcount clears PageTail before | ||
138 | * overwriting first_page, so if PageTail is still | ||
139 | * there it means the head pointer isn't dangling. | ||
140 | */ | ||
141 | if (PageTail(page)) | ||
142 | return head; | ||
143 | } | ||
144 | return page; | ||
145 | } | ||
129 | #else /* CONFIG_TRANSPARENT_HUGEPAGE */ | 146 | #else /* CONFIG_TRANSPARENT_HUGEPAGE */ |
130 | #define HPAGE_PMD_SHIFT ({ BUG(); 0; }) | 147 | #define HPAGE_PMD_SHIFT ({ BUG(); 0; }) |
131 | #define HPAGE_PMD_MASK ({ BUG(); 0; }) | 148 | #define HPAGE_PMD_MASK ({ BUG(); 0; }) |
@@ -144,6 +161,7 @@ static inline int split_huge_page(struct page *page) | |||
144 | do { } while (0) | 161 | do { } while (0) |
145 | #define wait_split_huge_page(__anon_vma, __pmd) \ | 162 | #define wait_split_huge_page(__anon_vma, __pmd) \ |
146 | do { } while (0) | 163 | do { } while (0) |
164 | #define compound_trans_head(page) compound_head(page) | ||
147 | static inline int hugepage_madvise(struct vm_area_struct *vma, | 165 | static inline int hugepage_madvise(struct vm_area_struct *vma, |
148 | unsigned long *vm_flags, int advice) | 166 | unsigned long *vm_flags, int advice) |
149 | { | 167 | { |