From patchwork Wed Dec 8 04:22:34 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 12663765 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 B7305C433EF for ; Wed, 8 Dec 2021 06:48:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4BBF76B0071; Wed, 8 Dec 2021 01:48:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 444FE6B0073; Wed, 8 Dec 2021 01:48:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2E5446B0074; Wed, 8 Dec 2021 01:48:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay026.a.hostedemail.com [64.99.140.26]) by kanga.kvack.org (Postfix) with ESMTP id 1A8316B0071 for ; Wed, 8 Dec 2021 01:48:36 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay13.hostedemail.com (Postfix) with ESMTP id 08943601B0 for ; Wed, 8 Dec 2021 04:28:56 +0000 (UTC) X-FDA: 78893346588.27.74151D0 Received: from relay.hostedemail.com (relay037.a.hostedemail.com [64.99.140.37]) by imf27.hostedemail.com (Postfix) with ESMTP id 8867D7000081 for ; Wed, 8 Dec 2021 04:28:55 +0000 (UTC) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay12.hostedemail.com (Postfix) with ESMTP id 2FDCD1201C8 for ; Wed, 8 Dec 2021 04:23:16 +0000 (UTC) X-FDA: 78893332308.21.EE4E6A5 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf18.hostedemail.com (Postfix) with ESMTP id B8C3E4002087 for ; Wed, 8 Dec 2021 04:23:15 +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=nGTKE0UdgttmA0mxrDkUyEEjWKbpIL8TqlNy2EdTN2Y=; b=hEyn3n48W+l3guJA++IEkfiI2Y iVK8k6jmg2oUNQJsrPCxZCXIFnEiRv0CvrbSKoQOTQ1Xzxl1zuuJvkBr/pFI9NBzSmImLbNBvX4jh FkLqKZCUbOFs5yXczMbrngvy58n+qVdR9QFCtsSQAlWxVEpfOkLs/mbapiEAg8eyFRVd+n+5p5thL sLDn84latXJS+Zq/jAnVfKaIM24ydC9Nh7dMCTgT9/hutecPX6bJQ9z2Z8sOVrXvinGWVq7JtsaWM pBva4x6KNMs2AyL+PabPq9CYw2sw1JnkfSJxxET6BBnwm0oJ6VorQEdxwVPjVHsLIMAbF0yqhp6YI AtjYuVbg==; Received: from willy by casper.infradead.org with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1muoU4-0084ZB-P9; Wed, 08 Dec 2021 04:23:12 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" Subject: [PATCH 26/48] filemap: Convert filemap_get_pages to use folios Date: Wed, 8 Dec 2021 04:22:34 +0000 Message-Id: <20211208042256.1923824-27-willy@infradead.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20211208042256.1923824-1-willy@infradead.org> References: <20211208042256.1923824-1-willy@infradead.org> MIME-Version: 1.0 X-Stat-Signature: d7osbycpinaayhgd1sxb91w3if6x7osd X-HE-Tag-Orig: 1638937395-951729 Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=hEyn3n48; spf=none (imf27.hostedemail.com: domain of FILTER%willy@infradead.org has no SPF policy when checking 64.99.140.37) smtp.mailfrom=FILTER%willy@infradead.org; dmarc=none X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 8867D7000081 X-HE-Tag: 1638937735-792531 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: This saves a few calls to compound_head(), including one in filemap_update_page(). Shrinks the kernel by 78 bytes. Signed-off-by: Matthew Wilcox (Oracle) Reviewed-by: Christoph Hellwig --- mm/filemap.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index f34dda0a7627..d191a4fd758a 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2422,9 +2422,8 @@ static bool filemap_range_uptodate(struct address_space *mapping, static int filemap_update_page(struct kiocb *iocb, struct address_space *mapping, struct iov_iter *iter, - struct page *page) + struct folio *folio) { - struct folio *folio = page_folio(page); int error; if (iocb->ki_flags & IOCB_NOWAIT) { @@ -2521,13 +2520,14 @@ static int filemap_create_folio(struct file *file, } static int filemap_readahead(struct kiocb *iocb, struct file *file, - struct address_space *mapping, struct page *page, + struct address_space *mapping, struct folio *folio, pgoff_t last_index) { + DEFINE_READAHEAD(ractl, file, &file->f_ra, mapping, folio->index); + if (iocb->ki_flags & IOCB_NOIO) return -EAGAIN; - page_cache_async_readahead(mapping, &file->f_ra, file, page, - page->index, last_index - page->index); + page_cache_async_ra(&ractl, folio, last_index - folio->index); return 0; } @@ -2539,7 +2539,7 @@ static int filemap_get_pages(struct kiocb *iocb, struct iov_iter *iter, struct file_ra_state *ra = &filp->f_ra; pgoff_t index = iocb->ki_pos >> PAGE_SHIFT; pgoff_t last_index; - struct page *page; + struct folio *folio; int err = 0; last_index = DIV_ROUND_UP(iocb->ki_pos + iter->count, PAGE_SIZE); @@ -2565,16 +2565,16 @@ static int filemap_get_pages(struct kiocb *iocb, struct iov_iter *iter, return err; } - page = pvec->pages[pagevec_count(pvec) - 1]; - if (PageReadahead(page)) { - err = filemap_readahead(iocb, filp, mapping, page, last_index); + folio = page_folio(pvec->pages[pagevec_count(pvec) - 1]); + if (folio_test_readahead(folio)) { + err = filemap_readahead(iocb, filp, mapping, folio, last_index); if (err) goto err; } - if (!PageUptodate(page)) { + if (!folio_test_uptodate(folio)) { if ((iocb->ki_flags & IOCB_WAITQ) && pagevec_count(pvec) > 1) iocb->ki_flags |= IOCB_NOWAIT; - err = filemap_update_page(iocb, mapping, iter, page); + err = filemap_update_page(iocb, mapping, iter, folio); if (err) goto err; } @@ -2582,7 +2582,7 @@ static int filemap_get_pages(struct kiocb *iocb, struct iov_iter *iter, return 0; err: if (err < 0) - put_page(page); + folio_put(folio); if (likely(--pvec->nr)) return 0; if (err == AOP_TRUNCATED_PAGE)