Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp1391987ybc; Tue, 12 Nov 2019 20:31:19 -0800 (PST) X-Google-Smtp-Source: APXvYqxX/TxLPAh5T4VyrULqR20qpaqy+3ONr3eIJStchhchhwCsfS+w7OK94U4gJ0xr7a/UgouY X-Received: by 2002:aa7:cd52:: with SMTP id v18mr1457067edw.280.1573619479413; Tue, 12 Nov 2019 20:31:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573619479; cv=none; d=google.com; s=arc-20160816; b=PXtdjTYkDBnbFSedYweNW+XYbi2sdKsAxKDJWP5kEHo+WPPsncKo2/TYSnU5bXJ6No uQajbCcQgoEQEQAVh56IwJa0C3GmTwGbWJXweMNh+Vt+octoFKNW+OlPkTH3k1uRnnQ0 Yx9DK5FB2vsNtUZY6w2XIZ1M8IQnv7ZR1n+H7hJPlubklHvuWWbzWWo69lBeRFUgIlxt jWLNem9/O9lGyW7YAG0MDC+vE8evS8v0PUgF+RIrZ9pzCtYdRKyCAf86uj0J0oWY+8Ej I7sbtTyAZx0YwrN+tYeSA2r2FrytRMnE8OaaRKHWT3Cbb3YCpWOboA+fG7FAS551h57o 9V6w== 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 :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=5vGfYGjp3s6bW36xq9/Bb46iugaNKE7HlOm7HXQ5wWg=; b=E9mAVJef+I7B1DEUelafthPxIPdpkxRrv0GDEyeVqKCfTNcuCEQmhmW2TbjllCTkda 0GD6yyfJCuxdiAXvK+1tS3PZKWOk5yCIc7K2Itwq1GGl1rB9Cfsrg0cos9J3zuKZ888T Yl4VmmOVmwRTRtrjxSxTXiPB5FbAilRDVrnMp/00kzVfPDzJ6NL3GrQ4ALGgvPBsJWoz GWnQhMvV19b4di3w4PjsE4RQV8rsEwcbgIo6zevxdguO/eCOJd5fPR9FnexrOnDEqTH6 LsNUlhmF0vGX5U2GEemGxHZkNgW3isY+gEpw4mvpKtvOAvqYgf5JP2IWIFebxRH3N6Ui 6Skg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@nvidia.com header.s=n1 header.b=aDYRJ65E; 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 t30si533462edt.330.2019.11.12.20.30.54; Tue, 12 Nov 2019 20:31:19 -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=aDYRJ65E; 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 S1728185AbfKME30 (ORCPT + 99 others); Tue, 12 Nov 2019 23:29:26 -0500 Received: from hqemgate16.nvidia.com ([216.228.121.65]:4025 "EHLO hqemgate16.nvidia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727647AbfKME1V (ORCPT ); Tue, 12 Nov 2019 23:27:21 -0500 Received: from hqpgpgate102.nvidia.com (Not Verified[216.228.121.13]) by hqemgate16.nvidia.com (using TLS: TLSv1.2, DES-CBC3-SHA) id ; Tue, 12 Nov 2019 20:26:17 -0800 Received: from hqmail.nvidia.com ([172.20.161.6]) by hqpgpgate102.nvidia.com (PGP Universal service); Tue, 12 Nov 2019 20:27:12 -0800 X-PGP-Universal: processed; by hqpgpgate102.nvidia.com on Tue, 12 Nov 2019 20:27:12 -0800 Received: from HQMAIL109.nvidia.com (172.20.187.15) by HQMAIL111.nvidia.com (172.20.187.18) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Wed, 13 Nov 2019 04:27:12 +0000 Received: from hqnvemgw03.nvidia.com (10.124.88.68) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1473.3 via Frontend Transport; Wed, 13 Nov 2019 04:27:12 +0000 Received: from blueforge.nvidia.com (Not Verified[10.110.48.28]) by hqnvemgw03.nvidia.com with Trustwave SEG (v7,5,8,10121) id ; Tue, 12 Nov 2019 20:27:11 -0800 From: John Hubbard To: Andrew Morton CC: Al Viro , Alex Williamson , Benjamin Herrenschmidt , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Christoph Hellwig , Dan Williams , Daniel Vetter , Dave Chinner , David Airlie , "David S . Miller" , Ira Weiny , Jan Kara , Jason Gunthorpe , Jens Axboe , Jonathan Corbet , =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= , Magnus Karlsson , Mauro Carvalho Chehab , Michael Ellerman , Michal Hocko , Mike Kravetz , Paul Mackerras , Shuah Khan , Vlastimil Babka , , , , , , , , , , , , , LKML , John Hubbard Subject: [PATCH v4 03/23] mm/gup: move try_get_compound_head() to top, fix minor issues Date: Tue, 12 Nov 2019 20:26:50 -0800 Message-ID: <20191113042710.3997854-4-jhubbard@nvidia.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191113042710.3997854-1-jhubbard@nvidia.com> References: <20191113042710.3997854-1-jhubbard@nvidia.com> MIME-Version: 1.0 X-NVConfidentiality: public Content-Transfer-Encoding: quoted-printable Content-Type: text/plain DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nvidia.com; s=n1; t=1573619177; bh=5vGfYGjp3s6bW36xq9/Bb46iugaNKE7HlOm7HXQ5wWg=; h=X-PGP-Universal:From:To:CC:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:X-NVConfidentiality: Content-Transfer-Encoding:Content-Type; b=aDYRJ65EWmsQXhIyoPNVlHMD4XaFMBDq9LhgDXzW3aeFZfWy/Umcf5WRXDosDuh/C Iguhvy6SdlWXbY0WQjgw75hqMELpFHBnuPhbUvyAdqmayZmFc0Ct5foXKr3lPnLr+d esLMwBoHbkb26V/3ZUMFdroJGbVsaYxlKpFruYZixcKAmYyaw0fCepkJKyZkd1IU2V ppZPKWqoduOZ3GQs4Vyf4PzpXrvMc1ELWDe3m5R6RE3VW58raBfYW6U3xggAC1eZ6/ Lm/GsrbCgbneT8v1BAHTg2YkK4CqTMioEziPnv2fP9F0ZUAyu9Ds/eOiHLazgPpxN3 cSreApeYiYlgQ== Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org An upcoming patch uses try_get_compound_head() more widely, so move it to the top of gup.c. Also fix a tiny spelling error and a checkpatch.pl warning. Signed-off-by: John Hubbard --- mm/gup.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index 199da99e8ffc..933524de6249 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -29,6 +29,21 @@ struct follow_page_context { unsigned int page_mask; }; =20 +/* + * Return the compound head page with ref appropriately incremented, + * or NULL if that failed. + */ +static inline struct page *try_get_compound_head(struct page *page, int re= fs) +{ + struct page *head =3D compound_head(page); + + if (WARN_ON_ONCE(page_ref_count(head) < 0)) + return NULL; + if (unlikely(!page_cache_add_speculative(head, refs))) + return NULL; + return head; +} + /** * put_user_pages_dirty_lock() - release and optionally dirty gup-pinned p= ages * @pages: array of pages to be maybe marked dirty, and definitely releas= ed. @@ -1793,20 +1808,6 @@ static void __maybe_unused undo_dev_pagemap(int *nr,= int nr_start, } } =20 -/* - * Return the compund head page with ref appropriately incremented, - * or NULL if that failed. - */ -static inline struct page *try_get_compound_head(struct page *page, int re= fs) -{ - struct page *head =3D compound_head(page); - if (WARN_ON_ONCE(page_ref_count(head) < 0)) - return NULL; - if (unlikely(!page_cache_add_speculative(head, refs))) - return NULL; - return head; -} - #ifdef CONFIG_ARCH_HAS_PTE_SPECIAL static int gup_pte_range(pmd_t pmd, unsigned long addr, unsigned long end, unsigned int flags, struct page **pages, int *nr) --=20 2.24.0