static struct page *page_trans_compound_anon(struct page *page)
{
if (PageTransCompound(page)) {
- struct page *head;
- head = compound_head(page);
+ struct page *head = compound_trans_head(page);
/*
- * head may be a dangling pointer.
- * __split_huge_page_refcount clears PageTail
- * before overwriting first_page, so if
- * PageTail is still there it means the head
- * pointer isn't dangling.
+ * head may actually be splitted and freed from under
+ * us but it's ok here.
*/
- if (head != page) {
- smp_rmb();
- if (!PageTransCompound(page))
- return NULL;
- }
if (PageAnon(head))
return head;
}
slot = ksm_scan.mm_slot;
if (slot == &ksm_mm_head) {
+ /*
+ * A number of pages can hang around indefinitely on per-cpu
+ * pagevecs, raised page count preventing write_protect_page
+ * from merging them. Though it doesn't really matter much,
+ * it is puzzling to see some stuck in pages_volatile until
+ * other activity jostles them out, and they also prevented
+ * LTP's KSM test from succeeding deterministically; so drain
+ * them here (here rather than on entry to ksm_do_scan(),
+ * so we don't IPI too often when pages_to_scan is set low).
+ */
+ lru_add_drain_all();
+
root_unstable_tree = RB_ROOT;
spin_lock(&ksm_mmlist_lock);