Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755999Ab0K3ArS (ORCPT ); Mon, 29 Nov 2010 19:47:18 -0500 Received: from TYO202.gate.nec.co.jp ([202.32.8.206]:57726 "EHLO tyo202.gate.nec.co.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755900Ab0K3ArP (ORCPT ); Mon, 29 Nov 2010 19:47:15 -0500 Date: Tue, 30 Nov 2010 09:38:04 +0900 From: Daisuke Nishimura To: Andrea Arcangeli Cc: linux-mm@kvack.org, Linus Torvalds , Andrew Morton , linux-kernel@vger.kernel.org, Marcelo Tosatti , Adam Litke , Avi Kivity , Hugh Dickins , Rik van Riel , Mel Gorman , Dave Hansen , Benjamin Herrenschmidt , Ingo Molnar , Mike Travis , KAMEZAWA Hiroyuki , Christoph Lameter , Chris Wright , bpicco@redhat.com, KOSAKI Motohiro , Balbir Singh , "Michael S. Tsirkin" , Peter Zijlstra , Johannes Weiner , Chris Mason , Borislav Petkov , Daisuke Nishimura Subject: Re: [PATCH 53 of 66] add numa awareness to hugepage allocations Message-Id: <20101130093804.23f8c355.nishimura@mxp.nes.nec.co.jp> In-Reply-To: <20101129161103.GE24474@random.random> References: <223ee926614158fc1353.1288798108@v2.random> <20101129143801.abef5228.nishimura@mxp.nes.nec.co.jp> <20101129161103.GE24474@random.random> Organization: NEC Soft, Ltd. X-Mailer: Sylpheed 3.0.3 (GTK+ 2.10.14; i686-pc-mingw32) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1155 Lines: 37 On Mon, 29 Nov 2010 17:11:03 +0100 Andrea Arcangeli wrote: > On Mon, Nov 29, 2010 at 02:38:01PM +0900, Daisuke Nishimura wrote: > > I think this should be: > > > > if (unlikely(mem_cgroup_newpage_charge(new_page, mm, GFP_KERNEL))) { > > #ifdef CONFIG_NUMA > > put_page(new_page); > > #endif > > goto out; > > } > > Hmm no, the change you suggest would generate memory corruption with > use after free. I'm sorry if I miss something, "new_page" will be reused in !CONFIG_NUMA case as you say, but, in CONFIG_NUMA case, it is allocated in this function (collapse_huge_page()) by alloc_hugepage_vma(), and is not freed when memcg's charge failed. Actually, we do in collapse_huge_page(): if (unlikely(!isolated)) { ... #ifdef CONFIG_NUMA put_page(new_page); #endif goto out; } later. I think we need a similar logic in memcg's failure path too. Thanks, Daisuke Nishimura. -- 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/