From patchwork Wed May 23 14:43:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10421507 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 254F060545 for ; Wed, 23 May 2018 14:44:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 157D726E82 for ; Wed, 23 May 2018 14:44:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0A5D8287E9; Wed, 23 May 2018 14:44:39 +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 AE04C287B4 for ; Wed, 23 May 2018 14:44:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8C5EE6B026B; Wed, 23 May 2018 10:44:28 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 823026B026C; Wed, 23 May 2018 10:44:28 -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 5DF476B026D; Wed, 23 May 2018 10:44:28 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pl0-f71.google.com (mail-pl0-f71.google.com [209.85.160.71]) by kanga.kvack.org (Postfix) with ESMTP id 03BD96B026B for ; Wed, 23 May 2018 10:44:28 -0400 (EDT) Received: by mail-pl0-f71.google.com with SMTP id x2-v6so14370488plv.0 for ; Wed, 23 May 2018 07:44:27 -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=uOaC8hBb4R3r/PFlZHXPz/5ZS6xvtqJeJilwMjzpfW0=; b=Fbfk0Fg+C6kLI4KYmwTufBeT0VLXzov1/AKXK67Rja2COyo4HdAzG/jUqf0mxuJ4ru y0O4qVyW+inHM27yQFyARIm3dw5c0i7MkgaPlwCiTxSSKnrq7id3hR+u8ZSIEJGLbQfc wh1Sav7iSzwjVfcXQF6dbYE6k/G3CwV7firi/hja36hZxjo0psB06zrOijvU/LiICgLA pOPREC38cI7LVwPDscS0RvwrYns42CkW1vxX+6Sm1FLmylGGtu5xs6VclvGqWan7QuRQ ezb6w3u7/EB/scPXqROx1F3W69ASPvotLFTWOZBcOqyRBybobG1jXkqyRRgs+kAMDOyd 9jnw== X-Gm-Message-State: ALKqPwc3wr3OOLYhBt91B4+R2pW0bF+SXoibi5alvROtmyvdOVTjGbYY /PJ/ciggDp5Q9rEDc/F4amhIHeZx5s9NE4ACXLSzx5dQGt0eY9JzSX/zpM3hjlQ7xVLoamUg1FW WjpT6+sHLfvKV/HOBTSHT9HiGpbl8F2/cC/eFqDK3kD2e50sUOAbi+COHE99elOc= X-Received: by 2002:a17:902:1c8:: with SMTP id b66-v6mr3201772plb.156.1527086667715; Wed, 23 May 2018 07:44:27 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoOjySS0BuBCWg3OmrcdBo6swXGBCAUqVxyQk7cTXEyyS9L2mTSbOQ2l9WyzjduEdzERKb6 X-Received: by 2002:a17:902:1c8:: with SMTP id b66-v6mr3201741plb.156.1527086667065; Wed, 23 May 2018 07:44:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527086667; cv=none; d=google.com; s=arc-20160816; b=LfGZrW4NUo67fvmklmwYJZDKmKWhQgkz1V2sZZjh6pIdhMPKqsbYJXpIzmHv86/ix8 j1nb0HU4dLl370O3xnWdVVj/XLKoHSSXPMO704lfy5l1ioQcMB3Q5d2ROEyM5Or+pZUI WOgIktlPkLwboxW5uyG/n+VFL3sqtWX9cOLM/4hV0qB6ghbNzO585xuXG4RMhibdG7MD B5BOoKS4iXAVhFINYNpqC05EFm1rbSuHh3nxSOnhS+sWUfJKXQpr5ElkVhAvM4O1D9f+ 860TqFuXSkyG2qOcFA0JxbzDNNXX4hONGz4mBPaVWvKAcnvBx5YsOHHmzfMu+X1nqDvt A9HQ== 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=uOaC8hBb4R3r/PFlZHXPz/5ZS6xvtqJeJilwMjzpfW0=; b=G4IqbVY9BmfH8csEpFjI12iN0CtGqA8H8x3ENjcmRbFqoswnpqjWnd3vxXfa9SHoyQ A+NImiFLdWus7Jnb1kga0QYgPDs8Xb27ynSM3aPiMAhSbrhDThZOB3KUA8geGdoTmUYY L2cb3lJfX3fFAo87CRoIq4CebMQFKwMX91I3xE54plQqFYY6z5qi07zWOPjMx57rbz+Y K8aZvEAJo6DEyFWa10f0lsk28J4J7WGN6MetWelc68QqM4ilk2/GeFFLZQDVWj52HqaG TWbI8NZijfleKKVqG2XoDoFNBJP/lUReKyDQv2Dp4zFOZHxZ905qb2e1j4Klo9Uuc0DA imqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=mWKisJVx; spf=pass (google.com: best guess record for domain of batv+df5a2477ff0fa86e9985+5386+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+df5a2477ff0fa86e9985+5386+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 l3-v6si18470034pfi.179.2018.05.23.07.44.26 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 23 May 2018 07:44:27 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of batv+df5a2477ff0fa86e9985+5386+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=mWKisJVx; spf=pass (google.com: best guess record for domain of batv+df5a2477ff0fa86e9985+5386+infradead.org+hch@bombadil.srs.infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=BATV+df5a2477ff0fa86e9985+5386+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=uOaC8hBb4R3r/PFlZHXPz/5ZS6xvtqJeJilwMjzpfW0=; b=mWKisJVxfTbdPIGsYOrWpYA2s auMTnmwG6BzuDkk9KSTwmVpyRA1eTkACYm/5Xd2tcogS3I33BSOGmu4TISGDOTgSKIBtvKB1kiuh7 SH5llxPVcIdTcbn+vMJDa2bJiv3eT/7IFI9Ly2BzOU1eLXg8zf7Dq2S/cJVmLSSGnQZ3cD0kek3IJ 0m5zP6+NpoGhi4Rpy3IHeat9jCAZ9RtxIQaSB/MPFGZmWuBkMdHr1m5TepVgGYyL7FG+uOwvVW5/J G3SaROccv/HUvCafOzn8wqkbaVGLGbLI9S24DXLY29p5keFGRoWCx9ViBa0xFGwDZAYiiydKzjzel 9oEHjjUwA==; Received: from 089144199016.atnat0008.highway.a1.net ([89.144.199.16] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fLV05-0000JH-L3; Wed, 23 May 2018 14:44:26 +0000 From: Christoph Hellwig To: linux-xfs@vger.kernel.org Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH 08/34] mm: split ->readpages calls to avoid non-contiguous pages lists Date: Wed, 23 May 2018 16:43:31 +0200 Message-Id: <20180523144357.18985-9-hch@lst.de> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180523144357.18985-1-hch@lst.de> References: <20180523144357.18985-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 --- 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)