From patchwork Sun Jan 2 21:57:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 12702368 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 A3E91C433FE for ; Sun, 2 Jan 2022 21:57:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C3BF46B007D; Sun, 2 Jan 2022 16:57:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id B4CD86B007E; Sun, 2 Jan 2022 16:57:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8B80D6B0080; Sun, 2 Jan 2022 16:57:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0229.hostedemail.com [216.40.44.229]) by kanga.kvack.org (Postfix) with ESMTP id 7528F6B007D for ; Sun, 2 Jan 2022 16:57:39 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 3A1C48249980 for ; Sun, 2 Jan 2022 21:57:39 +0000 (UTC) X-FDA: 78986709438.19.0675E8B Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf27.hostedemail.com (Postfix) with ESMTP id C249640003 for ; Sun, 2 Jan 2022 21:57:37 +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=7rrOX6FmyXBcc7eoNznqrOG9hGHkjj9XXUMuwFtq2qk=; b=BwVvF95q2utIqTHB292u8nyYx6 C7cYNEzygqW+8D/IXLvztbV5yBKEoHnaO8vD2wOJiIG2JwxdTeZGcZzho1raQvl4bSIfhPOEmweBe BtpdxSCNXxY7jSgPGn0wIvWXLdVjOt6o5yU4d3queXSU+IKKyljB4sVwxz6TSLdxlUarpkJPc8n/o fU9XgN+3HYL7+pAZI/rnSnnNCYBnX69yq98iUeQQ1UwNRK0zoipYgxKQXy0EDi0VfCUTUsXaW9UAa ZTwOrfCRCbEcrxfT+vpi/sVOxW/pC23gY7qqh+Z6VdqxsFdSD333UXd9vpc36mjzUSlqDapkaadSE ywgLEhEQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1n48r6-00CLoI-KZ; 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 10/17] gup: Convert gup_hugepte() to use a folio Date: Sun, 2 Jan 2022 21:57:22 +0000 Message-Id: <20220102215729.2943705-11-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 X-Rspamd-Queue-Id: C249640003 X-Stat-Signature: 7qbbicaskyqqq1qqpb5gwocy33ykxtat Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=BwVvF95q; spf=none (imf27.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: rspam10 X-HE-Tag: 1641160657-572540 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: There should be little to no effect from this patch; just removing uses of some old APIs. While I'm looking at this, take the opportunity to use nth_page() instead of doing the arithmetic ourselves in case hugetlbfs pages are ever allocated across memmap boundaries. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Christoph Hellwig Reviewed-by: John Hubbard --- mm/gup.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index d8535f9d5622..1c7fb668b46d 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -2435,7 +2435,7 @@ static int record_subpages(struct page *page, unsigned long addr, int nr; for (nr = 0; addr != end; addr += PAGE_SIZE) - pages[nr++] = page++; + pages[nr++] = nth_page(page, nr); return nr; } @@ -2453,7 +2453,8 @@ static int gup_hugepte(pte_t *ptep, unsigned long sz, unsigned long addr, struct page **pages, int *nr) { unsigned long pte_end; - struct page *head, *page; + struct page *page; + struct folio *folio; pte_t pte; int refs; @@ -2469,21 +2470,20 @@ static int gup_hugepte(pte_t *ptep, unsigned long sz, unsigned long addr, /* hugepages are never "special" */ VM_BUG_ON(!pfn_valid(pte_pfn(pte))); - head = pte_page(pte); - page = head + ((addr & (sz-1)) >> PAGE_SHIFT); + page = nth_page(pte_page(pte), (addr & (sz - 1)) >> PAGE_SHIFT); refs = record_subpages(page, addr, end, pages + *nr); - head = try_grab_compound_head(head, refs, flags); - if (!head) + folio = try_grab_folio(page, refs, flags); + if (!folio) return 0; if (unlikely(pte_val(pte) != pte_val(*ptep))) { - put_compound_head(head, refs, flags); + gup_put_folio(folio, refs, flags); return 0; } *nr += refs; - SetPageReferenced(head); + folio_set_referenced(folio); return 1; }