From patchwork Sun Jan 2 21:57:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 12702370 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 0A195C433FE for ; Sun, 2 Jan 2022 21:57:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 277516B0080; Sun, 2 Jan 2022 16:57:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1FEBA6B0081; Sun, 2 Jan 2022 16:57:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 077296B0082; Sun, 2 Jan 2022 16:57:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0230.hostedemail.com [216.40.44.230]) by kanga.kvack.org (Postfix) with ESMTP id DB3A46B0080 for ; Sun, 2 Jan 2022 16:57:43 -0500 (EST) Received: from smtpin25.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 9EF728F6C5 for ; Sun, 2 Jan 2022 21:57:43 +0000 (UTC) X-FDA: 78986709606.25.099616A Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf06.hostedemail.com (Postfix) with ESMTP id ABBD1180005 for ; Sun, 2 Jan 2022 21:57:41 +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=ogX81m9Ft4R1GjsUNqvQECfcCwDVZq/jxbq6z+UDrDo=; b=qpFifqnGGp7RAQdXRK2f+g159C GC0q1ToxvY78zsMJP5JZjQzPCRMm2zxwWsH7yKUcZNVCLyNGjxoHi8qRFFG0Hg8EX5GdImhxt+cuB iuFthD7h1EO5TOZabkVcmjhniuM3phImf13YqSYy/sE713NiR8fxg/R83MUtlCRRFi3dpLLO7ratl bfEqnL5YxWk+wISilndFwYqnT1QuoDkuPaQdm+TBi/XMRm9h+My+ICm/RNafA7zowDguLTUZILEzz HL9UgHIFfWkndfAOwGC7uTc11nwFcakxX6XJfArkQAG4x3M2EgWgk4VJoMAqH781UcTRJTXh8+KsW e52YwqSw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1n48r6-00CLoK-NY; 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 11/17] gup: Convert gup_huge_pmd() to use a folio Date: Sun, 2 Jan 2022 21:57:23 +0000 Message-Id: <20220102215729.2943705-12-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-Stat-Signature: 4kpzxixw8snqc9181zpfwidw1hh9abk3 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: ABBD1180005 Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=qpFifqnG; spf=none (imf06.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-HE-Tag: 1641160661-658254 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. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: John Hubbard --- mm/gup.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/mm/gup.c b/mm/gup.c index 1c7fb668b46d..be965c965484 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -2517,7 +2517,8 @@ static int gup_huge_pmd(pmd_t orig, pmd_t *pmdp, unsigned long addr, unsigned long end, unsigned int flags, struct page **pages, int *nr) { - struct page *head, *page; + struct page *page; + struct folio *folio; int refs; if (!pmd_access_permitted(orig, flags & FOLL_WRITE)) @@ -2530,20 +2531,20 @@ static int gup_huge_pmd(pmd_t orig, pmd_t *pmdp, unsigned long addr, pages, nr); } - page = pmd_page(orig) + ((addr & ~PMD_MASK) >> PAGE_SHIFT); + page = nth_page(pmd_page(orig), (addr & ~PMD_MASK) >> PAGE_SHIFT); refs = record_subpages(page, addr, end, pages + *nr); - head = try_grab_compound_head(pmd_page(orig), refs, flags); - if (!head) + folio = try_grab_folio(page, refs, flags); + if (!folio) return 0; if (unlikely(pmd_val(orig) != pmd_val(*pmdp))) { - put_compound_head(head, refs, flags); + gup_put_folio(folio, refs, flags); return 0; } *nr += refs; - SetPageReferenced(head); + folio_set_referenced(folio); return 1; }