summaryrefslogtreecommitdiffstats
path: root/mm/vmscan.c
diff options
context:
space:
mode:
authorAndrea Arcangeli <aarcange@redhat.com>2011-06-15 15:08:51 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2011-06-15 20:04:02 -0700
commitd179e84ba5da1d0024087d1759a2938817a00f3f (patch)
tree169c9cc4030a793df1bc29613eff85ee3acef9a9 /mm/vmscan.c
parent7454f4ba40b419eb999a3c61a99da662bf1a2bb8 (diff)
downloadop-kernel-dev-d179e84ba5da1d0024087d1759a2938817a00f3f.zip
op-kernel-dev-d179e84ba5da1d0024087d1759a2938817a00f3f.tar.gz
mm: vmscan: do not use page_count without a page pin
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. [mgorman@suse.de: split out patch] Signed-off-by: Andrea Arcangeli <aarcange@redhat.com> Signed-off-by: Mel Gorman <mgorman@suse.de> Reviewed-by: Michal Hocko <mhocko@suse.cz> Reviewed-by: Minchan Kim <minchan.kim@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/vmscan.c')
-rw-r--r--mm/vmscan.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/mm/vmscan.c b/mm/vmscan.c
index dbe6ea3..8ff834e 100644
--- a/mm/vmscan.c
+++ b/mm/vmscan.c
@@ -1124,8 +1124,20 @@ static unsigned long isolate_lru_pages(unsigned long nr_to_scan,
nr_lumpy_dirty++;
scan++;
} else {
- /* the page is freed already. */
- if (!page_count(cursor_page))
+ /*
+ * Check if the page is freed already.
+ *
+ * We can't use page_count() as that
+ * requires compound_head and we don't
+ * have a pin on the page here. If a
+ * page is tail, we may or may not
+ * have isolated the head, so assume
+ * it's not free, it'd be tricky to
+ * track the head status without a
+ * page pin.
+ */
+ if (!PageTail(cursor_page) &&
+ !atomic_read(&cursor_page->_count))
continue;
break;
}
OpenPOWER on IntegriCloud