Re: [PATCHv6 33/36] migrate_pages: try to split pages on qeueuing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Jun 11, 2015 at 11:27:19AM +0200, Vlastimil Babka wrote:
> On 06/03/2015 07:06 PM, Kirill A. Shutemov wrote:
> >We are not able to migrate THPs. It means it's not enough to split only
> >PMD on migration -- we need to split compound page under it too.
> >
> >Signed-off-by: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx>
> >---
> >  mm/mempolicy.c | 37 +++++++++++++++++++++++++++++++++----
> >  1 file changed, 33 insertions(+), 4 deletions(-)
> >
> >diff --git a/mm/mempolicy.c b/mm/mempolicy.c
> >index 528f6c467cf1..0b1499c2f890 100644
> >--- a/mm/mempolicy.c
> >+++ b/mm/mempolicy.c
> >@@ -489,14 +489,31 @@ static int queue_pages_pte_range(pmd_t *pmd, unsigned long addr,
> >  	struct page *page;
> >  	struct queue_pages *qp = walk->private;
> >  	unsigned long flags = qp->flags;
> >-	int nid;
> >+	int nid, ret;
> >  	pte_t *pte;
> >  	spinlock_t *ptl;
> >
> >-	split_huge_pmd(vma, pmd, addr);
> >-	if (pmd_trans_unstable(pmd))
> >-		return 0;
> >+	if (pmd_trans_huge(*pmd)) {
> >+		ptl = pmd_lock(walk->mm, pmd);
> >+		if (pmd_trans_huge(*pmd)) {
> >+			page = pmd_page(*pmd);
> >+			if (is_huge_zero_page(page)) {
> >+				spin_unlock(ptl);
> >+				split_huge_pmd(vma, pmd, addr);
> >+			} else {
> >+				get_page(page);
> >+				spin_unlock(ptl);
> >+				lock_page(page);
> >+				ret = split_huge_page(page);
> >+				unlock_page(page);
> >+				put_page(page);
> >+				if (ret)
> >+					return 0;
> >+			}
> >+		}
> >+	}
> >
> >+retry:
> >  	pte = pte_offset_map_lock(walk->mm, pmd, addr, &ptl);
> >  	for (; addr != end; pte++, addr += PAGE_SIZE) {
> >  		if (!pte_present(*pte))
> >@@ -513,6 +530,18 @@ static int queue_pages_pte_range(pmd_t *pmd, unsigned long addr,
> >  		nid = page_to_nid(page);
> >  		if (node_isset(nid, *qp->nmask) == !!(flags & MPOL_MF_INVERT))
> >  			continue;
> >+		if (PageTail(page) && PageAnon(page)) {
> 
> Hm, can it really happen that we stumble upon THP tail page here, without
> first stumbling upon it in the previous hunk above? If so, when?

The first hunk catch PMD-mapped THP and here we deal with PTE-mapped.
The scenario: fault in a THP, split PMD (not page) e.g. with mprotect()
and then try to migrate.

-- 
 Kirill A. Shutemov

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@xxxxxxxxx.  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@xxxxxxxxx";> email@xxxxxxxxx </a>



[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]