From patchwork Wed May 30 09:58:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10438137 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 5AF80603D7 for ; Wed, 30 May 2018 09:58:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C7EB281D2 for ; Wed, 30 May 2018 09:58:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 413032818E; Wed, 30 May 2018 09:58:38 +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 DD844281D2 for ; Wed, 30 May 2018 09:58:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D55356B0269; Wed, 30 May 2018 05:58:35 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id D02836B026A; Wed, 30 May 2018 05:58:35 -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 BF2C66B026B; Wed, 30 May 2018 05:58:35 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg0-f70.google.com (mail-pg0-f70.google.com [74.125.83.70]) by kanga.kvack.org (Postfix) with ESMTP id 7E1486B0269 for ; Wed, 30 May 2018 05:58:35 -0400 (EDT) Received: by mail-pg0-f70.google.com with SMTP id e1-v6so1885094pgp.20 for ; Wed, 30 May 2018 02:58:35 -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=NSp1zE7kUXSRWhvouw0Zy1M97rZHkGMekfVGV6bNo/U=; b=HKsEoA/H7YyiVE6y4ih9Hwftjslesn0KaFodsUyaA5ZVqGosy817ldkbg+rlooaBEx 8xhs7UcZ0omQ3t+B1+H9GNBlyrenzW4/PS9IIre0AzEiC3Cc/dVkkKIeT1liD5XcGfwg Z0wu5n4vhFd1JTe57/T4ojc41wOyGajOHROcJXfkdCm2H3sdTnPMGGLJmpH9d8AamdUV Tk8VORJOyMKkGQpwtm1tsHqd2kUwE4IRasND07AjZdyr2d9uJuksmoPyROs9FjkedNg9 GltEPLzrxbOhhBBMIQS7vkn+Rst5vrLKgLlAP5LM49SKBuY9ZA+bhnoPrneTnko3SBzP HThw== X-Gm-Message-State: ALKqPwdb4drPko19kuIbkam03TC6ORT07CLCvRj//B1aLtQ4m/5XX2h+ /DK8mektTrUe7YBJZmBIcivCX/7o108zQgMWyllJqI0Jh9g3vktie9wvYiHnZuDjS/kLa9um7Z/ E2gtaqZUnE7Ao/uuPviJ1wy0hTQ1PDDmAkhcS5pILMrKWImvdyx+UwJCWniylB5o= X-Received: by 2002:a65:6592:: with SMTP id u18-v6mr1681273pgv.366.1527674315180; Wed, 30 May 2018 02:58:35 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKIyJTJlHvq2Qr9wICsE2x9qXLtBOKgAGS16fFDUGIBy4pBYDSBXf+QxclVbQ4LNvFef97Y X-Received: by 2002:a65:6592:: with SMTP id u18-v6mr1681252pgv.366.1527674314440; Wed, 30 May 2018 02:58:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527674314; cv=none; d=google.com; s=arc-20160816; b=yuotcBWbIMXitm+A1XUVOH/Vmf3rO70FX2ITt6vRY4MU8sj9xBa4wiDcKrpS0j9L1r f62oue1sYocA9eNfyq5lk03H4wkEPaUKca3GN6JKkQrRAuAlgPIaByCrHphVmFnOW54a Rf2dzGe64DkjaBBgT0+f6o/7irbRHttfAOuC9dpEQuv9Wutt5bfo4kDPHZOcWRdGroR6 fKZZ7DxZHRvYRc3PEI1ojI5OkP9bhwYT3yslEqmqhmu0xPV3oXn9yeujCadLd3ZQlpj3 csqa9iKSdjq1Ic5mi+M2boizTVtVTqFCapfRJEJSCcp0u1QYvJPK5RrSjbNFtRM+c4eC CH+Q== 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=NSp1zE7kUXSRWhvouw0Zy1M97rZHkGMekfVGV6bNo/U=; b=nfNq1OwrDNTpM5lGqhFmbA69ZG3O+v5lzLDq6g8bX9sCrQhloCfrX6hJNhjROsz7FJ yIF0O4vLlPzeXnoRJoduOqaEXE/p2AIO+g8UVeIZhar1X/JQ2rRElXRz/WA5H3qL6wod 0LsfjULCsVCkyCgfbO+7Z7uFMbgF2FujvM7GfyFoeQYQR+NzY+j3OmIPCXelNFMy3mvH DdpunRX/ZVCVOggudqsoFIU9I1ttgHKecrplbs8ArF+OaTsN93PTNhV7pvZjvzNAKP6L LHLUVEsxhdMnyDJV46Rnxat2Lba83/NXLu4w2Im+tg50nMpqL09Xj7Dc3Y2q+WIhMK8h h+cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=EHfkyeiu; spf=pass (google.com: best guess record for domain of batv+1f4557cc97fec8e307c5+5393+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+1f4557cc97fec8e307c5+5393+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 o9-v6si27215048pgp.508.2018.05.30.02.58.34 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 30 May 2018 02:58:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+1f4557cc97fec8e307c5+5393+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=EHfkyeiu; spf=pass (google.com: best guess record for domain of batv+1f4557cc97fec8e307c5+5393+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+1f4557cc97fec8e307c5+5393+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=NSp1zE7kUXSRWhvouw0Zy1M97rZHkGMekfVGV6bNo/U=; b=EHfkyeiuw/mRKNd2jgmzWKWNl nXs8LYYdfWy9Cjjyxewl5iBSUu4e+Bb/wb/GLVbJerVIJ7CR4U5RyE87Cxbj5efLWfhphMd9y4TgB 7//2slkynHc5YjJp8ljPK39D1Nd2eRK1/QVgc6kebBMoFO+QOb0g9Zn99rLiCXnlhj3X37WKM3lHi AbXAAiNjJo2RhuvFoxMnYYZthGwz/1QABfid8jO+2Rq+fIfwbHd2i3fhfnip70MGj6sTsNUKwBazf /zmO65HUr+m7vHqmIFJXqmiW0FRn50BYv4/uM7BNnk8JjcEoSTmKXFUocNTmiNMhUiJbxgFhe+s7p CokzMtjiQ==; 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 1fNxsH-0006UF-6G; Wed, 30 May 2018 09:58:33 +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: Wed, 30 May 2018 11:58:04 +0200 Message-Id: <20180530095813.31245-5-hch@lst.de> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180530095813.31245-1-hch@lst.de> References: <20180530095813.31245-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: Darrick J. Wong Reviewed-by: Dave Chinner --- 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)