From patchwork Sun Jan 2 21:57:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Matthew Wilcox (Oracle)" X-Patchwork-Id: 12702375 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 07D0BC433F5 for ; Sun, 2 Jan 2022 21:58:00 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 166A36B0088; Sun, 2 Jan 2022 16:57:59 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0F00B6B0089; Sun, 2 Jan 2022 16:57:59 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E416C6B008A; Sun, 2 Jan 2022 16:57:58 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0034.hostedemail.com [216.40.44.34]) by kanga.kvack.org (Postfix) with ESMTP id C26C16B0088 for ; Sun, 2 Jan 2022 16:57:58 -0500 (EST) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 841EC181AC9C6 for ; Sun, 2 Jan 2022 21:57:58 +0000 (UTC) X-FDA: 78986710236.17.3FE95A9 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf19.hostedemail.com (Postfix) with ESMTP id 392311A0004 for ; Sun, 2 Jan 2022 21:57:58 +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=nhlQUBzMFsa5asyVak1xcCftk6Snd8OT173I7f6pJXs=; b=Fm/Lkv9eV2P2rsomeiY5g79wFy hOdy31eJACMCWR4Mf3nsY3ddwlrCQsqRtzN9rOszKJKDggsREr7nzgz+JztzJdUFsCzrNOF5l0LEr o0VyN6RzOkgkpnPscDCxPV8JBDmagLA7G4pvfLlrpmabgb4Nvb8IvaIH2Ix4sjuRWl9dyTR1pRKXN AlBbg20Th8LpiXxxC9N4SjuLmam1qvMx0vBhYdhPWBtmZciaO+4cKgrCaZfrcqPFy4t5tnygaq5iP +I4zm+vuzgJdVJSihUv3K6ROJOjuipAIRHOg6LvM8KMUr6XH5mVJvoOf81XQEUKIWVcQZH56smYct XTZMavKw==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1n48r6-00CLoM-R0; 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 12/17] gup: Convert gup_huge_pud() to use a folio Date: Sun, 2 Jan 2022 21:57:24 +0000 Message-Id: <20220102215729.2943705-13-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-Server: rspam07 X-Rspamd-Queue-Id: 392311A0004 X-Stat-Signature: at33cotscejm5w9jaxywyty74zbitpmb Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b="Fm/Lkv9e"; dmarc=none; spf=none (imf19.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org X-HE-Tag: 1641160678-863993 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 be965c965484..e7bcee8776e1 100644 --- a/mm/gup.c +++ b/mm/gup.c @@ -2552,7 +2552,8 @@ static int gup_huge_pud(pud_t orig, pud_t *pudp, 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 (!pud_access_permitted(orig, flags & FOLL_WRITE)) @@ -2565,20 +2566,20 @@ static int gup_huge_pud(pud_t orig, pud_t *pudp, unsigned long addr, pages, nr); } - page = pud_page(orig) + ((addr & ~PUD_MASK) >> PAGE_SHIFT); + page = nth_page(pud_page(orig), (addr & ~PUD_MASK) >> PAGE_SHIFT); refs = record_subpages(page, addr, end, pages + *nr); - head = try_grab_compound_head(pud_page(orig), refs, flags); - if (!head) + folio = try_grab_folio(page, refs, flags); + if (!folio) return 0; if (unlikely(pud_val(orig) != pud_val(*pudp))) { - put_compound_head(head, refs, flags); + gup_put_folio(folio, refs, flags); return 0; } *nr += refs; - SetPageReferenced(head); + folio_set_referenced(folio); return 1; }