Re: [PATCH 10/19] mm, mpol: Use special PROT_NONE to migrate pages

From: Rik van Riel
Date: Tue Jul 31 2012 - 17:24:15 EST


On 07/31/2012 03:12 PM, Peter Zijlstra wrote:

+ if (unlikely(pmd_trans_splitting(entry))) {
+ spin_unlock(&mm->page_table_lock);
+ wait_split_huge_page(vma->anon_vma, pmd);
+ return;
+ }
+
+#ifdef CONFIG_NUMA
+ page = pmd_page(entry);
+ VM_BUG_ON(!PageCompound(page) || !PageHead(page));
+
+ get_page(page);
+ spin_unlock(&mm->page_table_lock);
+
+ /*
+ * XXX should we serialize against split_huge_page ?
+ */

I believe we are already serialized here, because we check
for pmd_trans_splitting while holding the page table lock.

The THP code grabs the page table lock when modifying this
status, so we should be good.

+ /*
+ * Due to lacking code to migrate thp pages, we'll split
+ * (which preserves the special PROT_NONE) and re-take the
+ * fault on the normal pages.
+ */
+ split_huge_page(page);
+ put_page(page);
+ return;

Likewise, the THP code serializes split_huge_page, and has
protection against multiple simultaneous invocations of
split_huge_page.

A second invocation of split_huge_page will see that the
page was already split, and it will bail out.

+do_fixup:
+ spin_lock(&mm->page_table_lock);
+ if (unlikely(!pmd_same(*pmd, entry)))
+ goto out_unlock;

If the THP was split for another reason than a NUMA
fault, the !pmd_same check here should result in us
doing the right thing automatically.

I believe this code is correct.

Acked-by: Rik van Riel <riel@xxxxxxxxxx>

--
All rights reversed
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/