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=-6.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no 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 D1787C433DF for ; Fri, 16 Oct 2020 03:06:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7E08A2087D for ; Fri, 16 Oct 2020 03:06:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602817587; bh=PuHtxa1XKOXLdDCsKIDu/Y8AvzQgNpNNJqmT+WREfeM=; h=Date:From:To:Subject:In-Reply-To:Reply-To:List-ID:From; b=FW3j82uYWwh6Mw2nv6Fefktfbi7rJ1MNIYYyTtOTz+Try5yBAiDuraEyQlWJTiIsC 39STSoPZ/RjKog56fg4iFkz1XahuW5q25SrLML+cl37VXwkCCPV1SqysNHyU+7x3Ab xdTshSlD3YcEuLYQFmEbDL/LMULPkR+05VBWxqyI= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2404477AbgJPDG1 (ORCPT ); Thu, 15 Oct 2020 23:06:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:44674 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2404476AbgJPDG0 (ORCPT ); Thu, 15 Oct 2020 23:06:26 -0400 Received: from localhost.localdomain (c-73-231-172-41.hsd1.ca.comcast.net [73.231.172.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 95C0520789; Fri, 16 Oct 2020 03:06:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1602817586; bh=PuHtxa1XKOXLdDCsKIDu/Y8AvzQgNpNNJqmT+WREfeM=; h=Date:From:To:Subject:In-Reply-To:From; b=NT/4VeOSnj5Z8ihMIuhK5hGd7dXpbJXO8G7NizZ617pWsxvXjcxofpZg85pdTmRFp P0rnS6aFaezmBy0dMpmPOcn6dwM4Zdn2AfbxEy2dvXqQU65ZsPxSHZaDGZ28Ugvtg6 /P/nq4scYFYRYPQnhdHsypSWY4HYXp3GAnHqSR94= Date: Thu, 15 Oct 2020 20:06:24 -0700 From: Andrew Morton To: akpm@linux-foundation.org, dhowells@redhat.com, ebiggers@google.com, mm-commits@vger.kernel.org, torvalds@linux-foundation.org, willy@infradead.org Subject: [patch 037/156] mm/readahead: pass readahead_control to force_page_cache_ra Message-ID: <20201016030624.6iEE5pafN%akpm@linux-foundation.org> In-Reply-To: <20201015194043.84cda0c1d6ca2a6847f2384a@linux-foundation.org> User-Agent: s-nail v14.8.16 Precedence: bulk Reply-To: linux-kernel@vger.kernel.org List-ID: X-Mailing-List: mm-commits@vger.kernel.org From: David Howells Subject: mm/readahead: pass readahead_control to force_page_cache_ra Reimplement force_page_cache_readahead() as a wrapper around force_page_cache_ra(). Pass the existing readahead_control from page_cache_sync_readahead(). Link: https://lkml.kernel.org/r/20200903140844.14194-7-willy@infradead.org Signed-off-by: David Howells Signed-off-by: Matthew Wilcox (Oracle) Cc: Eric Biggers Signed-off-by: Andrew Morton --- mm/internal.h | 13 +++++++++---- mm/readahead.c | 18 ++++++++++-------- 2 files changed, 19 insertions(+), 12 deletions(-) --- a/mm/internal.h~mm-readahead-pass-readahead_control-to-force_page_cache_ra +++ a/mm/internal.h @@ -49,10 +49,15 @@ void unmap_page_range(struct mmu_gather unsigned long addr, unsigned long end, struct zap_details *details); -void force_page_cache_readahead(struct address_space *, struct file *, - pgoff_t index, unsigned long nr_to_read); -void do_page_cache_ra(struct readahead_control *, - 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); +void force_page_cache_ra(struct readahead_control *, unsigned long nr); +static inline void force_page_cache_readahead(struct address_space *mapping, + struct file *file, pgoff_t index, unsigned long nr_to_read) +{ + DEFINE_READAHEAD(ractl, file, mapping, index); + force_page_cache_ra(&ractl, nr_to_read); +} /* * Submit IO for the read-ahead request in file_ra_state. --- a/mm/readahead.c~mm-readahead-pass-readahead_control-to-force_page_cache_ra +++ a/mm/readahead.c @@ -271,13 +271,13 @@ void do_page_cache_ra(struct readahead_c * Chunk the readahead into 2 megabyte units, so that we don't pin too much * memory at once. */ -void force_page_cache_readahead(struct address_space *mapping, - struct file *file, pgoff_t index, unsigned long nr_to_read) +void force_page_cache_ra(struct readahead_control *ractl, + unsigned long nr_to_read) { - DEFINE_READAHEAD(ractl, file, mapping, index); + struct address_space *mapping = ractl->mapping; struct backing_dev_info *bdi = inode_to_bdi(mapping->host); - struct file_ra_state *ra = &file->f_ra; - unsigned long max_pages; + struct file_ra_state *ra = &ractl->file->f_ra; + unsigned long max_pages, index; if (unlikely(!mapping->a_ops->readpage && !mapping->a_ops->readpages && !mapping->a_ops->readahead)) @@ -287,14 +287,16 @@ void force_page_cache_readahead(struct a * If the request exceeds the readahead window, allow the read to * be up to the optimal hardware IO size */ + index = readahead_index(ractl); max_pages = max_t(unsigned long, bdi->io_pages, ra->ra_pages); - nr_to_read = min(nr_to_read, max_pages); + nr_to_read = min_t(unsigned long, nr_to_read, max_pages); while (nr_to_read) { unsigned long this_chunk = (2 * 1024 * 1024) / PAGE_SIZE; if (this_chunk > nr_to_read) this_chunk = nr_to_read; - do_page_cache_ra(&ractl, this_chunk, 0); + ractl->_index = index; + do_page_cache_ra(ractl, this_chunk, 0); index += this_chunk; nr_to_read -= this_chunk; @@ -576,7 +578,7 @@ void page_cache_sync_readahead(struct ad /* be dumb */ if (filp && (filp->f_mode & FMODE_RANDOM)) { - force_page_cache_readahead(mapping, filp, index, req_count); + force_page_cache_ra(&ractl, req_count); return; } _