From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail172.messagelabs.com (mail172.messagelabs.com [216.82.254.3]) by kanga.kvack.org (Postfix) with ESMTP id 169BC6B0069 for ; Fri, 18 Nov 2011 09:21:28 -0500 (EST) Received: by vcbfo1 with SMTP id fo1so2971262vcb.14 for ; Fri, 18 Nov 2011 06:21:26 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: Date: Fri, 18 Nov 2011 15:21:26 +0100 Message-ID: Subject: Re: [PATCH] hugetlb: detect race if fail to COW From: John Kacur Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Sender: owner-linux-mm@kvack.org List-ID: To: Hillf Danton Cc: Andrea Arcangeli , Andrew Morton , Michal Hocko , Johannes Weiner , linux-mm@kvack.org, LKML On Fri, Nov 18, 2011 at 3:16 PM, John Kacur wrote: > On Fri, Nov 18, 2011 at 3:04 PM, Hillf Danton wrote: >> In the error path that we fail to allocate new huge page, before try aga= in, we >> have to check race since page_table_lock is re-acquired. >> >> If racing, our job is done. >> >> Signed-off-by: Hillf Danton >> --- >> >> --- a/mm/hugetlb.c =A0 =A0 =A0Fri Nov 18 21:38:30 2011 >> +++ b/mm/hugetlb.c =A0 =A0 =A0Fri Nov 18 21:48:15 2011 >> @@ -2407,7 +2407,14 @@ retry_avoidcopy: >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0BUG_ON(pa= ge_count(old_page) !=3D 1); >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0BUG_ON(hu= ge_pte_none(pte)); >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0spin_lock= (&mm->page_table_lock); >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 goto retry= _avoidcopy; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ptep =3D h= uge_pte_offset(mm, address & huge_page_mask(h)); >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 if (likely= (pte_same(huge_ptep_get(ptep), pte))) >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 goto retry_avoidcopy; >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 /* >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* race = occurs while re-acquiring page_table_lock, and >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0* our j= ob is done. >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0*/ >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 return 0; >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0WARN_ON_ONCE(1); >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0} > > > I'm not sure about the veracity of the race condition, but you better > do spin_unlock before you return. > Ugh, sorry for the noise, I see that's not how it works here. -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/ Don't email: email@kvack.org