diff options
author | Minchan Kim <minchan@kernel.org> | 2012-07-31 19:42:59 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-07-31 21:42:42 -0400 |
commit | 97d255c816946388bab504122937730d3447c612 (patch) | |
tree | 828927fe44ebb6c0bd6cfd2a0da36b68ed45b4ba /mm/page_alloc.c | |
parent | de34d965a80d0f61a354bdefa0b15a88bcff2028 (diff) |
mm: do not use page_count() without a page pin
d179e84ba ("mm: vmscan: do not use page_count without a page pin") fixed
this problem in vmscan.c but same problem is in __count_immobile_pages().
I copy and paste d179e84ba's contents for description.
"It is unsafe to run page_count during the physical pfn scan because
compound_head could trip on a dangling pointer when reading
page->first_page if the compound page is being freed by another CPU."
Signed-off-by: Minchan Kim <minchan@kernel.org>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: Mel Gorman <mgorman@suse.de>
Cc: Michal Hocko <mhocko@suse.cz>
Reviewed-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Wanpeng Li <liwp.linux@gmail.com>
Cc: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/page_alloc.c')
-rw-r--r-- | mm/page_alloc.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/mm/page_alloc.c b/mm/page_alloc.c index 18747528eec3..bb790f5919e3 100644 --- a/mm/page_alloc.c +++ b/mm/page_alloc.c | |||
@@ -5500,11 +5500,18 @@ __count_immobile_pages(struct zone *zone, struct page *page, int count) | |||
5500 | continue; | 5500 | continue; |
5501 | 5501 | ||
5502 | page = pfn_to_page(check); | 5502 | page = pfn_to_page(check); |
5503 | if (!page_count(page)) { | 5503 | /* |
5504 | * We can't use page_count without pin a page | ||
5505 | * because another CPU can free compound page. | ||
5506 | * This check already skips compound tails of THP | ||
5507 | * because their page->_count is zero at all time. | ||
5508 | */ | ||
5509 | if (!atomic_read(&page->_count)) { | ||
5504 | if (PageBuddy(page)) | 5510 | if (PageBuddy(page)) |
5505 | iter += (1 << page_order(page)) - 1; | 5511 | iter += (1 << page_order(page)) - 1; |
5506 | continue; | 5512 | continue; |
5507 | } | 5513 | } |
5514 | |||
5508 | if (!PageLRU(page)) | 5515 | if (!PageLRU(page)) |
5509 | found++; | 5516 | found++; |
5510 | /* | 5517 | /* |