Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp2429878pxt; Sun, 8 Aug 2021 23:42:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw4SivzsOgWvLtYVvoX3dbYcwTcvyuEY7luNtYwFkGp6KNMzN766D8vTsJScKs+605P4qof X-Received: by 2002:aa7:c042:: with SMTP id k2mr28441631edo.104.1628491338831; Sun, 08 Aug 2021 23:42:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628491338; cv=none; d=google.com; s=arc-20160816; b=uLDk8vODNhb7x85nXwshgw5vUYgYYcjL+3ql6av3scrtcaPDWfBQH2DsHTDZ5Gz7uP q+g2ly8W9phbi4gXSKtrdWx+ZDqofhsuH9WsG/Sns2o7Ab33TbGChqM5C8xXj7T8HtZG 6lyjRWduYMjtg1t2PQPYPS9/Mg1SWKmV2ek5eTNuDA+eZ5HkVyYLf/rRYlvOxQDxCoho OgnurDUChPCcUuxEHXFhqxEfCXlvLH65PCVpTkWF5JJNayDhk9c95x1S3BIA6SD3oZS1 LAe180WC0y6joQOyQN0qnuGfADLvNDvFTsRcqOHPEwtaQloSz6LRZ6P9vsjqt/wRVCz4 8rgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=UOfsezeh2Rb2IHtiMvyy621DrExWSUzedq6b1M16AvE=; b=CJoOlDd+W0HXh6WdSAnvhYOj6kvRdNyTh1wYgCJlGT5jva96/mrMBQqoVg4KD5ROs9 P6tb6JGwYwZg2yC3PH1dWSXkuigMkYtRVIRE/7N+AGt8sXZMaGrg9rkl/gB6m7IiMTTi UmH+D68M9X/TfNvJOTugApa2KFsRuh4NDbj6+fFd+TCT0+tIQybrAApq5JBgXRojr04M +Ea0F8err7KkWSw9rrvmNXVLop74Y9ex+mjb8X4bLh/ZxHRdb4JbS4Y3TCoJkfeSNYkD Y53VWPXQHFDBMrQvTvjDUTkAbttF/FubYTVzXlUHlckNDUyPUxqVqqoOI916vJ+N+7jh HcpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=casper.20170209 header.b=uzvq4Qo0; 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 hr1si18461751ejc.424.2021.08.08.23.41.56; Sun, 08 Aug 2021 23:42:18 -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=@infradead.org header.s=casper.20170209 header.b=uzvq4Qo0; 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 S233318AbhHIGkt (ORCPT + 99 others); Mon, 9 Aug 2021 02:40:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50258 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233264AbhHIGkt (ORCPT ); Mon, 9 Aug 2021 02:40:49 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16AD5C0613CF for ; Sun, 8 Aug 2021 23:40:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=UOfsezeh2Rb2IHtiMvyy621DrExWSUzedq6b1M16AvE=; b=uzvq4Qo0mtKVu0YIlmp1mW0eek X/hjctzSksRyyLoyzQveO6Yko4Obw+RfWgBi/ltcaxWjZ6/RTyRlKUBzx7+Tt8CafYWhMz9cU+Zft 2LUQvkci7hUaizGb98YLijBrxYvPExZBLf+8Mw/peK9ipZqy7yvkYOojRYG0MsPlWp+sNAQhCRxHi mFvDlLHfozvD23UAYrLGhsrTLN7iTHkS38ZhObcEBmqweB1JJLWw4Keskwmrd3bQz8J7oxCaOwJq8 DKuz4oFxslJT5LfLzWnnrynYtfLtCHZZEAewnEe15ap6ES6twT7waZ46QeG4W2YLOuMrbBLjJthUB nZ04TlAg==; Received: from hch by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1mCyvx-00AiNV-H2; Mon, 09 Aug 2021 06:38:56 +0000 Date: Mon, 9 Aug 2021 07:38:49 +0100 From: Christoph Hellwig To: John Hubbard Cc: Andrew Morton , Matthew Wilcox , LKML , linux-mm@kvack.org Subject: Re: [PATCH 2/3] mm/gup: small refactoring: simplify try_grab_page() Message-ID: References: <20210808235018.1924918-1-jhubbard@nvidia.com> <20210808235018.1924918-3-jhubbard@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210808235018.1924918-3-jhubbard@nvidia.com> X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org. See http://www.infradead.org/rpr.html Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Aug 08, 2021 at 04:50:17PM -0700, John Hubbard wrote: > try_grab_page() does the same thing as try_grab_compound_head(..., > refs=1, ...), just with a different API. So there is a lot of code > duplication there. > > Change try_grab_page() to call try_grab_compound_head(), while keeping > the API contract identical for callers. > > Signed-off-by: John Hubbard > --- > mm/gup.c | 29 ++--------------------------- > 1 file changed, 2 insertions(+), 27 deletions(-) > > diff --git a/mm/gup.c b/mm/gup.c > index 5cb18b62921c..4be6f060fa0b 100644 > --- a/mm/gup.c > +++ b/mm/gup.c > @@ -203,33 +203,8 @@ static void put_compound_head(struct page *page, int refs, unsigned int flags) > */ > bool __must_check try_grab_page(struct page *page, unsigned int flags) > { > + if (flags & (FOLL_GET | FOLL_PIN)) > + return try_grab_compound_head(page, 1, flags) != NULL; > > return true; Nit: something like: if (!(flags & (FOLL_GET | FOLL_PIN))) return true; return try_grab_compound_head(page, 1, flags) != NULL; would be a little easier to read.