Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1188766pxb; Thu, 16 Sep 2021 01:36:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwsGU+slkujtniRT9fRU+NfGJmHh0XQDOy/TqO/5gjGCpj1QvmaOqbkZ00rIFnJgQ4bVKJO X-Received: by 2002:a92:c145:: with SMTP id b5mr2980258ilh.203.1631781362860; Thu, 16 Sep 2021 01:36:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631781362; cv=none; d=google.com; s=arc-20160816; b=kuT/upaZHYMBsrRHcu4zuRBVDH00SQelR6kORG/XtfEYHsybUV0KRKgfKNBOepRl/G sf107/Nv20tCGsD12eDzujKcBsP8D0a/9Rfo9XRahIkEu9DX5uf8wn0UWMrpncuEGoMY LcIxLK/pcUl1XBtB8ouL+Cf8Kz+T6ytijHwbWhDOqfWcBIRXfs99jcjM5ao+Cp1eBlY9 LDDXbrIPobpwsjDbmp28CdRyJTCpfwtP2Fa4h5USSUWwoBn2IKAg0aEX+UVziqfssNlF uzduSkAswV4OQPQwIV++j3lL6BGRvlUeJBfwbHsEER0IP78IYsAL99EdAbsDXfR4q9+/ cHtg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:dkim-signature; bh=4XohSGbOhJnp4vglMn1D3IB8biBQdodV80lSwfv+I84=; b=IjTC1pk4hHIsC/TQ+jvgLG2lvX4nKIdxUr7YGBJdmeaXiUpY1MxYjWBby9BeDFHhnj a4Tqc5OVSd+gc8b1Ghb/sHyFgq04uGJhqBzUAk21Rvpd+K7sW5T0o6Fj4TQUc37Dsphz HjUYMuuvlOxpo8IuMhlEa+S16sVZz+N1QYR6oowH28haM05/wTjB/bdsO0RxZBhLUyfm MnRP6iOCTsMAKiVLR+CiYt5bLKirEsCF94LTiJWqrxeQscsugcKJeKlvCOoegwUZhga8 M+Z/diUyttN4yZJA1rmhxNE3nxPcBfs8DEqVUnRAY5F7WVmtrc5/3YTQ/stY+E7xnlsd VHtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=1CauoTFB; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=fdn+2u1+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o16si1987363ilh.153.2021.09.16.01.35.51; Thu, 16 Sep 2021 01:36:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=1CauoTFB; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519 header.b=fdn+2u1+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235103AbhIPIgc (ORCPT + 99 others); Thu, 16 Sep 2021 04:36:32 -0400 Received: from smtp-out2.suse.de ([195.135.220.29]:54498 "EHLO smtp-out2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231273AbhIPIgb (ORCPT ); Thu, 16 Sep 2021 04:36:31 -0400 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id 9B9881FEB2; Thu, 16 Sep 2021 08:35:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1631781310; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=4XohSGbOhJnp4vglMn1D3IB8biBQdodV80lSwfv+I84=; b=1CauoTFBFQFg7BF844YSkm6XOAhpnNCHkSQD9tvtbMEAcmDRuqoPaodYdZZgMXsICXWmxZ uqSZy4qnbeCmdtTMjhWon6nKkLX0nrVPs1yE8FO/sTwap/v5SXiaabNEdxWFtStbh1t5yI oj6uCmJyMs7XzEQIwgAskFUnBK6Hbtw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1631781310; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=4XohSGbOhJnp4vglMn1D3IB8biBQdodV80lSwfv+I84=; b=fdn+2u1+9/iCrT3BVTDvKF5VjcOgIY04oaLpo5SnJcWu8aS4vwSa37uTXGClRK4XiQPHRd emeUAySK5rM1i4DA== Received: from quack2.suse.cz (unknown [10.100.224.230]) by relay2.suse.de (Postfix) with ESMTP id 86EC3A3BA6; Thu, 16 Sep 2021 08:35:09 +0000 (UTC) Received: by quack2.suse.cz (Postfix, from userid 1000) id B9D181E0C04; Thu, 16 Sep 2021 10:35:09 +0200 (CEST) Date: Thu, 16 Sep 2021 10:35:09 +0200 From: Jan Kara To: John Hubbard Cc: Andrew Morton , LKML , linux-mm@kvack.org, Linus Torvalds , Miaohe Lin , Claudio Imbrenda , Jan Kara , "Kirill A . Shutemov" Subject: Re: [PATCH] mm/gup: further simplify __gup_device_huge() Message-ID: <20210916083509.GB10610@quack2.suse.cz> References: <20210904004224.86391-1-jhubbard@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210904004224.86391-1-jhubbard@nvidia.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri 03-09-21 17:42:24, John Hubbard wrote: > commit 6401c4eb57f9 ("mm: gup: fix potential pgmap refcnt leak in > __gup_device_huge()") simplified the return paths, but didn't go quite > far enough, as discussed in [1]. > > Remove the "ret" variable entirely, because there is enough information > already available to provide the return value. > > [1] https://lore.kernel.org/r/CAHk-=wgQTRX=5SkCmS+zfmpqubGHGJvXX_HgnPG8JSpHKHBMeg@mail.gmail.com > > Suggested-by: Linus Torvalds > Cc: Miaohe Lin > Cc: Claudio Imbrenda > Cc: Jan Kara > Cc: Kirill A. Shutemov > Signed-off-by: John Hubbard Looks sane. Feel free to add: Reviewed-by: Jan Kara Honza > --- > mm/gup.c | 5 +---- > 1 file changed, 1 insertion(+), 4 deletions(-) > > diff --git a/mm/gup.c b/mm/gup.c > index 9935a4480710..6e62f1518c1f 100644 > --- a/mm/gup.c > +++ b/mm/gup.c > @@ -2241,7 +2241,6 @@ static int __gup_device_huge(unsigned long pfn, unsigned long addr, > { > int nr_start = *nr; > struct dev_pagemap *pgmap = NULL; > - int ret = 1; > > do { > struct page *page = pfn_to_page(pfn); > @@ -2249,14 +2248,12 @@ static int __gup_device_huge(unsigned long pfn, unsigned long addr, > pgmap = get_dev_pagemap(pfn, pgmap); > if (unlikely(!pgmap)) { > undo_dev_pagemap(nr, nr_start, flags, pages); > - ret = 0; > break; > } > SetPageReferenced(page); > pages[*nr] = page; > if (unlikely(!try_grab_page(page, flags))) { > undo_dev_pagemap(nr, nr_start, flags, pages); > - ret = 0; > break; > } > (*nr)++; > @@ -2264,7 +2261,7 @@ static int __gup_device_huge(unsigned long pfn, unsigned long addr, > } while (addr += PAGE_SIZE, addr != end); > > put_dev_pagemap(pgmap); > - return ret; > + return addr == end; > } > > static int __gup_device_huge_pmd(pmd_t orig, pmd_t *pmdp, unsigned long addr, > -- > 2.33.0 > -- Jan Kara SUSE Labs, CR