Received: by 2002:a25:c205:0:0:0:0:0 with SMTP id s5csp3041263ybf; Mon, 2 Mar 2020 21:42:00 -0800 (PST) X-Google-Smtp-Source: ADFU+vufrm1ieDqjZL9zAO4utQuAAc9GZ5gpMa2imGyofRBmR4jSlPCKZMgOuGpkxBHEYJ51uA4V X-Received: by 2002:aca:f2c5:: with SMTP id q188mr1388809oih.113.1583214120216; Mon, 02 Mar 2020 21:42:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583214120; cv=none; d=google.com; s=arc-20160816; b=v0OrO+xcrEvRRh7XaNzwwMzIpVUvvfUVLuS9TpqU0hFKvi/l9NmCl7NW8kyzsfbiMZ xtWlJku+Ci9Rvy5vho8hY19LCAt5OfuaO/Ccb5merHJ4xkSKz5CwaXSrcxUuRpOGoswr E4q1H+cZD+d/esyoupZwsZ0Hgt0o4evM8+iDrbZkWZtUlbshEr/yL3B/Gp6kGrS1knSA wqY/P5DtGCKk8AOTka4qdxl/UCY+GHzKrBgR1CV1KcoUD0sN9W7q84INUg5ohQWy2Sjk IiU/8CZbJc7u7aJsWrkVH+XzTDg7mbi5KZYpFrGhMR01L7090XhakOTVARMl7W9yMnOS Nt0g== 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=r/3wnhnvfxYDCvTiXpHphGDa2aKt2Zft4Tm9S+V9Tgc=; b=qr3u4wfDtNUCy5y5AkXdnzQAvIwgPmfNg4hLIWUCpCwifdfz9PaomyPyR/KElqMo33 8F25f8HDGAbwk8H/mpXJflqQVv+PobjMfDSnZhxtZrx+2ma9uM0i7OMCp9hN2uguUQG/ M852mhNO2rrqbLvDaygs4alxtz5JVhIGQBtU6RdPI3YEVR5yGA5ioL/aSIih1Ss/jSfv ta7zlILsr8QZ6sG3EDTqAO9Qg5Bus+WreXfQi70xcdAiSeAqm7mQl9cmdJl+uJ1QfU1V Uu8O9B+WcAuhJGqcv0B652Iwmlzz0+H+eToz7i1J8jcAPj+eozBzCnXyRsJ72HABLZ00 fvRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=NDk1S2EX; 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 e22si8048043oiy.124.2020.03.02.21.41.47; Mon, 02 Mar 2020 21:42:00 -0800 (PST) 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=NDk1S2EX; 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 S1727368AbgCCFlN (ORCPT + 99 others); Tue, 3 Mar 2020 00:41:13 -0500 Received: from hqnvemgate26.nvidia.com ([216.228.121.65]:8901 "EHLO hqnvemgate26.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725818AbgCCFlN (ORCPT ); Tue, 3 Mar 2020 00:41:13 -0500 Received: from hqpgpgate101.nvidia.com (Not Verified[216.228.121.13]) by hqnvemgate26.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Mon, 02 Mar 2020 21:40:59 -0800 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate101.nvidia.com (PGP Universal service); Mon, 02 Mar 2020 21:41:12 -0800 X-PGP-Universal: processed; by hqpgpgate101.nvidia.com on Mon, 02 Mar 2020 21:41:12 -0800 Received: from [10.2.160.177] (10.124.1.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 3 Mar 2020 05:41:12 +0000 Subject: Re: [PATCH v2 1/2] mm/gup: fixup for 9947ea2c1e608e32 "mm/gup: track FOLL_PIN pages" To: Claudio Imbrenda , , , , CC: , , , , , , , References: <20200303002506.173957-1-imbrenda@linux.ibm.com> <20200303002506.173957-2-imbrenda@linux.ibm.com> X-Nvconfidentiality: public From: John Hubbard Message-ID: Date: Mon, 2 Mar 2020 21:38:06 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.5.0 MIME-Version: 1.0 In-Reply-To: <20200303002506.173957-2-imbrenda@linux.ibm.com> X-Originating-IP: [10.124.1.5] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To HQMAIL107.nvidia.com (172.20.187.13) Content-Type: text/plain; charset="utf-8"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1583214059; bh=r/3wnhnvfxYDCvTiXpHphGDa2aKt2Zft4Tm9S+V9Tgc=; 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=NDk1S2EX/bLINrjs0wQkG2RHN73q1GcgISfIazE6XASrpm+XqtN4J39dfoIdEzuN+ gshDK3EcHBHgUzBWx77iRXGO/Lc8sXcQvwMw9qAdFdMaBb6Kw7KRY/doIevsI00IAw efEnazjaotIFNOwzK1QbCCt3n3vF2HMJ1qxKBma0vuFakbCswUUlr/CjiWnKfNFvJ/ MOs1Qjn7OOqlstgczLXBB3YR/gslVWoheI4k9DuOhdpfpCeWpfMLnFLQRIgr0McGlf SeLUIeHnMkUSjceIYOCFQo68vDwZrX4ImC2k8Xyahmad9t5fm0HAe9ZK7xtZ8aHTPo f8dGR2cjEljVA== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/2/20 4:25 PM, Claudio Imbrenda wrote: > In case pin fails, we need to unpin, a simple put_page will not be enough > > fixup for commit 9947ea2c1e608e32 ("mm/gup: track FOLL_PIN pages") > > it can be simply squashed in > > Signed-off-by: Claudio Imbrenda > --- > mm/gup.c | 46 +++++++++++++++++++++++----------------------- > 1 file changed, 23 insertions(+), 23 deletions(-) > Looks good, thanks for fixing this. thanks, -- John Hubbard NVIDIA > diff --git a/mm/gup.c b/mm/gup.c > index f589299b0d4a..81a95fbe9901 100644 > --- a/mm/gup.c > +++ b/mm/gup.c > @@ -116,6 +116,28 @@ static __maybe_unused struct page *try_grab_compound_head(struct page *page, > return NULL; > } > > +static void put_compound_head(struct page *page, int refs, unsigned int flags) > +{ > + if (flags & FOLL_PIN) { > + mod_node_page_state(page_pgdat(page), NR_FOLL_PIN_RELEASED, > + refs); > + > + if (hpage_pincount_available(page)) > + hpage_pincount_sub(page, refs); > + else > + refs *= GUP_PIN_COUNTING_BIAS; > + } > + > + VM_BUG_ON_PAGE(page_ref_count(page) < refs, page); > + /* > + * Calling put_page() for each ref is unnecessarily slow. Only the last > + * ref needs a put_page(). > + */ > + if (refs > 1) > + page_ref_sub(page, refs - 1); > + put_page(page); > +} > + > /** > * try_grab_page() - elevate a page's refcount by a flag-dependent amount > * > @@ -2134,7 +2156,7 @@ static int gup_pte_range(pmd_t pmd, unsigned long addr, unsigned long end, > goto pte_unmap; > > if (unlikely(pte_val(pte) != pte_val(*ptep))) { > - put_page(head); > + put_compound_head(head, 1, flags); > goto pte_unmap; > } > > @@ -2267,28 +2289,6 @@ static int record_subpages(struct page *page, unsigned long addr, > return nr; > } > > -static void put_compound_head(struct page *page, int refs, unsigned int flags) > -{ > - if (flags & FOLL_PIN) { > - mod_node_page_state(page_pgdat(page), NR_FOLL_PIN_RELEASED, > - refs); > - > - if (hpage_pincount_available(page)) > - hpage_pincount_sub(page, refs); > - else > - refs *= GUP_PIN_COUNTING_BIAS; > - } > - > - VM_BUG_ON_PAGE(page_ref_count(page) < refs, page); > - /* > - * Calling put_page() for each ref is unnecessarily slow. Only the last > - * ref needs a put_page(). > - */ > - if (refs > 1) > - page_ref_sub(page, refs - 1); > - put_page(page); > -} > - > #ifdef CONFIG_ARCH_HAS_HUGEPD > static unsigned long hugepte_addr_end(unsigned long addr, unsigned long end, > unsigned long sz) >