Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752994AbaBEAW5 (ORCPT ); Tue, 4 Feb 2014 19:22:57 -0500 Received: from mail-pb0-f49.google.com ([209.85.160.49]:65135 "EHLO mail-pb0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750742AbaBEAWz (ORCPT ); Tue, 4 Feb 2014 19:22:55 -0500 Date: Tue, 4 Feb 2014 16:22:53 -0800 (PST) From: David Rientjes X-X-Sender: rientjes@chino.kir.corp.google.com To: Andrew Morton , Holger Kiehl cc: Christoph Lameter , Rafael Aquini , Vlastimil Babka , Michal Hocko , Mel Gorman , linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [patch v2] mm, page_alloc: make first_page visible before PageTail In-Reply-To: Message-ID: References: <20140203122052.GC2495@dhcp22.suse.cz> <20140203162036.GJ2495@dhcp22.suse.cz> <52EFC93D.3030106@suse.cz> <20140204160641.8f5d369eeb2d0318618d6d5f@linux-foundation.org> User-Agent: Alpine 2.02 (DEB 1266 2009-07-14) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit bf6bddf1924e ("mm: introduce compaction and migration for ballooned pages") introduces page_count(page) into memory compaction which dereferences page->first_page if PageTail(page). Introduce a store memory barrier to ensure page->first_page is properly initialized so that code that does page_count(page) on pages off the lru always have a valid p->first_page. Reported-by: Holger Kiehl Signed-off-by: David Rientjes --- v2: with commentary, per checkpatch mm/page_alloc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/mm/page_alloc.c b/mm/page_alloc.c --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@ -369,9 +369,11 @@ void prep_compound_page(struct page *page, unsigned long order) __SetPageHead(page); for (i = 1; i < nr_pages; i++) { struct page *p = page + i; - __SetPageTail(p); set_page_count(p, 0); p->first_page = page; + /* Make sure p->first_page is always valid for PageTail() */ + smp_wmb(); + __SetPageTail(p); } } -- 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/