From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 605A5C433E9 for ; Thu, 3 Sep 2020 14:09:04 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 0D40120578 for ; Thu, 3 Sep 2020 14:09:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="rNBaXP6N" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0D40120578 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 649106B006E; Thu, 3 Sep 2020 10:08:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 606B16B0073; Thu, 3 Sep 2020 10:08:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2303D6B0071; Thu, 3 Sep 2020 10:08:57 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0112.hostedemail.com [216.40.44.112]) by kanga.kvack.org (Postfix) with ESMTP id 089526B0070 for ; Thu, 3 Sep 2020 10:08:57 -0400 (EDT) Received: from smtpin14.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id B977F824556B for ; Thu, 3 Sep 2020 14:08:56 +0000 (UTC) X-FDA: 77221931472.14.swing44_2f13aa0270aa Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin14.hostedemail.com (Postfix) with ESMTP id 8A52F18229818 for ; Thu, 3 Sep 2020 14:08:56 +0000 (UTC) X-HE-Tag: swing44_2f13aa0270aa X-Filterd-Recvd-Size: 6688 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf37.hostedemail.com (Postfix) with ESMTP for ; Thu, 3 Sep 2020 14:08:56 +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=eTwGtgPGcBumRp8Hea4BdT+Mx8Gt3M//B82u6fGGQ6c=; b=rNBaXP6NVLGcexEYZ63yUqlOBo XFjzBn5wmiOhufSy4PfLo9QT3AJuR44gzSHBWGRglvScyPGnYK2lJI6zFUbYqgnDh/k7FxLuVmwTB xV0q4leRzsTDGZG43UidhdRLPAv8wyWgrNDt6R2I5B2WCvgTw1lTW5cVeGce0VlGtXNiFPDKBxCGh /BpV/h4sQ4ONey0o/CY/ynPm7TuCsAz0Na6+evQ3KstXNSNTAWED/yOdU55ORaZsazxOGUksFDWlB MbeSlgfogup5l0+VRvzzYA1dEt9xU9b7U+yH0Z8EIwHzMYP2URZQbjQL06sM8jovvAj/jgliNePnn gSPO2yTg==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kDpv2-0003iE-56; Thu, 03 Sep 2020 14:08:52 +0000 From: "Matthew Wilcox (Oracle)" To: Andrew Morton Cc: "Matthew Wilcox (Oracle)" , David Howells , linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Eric Biggers Subject: [PATCH 4/9] mm/readahead: Make do_page_cache_ra take a readahead_control Date: Thu, 3 Sep 2020 15:08:39 +0100 Message-Id: <20200903140844.14194-5-willy@infradead.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20200903140844.14194-1-willy@infradead.org> References: <20200903140844.14194-1-willy@infradead.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 8A52F18229818 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 Content-Transfer-Encoding: quoted-printable 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: Rename __do_page_cache_readahead() to do_page_cache_ra() and call it directly from ondemand_readahead() instead of indirecting via ra_submit()= . Signed-off-by: Matthew Wilcox (Oracle) --- mm/internal.h | 11 +++++------ mm/readahead.c | 28 +++++++++++++++------------- 2 files changed, 20 insertions(+), 19 deletions(-) diff --git a/mm/internal.h b/mm/internal.h index 10c677655912..6aef85f62b9d 100644 --- a/mm/internal.h +++ b/mm/internal.h @@ -51,18 +51,17 @@ void unmap_page_range(struct mmu_gather *tlb, =20 void force_page_cache_readahead(struct address_space *, struct file *, pgoff_t index, unsigned long nr_to_read); -void __do_page_cache_readahead(struct address_space *, struct file *, - pgoff_t index, unsigned long nr_to_read, - unsigned long lookahead_size); +void do_page_cache_ra(struct readahead_control *, + unsigned long nr_to_read, unsigned long lookahead_size); =20 /* * Submit IO for the read-ahead request in file_ra_state. */ static inline void ra_submit(struct file_ra_state *ra, - struct address_space *mapping, struct file *filp) + struct address_space *mapping, struct file *file) { - __do_page_cache_readahead(mapping, filp, - ra->start, ra->size, ra->async_size); + DEFINE_READAHEAD(ractl, file, mapping, ra->start); + do_page_cache_ra(&ractl, ra->size, ra->async_size); } =20 /** diff --git a/mm/readahead.c b/mm/readahead.c index a444943781bb..577f180d9252 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -241,17 +241,16 @@ void page_cache_ra_unbounded(struct readahead_contr= ol *ractl, EXPORT_SYMBOL_GPL(page_cache_ra_unbounded); =20 /* - * __do_page_cache_readahead() actually reads a chunk of disk. It alloc= ates + * do_page_cache_ra() actually reads a chunk of disk. It allocates * the pages first, then submits them for I/O. This avoids the very bad * behaviour which would occur if page allocations are causing VM writeb= ack. * We really don't want to intermingle reads and writes like that. */ -void __do_page_cache_readahead(struct address_space *mapping, - struct file *file, pgoff_t index, unsigned long nr_to_read, - unsigned long lookahead_size) +void do_page_cache_ra(struct readahead_control *ractl, + unsigned long nr_to_read, unsigned long lookahead_size) { - DEFINE_READAHEAD(ractl, file, mapping, index); - struct inode *inode =3D mapping->host; + struct inode *inode =3D ractl->mapping->host; + unsigned long index =3D readahead_index(ractl); loff_t isize =3D i_size_read(inode); pgoff_t end_index; /* The last page we want to read */ =20 @@ -265,7 +264,7 @@ void __do_page_cache_readahead(struct address_space *= mapping, if (nr_to_read > end_index - index) nr_to_read =3D end_index - index + 1; =20 - page_cache_ra_unbounded(&ractl, nr_to_read, lookahead_size); + page_cache_ra_unbounded(ractl, nr_to_read, lookahead_size); } =20 /* @@ -273,10 +272,11 @@ void __do_page_cache_readahead(struct address_space= *mapping, * memory at once. */ void force_page_cache_readahead(struct address_space *mapping, - struct file *filp, pgoff_t index, unsigned long nr_to_read) + struct file *file, pgoff_t index, unsigned long nr_to_read) { + DEFINE_READAHEAD(ractl, file, mapping, index); struct backing_dev_info *bdi =3D inode_to_bdi(mapping->host); - struct file_ra_state *ra =3D &filp->f_ra; + struct file_ra_state *ra =3D &file->f_ra; unsigned long max_pages; =20 if (unlikely(!mapping->a_ops->readpage && !mapping->a_ops->readpages && @@ -294,7 +294,7 @@ void force_page_cache_readahead(struct address_space = *mapping, =20 if (this_chunk > nr_to_read) this_chunk =3D nr_to_read; - __do_page_cache_readahead(mapping, filp, index, this_chunk, 0); + do_page_cache_ra(&ractl, this_chunk, 0); =20 index +=3D this_chunk; nr_to_read -=3D this_chunk; @@ -432,10 +432,11 @@ static int try_context_readahead(struct address_spa= ce *mapping, * A minimal readahead algorithm for trivial sequential/random reads. */ static void ondemand_readahead(struct address_space *mapping, - struct file_ra_state *ra, struct file *filp, + struct file_ra_state *ra, struct file *file, bool hit_readahead_marker, pgoff_t index, unsigned long req_size) { + DEFINE_READAHEAD(ractl, file, mapping, index); struct backing_dev_info *bdi =3D inode_to_bdi(mapping->host); unsigned long max_pages =3D ra->ra_pages; unsigned long add_pages; @@ -516,7 +517,7 @@ static void ondemand_readahead(struct address_space *= mapping, * standalone, small random read * Read as is, and do not pollute the readahead state. */ - __do_page_cache_readahead(mapping, filp, index, req_size, 0); + do_page_cache_ra(&ractl, req_size, 0); return; =20 initial_readahead: @@ -542,7 +543,8 @@ static void ondemand_readahead(struct address_space *= mapping, } } =20 - ra_submit(ra, mapping, filp); + ractl._index =3D ra->start; + do_page_cache_ra(&ractl, ra->size, ra->async_size); } =20 /** --=20 2.28.0