From patchwork Mon Jan 16 19:39:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13103614 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 6DE32C54EBE for ; Mon, 16 Jan 2023 19:39:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0E5716B0078; Mon, 16 Jan 2023 14:39:37 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 06D466B007B; Mon, 16 Jan 2023 14:39:37 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E4F3E6B007D; Mon, 16 Jan 2023 14:39:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id CD5A26B0078 for ; Mon, 16 Jan 2023 14:39:36 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 8B154A6CA9 for ; Mon, 16 Jan 2023 19:39:36 +0000 (UTC) X-FDA: 80361676752.18.0968E3E Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf20.hostedemail.com (Postfix) with ESMTP id 091031C0016 for ; Mon, 16 Jan 2023 19:39:34 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=UB5qnZWo; dmarc=none; spf=none (imf20.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673897975; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=QxqbpS4ka82riIccVYXuKO6G2yQtQJPJB9RcfdFfrg8=; b=jSLv9XrHzXBpf4yNOYYEpUTqhfU37cS8+euYDQb8sUxm8UdnsEYt3qSgGHPF5GyOzW9iN2 P3HPrks7EkJSZ89/8iHdl9GmfzgBZv2HUusNVsWtegdWLu58NA7c9+g9nZrcLM7nzAS+QE rhVN1l7cQmwpPH/lK3Je39fibZlbnoY= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=UB5qnZWo; dmarc=none; spf=none (imf20.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673897975; a=rsa-sha256; cv=none; b=W7vsHz6AKZTRzqAwwuRajG51O7+9imivu4AWf6T+67YzoPs7hyIz3pr1zqnTjmXa9v0x9W Sya19psnQMCN7DsvpCSNF6pfv6ygixj2EYT2OzD30NQlfpBc7uD7TlLgbHMM6V/kvULi0+ Ghw3EXi43ok0h7mVDmVG3W9mF2KPOb4= 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=QxqbpS4ka82riIccVYXuKO6G2yQtQJPJB9RcfdFfrg8=; b=UB5qnZWomdpEqHeT8nvQg+7ugb an1WeBT0IQjHXPWYBoDH+HurvRcYe37yHzmHydD5BXUX+5k+zNfhXCPkolFnCRSZBS55Qs5RC1DOu IBKO5BQu1px5YCvXRCcK2lVDksdop/ojrzvBK7HtM5lPNRs72B2H2u+wlVavGQmmyIGYH98K9SWCk PNXY2bRYUP/jV7uHvcbkm184qhP8rmLfcq/yrF2wr2paVtow9Rl3dI6TTP1VXJPTss3e1ReNfGHDh N+kXzhgDMijk3pv0iWbOEbYztm/1bhBOa0S+dPAm8cMjkfWZPxVv5RtfQLUZXDeWy+xa0/zZFJTK4 g2+JreaA==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pHVKZ-0090vu-Ba; Mon, 16 Jan 2023 19:39:43 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , linux-mm@kvack.org Subject: [PATCH 1/3] filemap: Convert filemap_map_pmd() to take a folio Date: Mon, 16 Jan 2023 19:39:39 +0000 Message-Id: <20230116193941.2148487-2-willy@infradead.org> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230116193941.2148487-1-willy@infradead.org> References: <20230116193941.2148487-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 091031C0016 X-Rspamd-Server: rspam09 X-Rspam-User: X-Stat-Signature: ad5auot9ohbpxsfsyqjpeqmeq3mbgdp7 X-HE-Tag: 1673897974-491712 X-HE-Meta: U2FsdGVkX18BSIqOgejMOw9ZdV9G2Aw5trD50X4LtVcgo1eYHFVm6Loc036caSTwG2lGtvZlPZIcJPs/9d/4R3Nj74+SPryS9GcTW7h8nA1S0empFf87W160ZTqxpyDJr4yHDxJezEb+Myy2hvUXesX4pkzD8IYJHA1++t7V4F/wrXW+zn+gcX4wfBQ5nTzHapauHtQYlScCUGCCJ2Z0IVPOv7DfDa3vsPfxFouVTXdqBUM0PbM+ce0EHX7arnMTSZgJ4f77rkDqWcpIN0y7AMEDkHqThEo5wqBvxuivg25AkO+zfL8QlZLBJSXee0d17YydVpkdt3erPMqi8jVY1ZypGBLOZsAPSfeqPJzhcw/A8jUW79QOtoegW+yX3BwspPT2nfJWEzfQsCTAVVhoxAyOkiWpV73H4zzM1xt416ob6B1gbFVIlqtSoPu5SQ7dMT04/wGYvdjO/wKuXpuGJ+le2XOKs7SoeqvddkLO7JT2vegcXEzDomDO3HrY+ibdPGBQERF5SqQca/XmghPAt+ijb/YZay9MtUIe7PE9BRfmo66XhHWGy+onHadZiA1A7WB1U5V17ePrIzbweiWP+c80DHKPD3I1E7zUOW3vmRMV5NJUvPXvigZ5fcZZ52J2xPMtZyRiEp/qkS6R06AAwR/PCFy9TOCM4Jm7SYvDn5v3b4KXDaEnLg3RrVcy1WbmeBtcnLgRaQhErikjxmE6ED2+wGO+xvhwC9xLLHor2RhfTa58r85j2jPWuEsFGzhejSvWMI0ovXh3qcsHeIthdTFWBHXQ9x3/HM0Mk1OCm2/xe9/ZdenTbsr7IZYKmCetLEp20zyMwUS2eNc1932xphEnp/nCmquF85yj317OsR09yZ9Sc4AWGrt0msSZFtpwMW28t2YHQ96G3rMZgixnsn9IpBCM+E0I8Z32gyYGjUPZZ/TPGpt7/Q== 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: Save a few calls to compound_head(). We specify exactly which page from the folio to use by passing in start_pgoff, which means this will work for a folio which is larger than PMD size. The rest of the VM isn't prepared for that yet, but now this function is. Signed-off-by: Matthew Wilcox (Oracle) --- mm/filemap.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 31bf18ec6d01..b6b7efc9abc0 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -3259,22 +3259,24 @@ vm_fault_t filemap_fault(struct vm_fault *vmf) } EXPORT_SYMBOL(filemap_fault); -static bool filemap_map_pmd(struct vm_fault *vmf, struct page *page) +static bool filemap_map_pmd(struct vm_fault *vmf, struct folio *folio, + pgoff_t start) { struct mm_struct *mm = vmf->vma->vm_mm; /* Huge page is mapped? No need to proceed. */ if (pmd_trans_huge(*vmf->pmd)) { - unlock_page(page); - put_page(page); + folio_unlock(folio); + folio_put(folio); return true; } - if (pmd_none(*vmf->pmd) && PageTransHuge(page)) { + if (pmd_none(*vmf->pmd) && folio_test_pmd_mappable(folio)) { + struct page *page = folio_file_page(folio, start); vm_fault_t ret = do_set_pmd(vmf, page); if (!ret) { /* The page is mapped successfully, reference consumed. */ - unlock_page(page); + folio_unlock(folio); return true; } } @@ -3284,8 +3286,8 @@ static bool filemap_map_pmd(struct vm_fault *vmf, struct page *page) /* See comment in handle_pte_fault() */ if (pmd_devmap_trans_unstable(vmf->pmd)) { - unlock_page(page); - put_page(page); + folio_unlock(folio); + folio_put(folio); return true; } @@ -3368,7 +3370,7 @@ vm_fault_t filemap_map_pages(struct vm_fault *vmf, if (!folio) goto out; - if (filemap_map_pmd(vmf, &folio->page)) { + if (filemap_map_pmd(vmf, folio, start_pgoff)) { ret = VM_FAULT_NOPAGE; goto out; }