From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id C80A5C433F5 for ; Sun, 2 Jan 2022 21:58:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9D5666B0092; Sun, 2 Jan 2022 16:58:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8B4146B0095; Sun, 2 Jan 2022 16:58:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 61A4E6B0098; Sun, 2 Jan 2022 16:58:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0220.hostedemail.com [216.40.44.220]) by kanga.kvack.org (Postfix) with ESMTP id F036C6B0095 for ; Sun, 2 Jan 2022 16:58:04 -0500 (EST) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id A70DF8F6D6 for ; Sun, 2 Jan 2022 21:58:04 +0000 (UTC) X-FDA: 78986710488.20.86023FA Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf28.hostedemail.com (Postfix) with ESMTP id 2D7D6C000E for ; Sun, 2 Jan 2022 21:58:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=Content-Transfer-Encoding:MIME-Version: References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=ns/BmlmITh6DPrVTa85AsKcevSB+O645ygLvNbfaBNo=; b=bxh+BnEbPiGmCV0o3WD7D+ndHu cQlzqsf4HtnOrF1g0syobVubDvUSixq13s+XY831LkZTsTTDVEE2GKxog5uNcw8Y2OskfQidYisdD uI9DSwwfH7PSwwN/eXKdbyAXfN6EDRnSxrCvjgmzHMLw9/w+jhuk9xAOus2zsRwvy5BFooPMM2oLo +G8Xd0ax51hoYDrlrvwpZb6o0x9nOrbZ46j+pB8FT8WCykBU6RLWux+x8an6rDRv5+e3sCh1GJ30m 0/HsVcOqT0HXgQ0JNiRdyuIMP53zxwICOPEwd0sRlORHoGaz02cw8YofT8pFb96QbFjC/390wMVQz 14ll0eqA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1n48r6-00CLoO-TQ; Sun, 02 Jan 2022 21:57:32 +0000 From: "Matthew Wilcox (Oracle)" To: linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , John Hubbard , Andrew Morton Subject: [PATCH 13/17] gup: Convert gup_huge_pgd() to use a folio Date: Sun, 2 Jan 2022 21:57:25 +0000 Message-Id: <20220102215729.2943705-14-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220102215729.2943705-1-willy@infradead.org> References: <20220102215729.2943705-1-willy@infradead.org> MIME-Version: 1.0 Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=bxh+BnEb; spf=none (imf28.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 2D7D6C000E X-Stat-Signature: sfcradht7jewc4woobed5xjooy1ffajy X-HE-Tag: 1641160684-973393 Content-Transfer-Encoding: quoted-printable X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: Use the new folio-based APIs. Also fix an assumption that memmap is contiguous. This was the last user of try_grab_compound_head(), so remove it. Signed-off-by: Matthew Wilcox (Oracle) --- mm/gup.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index e7bcee8776e1..7bd1e4a2648a 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -152,12 +152,6 @@ struct folio *try_grab_folio(struct page *page, int = refs, unsigned int flags) return NULL; } =20 -static inline struct page *try_grab_compound_head(struct page *page, - int refs, unsigned int flags) -{ - return &try_grab_folio(page, refs, flags)->page; -} - static void gup_put_folio(struct folio *folio, int refs, unsigned int fl= ags) { if (flags & FOLL_PIN) { @@ -2588,27 +2582,28 @@ static int gup_huge_pgd(pgd_t orig, pgd_t *pgdp, = unsigned long addr, struct page **pages, int *nr) { int refs; - struct page *head, *page; + struct page *page; + struct folio *folio; =20 if (!pgd_access_permitted(orig, flags & FOLL_WRITE)) return 0; =20 BUILD_BUG_ON(pgd_devmap(orig)); =20 - page =3D pgd_page(orig) + ((addr & ~PGDIR_MASK) >> PAGE_SHIFT); + page =3D nth_page(pgd_page(orig), (addr & ~PGDIR_MASK) >> PAGE_SHIFT); refs =3D record_subpages(page, addr, end, pages + *nr); =20 - head =3D try_grab_compound_head(pgd_page(orig), refs, flags); - if (!head) + folio =3D try_grab_folio(page, refs, flags); + if (!folio) return 0; =20 if (unlikely(pgd_val(orig) !=3D pgd_val(*pgdp))) { - put_compound_head(head, refs, flags); + gup_put_folio(folio, refs, flags); return 0; } =20 *nr +=3D refs; - SetPageReferenced(head); + folio_set_referenced(folio); return 1; } =20 --=20 2.33.0