From patchwork Tue Jun 25 10:18:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13710839 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 6800CC2BBCA for ; Tue, 25 Jun 2024 10:19:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1B81C6B01F6; Tue, 25 Jun 2024 06:19:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 086E36B01F3; Tue, 25 Jun 2024 06:19:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9F9D36B02F0; Tue, 25 Jun 2024 06:19:15 -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 A13A26B02F1 for ; Tue, 25 Jun 2024 06:19:14 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 53D79121833 for ; Tue, 25 Jun 2024 10:19:14 +0000 (UTC) X-FDA: 82269013428.12.F3ACD09 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf09.hostedemail.com (Postfix) with ESMTP id 0162814001A for ; Tue, 25 Jun 2024 10:19:11 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=ikWfKa8b; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=IeaEZuPh; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=ikWfKa8b; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=IeaEZuPh; spf=pass (imf09.hostedemail.com: domain of jack@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719310745; 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=1PGCsNEAZb8feT1eGXK7ybre2/GF8QGIQq2PzvMqbP8=; b=s+TszfoKp36v9xXi+bemv3gTHryW9mc6rxLzJUk0/9M9gJz0fVq41yQfIaxtNciIWKibxK YBSc1dEGB9HLgNb8pEoH0S6/ApN6PygOdenAQ9P1XD/s108oNWLeoM7kWCsOo/QPCshd4s OBHJfQRbF+ywMunmcBfBUkrhH3+YeZc= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=ikWfKa8b; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=IeaEZuPh; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=ikWfKa8b; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=IeaEZuPh; spf=pass (imf09.hostedemail.com: domain of jack@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719310745; a=rsa-sha256; cv=none; b=1qVKQaI9rYQxAG+m5cQS8BYoYwY6ndviYZ3a3LXHbaXnLP5LJVQac1WZ/idSlWJ9sC0W1e eUAHO50Bd4KKQ0PqjcYF5Y5EyEtWo7iWu2odrJpLr9s5s70afVE3uH9BSvwLube248EjfI f9YT6eFun84hVmVYNC9WzChYLQcwZyQ= Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (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 smtp-out1.suse.de (Postfix) with ESMTPS id 3311F21972; Tue, 25 Jun 2024 10:19:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1719310750; h=from:from:reply-to: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=1PGCsNEAZb8feT1eGXK7ybre2/GF8QGIQq2PzvMqbP8=; b=ikWfKa8bne81WF9vVAJtHa0QPnc1LIizuvh4aPfFB1lSYHk1eS3SB1KHwnakTzv1X6jp1C S2ICBHjmdOtSSEnxQQp35KJPd3l2UgR/UggflD6wt2JWCAuvUXXPCguRd3MRAxealFQxRe RS0u8q0h0dJQrVXJEIwScpfdqBj/W5Q= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1719310750; h=from:from:reply-to: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=1PGCsNEAZb8feT1eGXK7ybre2/GF8QGIQq2PzvMqbP8=; b=IeaEZuPhSoqvbgTLHtMmztzmcS3MeIP9a99DQKV3gqPWf4qQhqR2jx3FMgWcrpu5l0va4w ncOskFr87u1gLuCg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1719310750; h=from:from:reply-to: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=1PGCsNEAZb8feT1eGXK7ybre2/GF8QGIQq2PzvMqbP8=; b=ikWfKa8bne81WF9vVAJtHa0QPnc1LIizuvh4aPfFB1lSYHk1eS3SB1KHwnakTzv1X6jp1C S2ICBHjmdOtSSEnxQQp35KJPd3l2UgR/UggflD6wt2JWCAuvUXXPCguRd3MRAxealFQxRe RS0u8q0h0dJQrVXJEIwScpfdqBj/W5Q= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1719310750; h=from:from:reply-to: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=1PGCsNEAZb8feT1eGXK7ybre2/GF8QGIQq2PzvMqbP8=; b=IeaEZuPhSoqvbgTLHtMmztzmcS3MeIP9a99DQKV3gqPWf4qQhqR2jx3FMgWcrpu5l0va4w ncOskFr87u1gLuCg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.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 imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 25F0213A9A; Tue, 25 Jun 2024 10:19:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id hE5/CZ6ZemZpWQAAD6G6ig (envelope-from ); Tue, 25 Jun 2024 10:19:10 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id C5A64A087B; Tue, 25 Jun 2024 12:19:09 +0200 (CEST) From: Jan Kara To: Cc: Andrew Morton , Matthew Wilcox , , Jan Kara Subject: [PATCH 01/10] readahead: Make sure sync readahead reads needed page Date: Tue, 25 Jun 2024 12:18:51 +0200 Message-Id: <20240625101909.12234-1-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240625100859.15507-1-jack@suse.cz> References: <20240625100859.15507-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3131; i=jack@suse.cz; h=from:subject; bh=2BByd5Qz40KJgLPQa4CRJHADLoyluDt7OXYy5Vc5KU8=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBmepmMsFecTDSrJB7mzuQeFHsMRnTlyeSDIRIpwYXj JqeNh6CJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCZnqZjAAKCRCcnaoHP2RA2fsnCA ChMH7hiJSHQTZszWhes0ZPL8tX8rXTRFqaWRv2zKdXrp/hdP1LP+k/C0c5FgLJWPBkB4t7ZsUBEOTi hdoHqmPCCc5PFg8glpeNB1rjxr9Ax0HIh5ds1oYLunJaAliyqGz4ChBZzRMPIksKDOnLcUiWdXUbOK rLDS8t4ulwXAyV24MxlhhkWN6I/L9lH/TN5MdcBMVcTwpXKz6pfUCbRQToHmOQhRw1UBWe8mxov+Mr jyIgX5xWV7/KuX/HyL/BtRkpVBEcc5rd/8uTi267fSnRLSyd/A208PjJpoTYhn5mDGjyaWKazOn/Rk Tw25TYpOrregPCejiqhHkWyp2+9+Md X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C X-Rspamd-Action: no action X-Rspam-User: X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 0162814001A X-Stat-Signature: zoxkji7ymxmjok6o16dt7fctntbmdfw5 X-HE-Tag: 1719310751-436326 X-HE-Meta: U2FsdGVkX1/a+7cqCvz77JgDSoNnAi2oeTc5VHw0FhaiqlDt0APf6MkEY8hw6SFwnMoTTkH4n2ktXMjIU9DREdckxfr09DTavR4TG6RhIPbiQpxTj+2Q9slF5+5cv8SDGGyO0SNqrFftFO5D8S14wQg4fwWw+UAOq70WdDcDv98ibTtYPiky5c4XWmkEDrBkY4IeXnJDBDWS75TKFmhP3g1q34PY2U34Bee3L3O4/X4sBmMSEILFM1glCJO3cznX2Qz4dIUv5d6j+k3kZ4Bz70pDcRPk6OI0I+2Yj69fSzDTaTEA7Wet5dDs36vXIv4VIibV9AGn6DZE1lagNoJPvntOmDXK9bKC84Re5XZAgvvg0M47idjVVQne9nOyFAM516dh2Np2o+r26cRfkkpplLDopjaaX7yTID13D/N83mo3L5YRlxD9CiuIrbI9vAXs2p0bufcDgnk//OH9sCkju6OCuKNP/1Qn6kgytOev9KZn3mbBLTHqfLQ9Fkx9qXbd2n/JuPQSFtshLxKFuFXyIceHK+uaTuPrftGjM2OFIojeWnf5ISD+jvKfPaapp0sPz77OE6zOmvoaeHN5RTP0AfS61MFsWrxgZ/qFBigk8qfjRhd5w224wYoL3BpFVvyntIX+i+Ki0rNhenhoPrjJeMocR8JMnOHuoir9+am2iQfQDPIBBgwFLb7UefiHjYP5vBGAuF8KSAE9nFdKyd7qxkqfMH+C6PA0CE802Xpw8HSBgpbJrLgKsPP1Jwfz7Za9J4It1M32SdrfM0c6n4F56EOBN1FgoHcNCWuEhTOgOCF6inwHFDkqlynBXVpfquXE9GaAbLQWfmvLDTy1InJ7Onn1yMmqCIbPK23QbHg7uOMNRerZ8KIoJdlbj2JU1q4UCyoXCxcddgdGnzuE6hKkYz15Gd6d3LM07+FMSE75Oj8o9+im4DcRri2NipO073fQdAxwxFa7iqWF+/DoCL3 UcXPuDED SAIuKi/bEoT1QUhnxVSrAaTiOAFx2tn0THJ6BMw3r/jCMGl9GySKU862duOv8MssoZemFRBXs2ngBqwBEUSIM6X6CzHwnORmGlC/E8u5SF+P9+phLQINMOSOjwb/nMPKmWb7+jJxYZYmF/0K02R9uXVkbJMwi3NADqeAJP0/yToQstB5NCTTzuzmtefrB6sTBgmyn6zo3Z8vqP02S+7G3lDT4eQ== 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: page_cache_sync_ra() is called when a folio we want to read is not in the page cache. It is expected that it creates the folio (and perhaps the following folios as well) and submits reads for them unless some error happens. However if index == ra->start + ra->size, ondemand_readahead() will treat the call as another async readahead hit. Thus ra->start will be advanced and we create pages and queue reads from ra->start + ra->size further. Consequentially the page at 'index' is not created and filemap_get_pages() has to always go through filemap_create_folio() path. This behavior has particularly unfortunate consequences when we have two IO threads sequentially reading from a shared file (as is the case when NFS serves sequential reads). In that case what can happen is: suppose ra->size == ra->async_size == 128, ra->start = 512 T1 T2 reads 128 pages at index 512 - hits async readahead mark filemap_readahead() ondemand_readahead() if (index == expected ...) ra->start = 512 + 128 = 640 ra->size = 128 ra->async_size = 128 page_cache_ra_order() blocks in ra_alloc_folio() reads 128 pages at index 640 - no page found page_cache_sync_readahead() ondemand_readahead() if (index == expected ...) ra->start = 640 + 128 = 768 ra->size = 128 ra->async_size = 128 page_cache_ra_order() submits reads from 768 - still no page found at index 640 filemap_create_folio() - goes on to index 641 page_cache_sync_readahead() ondemand_readahead() - founds ra is confused, trims is to small size finds pages were already inserted And as a result read performance suffers. Fix the problem by triggering async readahead case in ondemand_readahead() only if we are calling the function because we hit the readahead marker. In any other case we need to read the folio at 'index' and thus we cannot really use the current ra state. Note that the above situation could be viewed as a special case of file->f_ra state corruption. In fact two thread reading using the shared file can also seemingly corrupt file->f_ra in interesting ways due to concurrent access. I never saw that in practice and the fix is going to be much more complex so for now at least fix this practical problem while we ponder about the theoretically correct solution. Signed-off-by: Jan Kara --- mm/readahead.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/readahead.c b/mm/readahead.c index c1b23989d9ca..af0fbd302a38 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -580,7 +580,7 @@ static void ondemand_readahead(struct readahead_control *ractl, */ expected = round_down(ra->start + ra->size - ra->async_size, 1UL << order); - if (index == expected || index == (ra->start + ra->size)) { + if (folio && index == expected) { ra->start += ra->size; ra->size = get_next_ra_size(ra, max_pages); ra->async_size = ra->size; From patchwork Tue Jun 25 10:18:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13710834 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 A672EC30653 for ; Tue, 25 Jun 2024 10:19:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 29F5D6B02ED; Tue, 25 Jun 2024 06:19:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 123F86B02FC; Tue, 25 Jun 2024 06:19:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BF0DB6B02F2; Tue, 25 Jun 2024 06:19:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 819CB6B02EE for ; Tue, 25 Jun 2024 06:19:14 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 211F2C1828 for ; Tue, 25 Jun 2024 10:19:14 +0000 (UTC) X-FDA: 82269013428.07.F6D09B5 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf19.hostedemail.com (Postfix) with ESMTP id D797B1A0012 for ; Tue, 25 Jun 2024 10:19:11 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=CPRQuFTH; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=LSKvBC6Y; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=CPRQuFTH; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=LSKvBC6Y; spf=pass (imf19.hostedemail.com: domain of jack@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719310744; a=rsa-sha256; cv=none; b=sZFd41AtC/hf1eFZeUUzuFUs0ZvNg8pG2Ocwzp07GvcO4YL2UntiBh7Hc7aJX4j5TOCR8e 2z2uhIMr+XMCZAL9wr33HtryPpb7I2l8X26iWonSDx2Ycvviy5gFHPxOg+ltOzHfIntPvP 6PKA8ssnl9OH3fHvKhAhdNcaH6ECCQs= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=CPRQuFTH; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=LSKvBC6Y; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=CPRQuFTH; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=LSKvBC6Y; spf=pass (imf19.hostedemail.com: domain of jack@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719310744; 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=1mV9dyLmEXPNThSQksaqyuEvMuZusgKZh1jasd7YbD0=; b=XhMyVPw8IAv8E6bon+sVbkv+lQRCMHGMd9DAfcapnBoKjhADnIsPPlF3wnIk94baF6L7mg h34DiXO4gOtSWi5Mj3aGzJpu29tosU5T0sUMTOF65xLbZsbzQkEII8066xFyFNXvA7/kz9 P/kFX9y4zgI74SbdwCqY23aFjAi2EHc= Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (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 smtp-out1.suse.de (Postfix) with ESMTPS id 44D7B21A76; Tue, 25 Jun 2024 10:19:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1719310750; h=from:from:reply-to: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=1mV9dyLmEXPNThSQksaqyuEvMuZusgKZh1jasd7YbD0=; b=CPRQuFTHYwVxIVw+g2eMSlxsPjbggxxUXCQfRNDhD1NlW8q6JLK8+CshOYwk6anmoR3fUl fI1wjbJGYN2Y8P24bTasEf3jjhhar0FnMXRlnHgM5D8It4y/VOV3MTGZYxKM6yR3vEEjtQ HWweKL5aMgQia8Ifc1QTcjwFPIGBNHk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1719310750; h=from:from:reply-to: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=1mV9dyLmEXPNThSQksaqyuEvMuZusgKZh1jasd7YbD0=; b=LSKvBC6YgkeWCQAEFbdQnz+TjvBIusyCMWFQdOKdssCqrHIdrT1waldL2D1hTjtrGOQ9fI NisUhjrFQLpG+0Dg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1719310750; h=from:from:reply-to: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=1mV9dyLmEXPNThSQksaqyuEvMuZusgKZh1jasd7YbD0=; b=CPRQuFTHYwVxIVw+g2eMSlxsPjbggxxUXCQfRNDhD1NlW8q6JLK8+CshOYwk6anmoR3fUl fI1wjbJGYN2Y8P24bTasEf3jjhhar0FnMXRlnHgM5D8It4y/VOV3MTGZYxKM6yR3vEEjtQ HWweKL5aMgQia8Ifc1QTcjwFPIGBNHk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1719310750; h=from:from:reply-to: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=1mV9dyLmEXPNThSQksaqyuEvMuZusgKZh1jasd7YbD0=; b=LSKvBC6YgkeWCQAEFbdQnz+TjvBIusyCMWFQdOKdssCqrHIdrT1waldL2D1hTjtrGOQ9fI NisUhjrFQLpG+0Dg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.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 imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 3667A13AD9; Tue, 25 Jun 2024 10:19:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id cwcuDZ6ZemZyWQAAD6G6ig (envelope-from ); Tue, 25 Jun 2024 10:19:10 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id CF449A091A; Tue, 25 Jun 2024 12:19:09 +0200 (CEST) From: Jan Kara To: Cc: Andrew Morton , Matthew Wilcox , , Jan Kara Subject: [PATCH 02/10] filemap: Fix page_cache_next_miss() when no hole found Date: Tue, 25 Jun 2024 12:18:52 +0200 Message-Id: <20240625101909.12234-2-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240625100859.15507-1-jack@suse.cz> References: <20240625100859.15507-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=922; i=jack@suse.cz; h=from:subject; bh=lEGZ9ceRJWeyyjOzqii5re2SDGP3X5uqvnDqu1Uy374=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBmepmNR+m8V1id025gA4id7xWJlDI2ShIvOoiMTjnx wFCStsOJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCZnqZjQAKCRCcnaoHP2RA2ayRB/ 9Vncl9kDets3toPAMTLaVJH0Fp94LwwQ3A3q5pHytHp6I9LoJZ3gp6ZKcPsBivY1Mj5hyKeePMiHML esiIA89Qw5DzBd7UOQ3Nl02fWfbW7Opb3mVqgEM6HSs0DnwJLupoO2QCsv7vK9vTnQijG4iTH4B+nw UwqI3m37d5mrTvjEsJ8GBGqbZspt/gpTntHImQlJkfG1si+upQb4hwjcKDpNfWZfANaVjSzXe2+bom vcZdBrUot3hp5CHlD+zo9p8XDMUJ1E6IVeqIS4FQ9I/NjRwZSgv80DA/ARsF9d+/ZlOkknM4oc2Kza PyzKdZGZQltTyARM56NBoyf7VcK13N X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C X-Stat-Signature: s8zad4bfo5udo3fymk8fi37a3m1higns X-Rspamd-Queue-Id: D797B1A0012 X-Rspam-User: X-Rspamd-Server: rspam10 X-HE-Tag: 1719310751-455772 X-HE-Meta: U2FsdGVkX1/bwuh0lNFJq0VyjZzil1Q1R9IjAYZdT5RhTSHu0JdiL49vAimhb0gOmbvQVucbIzdFgBCf/sS6L+Jdyp6m4CFQdV7e7ljuJYME8pmVG+Rf0EDrsmeNZCHf1h8lVcWi/Kb0h/Uvt1Zb3riAZR0CjpfqxMki+q/nzy+zApzZNz4VE9jgFSjdBY7Jxq6uF+HUl0l7jfj5gSyLk2/JDNnx6z8Z4QsmHaeww7gQMlssV4caE1+sktToSN6wyFnwmQlavPiLRVaDH32PgPII+Ci90jKMmkybNwhQYDQ32ITiBqqNxgK26eu1ZAWg9s52n25pyzdpsPqlRKT5I+tO1biomusLLKVaRFBI7jHQ/zyQ6bljTNiXEP643w6Poa2cJ0/Vr2T5UJnRU+0l+zoj78+aPvRS9PlMiuSqITNEDDSim50Iitre8dJZBmTveEZdfjnQRxX2GD75i3aXKPK6Fc9aLLdEfvQBuTglvjtmq4DHuU9pZRHrmIbir1GVmVHUW/7ZXo3RE62pWlHdc+oWD7Te/Qj4ISyngKrYe7GYogxClnAiAdq/3GwMYmXVJwaphmmKkepNsl7yDYahbZq3ABaxiwWzDpPulHcxcgPqLGY6lVh0vv+2ESn8OtCq3+U07LHbpH2zstsXGHLw8+T/Lphq2O532GPoMtXonvSUjKk9jkITf0I0jS4cu0JjnOrhXaDD7p8EWBlZsnrrICu/rxpPjISq1DxU0LyjveOHf1PLnydbX3n2zzEeoLIJvmZt+QInpSO+8Ya/7Rk7IX2S7dJWvL9ND043duB8aaASgZmN09OWTebgjTASNeIhz03kFUkkAbw+B/VzM6UYlTOW1gcfeqlksYPnWk1mF+2/8Xi4kblen5KcfqspBEfIxOMbVfG2NELUoXe9vCbWNTMle8mmzzJa9xv5kgGU9RPSSNSeZ+x81MDf3Um9CTmVpQX1x7CgV7w66hG61Tx WDIANviU D+aMeTWkbQNMy4xu4CjtHUkq/9VTLoDs0PIyZndhccE+OlPPZMV2wi5l1f5esmoKrSkxwo1tUJeUTfjRulH5oJR+scbinx6S+/X/9dE/FJBS6/9ATojfzW17V7F7VzOaae1fKPhyCDDCyTZbVx76P8XX0PraoRtTmWBKNNO7MEA8Vxl7oHtQTDBDz5e8o5wy1EiooZDoPPATuECPfibkFXTopSaIHkEq1oQltCyAPJe1/DCbvnK0lB1ia6e2y+O8/JF+h 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: page_cache_next_miss() should return value outside of the specified range when no hole is found. However currently it will return the last index *in* the specified range confusing ondemand_readahead() to think there's a hole in the searched range and upsetting readahead logic. Signed-off-by: Jan Kara --- mm/filemap.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/mm/filemap.c b/mm/filemap.c index 876cc64aadd7..015efc261468 100644 --- a/mm/filemap.c +++ b/mm/filemap.c @@ -1752,12 +1752,12 @@ pgoff_t page_cache_next_miss(struct address_space *mapping, while (max_scan--) { void *entry = xas_next(&xas); if (!entry || xa_is_value(entry)) - break; + return xas.xa_index; if (xas.xa_index == 0) - break; + return 0; } - return xas.xa_index; + return index + max_scan; } EXPORT_SYMBOL(page_cache_next_miss); From patchwork Tue Jun 25 10:18:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13710841 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 6E071C30653 for ; Tue, 25 Jun 2024 10:19:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 875386B01F5; Tue, 25 Jun 2024 06:19:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 70F1B6B01F8; Tue, 25 Jun 2024 06:19:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 16B4D6B01F5; Tue, 25 Jun 2024 06:19:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id CC0716B02EE for ; Tue, 25 Jun 2024 06:19:14 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 8E5C1417EB for ; Tue, 25 Jun 2024 10:19:14 +0000 (UTC) X-FDA: 82269013428.23.91F8959 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf18.hostedemail.com (Postfix) with ESMTP id 3AD3B1C0005 for ; Tue, 25 Jun 2024 10:19:11 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=X1oBWrVg; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=ddLvbEk0; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=X1oBWrVg; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=ddLvbEk0; spf=pass (imf18.hostedemail.com: domain of jack@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719310744; 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=4GtSP3ENf+Nn0Zjpw67fKdoioBHD9GQRHkIbgNMfAUs=; b=XkbRCAy0QnbZqtAvd5/p9IJzNxcY7NRW2kl4qqg1HI2HJ3wH7HkIvA35EUM3hDJL/1yIbs hpqmaTqbPxJV2wUr9zgXqKSzJ1tnlkWQMIDi/IQRaVp87BfxxLU5Ipys5ylUMAia0tPxsB wjMPeUHcnL6rbF0o9CYCZPhQeUpax38= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=X1oBWrVg; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=ddLvbEk0; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=X1oBWrVg; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=ddLvbEk0; spf=pass (imf18.hostedemail.com: domain of jack@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719310744; a=rsa-sha256; cv=none; b=QThp5OdZ0HJePdn8peL4maWHbR6pF86ju64RTqYvZPZPr3QMuAyMBVwzFlMG2ve8ZUa7JQ 9wQIecSlY8zR7MyIF1sb0zZWWxGN+klVNS7bk4N5HencF6sfVfUuLebiyiefQWezs/LEMd XziqEosgANi4hi6I8enE+PvHgmYYkZw= Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (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 smtp-out1.suse.de (Postfix) with ESMTPS id 4314121A74; Tue, 25 Jun 2024 10:19:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1719310750; h=from:from:reply-to: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=4GtSP3ENf+Nn0Zjpw67fKdoioBHD9GQRHkIbgNMfAUs=; b=X1oBWrVg4xsMpqF+iw4/qzQawWAC3E53h61k9OlLG8EiWFmGMGYqx5rpsH2yKP9EnsNZ/W p86Al6f+AiXkDugDZvXYh/RCkFEQiVALRyyoKNMhGwQSmMkib0xFO8BxOsIHTJcPOo/STO p/TsyNeT9EaVqNEsCZrkQhiCgiB9NmU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1719310750; h=from:from:reply-to: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=4GtSP3ENf+Nn0Zjpw67fKdoioBHD9GQRHkIbgNMfAUs=; b=ddLvbEk0+zG6pO4x/CX5agTYzeBTfPG+6B/1j9SY6mbfWqNIhzw00lxmbnGW9W8TSucVtd hjyjeT+uvehZJLCw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1719310750; h=from:from:reply-to: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=4GtSP3ENf+Nn0Zjpw67fKdoioBHD9GQRHkIbgNMfAUs=; b=X1oBWrVg4xsMpqF+iw4/qzQawWAC3E53h61k9OlLG8EiWFmGMGYqx5rpsH2yKP9EnsNZ/W p86Al6f+AiXkDugDZvXYh/RCkFEQiVALRyyoKNMhGwQSmMkib0xFO8BxOsIHTJcPOo/STO p/TsyNeT9EaVqNEsCZrkQhiCgiB9NmU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1719310750; h=from:from:reply-to: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=4GtSP3ENf+Nn0Zjpw67fKdoioBHD9GQRHkIbgNMfAUs=; b=ddLvbEk0+zG6pO4x/CX5agTYzeBTfPG+6B/1j9SY6mbfWqNIhzw00lxmbnGW9W8TSucVtd hjyjeT+uvehZJLCw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.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 imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 3313213AD8; Tue, 25 Jun 2024 10:19:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id eOd3DJ6ZemZvWQAAD6G6ig (envelope-from ); Tue, 25 Jun 2024 10:19:10 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id D6C2DA091C; Tue, 25 Jun 2024 12:19:09 +0200 (CEST) From: Jan Kara To: Cc: Andrew Morton , Matthew Wilcox , , Jan Kara Subject: [PATCH 03/10] readahead: Properly shorten readahead when falling back to do_page_cache_ra() Date: Tue, 25 Jun 2024 12:18:53 +0200 Message-Id: <20240625101909.12234-3-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240625100859.15507-1-jack@suse.cz> References: <20240625100859.15507-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1393; i=jack@suse.cz; h=from:subject; bh=m/qJzAdNjRqtXAPnSZNOsBtxQm5ctHdoj1WYBPZKGcs=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBmepmNHpSB+XQ/EstcGHqo9zXZBB1e8CwiTXng+TGe fDYhmz6JATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCZnqZjQAKCRCcnaoHP2RA2XGOB/ 41/mS6sUw9L8KFEVMh/gHypoJtCWairiuHE5F2T0SgsKRL+5OTdU8t6rS8Rt0+rM6uHzX90ZGiWa5p 00FN8wTLlDa6vutwd/Sc1Xod1ESJWmLqqiulQ6TvdeAQAkabVbF9tfImx27PE1f+ul5/PGT1eGGGne e9o51jy0+23alb31k15nv0degSjvhPuf+TN/xut37QIU3LJFdV3GMlvPgOaRhgz2qHRbEDZQT5ClXW XW3eVo5umb82WlNwYlD7Ok5rb02xZKGhPkjvtCqyNfKKKNkhttTcer/cK2JR20pXAAtbzXQUSo0szT 14wwSa4lcdVqcVtcRYTgg4aCpA3xOE X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C X-Rspamd-Action: no action X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 3AD3B1C0005 X-Stat-Signature: dmg6buim1n3ma6hzjuczurcwpnth6axj X-Rspam-User: X-HE-Tag: 1719310751-34680 X-HE-Meta: U2FsdGVkX18jgX0gEAISkLhMN02pvapUS0CoUJ37m+HyBYkO09R1aDA2RU3YZXzoZ4XkYYVIsM5fTSfXkz3imsMFUFasiA+AJO4+4zzJIFbj9rTdTZdf2v5F5xNKP2A/pmu26QVri1L8ToUy4Pky+MhvrmVayc73oMt/gIGiy2FgajAwfikPFW1Cyl4/RZNiaSPJWYbSmRjihcKhye9wSjMJxjV4IeYNioVXa0qyPCa7paZEetzZ38vm4KALyosWH6COsbziPB4QKZnNkJwJnfNDBrWonw76EpkSIlF79v+Kg9RWYcjPFN2MiImZ/Cj3Knc2Lmz9u3Laxbf35a7oFkB7o4FAX/Vfa8R2RmbsQ64QX/qJtkKc3H5uCvxnF6GvOo6euZxHJHXZLAEOCMm+qh7/PxaDdiPgUNF5lcaan175Yd6vE05nokDCZGGbYN7D/lRwuUr0KS5Hw4FGpLgQXI4nC4vVjMX1jexIG7pZTsFqzMJII8Rrf2XMRBrMeMW0phm8ucMLAn6bgbb2wuBI9nsBf6Kx+6VIddbRPzx2XpRY8fzcKB8EuP/7PlyGXCC1uJ6vjVGAdUzRuyaGZaMtMLwAtsLWDIyA/Fck4p2wXwV2unaCBPFzb0k3/Qfgbz64NBKjDm6AStDDws84RC+tf0ssY4dcfues7+FzKR/TsdflNTJErmGQrpzh0YY9aEUNwQQz5nRW3t8PaG5Myx3Qmvp2F3yNyjh5aKWw5doEIJ8RgCv4MRYorOC/3TaVNsNXhHMW8d6X1R+XME+rsobpT5kJlsBUoZ6LzqrE7aifKr1ERvUH6jScwUPH9xW8c1WmUOdOOubD6uYI2e9exETsMwjSOJEyKwtHmXg2gmOD5rP0dGZ6Pgs3pNUeTLno1j98S/DW/jnAys3o/I7fxlCu3bEuTxHfFvmW6FJLXUl5qaYZ2LMES8fJy43TL6K670eUuixp70DsYVm0fLRjfBq k4HenyDJ uvrxAg+8imMaqoOXagqtTgGJUZVbodha1XhMjYg/n/Bzcn+n2rw1kHuIin74HfsK0F1067S7T9MSaVxet9d1In0pOtrMcv63T+HD64ZTHahCfmxB5XQP0uK7hFwYJ8wz3K010e6QqFWghfwor6lUPxpEP5Ojiyq+BsKBWwHv8jQ7ecE5sCl8u7fEoqxMovll/IfFkNDG5zSsaVYngqP9UqCJSio2kDIgsUOv3jv+YzCl6jjQitruzd0r/HBIUtuBprLVr 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: When we succeed in creating some folios in page_cache_ra_order() but then need to fallback to single page folios, we don't shorten the amount to read passed to do_page_cache_ra() by the amount we've already read. This then results in reading more and also in placing another readahead mark in the middle of the readahead window which confuses readahead code. Fix the problem by properly reducing number of pages to read. Signed-off-by: Jan Kara --- mm/readahead.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/readahead.c b/mm/readahead.c index af0fbd302a38..1c58e0463be1 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -491,7 +491,8 @@ void page_cache_ra_order(struct readahead_control *ractl, struct file_ra_state *ra, unsigned int new_order) { struct address_space *mapping = ractl->mapping; - pgoff_t index = readahead_index(ractl); + pgoff_t start = readahead_index(ractl); + pgoff_t index = start; pgoff_t limit = (i_size_read(mapping->host) - 1) >> PAGE_SHIFT; pgoff_t mark = index + ra->size - ra->async_size; unsigned int nofs; @@ -544,7 +545,7 @@ void page_cache_ra_order(struct readahead_control *ractl, if (!err) return; fallback: - do_page_cache_ra(ractl, ra->size, ra->async_size); + do_page_cache_ra(ractl, ra->size - (index - start), ra->async_size); } /* From patchwork Tue Jun 25 10:18:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13710836 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 4419CC2BBCA for ; Tue, 25 Jun 2024 10:19:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 808216B02EB; Tue, 25 Jun 2024 06:19:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5B0A06B02F2; Tue, 25 Jun 2024 06:19:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1DE336B02EC; Tue, 25 Jun 2024 06:19:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 806106B02EC for ; Tue, 25 Jun 2024 06:19:14 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 2BA0681630 for ; Tue, 25 Jun 2024 10:19:14 +0000 (UTC) X-FDA: 82269013428.01.92B717B Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf06.hostedemail.com (Postfix) with ESMTP id EE59C18000E for ; Tue, 25 Jun 2024 10:19:11 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=rE8i5kNl; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=oE0xVS7g; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=rE8i5kNl; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=oE0xVS7g; dmarc=none; spf=pass (imf06.hostedemail.com: domain of jack@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=jack@suse.cz ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719310740; a=rsa-sha256; cv=none; b=s8i2mAcbMUoV2r7226yhPVchmzzPc4WW+RDK4EpHrpZP8CRQ4cOdHEznhnGedAmTNTSXdM SkE57Jxbi2yddr5oo957eoh+h3VJ8qr0Xyr3C2v8nzAglXmSIoZoUn7KPAiL3/mGeGelQv 7IlF8UsKT8cergS7wcGfd1ZRk7iEZ7c= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=rE8i5kNl; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=oE0xVS7g; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=rE8i5kNl; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=oE0xVS7g; dmarc=none; spf=pass (imf06.hostedemail.com: domain of jack@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=jack@suse.cz ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719310740; 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=etKpcm5t3yeZbDdRLHHmNy7tT/UIvSIL59H6KxFIGCA=; b=7CbZihrBCkXqP5RuHjEWlZ9xX6v46MuB7CVa9VkwVokJfrlTubHS3dSfa7Z1IbENY3dAX2 zENptIwt8KCPWQN6lRtNWVxxouqLSEhM0fq8ije1aC87jTQDwn2v7gbiRSVoZ8I0rxAGdP Phptz7cz4wBPTdSw2KhIfhT0SMsTy3I= Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (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 smtp-out1.suse.de (Postfix) with ESMTPS id 4939121A77; Tue, 25 Jun 2024 10:19:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1719310750; h=from:from:reply-to: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=etKpcm5t3yeZbDdRLHHmNy7tT/UIvSIL59H6KxFIGCA=; b=rE8i5kNlaX0AgnQkr/e+qACaK70IxSWR442e2gE7u2USV9HVMwpFh/GJUHTmURYCZpPp7c 5gcp6/4uKvF5q6CNkR/SjnYYU0+xssoRyh6N49PPqZv0xUHHiE1+DZtOHfFaCj2zgcevno ko1oz7YvBO+lLK5Ut/ijE2Xyom1qj/U= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1719310750; h=from:from:reply-to: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=etKpcm5t3yeZbDdRLHHmNy7tT/UIvSIL59H6KxFIGCA=; b=oE0xVS7g8vkRXj4Bmf1lNIAQlt/gr3xGyg9YNceAg++iiya3vp1WPyoIWMJJhhBGJ1ukCy mcaWT/tJFiHYrIDA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1719310750; h=from:from:reply-to: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=etKpcm5t3yeZbDdRLHHmNy7tT/UIvSIL59H6KxFIGCA=; b=rE8i5kNlaX0AgnQkr/e+qACaK70IxSWR442e2gE7u2USV9HVMwpFh/GJUHTmURYCZpPp7c 5gcp6/4uKvF5q6CNkR/SjnYYU0+xssoRyh6N49PPqZv0xUHHiE1+DZtOHfFaCj2zgcevno ko1oz7YvBO+lLK5Ut/ijE2Xyom1qj/U= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1719310750; h=from:from:reply-to: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=etKpcm5t3yeZbDdRLHHmNy7tT/UIvSIL59H6KxFIGCA=; b=oE0xVS7g8vkRXj4Bmf1lNIAQlt/gr3xGyg9YNceAg++iiya3vp1WPyoIWMJJhhBGJ1ukCy mcaWT/tJFiHYrIDA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.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 imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 3AEF613ADA; Tue, 25 Jun 2024 10:19:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 0xxcDp6ZemZ0WQAAD6G6ig (envelope-from ); Tue, 25 Jun 2024 10:19:10 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id DE333A0936; Tue, 25 Jun 2024 12:19:09 +0200 (CEST) From: Jan Kara To: Cc: Andrew Morton , Matthew Wilcox , , Jan Kara Subject: [PATCH 04/10] readahead: Drop pointless index from force_page_cache_ra() Date: Tue, 25 Jun 2024 12:18:54 +0200 Message-Id: <20240625101909.12234-4-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240625100859.15507-1-jack@suse.cz> References: <20240625100859.15507-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1537; i=jack@suse.cz; h=from:subject; bh=YMGuebUrm0qSfydyCid1z7UHFeUsV68V8mO59Irwxfg=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBmepmOHQLH0PwzfW3mfxx2sEkVan7MxcaVI6ZACKFq jkqSlruJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCZnqZjgAKCRCcnaoHP2RA2eu4CA CqnwjdpuUvU0E8r6CCpeAHE+DzeV3rp7p0Z+WXReeccWJEVLIo9C6uoySJqZF6pzldz5Juuw+5Tq4d P4523q7ldw/oDZxNNKuSqei5MQeQHUHJqG86GHmZVOIb+WxSdlOaX0w4JwBZFI6weS+YMwQQ86Z+St ogUO3/Ev5niwgbxwUhqwA5OH5GtfBJw9su26AyzXPnUvuNyzVWajW6veMErhPUdp/RN4nuJC0sBGgR 5V49G5x3Z+LSQLkiRHS+Vmx/31fb4viCOg4+0zmfEIntH05yNwwPwQpn9HPdy+8KJ8xJFpJY1P+8/y nw+9is3leFpihkQHFjSyHEmm+7xmNo X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: EE59C18000E X-Stat-Signature: mj7oqnexmqxxrx1z6tnp64ho9qi764yn X-Rspam-User: X-HE-Tag: 1719310751-200934 X-HE-Meta: U2FsdGVkX1/bRC5zKz/jK0V2E3nzT7JYNUJHyZLA4gF/at2/k28QO+at6RKeKFjsDV0XnXUlC45AoGJDpvtmeY01YJEnclarq7bHPrF1sMYZUkWLItbFJ0qWB1pcREY2yoFXL1VDMsZdyx0yJMHfs3d+HrkDyiBNqspSkfD4gyc6+SGNUcmzqUGyngn9cvP1xVbeDh0KOY2YEMNrVtxmW/pVOmCwgjM3F0oA6ROKo9SIqaR+0Ag7sRVbnsWaUq6rNkxhw6O9wqMTdGKJQsgn+jqCCgAEEC6sGguRbMo5JIyPgC1Lesoww5S9UoWI4VW35suy9EqX2E+rtBFY2y4UVIziNv7/vBbgEmvsgXxdIq+n7Q91H2I8kMW3LFPG1c7Yz3jjChSOlSmljh8gIOqwfvlI6kyOKN3bQYrc012OoGBL/5ZhWNW4wLp26F8T0biBOpCUB211AS0Bbl/8GKqeJIpUbuaTD+FXQDXj4c7pEeIieg0oNu/6+XOz7eHI/0ZDIWKlIMhqPYwYDAHUh1HM6B490G7RSphQMLRUlGmPrMtjQgOKZGVsWUEIspYsGWCDm+mdCoXDRTyvBWceRuvASDkyTI8BEkzxLhCFwDZGORTkqg6CmU8Ydmm8wkfzeTA6pSodWeCSujPjWIg0zvCv1KZzuOCDdKFF5jbqVewjVk0IwQfZgG7RgtQUfk/Ukk6bUSH6mNs39CfnlBHMzssBbz+PnP1pictJK/3bXsTM/8KC64JXiLi7b404PdCrMlffp6UqoRqkd1E4Fa5vKpGY1L6+FGx21LgDlBA2oLicoP+eWTg6bDpBXnHs+7QNPMCIedVqfwyWdNGzflKYSjw7RHcAXulovu91JsDZC1g1giDI3tDqGMpcEOcFi9h4V/xW6hruuncIBtCP01g2eQTD3aVnw6eJQ1OohLd9ABW7BrUpdUEbooRml7RiK7leaybWFMFbS4Viz82/UMvzt7q pAA6DG9P OAP8if1vXtBXWTpK/w3x/X72GqRHjGNVL/UYoCdLNeqMXHklOn2Ss2jrO23CPFhPB81hOyW8BUG3HmlLUQcgwNDIOtH3Zpk4mI9Z2mwbnY/pPO3Rxt4WCwDlxfNHwFWNGCeGAYLaq6ZjEfvBm3NRXx6ue6TuTXIMsF/trCjGu3W12scPB2OV5WZqsgFxHvGeUVvPpsFZ7xKTJtYxzWIPjxB5MVqCj4V2twmLlrgQEKd7dFpJ0/a2cxacuAmVI8uBHO3zf 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: Current index to readahead is tracked in readahead_control and properly updated by page_cache_ra_unbounded() (read_pages() in fact). So there's no need to track the index separately in force_page_cache_ra(). Signed-off-by: Jan Kara --- mm/readahead.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/mm/readahead.c b/mm/readahead.c index 1c58e0463be1..455edafebb07 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -313,7 +313,7 @@ void force_page_cache_ra(struct readahead_control *ractl, struct address_space *mapping = ractl->mapping; struct file_ra_state *ra = ractl->ra; struct backing_dev_info *bdi = inode_to_bdi(mapping->host); - unsigned long max_pages, index; + unsigned long max_pages; if (unlikely(!mapping->a_ops->read_folio && !mapping->a_ops->readahead)) return; @@ -322,7 +322,6 @@ void force_page_cache_ra(struct readahead_control *ractl, * If the request exceeds the readahead window, allow the read to * be up to the optimal hardware IO size */ - index = readahead_index(ractl); max_pages = max_t(unsigned long, bdi->io_pages, ra->ra_pages); nr_to_read = min_t(unsigned long, nr_to_read, max_pages); while (nr_to_read) { @@ -330,10 +329,8 @@ void force_page_cache_ra(struct readahead_control *ractl, if (this_chunk > nr_to_read) this_chunk = nr_to_read; - ractl->_index = index; do_page_cache_ra(ractl, this_chunk, 0); - index += this_chunk; nr_to_read -= this_chunk; } } From patchwork Tue Jun 25 10:18:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13710835 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 6796AC30653 for ; Tue, 25 Jun 2024 10:19:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5B2966B02FB; Tue, 25 Jun 2024 06:19:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4EFCD6B02EB; Tue, 25 Jun 2024 06:19:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D76596B02F9; Tue, 25 Jun 2024 06:19:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 88B856B02EF for ; Tue, 25 Jun 2024 06:19:14 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 32F9216192A for ; Tue, 25 Jun 2024 10:19:14 +0000 (UTC) X-FDA: 82269013428.23.59BDA6C Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf20.hostedemail.com (Postfix) with ESMTP id D94821C0020 for ; Tue, 25 Jun 2024 10:19:11 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b="aLbP/MM9"; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=npRodn1v; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b="aLbP/MM9"; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=npRodn1v; spf=pass (imf20.hostedemail.com: domain of jack@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719310738; 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=+8Lca3al1fhzTJQxTF9PNVlpICKgh2TdoBsflcocPqU=; b=oHfTaYukeVDFKeO0ECu/j+0zeyZ7b7KLgcsPnw+rabE6IQ4KykxzaRai1m2jwwO3iVnIva peFfd6tW90ybmMFQVD+TOXeKQFhuSjB/EseUbviN9Et2VWq/1pFg+LofX4z8tF2+EaJ0eT zIEKHLE9HvY7YjasEBlfS2SMiIGec/s= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719310738; a=rsa-sha256; cv=none; b=hvm/90GTHpChZkjM8yNmm0P4oHPCyhXJIacQm6kCn03ummtmOuNqYb54RGY3fYCgAyzBJ+ htj5xaG0F5Zj9WZGwPMjdNEehaejmEeekGuurUvCGDlVszy7dIQW6vAaN+seB26o5aDvHG E5ATN2D+iqPAsWzqV/YqnNdP2muT3Bc= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b="aLbP/MM9"; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=npRodn1v; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b="aLbP/MM9"; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=npRodn1v; spf=pass (imf20.hostedemail.com: domain of jack@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (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 smtp-out1.suse.de (Postfix) with ESMTPS id 9038321A78; Tue, 25 Jun 2024 10:19:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1719310750; h=from:from:reply-to: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=+8Lca3al1fhzTJQxTF9PNVlpICKgh2TdoBsflcocPqU=; b=aLbP/MM9R/HRsbC+rOxPee0706vrfOroPL1a++4Gq0YAA+ZHFPQmMmIuEEow8axyZWO02E +xWtn5lDRaK4JEnd4pVYWFBgT7WYxbf91JRpi7nBXHOVIAzFU0W4jURryRY4RDU71oPHPo m673nOhFNLB6tKwiOyFEwknGni3ALvI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1719310750; h=from:from:reply-to: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=+8Lca3al1fhzTJQxTF9PNVlpICKgh2TdoBsflcocPqU=; b=npRodn1v5RJ6WpWaGog0gYIz4mqWaD2yvikAGJO5neCTaC2Xgks7xQb6+90bSZFtOwcdNq UCKfCQabGbgNSiDg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1719310750; h=from:from:reply-to: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=+8Lca3al1fhzTJQxTF9PNVlpICKgh2TdoBsflcocPqU=; b=aLbP/MM9R/HRsbC+rOxPee0706vrfOroPL1a++4Gq0YAA+ZHFPQmMmIuEEow8axyZWO02E +xWtn5lDRaK4JEnd4pVYWFBgT7WYxbf91JRpi7nBXHOVIAzFU0W4jURryRY4RDU71oPHPo m673nOhFNLB6tKwiOyFEwknGni3ALvI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1719310750; h=from:from:reply-to: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=+8Lca3al1fhzTJQxTF9PNVlpICKgh2TdoBsflcocPqU=; b=npRodn1v5RJ6WpWaGog0gYIz4mqWaD2yvikAGJO5neCTaC2Xgks7xQb6+90bSZFtOwcdNq UCKfCQabGbgNSiDg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.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 imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 839B513AD8; Tue, 25 Jun 2024 10:19:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 4jUmIJ6ZemaAWQAAD6G6ig (envelope-from ); Tue, 25 Jun 2024 10:19:10 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id E6F44A0937; Tue, 25 Jun 2024 12:19:09 +0200 (CEST) From: Jan Kara To: Cc: Andrew Morton , Matthew Wilcox , , Jan Kara Subject: [PATCH 05/10] readahead: Drop index argument of page_cache_async_readahead() Date: Tue, 25 Jun 2024 12:18:55 +0200 Message-Id: <20240625101909.12234-5-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240625100859.15507-1-jack@suse.cz> References: <20240625100859.15507-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2630; i=jack@suse.cz; h=from:subject; bh=YaPpgDx+Qmuj6I/gWcDPw0IJuohKdGqM4cxIZra6ocM=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBmepmPJlMUunnObQNV3cSQ7E5jsGTZZugbhFy9t2we 3vTzJjqJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCZnqZjwAKCRCcnaoHP2RA2VPxCA DjI+zbpNTOWZjm24JaNK8kwW96LsA6mIzfFDMpRH5Q7+tLMgfyh+bRIUakcieBituNu4bPjdIUpRgg e8B/R6bZ51rcc7vbqRlzQAcKB2mYYiE4VGY4BzZBT14p7QhdIcuNR1+0O/4gi4EzZ8+P/RmOQRC30u 8aR1AVLtY3fAVPv4fDROqN9gH8cu8A5wowtzrOe5wtPk+f+nCrH839vlpN16YK2Vkvk1X2MnyHLVuE bfT2JIcRhjSAuu7IgzMdqrMiC9Hm+zzZ6Ct/RzoASyDlYkCM5NYy2/6gu59wtHKdPR3WcHo/JTneTp sQ9aeDFOJT2gVEjdq1pM2wm/GD8huG X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C X-Rspamd-Action: no action X-Rspamd-Queue-Id: D94821C0020 X-Stat-Signature: pc8epwcw5tfrbmc9h48kkkka77xamtou X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1719310751-864456 X-HE-Meta: U2FsdGVkX1+OJ48cR/6dNy/BKiX9HHEpS4i9h+bCrq0ha5tHYuo3KhuTbb8A1liIeBFBaAFs1yDE4DRkmGHNcsCiQa883XXmj0rDyQDjPGQDMukVr47/b0H/w38WqspOBb4YBIk5Cp6rNh3uV2Xl7kaNokdJlvp+7ZYHEXC0ObvYZtlcbbqK/ZtueW1+hvBDbgWKbQvFTsfINZNiRw3X73+2FXAali2wfRqqngka/1W6mgZi+uQP/S3OXL68nmgLWlRZlx8rqlkV4eStPl6EPcw3mwzjJ5DMjsVdMQwpFQ2Hy1KT7cVlsgYARxsBTZBFj6+55lebnAGbo8fdA7PfMkAfNJ7A2Fnrtx6Lk3OQK2iTo4yBC2i+NfvDEjdXicyZdZmDPaBv96uBwewtQf4ToDUTTmKkkm0wSF2ESJEnwCTSnWLwInJiJddeuTrEaantep6quEuoAoP0XklnuE/Ih/URaiVdO7jEgffu25OYxqZ40qn6TLGgbP+Jh00rh0B+pJ4C2eyQLZBRrFJmkpFX0YFCKQWcoHvw1fPUKMABvCJeENYsUfxxbnQliZFhrXtBlXRJbrS6Yz21t+5T4O/oegMWGuYOD/aLKiZVIKhxyoAqdlWeNdzh9Ehv70hV+sujY9qy2dGDzTR0DanwKdj9ShaDV0lRTngBhYXcBuW7zsx9MnkzPvfK8c8FLhJanmK++82qMtfHQT+j+mAW3MOFrH0MQmWc6ZARUIV97eoCMDC5pjPjG05FGnKe+4g0kdM4JKQrERNapXTbeJcSgOAAwM9smq1bs3ChgooV9ggUYGkdSuMHPptX7bOTSPw+nH2vMs/Y8biMaAqCb0MDt/OwpBHMEJKUWcs4+/STjXWaYDgCy6F7/Lo2rX0Fn6RctI1BNtAeitnFVqsAFNYZcjzTaY915dnddhle3KcMQQLF5PbV6DV9w/fKawNGuPxtYqh4CHzUpNoxVZdbRmWCs8n 0fGVkYCv ib09mvJ07KTBRlh3f6lTtvXRJjNWx64gYWCjQgmy8dJgimMUv4lokG2sz7w79wIKDDDbe4a+AELGeRh6NjU86SXEVlwK/bKgQi+hQrewRk75CqlDxJjGO/rmEUVffdj/J3zBICx1XY0fSiC7N0psi/E2eqTvhHUTLtDp7ud2tHMgOX0m67U8vLTiIb1YLoXcHH1RfwZYnooEVEld3EfBZbk5c5epfc6IDs778nGTrBI36fMLx2jIsZY5Xa3Gn90XiPsm6 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: The index argument of page_cache_async_readahead() is just folio->index so there's no point in passing is separately. Drop it. Signed-off-by: Jan Kara --- fs/btrfs/relocation.c | 3 +-- fs/btrfs/send.c | 2 +- include/linux/pagemap.h | 7 +++---- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c index 8b24bb5a0aa1..e7e8fce70ccc 100644 --- a/fs/btrfs/relocation.c +++ b/fs/btrfs/relocation.c @@ -2975,8 +2975,7 @@ static int relocate_one_folio(struct inode *inode, struct file_ra_state *ra, if (folio_test_readahead(folio)) page_cache_async_readahead(inode->i_mapping, ra, NULL, - folio, index, - last_index + 1 - index); + folio, last_index + 1 - index); if (!folio_test_uptodate(folio)) { btrfs_read_folio(NULL, folio); diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index 3dd4a48479a9..dbf462e67ad0 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -5307,7 +5307,7 @@ static int put_file_data(struct send_ctx *sctx, u64 offset, u32 len) if (folio_test_readahead(folio)) page_cache_async_readahead(mapping, &sctx->ra, NULL, folio, - index, last_index + 1 - index); + last_index + 1 - index); if (!folio_test_uptodate(folio)) { btrfs_read_folio(NULL, folio); diff --git a/include/linux/pagemap.h b/include/linux/pagemap.h index ee633712bba0..7ad4decd4347 100644 --- a/include/linux/pagemap.h +++ b/include/linux/pagemap.h @@ -1307,8 +1307,7 @@ void page_cache_sync_readahead(struct address_space *mapping, * @mapping: address_space which holds the pagecache and I/O vectors * @ra: file_ra_state which holds the readahead state * @file: Used by the filesystem for authentication. - * @folio: The folio at @index which triggered the readahead call. - * @index: Index of first page to be read. + * @folio: The folio which triggered the readahead call. * @req_count: Total number of pages being read by the caller. * * page_cache_async_readahead() should be called when a page is used which @@ -1319,9 +1318,9 @@ void page_cache_sync_readahead(struct address_space *mapping, static inline void page_cache_async_readahead(struct address_space *mapping, struct file_ra_state *ra, struct file *file, - struct folio *folio, pgoff_t index, unsigned long req_count) + struct folio *folio, unsigned long req_count) { - DEFINE_READAHEAD(ractl, file, ra, mapping, index); + DEFINE_READAHEAD(ractl, file, ra, mapping, folio->index); page_cache_async_ra(&ractl, folio, req_count); } From patchwork Tue Jun 25 10:18:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13710838 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 633F3C2BBCA for ; Tue, 25 Jun 2024 10:19:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D4E7E6B02EC; Tue, 25 Jun 2024 06:19:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CB38D6B02FC; Tue, 25 Jun 2024 06:19:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7F9076B02EC; Tue, 25 Jun 2024 06:19:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 949A26B02F0 for ; Tue, 25 Jun 2024 06:19:14 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 52EF21C318E for ; Tue, 25 Jun 2024 10:19:14 +0000 (UTC) X-FDA: 82269013428.10.8F55C13 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf23.hostedemail.com (Postfix) with ESMTP id 094DE14001B for ; Tue, 25 Jun 2024 10:19:11 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=kBPyOTV0; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=xWW1KRCc; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=kBPyOTV0; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=xWW1KRCc; spf=pass (imf23.hostedemail.com: domain of jack@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719310737; 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=MSIf4jCjJDnMr8/f5CejiRw0oOxYjiOk2rPRf6qMsis=; b=qOn+a6hcs0Wgs2E0YaUEd2Yf19h3+17/nWe2YyUGLH/a6CyrlrFNhI03YVbOHr6X5nSIkz ROCfVxq0y9/lcaDmYxgBJYmZclQdB+Yyo29a2zIHjHnGenIHYINAV6SGyCQ4uczoxJtJM+ f2lP5sIheYZY8JtgpkEVZfBMRntadrQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719310737; a=rsa-sha256; cv=none; b=U74hG1+Y0TK6ERERYdRFJqwScttywgCHIp7ByjdEYV2xTrRna70sDGV6oSpV0ymUBWNJGC jL/eLA0or89pUeCjTe3vuOIYgVaSAPK5PSmI74DGo73iZUeE9ib+DV1ea5glxIhkqpfsIL skvW9XbQEO1vQj7ihOsFKA+PiFECrRw= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=kBPyOTV0; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=xWW1KRCc; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=kBPyOTV0; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=xWW1KRCc; spf=pass (imf23.hostedemail.com: domain of jack@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (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 smtp-out2.suse.de (Postfix) with ESMTPS id 8E9991F84E; Tue, 25 Jun 2024 10:19:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1719310750; h=from:from:reply-to: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=MSIf4jCjJDnMr8/f5CejiRw0oOxYjiOk2rPRf6qMsis=; b=kBPyOTV0CaOTXexoQ24sDAzDcrWGNQdGLdJUFDQX+LJyNiAjP52drz2g82eWlgUYeES32o yQM4/zfJ/ur3MNIK5pkc7HP7k775BA0oM1+DpbKqYL8hseJS8ArcT1O5j38k/zeuq4pfPT CFLzwK8gqJORSTSdbhODJ5HbTtnirT4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1719310750; h=from:from:reply-to: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=MSIf4jCjJDnMr8/f5CejiRw0oOxYjiOk2rPRf6qMsis=; b=xWW1KRCcPkzu29v7MB4OlDHn0/EQ27Zx2Yz1h01K2QfCfyRJSNbHCbJzeAJf6br/EKk1ik C2rEenkRSlbrJ+Ag== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1719310750; h=from:from:reply-to: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=MSIf4jCjJDnMr8/f5CejiRw0oOxYjiOk2rPRf6qMsis=; b=kBPyOTV0CaOTXexoQ24sDAzDcrWGNQdGLdJUFDQX+LJyNiAjP52drz2g82eWlgUYeES32o yQM4/zfJ/ur3MNIK5pkc7HP7k775BA0oM1+DpbKqYL8hseJS8ArcT1O5j38k/zeuq4pfPT CFLzwK8gqJORSTSdbhODJ5HbTtnirT4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1719310750; h=from:from:reply-to: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=MSIf4jCjJDnMr8/f5CejiRw0oOxYjiOk2rPRf6qMsis=; b=xWW1KRCcPkzu29v7MB4OlDHn0/EQ27Zx2Yz1h01K2QfCfyRJSNbHCbJzeAJf6br/EKk1ik C2rEenkRSlbrJ+Ag== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.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 imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 82EDC13AC1; Tue, 25 Jun 2024 10:19:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id k+H1H56ZemZ9WQAAD6G6ig (envelope-from ); Tue, 25 Jun 2024 10:19:10 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id EFF2DA0938; Tue, 25 Jun 2024 12:19:09 +0200 (CEST) From: Jan Kara To: Cc: Andrew Morton , Matthew Wilcox , , Jan Kara Subject: [PATCH 06/10] readahead: Drop dead code in page_cache_ra_order() Date: Tue, 25 Jun 2024 12:18:56 +0200 Message-Id: <20240625101909.12234-6-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240625100859.15507-1-jack@suse.cz> References: <20240625100859.15507-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=773; i=jack@suse.cz; h=from:subject; bh=W6XufS+irzkVLcuC4WuSgVtbQbyLhmOcwBflH4kmDVk=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBmepmQ2JTScI1xSohz7XtKQCtOoPQPG88nLecvwubO lW7qjfKJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCZnqZkAAKCRCcnaoHP2RA2Xx+CA CmfVeVtxYG6T8ol6AezzBq8gB1CHQ/WaA6+W++fNTLMPGH957HjzY4L35mmXxN4u0pCa7sTWJKJKW5 OUxXv/EftfilCXwI62XRrrtaDx6XU+Bc5TqjxWiUz1/6A5ZF5Omm1zcb3d4vlU++Wdnis/KCGZ2fvl shg+9PzVGDqz4h5o1e+/ktFQkxvQjhHXt48C9Roj4eLTatk4dKVkTLvDEzygNPJwjbiWHsYykkaxnf OzGCYGO7qW7ESPBX1LpZEZgAKQ9eHMUfgxutNs4eU5ZLFMPXENWNN/6iFf8nbuQE5a755DD30M9Gcm CGVwrh2HvtZqZDCsNeTcG4juey+zPS X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C X-Stat-Signature: 9w1ty4w833cemauuzsnc91pwqxpg8pdy X-Rspamd-Queue-Id: 094DE14001B X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1719310751-240294 X-HE-Meta: U2FsdGVkX19H7aXJf8GncW6H5VCTERs9IRjhkIJzf5noJXXo+Dcl7k6Dp4pij/6zYXG5cr2TigxXLuekCddUKYKuKY54hNTPVP+Y8N0oJCr3BzHRcRXzLGUj2lsadZF8Ne4YPG9MUbpDyhJDcPQTkrHZ/h5uSPHFQBp3PYy9AG/OAL1Q/fvU87/zJ3YnoN2mgnYy9cSCuLdkfMrKU1QEQ6bE69V4D5PYDvhQctD4h8irn5e2R+d6MlT+dicDeMMpLVEhHHA/jBdtD/NVAkeSHwk4Urhu+agAGy8TnV3u8iuXzNROSZcqGox090AFmLgz6pg2GGJhoKLnwt0GmEfoW6+o+z4a4VORHdaupDbQeYMdL/6MG4nKATVpLS3+Zx6c6vBTZCYedGlz8Y1HoA1Wd1WTkorqfyscwV7lLDzVO5LbQ+SVecnE5Vq7qiJfABDcWw4lINSQ+p1iFhvSgXZgsnT0xhwke8NyMMYA0Pd9wU53wPGCTY+qeLQWRDD0F76EqaMsazKoBYuyHnvOSssEBsEm/W+4aaRtQDw6VQ0MmVT0OF9n1UhmrGQHSG/E1yuFVQU36oRZmicbW2clPbJIV6YI9S6euptczu9S/57EEuCJ0pCYXQ5+D/IG5G/bt7MvXxQ48lgh1G/unmQKhnRtQ4O0866Xi5Tr/ThjdYejZukKAvf5/0ftd6/ZKB8k2BwnIE6wMccmozH/plLW2kOXyULjKqTo53XiKo+uKs+1GX9VbDoDcZL+XpFlbkKZEw3WzYP0Eb44/9cwy1fWxa67+df6UkM0x94t3foOu6Tw8HZ8bJNmi46+xodWQQDQuNg9F+CaYa2xCpuA9NTr/39uY/AOilC8L4x8aY0rmNQA1PW2Z/JYCu8lJkQZ5nzYHOEQ5fh/8tEoQaVg9nEQqmkBljQ6X2Kn8bzK+v82k7M0I7n6J1GB/AtAwDhuApNUaifOFvf8+oI1xOXqlHAYbqx qb5Oj0Vv mKST/hasFLBcsTzeW7FMT2aC6gGfofD4OkwNUzSjw8UYm8uwSdd5QGJrqlqZiINuw6igl9y/MrXLIvmP3mv/UvwGx+0aReNX/76BhVSwLogeGrH3OsRkkZ3AQVZsdCrQgMDbjLaJCnV2m8uawfYDN7tTemjcLC91rbuhGaHAOG/wd+iVOpaS39e0QrpW6Qj3CsH2/tOiuCh0C6PeJIGjgFjKOAHca8VOc8nYt1tcQk4ZZ7yw7FcXy5enFFoFatnzDdvlR 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: page_cache_ra_order() scales folio order down so that is fully fits within readahead window. Thus the code handling the case where we walked past the readahead window is a dead code. Remove it. Signed-off-by: Jan Kara --- mm/readahead.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/mm/readahead.c b/mm/readahead.c index 455edafebb07..9ea5125a0dce 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -525,11 +525,6 @@ void page_cache_ra_order(struct readahead_control *ractl, index += 1UL << order; } - if (index > limit) { - ra->size += index - limit - 1; - ra->async_size += index - limit - 1; - } - read_pages(ractl); filemap_invalidate_unlock_shared(mapping); memalloc_nofs_restore(nofs); From patchwork Tue Jun 25 10:18:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13710833 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 A0B9BC2BBCA for ; Tue, 25 Jun 2024 10:19:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E64136B02F5; Tue, 25 Jun 2024 06:19:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E145A6B02ED; Tue, 25 Jun 2024 06:19:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B2DE66B02F5; Tue, 25 Jun 2024 06:19:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 80F976B02ED for ; Tue, 25 Jun 2024 06:19:14 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 301361417C6 for ; Tue, 25 Jun 2024 10:19:14 +0000 (UTC) X-FDA: 82269013428.02.19BE244 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf06.hostedemail.com (Postfix) with ESMTP id DB13E180003 for ; Tue, 25 Jun 2024 10:19:11 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=GWFhszbJ; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=mBATL9t0; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=GWFhszbJ; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=mBATL9t0; dmarc=none; spf=pass (imf06.hostedemail.com: domain of jack@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=jack@suse.cz ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719310735; 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=XehjZz8U5jmUp0KBCATwed+k3plztjsxZR6NK0NE8js=; b=wGBYuzdge6LA9Nn+Bdt1h40hrZBdqFxQUA3Fun6xH776ByWRShpoIEVUbpXOdEcJpUHdoq umOmkMw2nkhiUYhw5xvRfIUcTv2gPeg6To6bw/dIO5SsElaXq7r5bWtsYOv0O36v0SVEA1 czgSJWqDyRrxhR9QfzfZyCpPWprzueo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719310735; a=rsa-sha256; cv=none; b=07ATDUB1tUJK7xyNwSVoAZ7gljvqXX41cFRLyuRKKxJMvwQl0+NsmwqOE1TcGTJmSuCw7L 22/N6RacBbvIQNn33Kpm3EnsTBxxTzHlleM0hop2pzvUErAlTnRpyhwv6p5IgE0/AIWMPL CNQCPwQYWQEdCOuonUHkphC39V+Oqkk= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=GWFhszbJ; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=mBATL9t0; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=GWFhszbJ; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=mBATL9t0; dmarc=none; spf=pass (imf06.hostedemail.com: domain of jack@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=jack@suse.cz Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (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 smtp-out2.suse.de (Postfix) with ESMTPS id 97CBD1F84F; Tue, 25 Jun 2024 10:19:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1719310750; h=from:from:reply-to: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=XehjZz8U5jmUp0KBCATwed+k3plztjsxZR6NK0NE8js=; b=GWFhszbJE7ATIih77tzjMT/oHF5iOzCCWki1h+d2WN7Z5nHgdpByImeREWmVCUhBYu6YqV 3l0MniMu2E2lA8iM6tQenHrCmSdMuIXbADrmzFDtd/HJfAqrBMLzpcrvnB7O+hT2EVa2Gy CFWfzW+KttaXZPkyrfFm2i09XF845Go= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1719310750; h=from:from:reply-to: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=XehjZz8U5jmUp0KBCATwed+k3plztjsxZR6NK0NE8js=; b=mBATL9t0EsnLa8nZMeqNI+5nPYPaDCLOzd1YBjwgIReTH8881d+1BTu5g3kuP1PAHPRVQS RTOatnacmb9vgXDQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1719310750; h=from:from:reply-to: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=XehjZz8U5jmUp0KBCATwed+k3plztjsxZR6NK0NE8js=; b=GWFhszbJE7ATIih77tzjMT/oHF5iOzCCWki1h+d2WN7Z5nHgdpByImeREWmVCUhBYu6YqV 3l0MniMu2E2lA8iM6tQenHrCmSdMuIXbADrmzFDtd/HJfAqrBMLzpcrvnB7O+hT2EVa2Gy CFWfzW+KttaXZPkyrfFm2i09XF845Go= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1719310750; h=from:from:reply-to: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=XehjZz8U5jmUp0KBCATwed+k3plztjsxZR6NK0NE8js=; b=mBATL9t0EsnLa8nZMeqNI+5nPYPaDCLOzd1YBjwgIReTH8881d+1BTu5g3kuP1PAHPRVQS RTOatnacmb9vgXDQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.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 imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 8260513A9A; Tue, 25 Jun 2024 10:19:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id PR/XH56ZemZ+WQAAD6G6ig (envelope-from ); Tue, 25 Jun 2024 10:19:10 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 02190A0957; Tue, 25 Jun 2024 12:19:09 +0200 (CEST) From: Jan Kara To: Cc: Andrew Morton , Matthew Wilcox , , Jan Kara Subject: [PATCH 07/10] readahead: Drop dead code in ondemand_readahead() Date: Tue, 25 Jun 2024 12:18:57 +0200 Message-Id: <20240625101909.12234-7-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240625100859.15507-1-jack@suse.cz> References: <20240625100859.15507-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2287; i=jack@suse.cz; h=from:subject; bh=uNQmjIDmbRqrgOgCnQp9TWHkJn+vXefHwUGc9G4atKs=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBmepmRD/ONRVBSq6jWi4Q/RKRyrz0CpCU34YA1tRUH XgUO4hyJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCZnqZkQAKCRCcnaoHP2RA2V5YCA CN7YjL+MmOOxmPo3WZp3x2ysmGA0VqwFNClS05kep1YLzxJZU1vur+K//frnsYZSNUsL5HwowaPz7E M8GLbyorUMoMLhl2uzW9Lt2yvwNeYJFI0A9Qm5omNEEicRYpodPu9BvNmubrJbxLFzg0SbjRdbQB7I jNP24eTOwdpa355UmJdxUbvypVjim8cgWvU/sGvePm7BbGgLmjGIuhFjB4D4pkOykjCdUaS4y64mvE u95uO41TEJdNTNpLrdFpz4uDB3qmC1iLOmgCvOqRH28W9o5el+AUeWT8s/wT6qn6vIPb3QrnxqQjrL M9534nEPUBagU+LyKPB/KkUOHeYZzx X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C X-Rspamd-Action: no action X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: DB13E180003 X-Stat-Signature: iy1rifmnqjrjzjxp1bzi8cn9n3wyqp5p X-Rspam-User: X-HE-Tag: 1719310751-864996 X-HE-Meta: U2FsdGVkX1+SYpVr+iyzuHAvYZTFNIa8b6LNKjFMigXJ80dMa3+PdtoUbKmTqDoIK9uxP7YVUDm/HKyLqbg/BxldGUhsj4ZtrC6ZQl9VnScjqUCmVKTgiHPKMg3aLLDBN2uOw2BPu3qIpSuVIsLICv3WURSFbH8EK2dQEflxCqyIw6KvM7RlTAUfq4kazGWVWbt5Jvhk1HgSHdPXFFon4xfiAx7GZ98tKHeeRHL/M7cdcwk3AwQ5uAyESdmWG5u0TgF0Sf9YGIY5AwgFR1rthN5xVQ8HR3hbkwrE1M9568G+GUp87aTNwRw5gDbGa4GKmydKAv+pOlQ9zCcycwCkmerZuZP3vp9hLrY6/wjZK9Dcg6wOE/ZZUbPeprRStpSVZQFGHxK22+BIYGHjOX1b0lZvj+npunQnYNXnHSpbUojiYmKIWuBpwBFsdxpyQSZbyegOD+TfMe57qW7n5kiwWtW9WDXsQan69HVPAXVoa6FoMtlw6sd0e+t6O95Q0kxG2XB8EbinNFqdGjLOhcY5zQwRHKRfY7SFL9nOu+NPGgkm2IxRftH/hXhlg1YDd169yrdVVUWZwvmbHzP9lHdDqsKsEajlM29eer5+UsIKXvIcleLWFa4dkJWWpg6Ug9rJijVxU+hcgH4PyOnOEi0Tfo1iwlPjh+CX8AePUqTeUozsq+WbTIdNTqxyh3rxgCGSNbrAevsLZYoCkR1PDhxmB7fLm78sfb4hsckAcmM/rUPZBlfpRnh4E6p7cOLOy3wLKfGl6XjSHrDibJ28P+S4djLDj5egTKr7fQwIVLq9v+g2BYM/j53PhENAsyZKUpvHiN1qI/Z+DgUwaUb7phaeDU17TbHuO8GChJEND0OTQWcOwceaGmkg2wLqVoJfx2bGDauWFXkJrolnCZmg1dcSsUzBBpj7yNrCCJSCZuOVYEqq5wY96lUx0GF3T8koEQd0xi2rAiQkMIIzwS3ZWTH +a04f1HW Fjt3MVBdzFJanZwnRwvUUdrrOdjkOwzXcP1aF1HM74ehHataBO88fiT0xpu9gS/uij+JhBwRyRL04DUq8HVPn3Wb5Sj4P8ls5Z8HC97hkl5eJBgKoXng7Xj2r4DRDJlWU0I86nHZJANbn8tjKMqTmb0SV8LHfqghRaaQ2ROYSEvEfuTuSgfsMydpEf6/lvbia8IJfOyN5R0TrWA6cKxJdYiQvKDlxY1eXEIm+VJYV4cus+aqGB4LEZsxMgmTAHyt4aT8E 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: ondemand_readahead() scales up the readahead window if the current read would hit the readahead mark placed by itself. However the condition is mostly dead code because: a) In case of async readahead we always increase ra->start so ra->start == index is never true. b) In case of sync readahead we either go through try_context_readahead() in which case ra->async_size == 1 < ra->size or we go through initial_readahead where ra->async_size == ra->size iff ra->size == max_pages. So the only practical effect is reducing async_size for large initial reads. Make the code more obvious. Signed-off-by: Jan Kara --- mm/readahead.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/mm/readahead.c b/mm/readahead.c index 9ea5125a0dce..d92a5e8d89c4 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -549,7 +549,6 @@ static void ondemand_readahead(struct readahead_control *ractl, struct backing_dev_info *bdi = inode_to_bdi(ractl->mapping->host); struct file_ra_state *ra = ractl->ra; unsigned long max_pages = ra->ra_pages; - unsigned long add_pages; pgoff_t index = readahead_index(ractl); pgoff_t expected, prev_index; unsigned int order = folio ? folio_order(folio) : 0; @@ -638,26 +637,10 @@ static void ondemand_readahead(struct readahead_control *ractl, initial_readahead: ra->start = index; ra->size = get_init_ra_size(req_size, max_pages); - ra->async_size = ra->size > req_size ? ra->size - req_size : ra->size; + ra->async_size = ra->size > req_size ? ra->size - req_size : + ra->size >> 1; readit: - /* - * Will this read hit the readahead marker made by itself? - * If so, trigger the readahead marker hit now, and merge - * the resulted next readahead window into the current one. - * Take care of maximum IO pages as above. - */ - if (index == ra->start && ra->size == ra->async_size) { - add_pages = get_next_ra_size(ra, max_pages); - if (ra->size + add_pages <= max_pages) { - ra->async_size = add_pages; - ra->size += add_pages; - } else { - ra->size = max_pages; - ra->async_size = max_pages >> 1; - } - } - ractl->_index = ra->start; page_cache_ra_order(ractl, ra, order); } From patchwork Tue Jun 25 10:18:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13710842 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 159C9C2BBCA for ; Tue, 25 Jun 2024 10:19:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B80CB6B01F3; Tue, 25 Jun 2024 06:19:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AB9806B01FE; Tue, 25 Jun 2024 06:19:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 49DE06B01F3; Tue, 25 Jun 2024 06:19:16 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id EA1B06B02F6 for ; Tue, 25 Jun 2024 06:19:14 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id A53FC1A1939 for ; Tue, 25 Jun 2024 10:19:14 +0000 (UTC) X-FDA: 82269013428.14.F7BD43E Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf05.hostedemail.com (Postfix) with ESMTP id 4B4FF100017 for ; Tue, 25 Jun 2024 10:19:12 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=g6XL5W2b; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=vdQLeaCI; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=g6XL5W2b; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=vdQLeaCI; spf=pass (imf05.hostedemail.com: domain of jack@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719310738; 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=+QN4nEN9WKE2t9Mr+WNlqEXF1yaaR/IE18O8y0vBXQ8=; b=uQonRdIf/W4WYCmcoXDQP0XHLeaAv+8Cv93eIDAJtk5SI+84/ajOku2T4dgG5Op1NpOCRt g7poMMM0JqGEQcwiPB47gX8XNYRQR9l6/2wEzg4lG8E1mP3JHF2FHW/W7GPM2MyFfy6Q9a cdTR+7GD5mpRmzzR0jp1OEXtjoQOurA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719310738; a=rsa-sha256; cv=none; b=WV9O9BTCL3YjrYCcf8kR0O5zwpxotpUducXjaWtAh6QEzSV7ngTLiQRMfkFfGnkW/M23Ez LTDdkfLoqKlgNXfReW9wBGjaCcT3QlfdtnaL2XEu+WdjdSwwIiP5r4XJku64CNDhelE5gc WCVBXabkBvhOxNGdVc6aBRBvQ7/RrvU= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=g6XL5W2b; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=vdQLeaCI; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=g6XL5W2b; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=vdQLeaCI; spf=pass (imf05.hostedemail.com: domain of jack@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (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 smtp-out2.suse.de (Postfix) with ESMTPS id AD8471F851; Tue, 25 Jun 2024 10:19:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1719310750; h=from:from:reply-to: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=+QN4nEN9WKE2t9Mr+WNlqEXF1yaaR/IE18O8y0vBXQ8=; b=g6XL5W2bx1lBimk/YVoIuBtM965nhwDCu2xk9Onv41jmFcbHqn9KuvihvDSSaLuHEowOJ2 /UN5aJGYMF4LA2+46i33DojSXDUa6jeXRssH/ht/bvel2vGoHwJD0U5xKGqdCY+Flcwreh S7zRmJNxULCDmjwdOhB7PKc68UFbZlQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1719310750; h=from:from:reply-to: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=+QN4nEN9WKE2t9Mr+WNlqEXF1yaaR/IE18O8y0vBXQ8=; b=vdQLeaCImos+Rr80rKGiS+1VVpK2XFb71QhEaeaFB/E7YvP4OYXu0EjLI7e+0o5rsVUNQh s0hkst8/4/1bojBA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1719310750; h=from:from:reply-to: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=+QN4nEN9WKE2t9Mr+WNlqEXF1yaaR/IE18O8y0vBXQ8=; b=g6XL5W2bx1lBimk/YVoIuBtM965nhwDCu2xk9Onv41jmFcbHqn9KuvihvDSSaLuHEowOJ2 /UN5aJGYMF4LA2+46i33DojSXDUa6jeXRssH/ht/bvel2vGoHwJD0U5xKGqdCY+Flcwreh S7zRmJNxULCDmjwdOhB7PKc68UFbZlQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1719310750; h=from:from:reply-to: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=+QN4nEN9WKE2t9Mr+WNlqEXF1yaaR/IE18O8y0vBXQ8=; b=vdQLeaCImos+Rr80rKGiS+1VVpK2XFb71QhEaeaFB/E7YvP4OYXu0EjLI7e+0o5rsVUNQh s0hkst8/4/1bojBA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.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 imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 8BCAA13AD9; Tue, 25 Jun 2024 10:19:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id zTIcIp6ZemaDWQAAD6G6ig (envelope-from ); Tue, 25 Jun 2024 10:19:10 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 0AA73A0958; Tue, 25 Jun 2024 12:19:10 +0200 (CEST) From: Jan Kara To: Cc: Andrew Morton , Matthew Wilcox , , Jan Kara Subject: [PATCH 08/10] readahead: Disentangle async and sync readahead Date: Tue, 25 Jun 2024 12:18:58 +0200 Message-Id: <20240625101909.12234-8-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240625100859.15507-1-jack@suse.cz> References: <20240625100859.15507-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=7472; i=jack@suse.cz; h=from:subject; bh=kzZAggEGB8nxww3IMybdnW/wrXAOWD0Xm8Cb8kJ8pv4=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBmepmSvtCyAHd7WRo5r/OLGFdaWl9D2kCzIBgqLdiE FKlKbk2JATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCZnqZkgAKCRCcnaoHP2RA2eLXB/ 0dO6bkv2zDY47lCTrKzJepiIL+qGydhiLaAQjXHcOGbE4kM8EnU8XQLHG5D+SfUNxo/nBCcqGAnyHC Jyi3YPBdfzpZuxcK7Yp8LckjSCPEe++CiPP5kJ8RSkAy1sf7srpMB7bezdySY1DTPVcuAKPW3UZzek gHUq0IyvUhMercFXtAd1A8VQdDi8z43l06WseCBgtK7Pw/kMFHFPHGdgedUfgsCwYaP7uzkAw/yBs2 cURzHIg5Q7/6xzNEAPoH6t7/E/3VAdnQZrJwaI9/VJzcby2Ujo6GCNyAslXUyeAZXyqlyXXdzUgVtI UT04cbN4zUManqKe7GMOhZQ5vimZDQ X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C X-Rspamd-Queue-Id: 4B4FF100017 X-Stat-Signature: xqp1g3dsrzd7yggyp6p97tsdek7ncj6q X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1719310752-910358 X-HE-Meta: U2FsdGVkX18S2R3Oy7OofOIMKdqHY8mg/7EYRanRkelvVYkm5WKCht5IbE6rRjafxhoh4I3bJrb513e/laxBEpmMfMnWnFt2PaiUqQHzfyt8UZTrdp0ZFLHVG/1+0SzhhbSE4pFfaBQYwmrhbYiYGkBa35AwOqt96b/t//EXgCkCw9yzztd5GhSMv0yQnexp7Ikfg/36L93uFhkx+HxQv9M4EYUmXRQ8Pqfxy8gZJrDJeHyPA1f1MsT1+04/JfCuNKYanxUc50DUCkjXoYQ4BlNYVIFxptiPG3fLSxDH+Rzqg+XVZsB510NoYqKFC7900BjBNTdSdn6sf2u71tFdP8hws31tAlVDiSzp2Z8bg0ifyl28KVNh7QIo9VseoIQTbvR5wh6p+iKbFeTZdI0mnL0m4YONr2GHXlA3T6JEHAHyRDT8Grkhdbzw2oHcOJFtzJkA18tKc2VQMLzc9hiLxdTyNtOhFF3rMuZqa3eEgOCskSumj6HqRoxbxOYAOOjm5Y8IgrC22je6GnKhdhaW88sixlhk3m3OmIgXtaPdJmOnaAp+HOA0seMDAHsL+9K05jANiT2C7O6471lTPBYm8QkvqmiywilBPqURD1bC/LBVa5yqmc5YFwqdWQFvhZ+o77uY8vpBB1aUTTWPQD9FrtggEzA4PLGddOkqNtXc9dLOHMLi3Ga4pz80K3zPhdqSaWbJAY/gKLkUYkCRpCEpEnbOubsbTGcSoqWCtZj2lHga/VtZ3Jz3MG2l0Hv1QpfHkr1NrqO9ndpUw/I5yUpxRH5zyt4xppIzaKQLK3MjHOINISF7KWzTugBthTUgRA564TSBXr3e+VYDzDp6YxPNdxU0gG1xnS940qgqONSwHe59jJsyse38VPmrbTMU0DnD1Xin4htBSGw0pn40axbbHORXhii9NtpwIEdUeFz3bwzgBa3ibNrB68vynFWgpKkbo5XxGW5pAILJIRIpdEq H+U+O+xf tPNPJWFEbHu20VXpO6QnUnJI0CfBHXfxCjWaOAGMq6O/anYLGjyw0tb5aS6lSU/ClSvIw/E9xneT8I/st+BQX9wBfEAueSi3KsBNg1pphj/709WNFSK5O5IW8OAazH3zu46c6eOvKw8kCzqI3xhXxQE9Q0UFDyYzmTt4TvgmDAdtKxlnkHXXDtYfOHMyU2isEpF24mf8QKfS7s3Zfmtb+8aNtJQ== 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: Both async and sync readahead are handled by ondemand_readahead() function. However there isn't actually much in common. Just move async related parts into page_cache_ra_async() and sync related parts to page_cache_ra_sync(). No functional changes. Signed-off-by: Jan Kara --- mm/readahead.c | 162 +++++++++++++++++++++++-------------------------- 1 file changed, 77 insertions(+), 85 deletions(-) diff --git a/mm/readahead.c b/mm/readahead.c index d92a5e8d89c4..a44daa12ebd2 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -540,18 +540,11 @@ void page_cache_ra_order(struct readahead_control *ractl, do_page_cache_ra(ractl, ra->size - (index - start), ra->async_size); } -/* - * A minimal readahead algorithm for trivial sequential/random reads. - */ -static void ondemand_readahead(struct readahead_control *ractl, - struct folio *folio, unsigned long req_size) +static unsigned long ractl_max_pages(struct readahead_control *ractl, + unsigned long req_size) { struct backing_dev_info *bdi = inode_to_bdi(ractl->mapping->host); - struct file_ra_state *ra = ractl->ra; - unsigned long max_pages = ra->ra_pages; - pgoff_t index = readahead_index(ractl); - pgoff_t expected, prev_index; - unsigned int order = folio ? folio_order(folio) : 0; + unsigned long max_pages = ractl->ra->ra_pages; /* * If the request exceeds the readahead window, allow the read to @@ -559,55 +552,42 @@ static void ondemand_readahead(struct readahead_control *ractl, */ if (req_size > max_pages && bdi->io_pages > max_pages) max_pages = min(req_size, bdi->io_pages); + return max_pages; +} - /* - * start of file - */ - if (!index) - goto initial_readahead; - - /* - * It's the expected callback index, assume sequential access. - * Ramp up sizes, and push forward the readahead window. - */ - expected = round_down(ra->start + ra->size - ra->async_size, - 1UL << order); - if (folio && index == expected) { - ra->start += ra->size; - ra->size = get_next_ra_size(ra, max_pages); - ra->async_size = ra->size; - goto readit; - } +void page_cache_sync_ra(struct readahead_control *ractl, + unsigned long req_count) +{ + pgoff_t index = readahead_index(ractl); + bool do_forced_ra = ractl->file && (ractl->file->f_mode & FMODE_RANDOM); + struct file_ra_state *ra = ractl->ra; + unsigned long max_pages; + pgoff_t prev_index; /* - * Hit a marked folio without valid readahead state. - * E.g. interleaved reads. - * Query the pagecache for async_size, which normally equals to - * readahead size. Ramp it up and use it as the new readahead size. + * Even if readahead is disabled, issue this request as readahead + * as we'll need it to satisfy the requested range. The forced + * readahead will do the right thing and limit the read to just the + * requested range, which we'll set to 1 page for this case. */ - if (folio) { - pgoff_t start; - - rcu_read_lock(); - start = page_cache_next_miss(ractl->mapping, index + 1, - max_pages); - rcu_read_unlock(); - - if (!start || start - index > max_pages) + if (!ra->ra_pages || blk_cgroup_congested()) { + if (!ractl->file) return; + req_count = 1; + do_forced_ra = true; + } - ra->start = start; - ra->size = start - index; /* old async_size */ - ra->size += req_size; - ra->size = get_next_ra_size(ra, max_pages); - ra->async_size = ra->size; - goto readit; + /* be dumb */ + if (do_forced_ra) { + force_page_cache_ra(ractl, req_count); + return; } + max_pages = ractl_max_pages(ractl, req_count); /* - * oversize read + * start of file or oversized read */ - if (req_size > max_pages) + if (!index || req_count > max_pages) goto initial_readahead; /* @@ -623,7 +603,7 @@ static void ondemand_readahead(struct readahead_control *ractl, * Query the page cache and look for the traces(cached history pages) * that a sequential stream would leave behind. */ - if (try_context_readahead(ractl->mapping, ra, index, req_size, + if (try_context_readahead(ractl->mapping, ra, index, req_count, max_pages)) goto readit; @@ -631,53 +611,31 @@ static void ondemand_readahead(struct readahead_control *ractl, * standalone, small random read * Read as is, and do not pollute the readahead state. */ - do_page_cache_ra(ractl, req_size, 0); + do_page_cache_ra(ractl, req_count, 0); return; initial_readahead: ra->start = index; - ra->size = get_init_ra_size(req_size, max_pages); - ra->async_size = ra->size > req_size ? ra->size - req_size : - ra->size >> 1; - + ra->size = get_init_ra_size(req_count, max_pages); + ra->async_size = ra->size > req_count ? ra->size - req_count : + ra->size >> 1; readit: ractl->_index = ra->start; - page_cache_ra_order(ractl, ra, order); -} - -void page_cache_sync_ra(struct readahead_control *ractl, - unsigned long req_count) -{ - bool do_forced_ra = ractl->file && (ractl->file->f_mode & FMODE_RANDOM); - - /* - * Even if readahead is disabled, issue this request as readahead - * as we'll need it to satisfy the requested range. The forced - * readahead will do the right thing and limit the read to just the - * requested range, which we'll set to 1 page for this case. - */ - if (!ractl->ra->ra_pages || blk_cgroup_congested()) { - if (!ractl->file) - return; - req_count = 1; - do_forced_ra = true; - } - - /* be dumb */ - if (do_forced_ra) { - force_page_cache_ra(ractl, req_count); - return; - } - - ondemand_readahead(ractl, NULL, req_count); + page_cache_ra_order(ractl, ra, 0); } EXPORT_SYMBOL_GPL(page_cache_sync_ra); void page_cache_async_ra(struct readahead_control *ractl, struct folio *folio, unsigned long req_count) { + unsigned long max_pages; + struct file_ra_state *ra = ractl->ra; + pgoff_t index = readahead_index(ractl); + pgoff_t expected, start; + unsigned int order = folio_order(folio); + /* no readahead */ - if (!ractl->ra->ra_pages) + if (!ra->ra_pages) return; /* @@ -691,7 +649,41 @@ void page_cache_async_ra(struct readahead_control *ractl, if (blk_cgroup_congested()) return; - ondemand_readahead(ractl, folio, req_count); + max_pages = ractl_max_pages(ractl, req_count); + /* + * It's the expected callback index, assume sequential access. + * Ramp up sizes, and push forward the readahead window. + */ + expected = round_down(ra->start + ra->size - ra->async_size, + 1UL << order); + if (index == expected) { + ra->start += ra->size; + ra->size = get_next_ra_size(ra, max_pages); + ra->async_size = ra->size; + goto readit; + } + + /* + * Hit a marked folio without valid readahead state. + * E.g. interleaved reads. + * Query the pagecache for async_size, which normally equals to + * readahead size. Ramp it up and use it as the new readahead size. + */ + rcu_read_lock(); + start = page_cache_next_miss(ractl->mapping, index + 1, max_pages); + rcu_read_unlock(); + + if (!start || start - index > max_pages) + return; + + ra->start = start; + ra->size = start - index; /* old async_size */ + ra->size += req_count; + ra->size = get_next_ra_size(ra, max_pages); + ra->async_size = ra->size; +readit: + ractl->_index = ra->start; + page_cache_ra_order(ractl, ra, order); } EXPORT_SYMBOL_GPL(page_cache_async_ra); From patchwork Tue Jun 25 10:18:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13710840 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 48B49C2BBCA for ; Tue, 25 Jun 2024 10:19:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4C35C6B01F7; Tue, 25 Jun 2024 06:19:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3E00B6B01FA; Tue, 25 Jun 2024 06:19:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C1FC06B02EF; Tue, 25 Jun 2024 06:19:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id AF2F26B02F3 for ; Tue, 25 Jun 2024 06:19:14 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 600F91417C7 for ; Tue, 25 Jun 2024 10:19:14 +0000 (UTC) X-FDA: 82269013428.04.779A446 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf22.hostedemail.com (Postfix) with ESMTP id 056F5C000D for ; Tue, 25 Jun 2024 10:19:11 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=JmDEVsny; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=xWktmHdd; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=JmDEVsny; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=xWktmHdd; dmarc=none; spf=pass (imf22.hostedemail.com: domain of jack@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=jack@suse.cz ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719310741; a=rsa-sha256; cv=none; b=dr5by6McKMZtGVOOF3lhkTQUYM/2MAedPraVjHbnNIwfsRzVeidX1AYcBLlTltNJz6kY3M o3UAbwR2SQQXHN77arB9l6Bct0oMxaPjcozO0s6febaDkNCV6fm2XqtXDNAZR13NFs3HZb HLmWAAKvXBYHf8D8qOgqt+gaNIQEapU= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=JmDEVsny; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=xWktmHdd; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=JmDEVsny; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=xWktmHdd; dmarc=none; spf=pass (imf22.hostedemail.com: domain of jack@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=jack@suse.cz ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719310741; 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=t1HXAqj4fgZF3IBo1CB4bn3i39dMk3y6JrzdfxQccxs=; b=W2hMry7Ohf9hk2lDERdHTDqKVF6o7c2K1hC+UHdA7VO63bNPWbMrO91u8gUN/jsvdduYi5 R8JT9Z3ndnxe/t9LdDg5+nJimxSAc+CTYo430pob5HkTIJG43OIixASut3Vn/gkQT1ZtKN lD6u9n2u+SCZ2kyPnu8cVXXrZ4aYXkE= Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (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 smtp-out2.suse.de (Postfix) with ESMTPS id 9AA5A1F850; Tue, 25 Jun 2024 10:19:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1719310750; h=from:from:reply-to: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=t1HXAqj4fgZF3IBo1CB4bn3i39dMk3y6JrzdfxQccxs=; b=JmDEVsnyYknVUA8/3NzWzbdFr1DvMcLwFTk51FWNZUb+5+ubt7ec2MOHPKj+l4uwoR09GG ucPE+ngfD5BDg/AaAyXUUgW2mBsj3Hb6cXwSozaSbXn7VgA0fmvFw+pEVLsZxRo7ZRs1on ltAagy5F+Tf/B8+HZP7UkqoyARUySV0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1719310750; h=from:from:reply-to: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=t1HXAqj4fgZF3IBo1CB4bn3i39dMk3y6JrzdfxQccxs=; b=xWktmHddUmOllDfb/XAwt8UC0TSzeT0lKN1u4Ub0oLuIeaLdYkC0YpAuszw7LfrBFiqCkq YUAW1W26baZgL0AA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1719310750; h=from:from:reply-to: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=t1HXAqj4fgZF3IBo1CB4bn3i39dMk3y6JrzdfxQccxs=; b=JmDEVsnyYknVUA8/3NzWzbdFr1DvMcLwFTk51FWNZUb+5+ubt7ec2MOHPKj+l4uwoR09GG ucPE+ngfD5BDg/AaAyXUUgW2mBsj3Hb6cXwSozaSbXn7VgA0fmvFw+pEVLsZxRo7ZRs1on ltAagy5F+Tf/B8+HZP7UkqoyARUySV0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1719310750; h=from:from:reply-to: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=t1HXAqj4fgZF3IBo1CB4bn3i39dMk3y6JrzdfxQccxs=; b=xWktmHddUmOllDfb/XAwt8UC0TSzeT0lKN1u4Ub0oLuIeaLdYkC0YpAuszw7LfrBFiqCkq YUAW1W26baZgL0AA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.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 imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 8E90213ADB; Tue, 25 Jun 2024 10:19:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 2mbNIp6ZemaEWQAAD6G6ig (envelope-from ); Tue, 25 Jun 2024 10:19:10 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 11A80A0959; Tue, 25 Jun 2024 12:19:10 +0200 (CEST) From: Jan Kara To: Cc: Andrew Morton , Matthew Wilcox , , Jan Kara Subject: [PATCH 09/10] readahead: Fold try_context_readahead() into its single caller Date: Tue, 25 Jun 2024 12:18:59 +0200 Message-Id: <20240625101909.12234-9-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240625100859.15507-1-jack@suse.cz> References: <20240625100859.15507-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3529; i=jack@suse.cz; h=from:subject; bh=1E7MXXKYPrw3MTlpAhRlnbE6/sd+3vrz3Oi0fWfrESc=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBmepmTxfL2AnX6xjFCTZIXemzzgVjcZY/mbaACqC9D b7l4ukeJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCZnqZkwAKCRCcnaoHP2RA2ULTCA C42Af5j1m3W6QOH/yr7+kHSYKnjj2QgCuJyEAbWwVKxOCcN0N+Olqw/+ZO6BVqISD2Q/SX/2YDQjtg whoRGFB4y2QbNjVofmkB2/cq7eSQ2oapnZf/6pVaZtb7teQuRHR0ID43l53sDCZlzl6YzWvaeEFozi rgrtmGjwY+Ve5HoBGdP6QpWfFuxepgabt5TPSFL2xz3rK5f8hE4VC5kASIC/0OoyjpXzNC0G3lOvcX xcJmK34oh6y2TjAKbnqw+8K/cliMtIvzPshjtC5jKg7HD31j4Y6bpC//o6MZIJdmGOdAK3++or2InK tQsfNhcns6P6G7J+UrQMQRGBFVFtFE X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C X-Rspamd-Action: no action X-Rspamd-Queue-Id: 056F5C000D X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: mc4ousepmctoymmhj8oxhrt75ak11o77 X-HE-Tag: 1719310751-388570 X-HE-Meta: U2FsdGVkX1/0Dq5BLOyBf5vlAcpaBlTqZVTuFleDlooYoddCX0IqBolQUz0xxR2buDuKO9hBnWXJGRZUQs/J/jZ3ZAuFckrHfatvi1FQ0jv+gQqrjh7qAPW6Ui96S5nh55Bp7Rd6CUjHnwhZpGAGbYc3RJBaqxCfe/et5xrjpuR571i1XaSiuVvpWhjZpxM9vT3d0j62OixMKc4EcVJ62S27ws6QiENpAYmaX4D3msH/eZthfO+CBJrbCvRcDyYPRQJ7pIaKjqbQ+Fu/vgZhx/WzLvTjw8HmWUum2lm0ZywMV15hj8qmDJs8Gw9PVTMvNm4BzejV7C7gcr2xbB1r4wa3r8CxZPjnsaA5b1JVqAXecNAJR/PvT5E0+/05YD2ElM6Rjyd/McVpN6mslcGAf/a6vutF+8Iq4OmUDf6zKHh+1SPSF6dcdaGWiX+ojh1QdghLaTqG8lNo2Q5PqKQSg9Z2Mga0CYEabvuJenSSF7yuGhAGm/Sz5zS1MdhI0k1SLvzyJOJXtWL3R2e0LBdjxZ3HYOf49X+J4Sfp2pspU13QHdomcubDVVnYLSZL3ldbomwgp61E3HHQrtRZzN3udkfasVGlv8oaFlKm71Ji4+s9dx2cIAJyYGprVQwZ5fKTqTIWitokD9ZKVMDsay8i7mgYq8LqkhjrFr65g13W2QHPSYpQvU790VUvwCmLejvfAA/8o+h78g69DX0RtkGlOUt/QVtlJKUCzYYQRk0YyzaeTqaZev5GWaoaG+FtttoFOgtWJDSUsdPyZbSkFtvLZYJGjKHshJvQWswYJANqUbiy8S6ykrm5Utdu1Zr+R01rGKqBhyCXclN2pcZsCXadT/xKhh6oAj8t8DVfRbdQ+dLXp4XeDF6Ew1KZteQIhWx55q1idk3ubVGJhHDME5E36MRqNBxBwHuZ2kd8b/C/hQdbvvfFZfH9DETuX5gTG72c6akug0qszmEiyR3W1T0 LUA9ZSDM DcdVJVFNFVvlCoNwNP81EceojovRHweCqr31zoPBlpVbQGDQd4ncOBjDxpJlTVliW7dSwxOTwXNzKUI7aD1j+NvoSHPCAERK/eFcxamPlq6p65XrHdoGSjsfGot9GIFC+t70hR8KoeKZ8XZubMcUIgNr2Zmw8YopJblUIwGX3tXO0J7ZnbkI4cgLuwXxxw1gH+6ZHaG8msDsO74DANHfkasDBVnPpAWOqxPoveX5dO9d4MH8WVdwczVrS82WfAaXWxW1M 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: try_context_readahead() has a single caller page_cache_sync_ra(). Fold the function there to make ra state modifications more obvious. No functional changes. Signed-off-by: Jan Kara --- mm/readahead.c | 84 +++++++++++++------------------------------------- 1 file changed, 22 insertions(+), 62 deletions(-) diff --git a/mm/readahead.c b/mm/readahead.c index a44daa12ebd2..12c0d2215329 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -410,58 +410,6 @@ static unsigned long get_next_ra_size(struct file_ra_state *ra, * it approaches max_readhead. */ -/* - * Count contiguously cached pages from @index-1 to @index-@max, - * this count is a conservative estimation of - * - length of the sequential read sequence, or - * - thrashing threshold in memory tight systems - */ -static pgoff_t count_history_pages(struct address_space *mapping, - pgoff_t index, unsigned long max) -{ - pgoff_t head; - - rcu_read_lock(); - head = page_cache_prev_miss(mapping, index - 1, max); - rcu_read_unlock(); - - return index - 1 - head; -} - -/* - * page cache context based readahead - */ -static int try_context_readahead(struct address_space *mapping, - struct file_ra_state *ra, - pgoff_t index, - unsigned long req_size, - unsigned long max) -{ - pgoff_t size; - - size = count_history_pages(mapping, index, max); - - /* - * not enough history pages: - * it could be a random read - */ - if (size <= req_size) - return 0; - - /* - * starts from beginning of file: - * it is a strong indication of long-run stream (or whole-file-read) - */ - if (size >= index) - size *= 2; - - ra->start = index; - ra->size = min(size + req_size, max); - ra->async_size = 1; - - return 1; -} - static inline int ra_alloc_folio(struct readahead_control *ractl, pgoff_t index, pgoff_t mark, unsigned int order, gfp_t gfp) { @@ -561,8 +509,8 @@ void page_cache_sync_ra(struct readahead_control *ractl, pgoff_t index = readahead_index(ractl); bool do_forced_ra = ractl->file && (ractl->file->f_mode & FMODE_RANDOM); struct file_ra_state *ra = ractl->ra; - unsigned long max_pages; - pgoff_t prev_index; + unsigned long max_pages, contig_count; + pgoff_t prev_index, miss; /* * Even if readahead is disabled, issue this request as readahead @@ -603,16 +551,28 @@ void page_cache_sync_ra(struct readahead_control *ractl, * Query the page cache and look for the traces(cached history pages) * that a sequential stream would leave behind. */ - if (try_context_readahead(ractl->mapping, ra, index, req_count, - max_pages)) - goto readit; - + rcu_read_lock(); + miss = page_cache_prev_miss(ractl->mapping, index - 1, max_pages); + rcu_read_unlock(); + contig_count = index - miss - 1; /* - * standalone, small random read - * Read as is, and do not pollute the readahead state. + * Standalone, small random read. Read as is, and do not pollute the + * readahead state. */ - do_page_cache_ra(ractl, req_count, 0); - return; + if (contig_count <= req_count) { + do_page_cache_ra(ractl, req_count, 0); + return; + } + /* + * File cached from the beginning: + * it is a strong indication of long-run stream (or whole-file-read) + */ + if (miss == ULONG_MAX) + contig_count *= 2; + ra->start = index; + ra->size = min(contig_count + req_count, max_pages); + ra->async_size = 1; + goto readit; initial_readahead: ra->start = index; From patchwork Tue Jun 25 10:19:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13710843 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 82ADEC2BBCA for ; Tue, 25 Jun 2024 10:19:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 256546B02F6; Tue, 25 Jun 2024 06:19:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1E0AC6B02FC; Tue, 25 Jun 2024 06:19:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E895B6B02F6; Tue, 25 Jun 2024 06:19:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id BDBA56B02F2 for ; Tue, 25 Jun 2024 06:19:17 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 7DA251C33AE for ; Tue, 25 Jun 2024 10:19:17 +0000 (UTC) X-FDA: 82269013554.06.2AD33C9 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf20.hostedemail.com (Postfix) with ESMTP id 426C91C0016 for ; Tue, 25 Jun 2024 10:19:14 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=GDIuGNll; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=VDTO+LRc; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=GDIuGNll; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=VDTO+LRc; spf=pass (imf20.hostedemail.com: domain of jack@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719310736; 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=vyxwvvsZ7JcW5Bl3ExPGCArwxKk1bgXwcn4XRHBgVco=; b=weTbVZK5Y0bAbD6XQPkiA9e9SYnjqaiaH5abAs1b+HFCbtVlqQCmwnLBq/W44fQMfcW2PD YfvQslKmVfgAYwYCB2bTJk7hBP2yLdxUNzQOidpAy+Dc2v64vH1nU1aQSn6Z5Ds8YIPvb3 LmGaABa0pwvONmu0VOYDSCA36H/qYS8= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=GDIuGNll; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=VDTO+LRc; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=GDIuGNll; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=VDTO+LRc; spf=pass (imf20.hostedemail.com: domain of jack@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719310736; a=rsa-sha256; cv=none; b=sh9f06l+rWsxl3NMrvytX3+v0b68xXJYbzfvQFks6NdjCRbhk+MSrbxY7WR4X6zdleFmrS dTB/KNCDcZSKYVCj44vJ/ZRXoZ3zAtcGzq6/q6HOELXn7YOpWabvroeBWHyX3AMLzs2cHG 1iGjDsDpFC/+2xXmYetRdUQqEd6rthY= Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (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 smtp-out1.suse.de (Postfix) with ESMTPS id 9A0FB21A79; Tue, 25 Jun 2024 10:19:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1719310750; h=from:from:reply-to: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=vyxwvvsZ7JcW5Bl3ExPGCArwxKk1bgXwcn4XRHBgVco=; b=GDIuGNll6Qe2PeuRVsfKphDYbItj3AF5g43txEQCUQJAggZ6VXUKHHY9bZ+gjMr0yY+GbI 84qjRTOGYMW7tJYx9O8On/Hr4C6H5HGwZNYJh8AeeCGpo6BSXa6XpwI3TC56DJ9C30Yhau 7dz3o12FaNDLe8XcftJwZ+VT9nQNvb0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1719310750; h=from:from:reply-to: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=vyxwvvsZ7JcW5Bl3ExPGCArwxKk1bgXwcn4XRHBgVco=; b=VDTO+LRc94g0SdBAa/BekynpkCYovk3M7Lh9FdpVcOjuso/mEHBO7mhbuyV1D8UlapQz14 poFwR1XOAms4beAQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1719310750; h=from:from:reply-to: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=vyxwvvsZ7JcW5Bl3ExPGCArwxKk1bgXwcn4XRHBgVco=; b=GDIuGNll6Qe2PeuRVsfKphDYbItj3AF5g43txEQCUQJAggZ6VXUKHHY9bZ+gjMr0yY+GbI 84qjRTOGYMW7tJYx9O8On/Hr4C6H5HGwZNYJh8AeeCGpo6BSXa6XpwI3TC56DJ9C30Yhau 7dz3o12FaNDLe8XcftJwZ+VT9nQNvb0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1719310750; h=from:from:reply-to: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=vyxwvvsZ7JcW5Bl3ExPGCArwxKk1bgXwcn4XRHBgVco=; b=VDTO+LRc94g0SdBAa/BekynpkCYovk3M7Lh9FdpVcOjuso/mEHBO7mhbuyV1D8UlapQz14 poFwR1XOAms4beAQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.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 imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 8E8CE13ADA; Tue, 25 Jun 2024 10:19:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 1ZjMIp6ZemaFWQAAD6G6ig (envelope-from ); Tue, 25 Jun 2024 10:19:10 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 19B82A095B; Tue, 25 Jun 2024 12:19:10 +0200 (CEST) From: Jan Kara To: Cc: Andrew Morton , Matthew Wilcox , , Jan Kara Subject: [PATCH 10/10] readahead: Simplify gotos in page_cache_sync_ra() Date: Tue, 25 Jun 2024 12:19:00 +0200 Message-Id: <20240625101909.12234-10-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240625100859.15507-1-jack@suse.cz> References: <20240625100859.15507-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1867; i=jack@suse.cz; h=from:subject; bh=Bu7YUmZoT9vACQSaTZDW2SetomtAJn73UDFWVLSHt8E=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBmepmUjRLlwaM3NNckyBBmL/c1D6Ha48fvdYE17Sg7 YsrS5YCJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCZnqZlAAKCRCcnaoHP2RA2djbCA DfC3XEexGDrUgHi3trjPNNDxHxAd2Pva0wrWmypURWj66YlO7SJWQpMNasQ2bKT9dqrU14g+aQdOtM ywVLaQ89uqqhzMyYqN2QD7GWOJhPsAnmjiDF0HoGOb4kjYN1xw8cDvsXeRHBrvTZk33sducrLHSQ3d uPmmSNSQt7JMFIerXvN0yyWyTJIIJmkdgio0e/Y5bR0C+ftUFk5bI7hZaBu74XjehHu6ZkCCzLv1Fn xfdbJ6zFIi1KAjYcd82rXzJdRbit6boVBpqlf8W4tMlaG2m9qhkM8nWwC3QvkSEODq4U6f2nwlkQm2 Lhs8n/XI7CFY64o2ljZ6XcCcF7PvIo X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C X-Rspamd-Action: no action X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 426C91C0016 X-Stat-Signature: oinsb4oof8mk3sk4homupfxuwszw9r9d X-Rspam-User: X-HE-Tag: 1719310754-850451 X-HE-Meta: U2FsdGVkX1/c8aVlRv+aFCU2UGgq8cIQehEphb/IXjmkYzGCPM+l340JSkUNjXj92TliVQNyN4doKYbKwGxw0JVd721IJq8FYKeM8Zdhmw5kMu1EfI1T3xQjX6cMW+fOszd1Nfz5/a1Ldz3VwlqqjMlQR709E/H2qDv6VyBxQwUG5JIUXhaMJe+VuZCfied80T8nLR2EgMVQ6FPaNTj8cqcUEfz3YkEawUdE7J91kSXdzNw3PwGyAqchExlzH1FYA3tNUJf6TYAPnb7TyGXs+TJarjgNCHlrPBSmm5vjXFjAPBz5TYv4pCvErH4qgTNlXMdF/zjEpSejFzXSC8fEa88JULJE6c1UDKfm7n+InR8je9UQn9IrvsBD78WejAH9ztL9gIO9LVkMkZClBJbPC1mwJhLA16SYKLyEXT8/4jVpskoxMyk/RMOb1cit2JMmt/5b37cgcdiPiSri/EKLSJ3Ho6jSQx0MfdGccXNuwipwe4cbmEdPTWIWWiUgDPWHQAIDS+ewsgyOZBP6dreJv8JfF+Vtq4qlZI/YURWXxGwEDg7Dr72DT072EK3iUTrFSPMijANAiQCCTTTRnf1yFIU/MJ1MfMmQ117iRBxX0CvIrBeAEi6ZbVd9pS3H4mXOMWEJ0i3wOwNJG9SKM3wpD0lg4qTim1xOLBiCAWNYD+rlMBRnpr03XBFh9zy4bglxVKDvXbOvADl+QEIRKALDOMr8SR3EwuoNIXmQIkY/PuS4RQXeweMyQLcaOQV47oAo2BvjT4CtJ1nJTN4gOwSbdleSjrqdy259IfS45jqDc9RMfzm5+ej1BQxSqyyQ6vUKMOkoNoQdkod/9JKxIV16jtec5JWzcHPQOoVmkgbXQGRjXLnMCB5L86AzshcA1ocOSGzZpiTZeeTxERAi+r+/dknhQW9TpNyD9yU5zBH8s1VzoaaCFUiwqtzr6NUVONKFTmYarL+j0hco+HHaJcQ H7zaU3hg NX4VQmbrGQYp5wRsgifyrN1yNM0fyT8Hw58roEEsgNKjtT69HhVq8MOE8tjnDCnqmWHLG+Q1ECgX+g9FhbC0Rltc6NjybpZNGLVi8WYiau5mT24TJyUg9GdnYS+/VlcSo369VHMBKlgvB0hfMvEStm4seJMjechBGxfqYYEnbGnxbK6nN8MTGoX+QPt794lMtV2xDbpMkHtVsjhqjuCxRPhPE3X2JcCwe8Jdo1wDY35V4TtEvHDdmMTfzCEopos3UxxZJ 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: Unify all conditions for initial readahead to simplify goto logic in page_cache_sync_ra(). No functional changes. Signed-off-by: Jan Kara --- mm/readahead.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/mm/readahead.c b/mm/readahead.c index 12c0d2215329..d68d5ce657a7 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -532,20 +532,19 @@ void page_cache_sync_ra(struct readahead_control *ractl, } max_pages = ractl_max_pages(ractl, req_count); + prev_index = (unsigned long long)ra->prev_pos >> PAGE_SHIFT; /* - * start of file or oversized read - */ - if (!index || req_count > max_pages) - goto initial_readahead; - - /* - * sequential cache miss + * A start of file, oversized read, or sequential cache miss: * trivial case: (index - prev_index) == 1 * unaligned reads: (index - prev_index) == 0 */ - prev_index = (unsigned long long)ra->prev_pos >> PAGE_SHIFT; - if (index - prev_index <= 1UL) - goto initial_readahead; + if (!index || req_count > max_pages || index - prev_index <= 1UL) { + ra->start = index; + ra->size = get_init_ra_size(req_count, max_pages); + ra->async_size = ra->size > req_count ? ra->size - req_count : + ra->size >> 1; + goto readit; + } /* * Query the page cache and look for the traces(cached history pages) @@ -572,13 +571,6 @@ void page_cache_sync_ra(struct readahead_control *ractl, ra->start = index; ra->size = min(contig_count + req_count, max_pages); ra->async_size = 1; - goto readit; - -initial_readahead: - ra->start = index; - ra->size = get_init_ra_size(req_count, max_pages); - ra->async_size = ra->size > req_count ? ra->size - req_count : - ra->size >> 1; readit: ractl->_index = ra->start; page_cache_ra_order(ractl, ra, 0);