summaryrefslogtreecommitdiff
path: root/mm
diff options
context:
space:
mode:
Diffstat (limited to 'mm')
-rw-r--r--mm/page_alloc.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 3f81bc374ca8..42b64528bbb3 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -890,8 +890,6 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
}
set_page_private(page, 0);
- set_page_refcounted(page);
-
arch_alloc_page(page, order);
kernel_map_pages(page, 1 << order, 1);
@@ -901,6 +899,16 @@ static int prep_new_page(struct page *page, int order, gfp_t gfp_flags)
if (order && (gfp_flags & __GFP_COMP))
prep_compound_page(page, order);
+ /*
+ * Make sure the caller of get_page_unless_zero() will see the
+ * fully initialized page. Say, to ensure that compound_lock()
+ * can't race with the non-atomic __SetPage*() above.
+ */
+#ifdef CONFIG_TRANSPARENT_HUGEPAGE
+ smp_wmb();
+#endif
+ set_page_refcounted(page);
+
return 0;
}