[PATCH 3/3] balancenuma: fix page locking in migrating thp

From: Hillf Danton
Date: Fri Nov 23 2012 - 23:27:49 EST


If fail to migrate thp(due to unsuccessful isolation), and if the original
pmd entry is changed after reaquiring page table lock, it is unsafe to
release the page lock as page maybe unstable.

It is fixed by raising extra page count before trying migration.

Signed-off-by: Hillf Danton <dhillf@xxxxxxxxx>
---

--- a/mm/huge_memory.c Fri Nov 23 22:07:38 2012
+++ b/mm/huge_memory.c Fri Nov 23 22:55:32 2012
@@ -1060,11 +1060,13 @@ int do_huge_pmd_numa_page(struct mm_stru
}
spin_unlock(&mm->page_table_lock);

+ get_page(page);
/* Migrate the THP to the requested node */
migrated = migrate_misplaced_transhuge_page(mm, vma,
pmdp, pmd, addr,
page, target_nid);
if (migrated) {
+ put_page(page);
count_vm_numa_event(NUMA_THP_MIGRATE_SUCCESS);
current_nid = target_nid;
} else {
@@ -1072,8 +1074,10 @@ int do_huge_pmd_numa_page(struct mm_stru
spin_lock(&mm->page_table_lock);
if (unlikely(!pmd_same(pmd, *pmdp))) {
unlock_page(page);
+ put_page(page);
goto out_unlock;
}
+ put_page(page);
goto clear_pmdnuma;
}

--
--
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/