Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp8597332ybi; Thu, 6 Jun 2019 15:32:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqyl6tEyGKq+XC2EzbIGyjFGgHnFtsOH+XOuz41A8U4S8UvbddhypdoZlU5txSTHlCTLRZI1 X-Received: by 2002:a63:f44b:: with SMTP id p11mr90729pgk.225.1559860323637; Thu, 06 Jun 2019 15:32:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559860323; cv=none; d=google.com; s=arc-20160816; b=N2HbN9ViB1CgolpiuRePc7FEimVTgAgc86lw9vImxQHBGnsL0nGabG+s5n5AwVgKng HixbcAR2Cq9d+v/9cpd2/ruNwpTIcx0ITSsgzsNuucU/oyzFRqVtKoLVZZlh0fWaAi31 WryX7zmvnl2MbQ9pZ1OZkqGSDRMNPnc11ZBMoUxDFsUaZPPTkxxzh9Iz5jpVYYiLbAI5 ZDlIS/e7AmwlD5MsZjsxo0ls+gwQCvEAAT0ps/3CBUDyFjZIfC6Ja1s0jfJAOXIZlAhe Y5Alc5O0Z7B361FXogauJhGg7irw1+BjPBzQQZ2FI+27BfgmmVl1HUafShqUcS2zGtSt iEtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:dkim-signature:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=Y4XntF7b7G4DQ81sR0y/Jn2xedJWjLJRstkFUo/OuT8=; b=EEusHd83Z/Rwd0Yq8m1Ieh6WCXjVrOUkWEApdSYDVKgujvkFiQKF2f09j//seycCGy /f3EScDceSM4Pu+kIPvgln8NgxdTbPDklxm7kl2sVg+6n8Bp4+nQP0TejOZdmSxN+xm7 gSEijqCcYfqGIBX/NkGXO82lQo589Pf9ET1jFvO8lvdD6zVWvVjX0DU0HPaeTHczDYA3 N7swMehIF6HcBYFk44x/XjHh3akK2UNDwBCFUvZAWXecJ2ctR9SlU6NdrUX/nfmOprOx fDgD5/nvANAfDzqQSa/cfTUp5aOvSCj8JlXY9YTBoEwNm95Th9bGX+QEVBnI+CbY/8k+ iEOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=YMIH7Umh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b22si247402plz.417.2019.06.06.15.31.47; Thu, 06 Jun 2019 15:32:03 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=YMIH7Umh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nvidia.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727866AbfFFVIR (ORCPT + 99 others); Thu, 6 Jun 2019 17:08:17 -0400 Received: from hqemgate15.nvidia.com ([216.228.121.64]:19743 "EHLO hqemgate15.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725267AbfFFVIR (ORCPT ); Thu, 6 Jun 2019 17:08:17 -0400 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqemgate15.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Thu, 06 Jun 2019 14:08:00 -0700 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Thu, 06 Jun 2019 14:08:15 -0700 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Thu, 06 Jun 2019 14:08:15 -0700 Received: from rcampbell-dev.nvidia.com (10.124.1.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 6 Jun 2019 21:08:15 +0000 Subject: Re: [PATCH 4/5] mm/hmm: hmm_vma_fault() doesn't always call hmm_range_unregister() To: Jason Gunthorpe CC: Felix Kuehling , Philip Yang , Alex Deucher , , , John Hubbard , Ira Weiny , Dan Williams , Arnd Bergmann , Balbir Singh , Dan Carpenter , "Matthew Wilcox" , Souptick Joarder , "Andrew Morton" References: <20190506232942.12623-1-rcampbell@nvidia.com> <20190506232942.12623-5-rcampbell@nvidia.com> <20190606145018.GA3658@ziepe.ca> <45c7f8ae-36b2-60cc-7d1d-d13ddd402d4b@nvidia.com> <20190606195404.GJ17373@ziepe.ca> X-Nvconfidentiality: public From: Ralph Campbell Message-ID: <716383df-9985-03b4-bd0c-93de87bffa90@nvidia.com> Date: Thu, 6 Jun 2019 14:08:14 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.0 MIME-Version: 1.0 In-Reply-To: <20190606195404.GJ17373@ziepe.ca> X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1559855280; bh=Y4XntF7b7G4DQ81sR0y/Jn2xedJWjLJRstkFUo/OuT8=; h=X-PGP-Universal:Subject:To:CC:References:X-Nvconfidentiality:From: Message-ID:Date:User-Agent:MIME-Version:In-Reply-To: X-Originating-IP:X-ClientProxiedBy:Content-Type:Content-Language: Content-Transfer-Encoding; b=YMIH7Umhi4BIMhgVQhYRmUeQw1+kXYUpAhobvb7PiW1Vf+rDjc0Hn9H3i5vjlY58R Ki+k06AVcac5VD5x4cnYgL6j4SSyhmQqpp7FmMoBYSBdHn1utQ8MWkrdRYI4L5qWf2 CsX6cpb+rH3mzDRwHkEPm8MqtFvTDP3V7TjDq54dSuVRPQ0YIRMIGmAioXkwEnMSKY TYHX1WxoxUPWQx1T/Xog6YC/Y4acWP0UuaeT68p1n3EFgjEIl9gREBcBvj4dI6wj0L 5WNge292oaRHVcYfEP9Jl1UAbp69ACRJKuVUQfYbkY5SV99iyL9EXbwtFHPWupfdnO KQ25V6EZu+cJg== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/6/19 12:54 PM, Jason Gunthorpe wrote: > On Thu, Jun 06, 2019 at 12:44:36PM -0700, Ralph Campbell wrote: >> >> On 6/6/19 7:50 AM, Jason Gunthorpe wrote: >>> On Mon, May 06, 2019 at 04:29:41PM -0700, rcampbell@nvidia.com wrote: >>>> From: Ralph Campbell >>>> >>>> The helper function hmm_vma_fault() calls hmm_range_register() but is >>>> missing a call to hmm_range_unregister() in one of the error paths. >>>> This leads to a reference count leak and ultimately a memory leak on >>>> struct hmm. >>>> >>>> Always call hmm_range_unregister() if hmm_range_register() succeeded. >>>> >>>> Signed-off-by: Ralph Campbell >>>> Signed-off-by: J=C3=A9r=C3=B4me Glisse >>>> Cc: John Hubbard >>>> Cc: Ira Weiny >>>> Cc: Dan Williams >>>> Cc: Arnd Bergmann >>>> Cc: Balbir Singh >>>> Cc: Dan Carpenter >>>> Cc: Matthew Wilcox >>>> Cc: Souptick Joarder >>>> Cc: Andrew Morton >>>> include/linux/hmm.h | 3 ++- >>>> 1 file changed, 2 insertions(+), 1 deletion(-) >>> >>>> diff --git a/include/linux/hmm.h b/include/linux/hmm.h >>>> index 35a429621e1e..fa0671d67269 100644 >>>> +++ b/include/linux/hmm.h >>>> @@ -559,6 +559,7 @@ static inline int hmm_vma_fault(struct hmm_range *= range, bool block) >>>> return (int)ret; >>>> if (!hmm_range_wait_until_valid(range, HMM_RANGE_DEFAULT_TIMEOUT))= { >>>> + hmm_range_unregister(range); >>>> /* >>>> * The mmap_sem was taken by driver we release it here and >>>> * returns -EAGAIN which correspond to mmap_sem have been >>>> @@ -570,13 +571,13 @@ static inline int hmm_vma_fault(struct hmm_range= *range, bool block) >>>> ret =3D hmm_range_fault(range, block); >>>> if (ret <=3D 0) { >>>> + hmm_range_unregister(range); >>> >>> While this seems to be a clear improvement, it seems there is still a >>> bug in nouveau_svm.c around here as I see it calls hmm_vma_fault() but >>> never calls hmm_range_unregister() for its on stack range - and >>> hmm_vma_fault() still returns with the range registered. >>> >>> As hmm_vma_fault() is only used by nouveau and is marked as >>> deprecated, I think we need to fix nouveau, either by dropping >>> hmm_range_fault(), or by adding the missing unregister to nouveau in >>> this patch. >> >> I will send a patch for nouveau to use hmm_range_register() and >> hmm_range_fault() and do some testing with OpenCL. >=20 > wow, thanks, I'd like to also really like to send such a thing through > hmm.git - do you know who the nouveau maintainers are so we can > collaborate on patch planning this? Ben Skeggs is the maintainer and nouveau@lists.freedesktop.org is the mailing list for changes. I'll be sure to CC them for the patch. >> I can also send a separate patch to then remove hmm_vma_fault() >> but I guess that should be after AMD's changes. >=20 > Let us wait to hear back from AMD how they can consume hmm.git - I'd > very much like to get everything done in one kernel cycle! >=20 > Regards, > Jason >=20