From patchwork Wed Mar 13 17:02:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Pankaj Raghav (Samsung)" X-Patchwork-Id: 13591601 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5F54FC54E66 for ; Wed, 13 Mar 2024 17:03:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EA6E480046; Wed, 13 Mar 2024 13:03:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E57BD940010; Wed, 13 Mar 2024 13:03:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CF80F80046; Wed, 13 Mar 2024 13:03:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id BD8CF940010 for ; Wed, 13 Mar 2024 13:03:25 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 9113E140432 for ; Wed, 13 Mar 2024 17:03:25 +0000 (UTC) X-FDA: 81892636770.19.56B7470 Received: from mout-p-201.mailbox.org (mout-p-201.mailbox.org [80.241.56.171]) by imf03.hostedemail.com (Postfix) with ESMTP id EF64C2003B for ; Wed, 13 Mar 2024 17:03:19 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=iLuEZtwu; spf=pass (imf03.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.171 as permitted sender) smtp.mailfrom=me@pankajraghav.com; dmarc=pass (policy=quarantine) header.from=pankajraghav.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1710349400; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=LlktHRrCotj7h+dmYranbD+6rKP22De/aSKpvLU15xI=; b=XpLIHIPJy4YsAxtlTz10vI17OjBUlaqd0j1q36c/RD2+B5Ll7mmwJEZgtQM1aPHIZEaT6m mq2Z5TjGFFkVrHsxFpHeskDn1z18WPNvbqUuYlgeQEsoIF/4oImznatk5wTFx7ZsbOieSD wASfIImaI/05S/XOUDTD3DbSV4lM4GA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1710349400; a=rsa-sha256; cv=none; b=JMjPhan/NihQyqHX8il4FBr0a8bbWrRZ+eD44JmI3RtIzn4KelFxKD9Nt0T5yGCW+3D1bb pXqZD6Xk5dO7tO8p3mPVS0Hef9SBt/l/eelnsgJJbhC7h7cM3Sk3/Hoq/iycRs5crkCBos uAwuDclE6iFgJ4dTfysTX6z/xmCgW3o= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=pankajraghav.com header.s=MBO0001 header.b=iLuEZtwu; spf=pass (imf03.hostedemail.com: domain of me@pankajraghav.com designates 80.241.56.171 as permitted sender) smtp.mailfrom=me@pankajraghav.com; dmarc=pass (policy=quarantine) header.from=pankajraghav.com Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:b231:465::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-201.mailbox.org (Postfix) with ESMTPS id 4TvxfX4xPNz9sv2; Wed, 13 Mar 2024 18:03:16 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pankajraghav.com; s=MBO0001; t=1710349396; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LlktHRrCotj7h+dmYranbD+6rKP22De/aSKpvLU15xI=; b=iLuEZtwukGR8j/wP2yTR5lqu8w1dn1Om8H+h1Jrn/yb2Op1vTScowf81qXdWfFwhx03M/k lQ/ljugRNgFKv69Zpc6GDcMiFT9VCHupZ6ValiBdiFfuWsmov6aNUmcQiDMialZfyaybui 8T59W5m15KIJ0u/Ty4jAsUYT9GrTgDUpkTktfRWjiysbyXYSygMpuhFGLRtvAF3XUnEXNb PjoKw2atBz6K73ROKH0xNo9tEt25+B4heTtlXX02+5MGRYL4KHK5fIQB8ASFf3iPeRzqLB qWHeD/50YVeH/RmWQXjuSiVGmXs3wQCjp0KP/PxP8pUf+qiTnxODf+IHoVquZQ== From: "Pankaj Raghav (Samsung)" To: willy@infradead.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Cc: gost.dev@samsung.com, chandan.babu@oracle.com, hare@suse.de, mcgrof@kernel.org, djwong@kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, david@fromorbit.com, akpm@linux-foundation.org, Pankaj Raghav Subject: [PATCH v3 04/11] readahead: rework loop in page_cache_ra_unbounded() Date: Wed, 13 Mar 2024 18:02:46 +0100 Message-ID: <20240313170253.2324812-5-kernel@pankajraghav.com> In-Reply-To: <20240313170253.2324812-1-kernel@pankajraghav.com> References: <20240313170253.2324812-1-kernel@pankajraghav.com> MIME-Version: 1.0 X-Stat-Signature: bgujofrdz41x11cp3nwjjweo8esq7kzm X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: EF64C2003B X-Rspam-User: X-HE-Tag: 1710349399-262072 X-HE-Meta: U2FsdGVkX1+83YSXOH3jlf/yfRCYwkwUpOGXcEsP/eSxRGEAmVK9qoytH0AmeHUWQVirV7rJi7CGI3O29Ie8mWIwVr5efytYQJwKEeHVGQ6Jovc3JYBWTnCdSoEwEv44a7m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shhECdx7IkDPulTbxAAEGSkR+aX+ETNQ821gVmrwp197MrcFTuf8p6fqlQzKJL6q0DVN8WogeTROFpYIVR6AcgGmJfE0aC5V+dniMyZIbi3cncjly+Aqs0uwt3fEyMgi5bX39N/8mSlKNiqJVFAQdr07tpqDvA+Pie2ob4/fxizbEyPfE0vOQIuSGdf0lOqP2eZyWYz9tDpmNrtACm3Q3xmzWTdqi6GtXYAJP5zR2CVK1q1a4O1LgjRpL9NNgoiwG4Z95HCC00ot8WYYqxZ3y6bXcUd39uVmW99x7nuF3OZF7Us+eV238JT6oergynqPnjxdcQup6r7IfzJhG8/5UNTSVEJZxoqesT+jflcK6KSrb3fMa+A== 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: List-Subscribe: List-Unsubscribe: From: Hannes Reinecke Rework the loop in page_cache_ra_unbounded() to advance with the number of pages in a folio instead of just one page at a time. Signed-off-by: Hannes Reinecke Co-developed-by: Pankaj Raghav Signed-off-by: Pankaj Raghav Acked-by: Darrick J. Wong --- mm/readahead.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/mm/readahead.c b/mm/readahead.c index 369c70e2be42..37b938f4b54f 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -208,7 +208,7 @@ void page_cache_ra_unbounded(struct readahead_control *ractl, struct address_space *mapping = ractl->mapping; unsigned long index = readahead_index(ractl); gfp_t gfp_mask = readahead_gfp_mask(mapping); - unsigned long i; + unsigned long i = 0; /* * Partway through the readahead operation, we will have added @@ -226,7 +226,7 @@ void page_cache_ra_unbounded(struct readahead_control *ractl, /* * Preallocate as many pages as we will need. */ - for (i = 0; i < nr_to_read; i++) { + while (i < nr_to_read) { struct folio *folio = xa_load(&mapping->i_pages, index + i); if (folio && !xa_is_value(folio)) { @@ -239,8 +239,8 @@ void page_cache_ra_unbounded(struct readahead_control *ractl, * not worth getting one just for that. */ read_pages(ractl); - ractl->_index++; - i = ractl->_index + ractl->_nr_pages - index - 1; + ractl->_index += folio_nr_pages(folio); + i = ractl->_index + ractl->_nr_pages - index; continue; } @@ -252,13 +252,14 @@ void page_cache_ra_unbounded(struct readahead_control *ractl, folio_put(folio); read_pages(ractl); ractl->_index++; - i = ractl->_index + ractl->_nr_pages - index - 1; + i = ractl->_index + ractl->_nr_pages - index; continue; } if (i == nr_to_read - lookahead_size) folio_set_readahead(folio); ractl->_workingset |= folio_test_workingset(folio); - ractl->_nr_pages++; + ractl->_nr_pages += folio_nr_pages(folio); + i += folio_nr_pages(folio); } /*