diff options
author | Andrea Arcangeli <aarcange@redhat.com> | 2011-01-13 18:46:32 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2011-01-13 20:32:38 -0500 |
commit | e9da73d67729b58bba256123e2b4651e0d8a01ac (patch) | |
tree | 5e7f8c4d394d625f7832cbd04a8d55f9f0cd0d95 /include | |
parent | a826e422420b461a6247137c292ff83c4800354a (diff) |
thp: compound_lock
Add a new compound_lock() needed to serialize put_page against
__split_huge_page_refcount().
Signed-off-by: Andrea Arcangeli <aarcange@redhat.com>
Acked-by: Rik van Riel <riel@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/mm.h | 34 | ||||
-rw-r--r-- | include/linux/page-flags.h | 12 |
2 files changed, 45 insertions, 1 deletions
diff --git a/include/linux/mm.h b/include/linux/mm.h index 57e11b2a18ba..3b1754ad8785 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/mm_types.h> | 14 | #include <linux/mm_types.h> |
15 | #include <linux/range.h> | 15 | #include <linux/range.h> |
16 | #include <linux/pfn.h> | 16 | #include <linux/pfn.h> |
17 | #include <linux/bit_spinlock.h> | ||
17 | 18 | ||
18 | struct mempolicy; | 19 | struct mempolicy; |
19 | struct anon_vma; | 20 | struct anon_vma; |
@@ -305,6 +306,39 @@ static inline int is_vmalloc_or_module_addr(const void *x) | |||
305 | } | 306 | } |
306 | #endif | 307 | #endif |
307 | 308 | ||
309 | static inline void compound_lock(struct page *page) | ||
310 | { | ||
311 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE | ||
312 | bit_spin_lock(PG_compound_lock, &page->flags); | ||
313 | #endif | ||
314 | } | ||
315 | |||
316 | static inline void compound_unlock(struct page *page) | ||
317 | { | ||
318 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE | ||
319 | bit_spin_unlock(PG_compound_lock, &page->flags); | ||
320 | #endif | ||
321 | } | ||
322 | |||
323 | static inline unsigned long compound_lock_irqsave(struct page *page) | ||
324 | { | ||
325 | unsigned long uninitialized_var(flags); | ||
326 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE | ||
327 | local_irq_save(flags); | ||
328 | compound_lock(page); | ||
329 | #endif | ||
330 | return flags; | ||
331 | } | ||
332 | |||
333 | static inline void compound_unlock_irqrestore(struct page *page, | ||
334 | unsigned long flags) | ||
335 | { | ||
336 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE | ||
337 | compound_unlock(page); | ||
338 | local_irq_restore(flags); | ||
339 | #endif | ||
340 | } | ||
341 | |||
308 | static inline struct page *compound_head(struct page *page) | 342 | static inline struct page *compound_head(struct page *page) |
309 | { | 343 | { |
310 | if (unlikely(PageTail(page))) | 344 | if (unlikely(PageTail(page))) |
diff --git a/include/linux/page-flags.h b/include/linux/page-flags.h index 4805fdec8d6e..5a743cc87238 100644 --- a/include/linux/page-flags.h +++ b/include/linux/page-flags.h | |||
@@ -108,6 +108,9 @@ enum pageflags { | |||
108 | #ifdef CONFIG_MEMORY_FAILURE | 108 | #ifdef CONFIG_MEMORY_FAILURE |
109 | PG_hwpoison, /* hardware poisoned page. Don't touch */ | 109 | PG_hwpoison, /* hardware poisoned page. Don't touch */ |
110 | #endif | 110 | #endif |
111 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE | ||
112 | PG_compound_lock, | ||
113 | #endif | ||
111 | __NR_PAGEFLAGS, | 114 | __NR_PAGEFLAGS, |
112 | 115 | ||
113 | /* Filesystems */ | 116 | /* Filesystems */ |
@@ -397,6 +400,12 @@ static inline void __ClearPageTail(struct page *page) | |||
397 | #define __PG_MLOCKED 0 | 400 | #define __PG_MLOCKED 0 |
398 | #endif | 401 | #endif |
399 | 402 | ||
403 | #ifdef CONFIG_TRANSPARENT_HUGEPAGE | ||
404 | #define __PG_COMPOUND_LOCK (1 << PG_compound_lock) | ||
405 | #else | ||
406 | #define __PG_COMPOUND_LOCK 0 | ||
407 | #endif | ||
408 | |||
400 | /* | 409 | /* |
401 | * Flags checked when a page is freed. Pages being freed should not have | 410 | * Flags checked when a page is freed. Pages being freed should not have |
402 | * these flags set. It they are, there is a problem. | 411 | * these flags set. It they are, there is a problem. |
@@ -406,7 +415,8 @@ static inline void __ClearPageTail(struct page *page) | |||
406 | 1 << PG_private | 1 << PG_private_2 | \ | 415 | 1 << PG_private | 1 << PG_private_2 | \ |
407 | 1 << PG_buddy | 1 << PG_writeback | 1 << PG_reserved | \ | 416 | 1 << PG_buddy | 1 << PG_writeback | 1 << PG_reserved | \ |
408 | 1 << PG_slab | 1 << PG_swapcache | 1 << PG_active | \ | 417 | 1 << PG_slab | 1 << PG_swapcache | 1 << PG_active | \ |
409 | 1 << PG_unevictable | __PG_MLOCKED | __PG_HWPOISON) | 418 | 1 << PG_unevictable | __PG_MLOCKED | __PG_HWPOISON | \ |
419 | __PG_COMPOUND_LOCK) | ||
410 | 420 | ||
411 | /* | 421 | /* |
412 | * Flags checked when a page is prepped for return by the page allocator. | 422 | * Flags checked when a page is prepped for return by the page allocator. |