From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9E406C2BB1D for ; Thu, 12 Mar 2020 08:54:48 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 5972A20578 for ; Thu, 12 Mar 2020 08:54:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5972A20578 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id E2DEA6B0003; Thu, 12 Mar 2020 04:54:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DDEBE6B0006; Thu, 12 Mar 2020 04:54:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CF4886B0007; Thu, 12 Mar 2020 04:54:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0184.hostedemail.com [216.40.44.184]) by kanga.kvack.org (Postfix) with ESMTP id B4AB36B0003 for ; Thu, 12 Mar 2020 04:54:47 -0400 (EDT) Received: from smtpin28.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 55E23181AEF30 for ; Thu, 12 Mar 2020 08:54:47 +0000 (UTC) X-FDA: 76586099814.28.dock90_29c4b33a8a428 X-HE-Tag: dock90_29c4b33a8a428 X-Filterd-Recvd-Size: 3729 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf09.hostedemail.com (Postfix) with ESMTP for ; Thu, 12 Mar 2020 08:54:46 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 46FC11FB; Thu, 12 Mar 2020 01:54:46 -0700 (PDT) Received: from [10.57.15.252] (unknown [10.57.15.252]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 140973F67D; Thu, 12 Mar 2020 01:54:43 -0700 (PDT) Subject: Re: [PATCH hmm 3/8] mm/hmm: do not call hmm_vma_walk_hole() while holding a spinlock To: Jason Gunthorpe , Jerome Glisse , Ralph Campbell , "Felix.Kuehling@amd.com" Cc: "linux-mm@kvack.org" , John Hubbard , "dri-devel@lists.freedesktop.org" , "amd-gfx@lists.freedesktop.org" , Christoph Hellwig , Philip Yang , Jason Gunthorpe References: <20200311183506.3997-1-jgg@ziepe.ca> <20200311183506.3997-4-jgg@ziepe.ca> From: Steven Price Message-ID: <5bd778fa-51e5-3e0c-d9bb-b38539b03c8d@arm.com> Date: Thu, 12 Mar 2020 08:54:41 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <20200311183506.3997-4-jgg@ziepe.ca> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-GB Content-Transfer-Encoding: 7bit X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 11/03/2020 18:35, Jason Gunthorpe wrote: > From: Jason Gunthorpe > > This eventually calls into handle_mm_fault() which is a sleeping function. > Release the lock first. > > hmm_vma_walk_hole() does not touch the contents of the PUD, so it does not > need the lock. > > Fixes: 3afc423632a1 ("mm: pagewalk: add p4d_entry() and pgd_entry()") > Cc: Steven Price > Signed-off-by: Jason Gunthorpe Sorry about that, thanks for fixing. Reviewed-by: Steven Price > --- > mm/hmm.c | 14 +++++++------- > 1 file changed, 7 insertions(+), 7 deletions(-) > > diff --git a/mm/hmm.c b/mm/hmm.c > index 9e8f68eb83287a..32dcbfd3908315 100644 > --- a/mm/hmm.c > +++ b/mm/hmm.c > @@ -473,8 +473,8 @@ static int hmm_vma_walk_pud(pud_t *pudp, unsigned long start, unsigned long end, > > pud = READ_ONCE(*pudp); > if (pud_none(pud)) { > - ret = hmm_vma_walk_hole(start, end, -1, walk); > - goto out_unlock; > + spin_unlock(ptl); > + return hmm_vma_walk_hole(start, end, -1, walk); > } > > if (pud_huge(pud) && pud_devmap(pud)) { > @@ -483,8 +483,8 @@ static int hmm_vma_walk_pud(pud_t *pudp, unsigned long start, unsigned long end, > bool fault, write_fault; > > if (!pud_present(pud)) { > - ret = hmm_vma_walk_hole(start, end, -1, walk); > - goto out_unlock; > + spin_unlock(ptl); > + return hmm_vma_walk_hole(start, end, -1, walk); > } > > i = (addr - range->start) >> PAGE_SHIFT; > @@ -495,9 +495,9 @@ static int hmm_vma_walk_pud(pud_t *pudp, unsigned long start, unsigned long end, > hmm_range_need_fault(hmm_vma_walk, pfns, npages, > cpu_flags, &fault, &write_fault); > if (fault || write_fault) { > - ret = hmm_vma_walk_hole_(addr, end, fault, > - write_fault, walk); > - goto out_unlock; > + spin_unlock(ptl); > + return hmm_vma_walk_hole_(addr, end, fault, write_fault, > + walk); > } > > pfn = pud_pfn(pud) + ((addr & ~PUD_MASK) >> PAGE_SHIFT); >