From patchwork Fri Nov 6 12:30:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 11887065 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F0EFF1130 for ; Fri, 6 Nov 2020 12:30:48 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 962472071A for ; Fri, 6 Nov 2020 12:30:48 +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="QGgesoFq" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 962472071A 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 4307A6B005D; Fri, 6 Nov 2020 07:30:47 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 3B6F66B0068; Fri, 6 Nov 2020 07:30:47 -0500 (EST) 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 2CDCD6B006C; Fri, 6 Nov 2020 07:30:47 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0007.hostedemail.com [216.40.44.7]) by kanga.kvack.org (Postfix) with ESMTP id 0040E6B005D for ; Fri, 6 Nov 2020 07:30:46 -0500 (EST) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id A0DE2180AD815 for ; Fri, 6 Nov 2020 12:30:46 +0000 (UTC) X-FDA: 77453927292.15.grape83_6016a4e272d2 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin15.hostedemail.com (Postfix) with ESMTP id 7A2601814B0C8 for ; Fri, 6 Nov 2020 12:30:46 +0000 (UTC) X-Spam-Summary: 1,0,0,32e66db992df9d71,d41d8cd98f00b204,willy@infradead.org,,RULES_HIT:41:355:379:541:800:960:973:988:989:1260:1311:1314:1345:1359:1515:1534:1542:1711:1730:1747:1777:1792:2393:2559:2562:3138:3139:3140:3141:3142:3353:3868:5007:6261:6653:7875:9036:10004:11026:11658:11914:12043:12048:12296:12297:12555:12895:13894:14181:14394:14721:21080:21212:21451:21627:21987:21990:30054:30069,0,RBL:90.155.50.34:@infradead.org:.lbl8.mailshell.net-62.8.15.100 64.201.201.201;04ygpp4ffpe61auuq3ara3fgfr8hoypppd4ku8csq738pdqgchm8749jf69ryi3.b3m1tqm8osqe114ig9wyx3nzmpy5fb3txtmmwfyd3tcwqkx61bbczfo1bb8b7su.o-lbl8.mailshell.net-223.238.255.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:69,LUA_SUMMARY:none X-HE-Tag: grape83_6016a4e272d2 X-Filterd-Recvd-Size: 3880 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf07.hostedemail.com (Postfix) with ESMTP for ; Fri, 6 Nov 2020 12:30:45 +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=FYfTJc/cRnp3dh2kVQ7v0u0iDrX6gANg53dGJ+BqfQ0=; b=QGgesoFqkX35kbIS61E/vS9DMw nrOfKvHPvDPlMupVmUbr30VyOixlbjuISXTjvoEvLDo9kHtfc3Ry8ZF2v8CAXlZHnDcWrHnA+PMkt ZeuGGhVZaC4/F9vl8iF89cbcXzs1oSYN4N5FUQOdoyIWOPEsyeEtQ19eGzHFQERjW0Y2AgiLoaL13 uF461OmOzcn6MCRt02ce7mHnbZgW8gHhUaLBMgxHE+9HveyzYwOXl0/OPuVwTtJRZIaC+iOJ/aTEP Mgf0UtFim0JjZBJInTLICZK9Yt+FObqAK3ns2T/KM+4C3YykoHjXs66Ggw4gCQbNQyYy0EvkUNz61 lkHyWdsQ==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kb0t8-0007Qr-Oh; Fri, 06 Nov 2020 12:30:42 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, hch@lst.de, kent.overstreet@gmail.com Cc: "Matthew Wilcox (Oracle)" Subject: [PATCH 4/4] mm/filemap: Use a dynamically allocated pagevec in filemap_read Date: Fri, 6 Nov 2020 12:30:40 +0000 Message-Id: <20201106123040.28451-4-willy@infradead.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201106123040.28451-1-willy@infradead.org> References: <20201106080815.GC31585@lst.de> <20201106123040.28451-1-willy@infradead.org> MIME-Version: 1.0 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: Restore Kent's optimisation for I/O sizes between 64kB and 1MB. Signed-off-by: Matthew Wilcox (Oracle) --- mm/filemap.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index f41de0759e86..2b4d8ed241bd 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2427,7 +2427,7 @@ ssize_t filemap_read(struct kiocb *iocb, struct iov_iter *iter, struct file_ra_state *ra = &filp->f_ra; struct address_space *mapping = filp->f_mapping; struct inode *inode = mapping->host; - struct pagevec pvec; + struct pagevec pvec_stack, *pvec = NULL; int i, error = 0; bool writably_mapped; loff_t isize, end_offset; @@ -2436,6 +2436,10 @@ ssize_t filemap_read(struct kiocb *iocb, struct iov_iter *iter, return 0; iov_iter_truncate(iter, inode->i_sb->s_maxbytes); + if (iter->count / PAGE_SIZE > PAGEVEC_SIZE) + pvec = pagevec_alloc(iter->count / PAGE_SIZE + 1, GFP_KERNEL); + if (!pvec) + pvec = &pvec_stack; do { cond_resched(); @@ -2447,7 +2451,7 @@ ssize_t filemap_read(struct kiocb *iocb, struct iov_iter *iter, if ((iocb->ki_flags & IOCB_WAITQ) && already_read) iocb->ki_flags |= IOCB_NOWAIT; - error = filemap_get_pages(iocb, iter, &pvec); + error = filemap_get_pages(iocb, iter, pvec); if (error < 0) break; @@ -2476,10 +2480,10 @@ ssize_t filemap_read(struct kiocb *iocb, struct iov_iter *iter, */ if (iocb->ki_pos >> PAGE_SHIFT != ra->prev_pos >> PAGE_SHIFT) - mark_page_accessed(pvec.pages[0]); + mark_page_accessed(pvec->pages[0]); - for (i = 0; i < pagevec_count(&pvec); i++) { - struct page *page = pvec.pages[i]; + for (i = 0; i < pagevec_count(pvec); i++) { + struct page *page = pvec->pages[i]; size_t page_size = thp_size(page); size_t offset = iocb->ki_pos & (page_size - 1); size_t bytes = min_t(loff_t, end_offset - iocb->ki_pos, @@ -2514,7 +2518,7 @@ ssize_t filemap_read(struct kiocb *iocb, struct iov_iter *iter, } } put_pages: - pagevec_release(&pvec); + pagevec_release(pvec); } while (iov_iter_count(iter) && iocb->ki_pos < isize && !error); file_accessed(filp);