* [PATCH 3/3] balancenuma: fix page locking in migrating thp
@ 2012-11-24 4:27 Hillf Danton
2012-11-24 13:13 ` Mel Gorman
0 siblings, 1 reply; 2+ messages in thread
From: Hillf Danton @ 2012-11-24 4:27 UTC (permalink / raw)
To: Mel Gorman; +Cc: Hillf Danton, LKML
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@gmail.com>
---
--- 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;
}
--
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 3/3] balancenuma: fix page locking in migrating thp
2012-11-24 4:27 [PATCH 3/3] balancenuma: fix page locking in migrating thp Hillf Danton
@ 2012-11-24 13:13 ` Mel Gorman
0 siblings, 0 replies; 2+ messages in thread
From: Mel Gorman @ 2012-11-24 13:13 UTC (permalink / raw)
To: Hillf Danton; +Cc: LKML
On Sat, Nov 24, 2012 at 12:27:39PM +0800, Hillf Danton wrote:
> 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.
>
Less sure of this one but the locking here is a mess. A reference count
is already taken. Isolating the page takes another reference count so the
first one can be dropped without the page being freed underneath us. The
migration function takes care of unlocking the page on a successful
migration. On unsuccessful migration, the PMD is rechecked under the
lock before clearing the pmd_numa. I'm not sure where you are seeing
the instability but I haven't fired up my brain either (it's the weekend
:)). I'll take a fresh look at this Monday.
Thanks!
--
Mel Gorman
SUSE Labs
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-11-24 13:13 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-24 4:27 [PATCH 3/3] balancenuma: fix page locking in migrating thp Hillf Danton
2012-11-24 13:13 ` Mel Gorman
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.