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; } From patchwork Mon Jan 16 19:39:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13103615 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 65A78C54EBE for ; Mon, 16 Jan 2023 19:39:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CA1A96B007B; Mon, 16 Jan 2023 14:39:39 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C2B7B6B007D; Mon, 16 Jan 2023 14:39:39 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ACB9C6B007E; Mon, 16 Jan 2023 14:39:39 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 993B86B007B for ; Mon, 16 Jan 2023 14:39:39 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 6EFA81202F6 for ; Mon, 16 Jan 2023 19:39:39 +0000 (UTC) X-FDA: 80361676878.27.D474E81 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf12.hostedemail.com (Postfix) with ESMTP id ED5E340012 for ; Mon, 16 Jan 2023 19:39:37 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=XH2W9gs7; spf=none (imf12.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1673897978; 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=xC72UzgGngSDoXt52H+Zit4qgNWY+zzDo/EkJgHacCc=; b=Pt8E7KPRzY59uKsDzC6oD8iodIkEpSpctuVG6qh8W6BQHtO9aDgfrl5ypibkbJTGZQ8COa X+DT5qxHuO9Qf0RJamndiRiHh3JZxC09bEqblLA71vkwxTdMU5K5FAfT5+rDb0Ydpc50WJ ZPtgF0/mCXILPiCNicEbMkz5JUBu1d0= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=XH2W9gs7; spf=none (imf12.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1673897978; a=rsa-sha256; cv=none; b=MBVVCk8wY5K+QRjtJBbsT29tNDi60/9AxsieA1O3+N4jMnrvFdjgRP41+vSnNWUSclGJHn 0GMZAXKnIFuTILK0OFiWIOsREV3+H/oadT1bFKWNooFGmFBvi4dj7MYcj6bWTwEtXpcK0W Mfz9PhwUTv4ABnLTfrwy5F8r+5BQtP0= 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=xC72UzgGngSDoXt52H+Zit4qgNWY+zzDo/EkJgHacCc=; b=XH2W9gs7YN/z31Bfeb35drSRey mi5JNUqOWG8PkbyhqvYte5nTS2+9gFGoAiNs57Sk6ANglcdQEoVox9eej6Cew+uk4P+TGMhU0b4Aa u1WELsjEXyIQQX3fVgSRRO7/ZkWfM6pbQCo2BfiNBRi69z6+4NAx4tS1/SibanSwjuxuBxHmJAS+L Xqcan1hqCzWh0TbXiyutbkPJZG3c1dYsy4a1uqlBT/2VQnTlolM9+f3TK/B8ddaaF/gUZVinFUL9H Kq0hWHbhMTZuJ2kLQeLLTTulgqjMtbYRH4gH7RA+pQyODQvexMVTg6zsI5T8oVKxJSAnoo4S66m2/ mHVdZ0hg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pHVKZ-0090vw-EY; 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 2/3] filemap: Convert filemap_range_has_page() to use a folio Date: Mon, 16 Jan 2023 19:39:40 +0000 Message-Id: <20230116193941.2148487-3-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: ED5E340012 X-Stat-Signature: 3rs4fgn8tmk5ds4ae1t3fdmwww8119hx X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1673897977-903362 X-HE-Meta: U2FsdGVkX19mxFx+xjYaNA9mrfvTT4Uy1wdpIB8O9/UdAvyu8ZkDbDSEfOlBaAtYPIkHE6IoFTJ22m4TwqCrdy/0Yustto5zXtRmr5WfAtBwCbpr7GeEyQrmFaFlaov8+HxNLGpkteE/vcPZVkBH6S+taqwKhK+GPe7ezUm3oIGxaFpTQqWIUDoKnlAM1fEGz7FGTbZklztguHRPqDxKmaQqtpZ98h9qY3EgIs8Pj2t+VkF9Q84XH76U/H6wpP8YssczWz9fFeSR0sKFlQ73dU1mjdqoMOXdoGJVc9H2I3A4Vdu4imwbY1yUh/xa0kDXIJGYpLHoFkLm8sPeODoblBuAq1GhQaSZhjfxtphrEeIlyo0qUktwP/rGqhsn53Ctay8oTWpksC3mHF4HP1INpzQh1AOKsGwJD+/UAkxOAFcu9We9+Lnodz6JBOr4DwFqbtF/swuKN2kiWnXCmZu1So/HcWtZiyddfMgDBKJsfS+OQ+G131mB5AdFXV20K24XuF/hLi7O2ECVItGN9b7uut62gVCFQ0RTeJYGJwbv4cUfk3edI9QcbV2mRGxUNWjKfCUeu9inNOGk7DJKgt2Qxt+ZpjKnFM+bgd94fRVep4RZSvfTjOBf95SnDgJvEJkE/oVbG/HDc0SVwflgtVMwBOfgMqyPzQ44/i88r5jG6mNEmyuKPMwfNF7ihPToaeYZqk72ygaLrX2g8/lMfsDhRDfu3GnFEEy4ZCGLufseFcckcXhDgCQShNoTahgFZFXK1tL6Pqa5PjQ8CpaPDgFVtB+M7NdB/T/FrZ5BtG2m0WrVgbzqURYh+yrUPd7iQVyRZeYDukNGSKNoICDs57rcSPXmDA4uiA1tB/QzSDleyv/s/J5+uB0gxhNeQznihZFyvVis8qDprYUv0EVeU3kC+1Jn4SGm0TNRIRvQtuVv+wZx18hfYZvOvg== 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: The folio isn't returned from this function, so this is an entirely internal change. Signed-off-by: Matthew Wilcox (Oracle) --- mm/filemap.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index b6b7efc9abc0..c915ded191f0 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -470,7 +470,7 @@ EXPORT_SYMBOL(filemap_flush); bool filemap_range_has_page(struct address_space *mapping, loff_t start_byte, loff_t end_byte) { - struct page *page; + struct folio *folio; XA_STATE(xas, &mapping->i_pages, start_byte >> PAGE_SHIFT); pgoff_t max = end_byte >> PAGE_SHIFT; @@ -479,11 +479,11 @@ bool filemap_range_has_page(struct address_space *mapping, rcu_read_lock(); for (;;) { - page = xas_find(&xas, max); - if (xas_retry(&xas, page)) + folio = xas_find(&xas, max); + if (xas_retry(&xas, folio)) continue; /* Shadow entries don't count */ - if (xa_is_value(page)) + if (xa_is_value(folio)) continue; /* * We don't need to try to pin this page; we're about to @@ -494,7 +494,7 @@ bool filemap_range_has_page(struct address_space *mapping, } rcu_read_unlock(); - return page != NULL; + return folio != NULL; } EXPORT_SYMBOL(filemap_range_has_page); From patchwork Mon Jan 16 19:39:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 13103616 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 41678C46467 for ; Mon, 16 Jan 2023 19:39:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D65F96B007D; Mon, 16 Jan 2023 14:39:42 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CEDDD6B007E; Mon, 16 Jan 2023 14:39:42 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B8F826B0080; Mon, 16 Jan 2023 14:39:42 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id A596F6B007D for ; Mon, 16 Jan 2023 14:39:42 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 868D7120147 for ; Mon, 16 Jan 2023 19:39:42 +0000 (UTC) X-FDA: 80361677004.05.8DD9264 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf02.hostedemail.com (Postfix) with ESMTP id 0F46180012 for ; Mon, 16 Jan 2023 19:39:40 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=UXEKrcXb; dmarc=none; spf=none (imf02.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=1673897981; 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=HiN0YNe+znluR1269CImH1XlG1nnRL1homAmxF2BJLg=; b=qp2rm157HdZE1x3cTEyqhRgPAdRteh/+hQukMuGZawdeTwqngch1Bq18uuVvVyZ0nI709H RpyKXRksfO+NCWiPNhpCUdCh3tKHit8vEq0xqkuLWMWdaJUMlPnUl1YhVDj2q/BB0ugNRe 1zlOkT9i+5LBdjPglYZvSPWYFaL/yEo= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=UXEKrcXb; dmarc=none; spf=none (imf02.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=1673897981; a=rsa-sha256; cv=none; b=yKu+N34vvSFILfSfMKEikYnecvNiajtt3MlyGbkKeDrgfSASfnlTTUgt+0jcwsQK6F/FNT 3NFaP7yUrzXZs+4h1kjosmNj78MiieY6Ey4KUgrn2sVnubum1fr7Ah7I4UWejEOWjb5to2 vy7xduXCOeyOTIJAVmoQAz2iuQ9S9oI= 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=HiN0YNe+znluR1269CImH1XlG1nnRL1homAmxF2BJLg=; b=UXEKrcXbXxCSKA6IgPtZLKHaMx ZV3lpOghDjJbw1isWUD2HHAiqFYYj6NLCHCLQypJp+2KymFwEHDOk0d8cIma+HyBmJtDEYXjYxWyR w+pzj8s6ZKgic0J09RQljYnWfUbPVWHg59doqwrtIcO7iHBcAhjVj65IsWtQsS7QWSRK2qy7/ybD1 rqzN/Hjd7Guhbb5iHpXnX85AchJvWjYeoCibhIPTTjEr5p0iXOo/gdKJqJjgr8QIERRyRlXdprfrM sMU6vhqEc3m6lW8dWdPaF5xnyx6ZI7oB6nNmTqUMRpcg0oflVySYKtfahvXyuPg3KvaIQ3AJ1LKM8 bLw1kVtQ==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1pHVKZ-0090vy-HZ; 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 3/3] readahead: Convert readahead_expand() to use a folio Date: Mon, 16 Jan 2023 19:39:41 +0000 Message-Id: <20230116193941.2148487-4-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-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 0F46180012 X-Stat-Signature: 8iyzca3ywf5hjtdf7yrsh9ztm3t7fw3z X-HE-Tag: 1673897980-151613 X-HE-Meta: U2FsdGVkX18bx1D5xZKDH4LJun3uScggpgDdI/lnDTO0GKXCD53fzVrMlxuHf4ssLau1okC9fxrYE0fM6qoi0m+L/Fgg2g1HrEpMHP9wSqsAEKRJMk+i8+7kLq8js4r2F7Al06f1wvAb7xm8e9g/0BL7TuQMeviZd5tPi6aAl9uGASNNtP5BvhSuDucyR2tHL2wvf1ofz/scBsxXi4d/s0/GNv9/qtocutY7O+AqDbDA6f3fh57IDBpd8bDv9e5kInQN3xC6LIQJRkWZGNRsuSIwyIs34RF6yB105D6gnY88+z9MxEpl0LXnsHztvaHoNg+hLItMdluZQNmn5AAAQQmFPMgJVgGMixehUkcQyY+CwY+JDLJEDqTefqwngc83OZk2VCwP62mvnTSot6c67nekPX3uf4iCKexyfoOi+ThbvdHJFlhRNoO2St+Czja9QtJWue+cNlgzkqAdgKekY02fS4wyQcy9V2d1+zu1o4zPchFOTLiB5Uj6avCC+xYbbZdjifdGTdm4hbrR418efgMcQ8Me6qcsL4GrpLS7iAO2UFR1DZ3prx02gMgWNNv0+C3YRDMIcAp75IE0YmW+PC6BzQssAk1U8/gjtt1gltGG4iqfxT3JEj/EMqjQTvEAysp5oj+ykEs7XA7otsISmfq6qm4Ti4FAzyqnJlbHix1UhvC/QfvAH5xCAhsZFIbF0yRNqYu9TXW2PTq3ltttwnnU09DUU5p1RWqF49JZlNccw9JguBVgwIBJG7FwvyJ/yAlZi7ehmfXqoUNzWLgOYfDRkobl32JZ/fhBoSdEisCK9wm2FyvZNgMqm+Sy9OkHpU89Z2hYQVdeC4a9eWDqhSjmpXn4VSP3r1qfw7lSv9IIEGjLrhsPTvDuciyDdzAhRzG8luyv8Va8I7K2R2kUtmYmgpkBxP09LAaWeuySpYmeburtiv6dAg== 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: Replace the uses of page with a folio. Also add a missing test for workingset in the leading edge expansion. Signed-off-by: Matthew Wilcox (Oracle) --- mm/readahead.c | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/mm/readahead.c b/mm/readahead.c index b10f0cf81d80..47afbca1d122 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -801,21 +801,25 @@ void readahead_expand(struct readahead_control *ractl, /* Expand the leading edge downwards */ while (ractl->_index > new_index) { unsigned long index = ractl->_index - 1; - struct page *page = xa_load(&mapping->i_pages, index); + struct folio *folio = xa_load(&mapping->i_pages, index); - if (page && !xa_is_value(page)) - return; /* Page apparently present */ + if (folio && !xa_is_value(folio)) + return; /* Folio apparently present */ - page = __page_cache_alloc(gfp_mask); - if (!page) + folio = filemap_alloc_folio(gfp_mask, 0); + if (!folio) return; - if (add_to_page_cache_lru(page, mapping, index, gfp_mask) < 0) { - put_page(page); + if (filemap_add_folio(mapping, folio, index, gfp_mask) < 0) { + folio_put(folio); return; } - + if (unlikely(folio_test_workingset(folio)) && + !ractl->_workingset) { + ractl->_workingset = true; + psi_memstall_enter(&ractl->_pflags); + } ractl->_nr_pages++; - ractl->_index = page->index; + ractl->_index = folio->index; } new_len += new_start - readahead_pos(ractl); @@ -824,19 +828,20 @@ void readahead_expand(struct readahead_control *ractl, /* Expand the trailing edge upwards */ while (ractl->_nr_pages < new_nr_pages) { unsigned long index = ractl->_index + ractl->_nr_pages; - struct page *page = xa_load(&mapping->i_pages, index); + struct folio *folio = xa_load(&mapping->i_pages, index); - if (page && !xa_is_value(page)) - return; /* Page apparently present */ + if (folio && !xa_is_value(folio)) + return; /* Folio apparently present */ - page = __page_cache_alloc(gfp_mask); - if (!page) + folio = filemap_alloc_folio(gfp_mask, 0); + if (!folio) return; - if (add_to_page_cache_lru(page, mapping, index, gfp_mask) < 0) { - put_page(page); + if (filemap_add_folio(mapping, folio, index, gfp_mask) < 0) { + folio_put(folio); return; } - if (unlikely(PageWorkingset(page)) && !ractl->_workingset) { + if (unlikely(folio_test_workingset(folio)) && + !ractl->_workingset) { ractl->_workingset = true; psi_memstall_enter(&ractl->_pflags); }