]> git.karo-electronics.de Git - karo-tx-linux.git/commit
mm/memory-failure.c: fix memory leak in successful soft offlining
authorNaoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Fri, 7 Jun 2013 00:07:54 +0000 (10:07 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Fri, 7 Jun 2013 05:42:15 +0000 (15:42 +1000)
commit91e20931addbf524eafa82048d59b34bbb2591e9
treea42e9283694fcfc6bab89775e37d503e4a8969ec
parent20de3cf0c143a6dbcc77b0ee97d5edfc99143139
mm/memory-failure.c: fix memory leak in successful soft offlining

After a successful page migration by soft offlining, the source page is
not properly freed and it's never reusable even if we unpoison it
afterward.

This is caused by the race between freeing page and setting PG_hwpoison.
In successful soft offlining, the source page is put (and the refcount
becomes 0) by putback_lru_page() in unmap_and_move(), where it's linked to
pagevec and actual freeing back to buddy is delayed.  So if PG_hwpoison is
set for the page before freeing, the freeing does not functions as
expected (in such case freeing aborts in free_pages_prepare() check.)

This patch tries to make sure to free the source page before setting
PG_hwpoison on it.  To avoid reallocating, the page keeps MIGRATE_ISOLATE
until after setting PG_hwpoison.

This patch also removes obsolete comments about "keeping elevated
refcount" because what they say is not true.  Unlike memory_failure(),
soft_offline_page() uses no special page isolation code, and the
soft-offlined pages have no elevated.

Signed-off-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Mel Gorman <mel@csn.ul.ie>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/memory-failure.c