Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755702Ab1FGPHN (ORCPT ); Tue, 7 Jun 2011 11:07:13 -0400 Received: from cantor.suse.de ([195.135.220.2]:58531 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754557Ab1FGPHK (ORCPT ); Tue, 7 Jun 2011 11:07:10 -0400 From: Mel Gorman To: Andrew Morton Cc: Andrea Arcangeli , Minchan Kim , Thomas Sattler , Ury Stankevich , Andi Kleen , linux-mm , linux-kernel Subject: [PATCH 2/4] mm: vmscan: Do not use page_count without a page pin Date: Tue, 7 Jun 2011 16:07:03 +0100 Message-Id: <1307459225-4481-3-git-send-email-mgorman@suse.de> X-Mailer: git-send-email 1.7.3.4 In-Reply-To: <1307459225-4481-1-git-send-email-mgorman@suse.de> References: <1307459225-4481-1-git-send-email-mgorman@suse.de> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1582 Lines: 50 From: Andrea Arcangeli From: Andrea Arcangeli 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 Signed-off-by: Mel Gorman --- mm/vmscan.c | 16 ++++++++++++++-- 1 files changed, 14 insertions(+), 2 deletions(-) diff --git a/mm/vmscan.c b/mm/vmscan.c index faa0a08..001a504 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; } -- 1.7.3.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/