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 SMTP id 524D46B005A for ; Sun, 2 Aug 2009 04:34:31 -0400 (EDT) Received: by bwz24 with SMTP id 24so2508163bwz.38 for ; Sun, 02 Aug 2009 01:44:44 -0700 (PDT) Message-ID: <4A755201.1010200@gmail.com> Date: Sun, 02 Aug 2009 10:44:49 +0200 From: Jiri Slaby MIME-Version: 1.0 Subject: mm/hugetlb: GFP_KERNEL allocation under spinlock? Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: owner-linux-mm@kvack.org To: linux-mm@kvack.org Cc: Mel Gorman , Hugh Dickins List-ID: Hi, could anybody please confirm this cannot happen? hugetlb_fault() -> spin_lock() -> hugetlb_cow() -> alloc_huge_page() -> vma_needs_reservation() -> region_chg() (either of the 2) -> kmalloc(*, GFP_KERNEL) Thanks. -- 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/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail144.messagelabs.com (mail144.messagelabs.com [216.82.254.51]) by kanga.kvack.org (Postfix) with SMTP id 8C51D6B005D for ; Sun, 2 Aug 2009 06:43:27 -0400 (EDT) Date: Sun, 2 Aug 2009 11:54:13 +0100 (BST) From: Hugh Dickins Subject: Re: mm/hugetlb: GFP_KERNEL allocation under spinlock? In-Reply-To: <4A755201.1010200@gmail.com> Message-ID: References: <4A755201.1010200@gmail.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-linux-mm@kvack.org To: Jiri Slaby Cc: linux-mm@kvack.org, Mel Gorman List-ID: On Sun, 2 Aug 2009, Jiri Slaby wrote: > > could anybody please confirm this cannot happen? I'm no authority on hugetlb.c nowadays: you'll have studied this in more detail than I have, so please don't believe me. (And I'm no longer at my old address, but lkml's enjoying a quiet Sunday.) > > hugetlb_fault() > -> spin_lock() > -> hugetlb_cow() > -> alloc_huge_page() > -> vma_needs_reservation() > -> region_chg() (either of the 2) > -> kmalloc(*, GFP_KERNEL) > > Thanks. That should be taken care of by the successful vma_needs_reservation() on the same address in hugetlb_fault(), before taking page_table_lock, shouldn't it? It is possible that a hugetlb_vmtruncate() comes in between that vma_needs_reservation() and taking the page_table_lock, which could remove the region (or "nrg") needed. But if that's the case then the pte_same test immediately after taking page_table_lock should catch it: we're in the part of hugetlb_fault() dealing with !huge_pte_none, whereas truncation would have made it huge_pte_none (and it won't get to freeing the reservations before it's nullified the page tables, holding page_table_lock). Hugh -- 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/ . Don't email: email@kvack.org From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail202.messagelabs.com (mail202.messagelabs.com [216.82.254.227]) by kanga.kvack.org (Postfix) with ESMTP id 5A7836B005A for ; Tue, 4 Aug 2009 07:20:54 -0400 (EDT) Date: Tue, 4 Aug 2009 12:48:08 +0100 From: Mel Gorman Subject: Re: mm/hugetlb: GFP_KERNEL allocation under spinlock? Message-ID: <20090804114808.GB6608@csn.ul.ie> References: <4A755201.1010200@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Disposition: inline In-Reply-To: Sender: owner-linux-mm@kvack.org To: Hugh Dickins Cc: Jiri Slaby , linux-mm@kvack.org List-ID: On Sun, Aug 02, 2009 at 11:54:13AM +0100, Hugh Dickins wrote: > On Sun, 2 Aug 2009, Jiri Slaby wrote: > > > > could anybody please confirm this cannot happen? > > I'm no authority on hugetlb.c nowadays: you'll have studied this > in more detail than I have, so please don't believe me. (And I'm > no longer at my old address, but lkml's enjoying a quiet Sunday.) > > > > > hugetlb_fault() > > -> spin_lock() > > -> hugetlb_cow() > > -> alloc_huge_page() > > -> vma_needs_reservation() > > -> region_chg() (either of the 2) > > -> kmalloc(*, GFP_KERNEL) > > > > Thanks. > > That should be taken care of by the successful vma_needs_reservation() > on the same address in hugetlb_fault(), before taking page_table_lock, > shouldn't it? > Yes, any kmalloc() required should be happening outside spinlocks. The region_chg and region_add acts like a prepare,commit pair except the naming is diabolical. There was a mistake made at one point where kmalloc() was called within a spinlock but enabling lock debugging caught it. > It is possible that a hugetlb_vmtruncate() comes in between that > vma_needs_reservation() and taking the page_table_lock, which could > remove the region (or "nrg") needed. > > But if that's the case then the pte_same test immediately after taking > page_table_lock should catch it: we're in the part of hugetlb_fault() > dealing with !huge_pte_none, whereas truncation would have made it > huge_pte_none (and it won't get to freeing the reservations before > it's nullified the page tables, holding page_table_lock). > -- Mel Gorman Part-time Phd Student Linux Technology Center University of Limerick IBM Dublin Software Lab -- 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/ . Don't email: email@kvack.org