From patchwork Thu May 31 18:06:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10441661 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 70B44602BC for ; Thu, 31 May 2018 18:06:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5E1B028F25 for ; Thu, 31 May 2018 18:06:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 533A028F92; Thu, 31 May 2018 18:06:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F308A28F25 for ; Thu, 31 May 2018 18:06:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DEBDB6B0010; Thu, 31 May 2018 14:06:38 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D9EC46B0266; Thu, 31 May 2018 14:06:38 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C42AA6B026A; Thu, 31 May 2018 14:06:38 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f198.google.com (mail-pf0-f198.google.com [209.85.192.198]) by kanga.kvack.org (Postfix) with ESMTP id 7EF4C6B0010 for ; Thu, 31 May 2018 14:06:38 -0400 (EDT) Received: by mail-pf0-f198.google.com with SMTP id c4-v6so13045272pfg.22 for ; Thu, 31 May 2018 11:06:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=2bufmFX8k+ljxXmZzcWhxz19vmI5+zyCU3VeVyjsOqg=; b=nZFQQWD96PDJ6oTiaEHDJ11oWMXZU4DeAdI8tc0ukCFVLmxA+gkKoCpaDcJQfO8ydQ wfgsG86eG7MNwYTnWrpyq6sq8+ls6VLG7591sSfoNOGd/jjtCdOvERldKNWF3s2nnIxJ JEY8aazE1W6NzIvEaU5r4V4wFziVdb9XIVeUgFTOdEbf8w47Bl4o4/9V+LFdUecws5HY awjGnz7/FNS/fcA974UpfXy+SombQiWYv4BQGXFOvkxhCChGH1k1RJDjnU7cXHig4S19 kAWmC6IUBU+xb/DHYeILoN/dnhF3GQT7qtZhQQtruFflcZEG0RwLPg1/LHzlBca1tn62 9kCA== X-Gm-Message-State: ALKqPwfWj1m8f/KiFsP5d3YBKpPsFw4FOc8BwTHblkD2xFt0j/9zTTGT QLzVms89hHwoGV5UZgbTWZKbd3KkqnnR+IguYJ6P+hxLvlAw2D+abj09pJY9ILwu4ByX7nkVX+6 YJq06GyEF/f/FeQrpa9BDOMa/dAH7diEZoq82uywllN6ivvgEx+4t0J1jbG4sbFU= X-Received: by 2002:a63:7804:: with SMTP id t4-v6mr6474886pgc.323.1527789998188; Thu, 31 May 2018 11:06:38 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ9yvSMKgwckOSdu/os1q5PoztjGU9VH0ZXZmlcF3Cl/xNbyyj6gwfC7knmgn4g23Nd8ecR X-Received: by 2002:a63:7804:: with SMTP id t4-v6mr6474831pgc.323.1527789996819; Thu, 31 May 2018 11:06:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527789996; cv=none; d=google.com; s=arc-20160816; b=uieCMzkwMiGfsSihWyQUw0CizB7NFqn3s19T2uTiNYfRoP1IWA0vecgPhDDZobTJUa sKDi/p2e2JGlIunPkbjgdXUQrIt0CPBs9GAYKtD13wJfF7L5Ihf8ICvykUBPqMHDDzQv 21DYxntg/iVHFDxlMp5ojptv9En89Kse56nQbzeeXsmFk1jti5YVI/YPjadhfj/SjFVF DRd6Na0oLR1dtao+8R9n5mIQuCCmcygbPIZSGldZwbD1KPMWHkLxO4PQRgQmb7qGAhfk HhLXlfFyTqsicRPaMUv/a+P56v3QrDZbVWAPDjFCJmARTtXaMBmiU8hZ6ipfB65htSCT YJOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=2bufmFX8k+ljxXmZzcWhxz19vmI5+zyCU3VeVyjsOqg=; b=u8kU/+SYGpDojSsAYgjNVgMXWZ13df4zrCDIW9pGK0bUJKREGoTk2bTYP3WSm8mMAx 5F7qBckbwaDjWaW5yWeHdLgBagQ7LcT1vHlkIQ3QWa65oYOGHJMI77gQI3HfkizwrIt6 z+B6kiUQO5Mn7jMbyKvXopYQwnoreyjaB6CAhqaUqwVrkCEUbvewpuRTvd3T/jMctxxX dpY63xcyR1WyDEnRGVEa92qxbFzVmebKQNvCI8IxqURw3r8JLynUwUOd0ZozIzwtJEjj yCGQRLFMGexGa1S5+BH998X8ihZ+15P4fAFQjPVwN/dORec86VwU+IX7i/j7jSDNuBTo H2Rg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=uBMspIy5; spf=pass (google.com: best guess record for domain of batv+67dfbb8f664e29ec4bbc+5394+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+67dfbb8f664e29ec4bbc+5394+infradead.org+hch@bombadil.srs.infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id c12-v6si38961387plr.467.2018.05.31.11.06.36 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 31 May 2018 11:06:36 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+67dfbb8f664e29ec4bbc+5394+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=uBMspIy5; spf=pass (google.com: best guess record for domain of batv+67dfbb8f664e29ec4bbc+5394+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+67dfbb8f664e29ec4bbc+5394+infradead.org+hch@bombadil.srs.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=2bufmFX8k+ljxXmZzcWhxz19vmI5+zyCU3VeVyjsOqg=; b=uBMspIy5FYsTLik346hPc7GlU eWVxrRhwFVJzkAyGdz6fqfKtmETZuzsiMiXjP2EfSZlKMlIy/dYU91rTR+FUdH+D1rnUV4r6QwQgU EoUzqr/MervCaOOH2p1EdzVMXpci08gcXhMSerm8dKdJx4Z8fYAtAZr9ejNzCql5dZ+etDb4XGmwI pF3HtChzpRpfxx1xLhfC0Sxq956D8iutZDEHvKvHEvTSHXwZ6zwJ+PMVOuGQJ45XY/mNgDKSXWwXc 4pHx49o8paonDkUTAoM5R2mhrpUPUzajXgJziA+tuJlRSgUNXwmIKoccbNhFDXSuhQFbUdbuEprQR 3M1X1QvCA==; Received: from 213-225-38-123.nat.highway.a1.net ([213.225.38.123] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fORy2-0003GC-UP; Thu, 31 May 2018 18:06:31 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 04/13] mm: split ->readpages calls to avoid non-contiguous pages lists Date: Thu, 31 May 2018 20:06:05 +0200 Message-Id: <20180531180614.21506-5-hch@lst.de> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180531180614.21506-1-hch@lst.de> References: <20180531180614.21506-1-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html 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: X-Virus-Scanned: ClamAV using ClamSMTP That way file systems don't have to go spotting for non-contiguous pages and work around them. It also kicks off I/O earlier, allowing it to finish earlier and reduce latency. Signed-off-by: Christoph Hellwig Reviewed-by: Dave Chinner Reviewed-by: Darrick J. Wong --- mm/readahead.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/mm/readahead.c b/mm/readahead.c index fa4d4b767130..e273f0de3376 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -140,8 +140,8 @@ static int read_pages(struct address_space *mapping, struct file *filp, } /* - * __do_page_cache_readahead() actually reads a chunk of disk. It allocates all - * the pages first, then submits them all for I/O. This avoids the very bad + * __do_page_cache_readahead() 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 writeback. * We really don't want to intermingle reads and writes like that. * @@ -177,8 +177,18 @@ unsigned int __do_page_cache_readahead(struct address_space *mapping, rcu_read_lock(); page = radix_tree_lookup(&mapping->i_pages, page_offset); rcu_read_unlock(); - if (page && !radix_tree_exceptional_entry(page)) + if (page && !radix_tree_exceptional_entry(page)) { + /* + * Page already present? Kick off the current batch of + * contiguous pages before continuing with the next + * batch. + */ + if (nr_pages) + read_pages(mapping, filp, &page_pool, nr_pages, + gfp_mask); + nr_pages = 0; continue; + } page = __page_cache_alloc(gfp_mask); if (!page)