From mboxrd@z Thu Jan 1 00:00:00 1970 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=-12.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 D9745C2D0A3 for ; Tue, 10 Nov 2020 03:38:31 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 2615920829 for ; Tue, 10 Nov 2020 03:37:28 +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="Hl/PQO2F" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 2615920829 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 ECAE66B0072; Mon, 9 Nov 2020 22:37:14 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E02706B0075; Mon, 9 Nov 2020 22:37:14 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BD9656B0072; Mon, 9 Nov 2020 22:37:14 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0248.hostedemail.com [216.40.44.248]) by kanga.kvack.org (Postfix) with ESMTP id 6FD0B6B0074 for ; Mon, 9 Nov 2020 22:37:14 -0500 (EST) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 0F45B180AD811 for ; Tue, 10 Nov 2020 03:37:14 +0000 (UTC) X-FDA: 77467097988.16.pear64_2917b39272f1 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin16.hostedemail.com (Postfix) with ESMTP id DD066100E690C for ; Tue, 10 Nov 2020 03:37:13 +0000 (UTC) X-HE-Tag: pear64_2917b39272f1 X-Filterd-Recvd-Size: 3304 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf16.hostedemail.com (Postfix) with ESMTP for ; Tue, 10 Nov 2020 03:37:11 +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=IEtkIPQsQeLEcKSFUu4N+/Cun43SD1V6eMts9/zmGx4=; b=Hl/PQO2FwemV3wj9gFckd/k1bb QaKrhl83gqTYX0WnUJ9jf3dEN5UboqfjNIojp5j8tMj+XiMBYPQSPtTJzXQyS5kIrYiVE7ieu0j3K h8EgrvXYmFbz7ctdNQsKrsJ/BzY/2d+k/iEkbOKebEedPcIkSF5ehwUepFxDsV+QqcuXEDNcaFyEL aPg69wlCihBhyGTQ55rRbVhq7rG9OqZMcnIMh9/G6wsIRRFWbkzHNQfJj9yujQV3zlwxwrSYv6URg x/GvQ8i6CYUYo9i06rG7rrMP9uh+agpPr4yFIT4yFeP97ITAyOmV/5BuT54lCYS3W4KQqpub1C4bG fBK9Jolw==; Received: from willy by casper.infradead.org with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1kcKSv-00064X-Q6; Tue, 10 Nov 2020 03:37:05 +0000 From: "Matthew Wilcox (Oracle)" To: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org Cc: "Matthew Wilcox (Oracle)" , hch@lst.de, kent.overstreet@gmail.com Subject: [PATCH v3 02/18] mm/filemap: Remove dynamically allocated array from filemap_read Date: Tue, 10 Nov 2020 03:36:47 +0000 Message-Id: <20201110033703.23261-3-willy@infradead.org> X-Mailer: git-send-email 2.21.3 In-Reply-To: <20201110033703.23261-1-willy@infradead.org> References: <20201110033703.23261-1-willy@infradead.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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: Increasing the batch size runs into diminishing returns. It's probably better to make, eg, three calls to filemap_get_pages() than it is to call into kmalloc(). Signed-off-by: Matthew Wilcox (Oracle) --- mm/filemap.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 23e3781b3aef..bb1c42d0223c 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -2429,8 +2429,8 @@ ssize_t generic_file_buffered_read(struct kiocb *io= cb, struct file_ra_state *ra =3D &filp->f_ra; struct address_space *mapping =3D filp->f_mapping; struct inode *inode =3D mapping->host; - struct page *pages_onstack[PAGEVEC_SIZE], **pages =3D NULL; - unsigned int nr_pages =3D min_t(unsigned int, 512, + struct page *pages[PAGEVEC_SIZE]; + unsigned int nr_pages =3D min_t(unsigned int, PAGEVEC_SIZE, ((iocb->ki_pos + iter->count + PAGE_SIZE - 1) >> PAGE_SHIFT) - (iocb->ki_pos >> PAGE_SHIFT)); int i, pg_nr, error =3D 0; @@ -2441,14 +2441,6 @@ ssize_t generic_file_buffered_read(struct kiocb *i= ocb, return 0; iov_iter_truncate(iter, inode->i_sb->s_maxbytes); =20 - if (nr_pages > ARRAY_SIZE(pages_onstack)) - pages =3D kmalloc_array(nr_pages, sizeof(void *), GFP_KERNEL); - - if (!pages) { - pages =3D pages_onstack; - nr_pages =3D min_t(unsigned int, nr_pages, ARRAY_SIZE(pages_onstack)); - } - do { cond_resched(); =20 @@ -2533,9 +2525,6 @@ ssize_t generic_file_buffered_read(struct kiocb *io= cb, =20 file_accessed(filp); =20 - if (pages !=3D pages_onstack) - kfree(pages); - return written ? written : error; } EXPORT_SYMBOL_GPL(generic_file_buffered_read); --=20 2.28.0