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: 13710830 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F256314A09F for ; Tue, 25 Jun 2024 10:19:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719310755; cv=none; b=N5jcWGPmNJ9KghNwPlkuwGTeivCsJlCSk05QK2iYee4EhWFmr6HsHh1JaGImtctnzNiKMrV+zsptE5RqlUAY03i34wcUUmMoreLlRgjBP2CJ0eQOcukb99xejDVpDfeKmt/4wXjzOFJxdc7QqWn0im+EH7rsL1CogtkQ6GzBxRI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719310755; c=relaxed/simple; bh=2BByd5Qz40KJgLPQa4CRJHADLoyluDt7OXYy5Vc5KU8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Am1vyP5HteqlQduVpFUo+1c3KNxlebQAjbNwxAsaJ3SKE0mYs7mTYxRn+33acwXkUytzytmsPUC3EXHfURbrSv3AaqPoOtkeO6A++MfV2RkME5775jNc9B/C4CD5D0z1I34ZsBPn4ajoTFl5s3TD/AGoMKwCCFfGFqSfXECYDGw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=ikWfKa8b; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=IeaEZuPh; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=ikWfKa8b; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=IeaEZuPh; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="ikWfKa8b"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="IeaEZuPh"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="ikWfKa8b"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="IeaEZuPh" 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== Authentication-Results: smtp-out1.suse.de; 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-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> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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-Queue-Id: 3311F21972 X-Spam-Score: -3.01 X-Spam-Level: X-Spam-Flag: NO X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_THREE(0.00)[3]; RCPT_COUNT_FIVE(0.00)[5]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; DWL_DNSWL_BLOCKED(0.00)[suse.cz:dkim]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:email,suse.cz:dkim,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; RCVD_TLS_LAST(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.cz:+] X-Rspamd-Action: no action X-Rspamd-Server: rspamd1.dmz-prg2.suse.org 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: 13710829 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F260E14A0AA for ; Tue, 25 Jun 2024 10:19:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719310754; cv=none; b=C4asBrfc9JTI6xA9S7gFOqJm8xQ0KuxxL9/TbkrIsTeyvmmr6AgtiihoBLY4IEkfQs5iJa/y6LpPF6ClgIce8BiVWO1vNx+QixS5of6LqXtXz0J4dOVoVPSQu/aCGVnyqvDWhuMdWDDrEjzGYchOPxJyG4dKXNv7i1opO15+eQQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719310754; c=relaxed/simple; bh=lEGZ9ceRJWeyyjOzqii5re2SDGP3X5uqvnDqu1Uy374=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=kxvbbM3yvwiwNzNPrZNaSUGYzUAPg6WuuWDne3rMFKTFI3Y5bRsSCQVc6TSN7y6LPQfHVGkyq1qYAbAXhUUtsC+g3caZNIjYrxrldGwCr2QR1BQ9A1X5hAKyd7IPW5vcpJSzHZYXv5QssuJI2n0QsOSy5+b9ELIH0m/tLrPi2pI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=CPRQuFTH; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=LSKvBC6Y; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=CPRQuFTH; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=LSKvBC6Y; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="CPRQuFTH"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="LSKvBC6Y"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="CPRQuFTH"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="LSKvBC6Y" 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== Authentication-Results: smtp-out1.suse.de; none 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> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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-Spam-Score: -0.10 X-Spam-Level: X-Spam-Flag: NO X-Spamd-Result: default: False [-0.10 / 50.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; BAYES_HAM(-0.30)[75.00%]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; TO_DN_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_FIVE(0.00)[5]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:email,imap1.dmz-prg2.suse.org:helo] 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: 13710823 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E8D0E14A089 for ; Tue, 25 Jun 2024 10:19:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719310753; cv=none; b=mpNzxZ5MaxxU7RrioxrbaQN3neRgKfByhElsHgDic0+GSmx9qJo3Poe7tnXHtPoF7xq44veOc5RWT5u0GMPgmFLYDuB4CqBdyrhRloX8/oZL83eaTcUwUKh5QUHzmzUfpmlsRanClpuDL0r1ObFlZr0UdyiRZqzUYnOeiF7SuPw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719310753; c=relaxed/simple; bh=m/qJzAdNjRqtXAPnSZNOsBtxQm5ctHdoj1WYBPZKGcs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Ri8WrdnWPfdfQjyMPeAyPRZu44f9wqc5q90vo7zVObOPw5j9gfbcU/4Wxr4g80nOw5JpFGwEBvlkWNReCOoETNWJTryw5bFndCuuAapLS01SWyMNtnfaz5HrIO6F+Z6++lHPiRjAj0rN8HQpDzKfemsUvb0xzw1seaYzovoRFdA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=X1oBWrVg; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=ddLvbEk0; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=X1oBWrVg; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=ddLvbEk0; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="X1oBWrVg"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="ddLvbEk0"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="X1oBWrVg"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="ddLvbEk0" 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== Authentication-Results: smtp-out1.suse.de; 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-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> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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-Spamd-Result: default: False [-1.70 / 50.00]; BAYES_HAM(-1.69)[93.06%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_SOME(0.00)[]; RCVD_TLS_LAST(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_EQ_ENVFROM(0.00)[]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:email,suse.cz:dkim,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; RCVD_COUNT_THREE(0.00)[3]; RCPT_COUNT_FIVE(0.00)[5]; DKIM_TRACE(0.00)[suse.cz:+] X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: 4314121A74 X-Spam-Flag: NO X-Spam-Score: -1.70 X-Spam-Level: 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: 13710822 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E8D5414A08B for ; Tue, 25 Jun 2024 10:19:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719310753; cv=none; b=WtyxPbWTrOlD9ecSViEj9U3J/Wjz99u2V7WIruT6XyfIdCMFx6HxCgYiE+bfRkEnMwaUmsZAIUZuDk+J7kdQEDek8o2P7CYzX4p903MUxXp2clI3+qKWlyBmH+YRByZTXK47exHros7rg1qLGJDtQBjqBjr+EnKOMyL6BGQ3MNM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719310753; c=relaxed/simple; bh=YMGuebUrm0qSfydyCid1z7UHFeUsV68V8mO59Irwxfg=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=cbO6PlqjSbf5jTdxv9PzwT6t/6q57LZuK7xHAAxOBguKb8mAGd/KEIfyXyrOcKA/UQEXfHqAHvDbpQBRZoy9tbt7rasPSSJNibRQHOlCLVLCUf/zAsFRU2JWQq5xyPIgjMU2be7OR0fYpzVg8c/PxV/OxV/YsCtyPCzlNtkKPcA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=rE8i5kNl; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=oE0xVS7g; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=rE8i5kNl; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=oE0xVS7g; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="rE8i5kNl"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="oE0xVS7g"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="rE8i5kNl"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="oE0xVS7g" 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== Authentication-Results: smtp-out1.suse.de; none 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> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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-Spamd-Result: default: False [-2.60 / 50.00]; BAYES_HAM(-2.80)[99.12%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; TO_DN_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_FIVE(0.00)[5]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.cz:email] X-Spam-Flag: NO X-Spam-Score: -2.60 X-Spam-Level: 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: 13710825 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 46B6214A0B9 for ; Tue, 25 Jun 2024 10:19:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719310754; cv=none; b=G5dvM0Oi9jIV+6l6r1XdO2JOMOZXie6ntQ6H0MFi/qo8PQnzqB3pBT9qjbEqG3tjBf14+C3FnHOzrAjdl7VhYEFC/92vZdlRMtUYHfoNHOcY0QpuFAQD6EXgjKvldkmsBHpMy1YPD/FlBT/O4XE8opI3Na5YW5EHOUUV89Ni9E4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719310754; c=relaxed/simple; bh=YaPpgDx+Qmuj6I/gWcDPw0IJuohKdGqM4cxIZra6ocM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CEexVzigsCkvfPoChJxlpUeFDKc6nDDyl9fc5hTqr7/rz2fhQ/5lJeLmCK9i3QjS1V+406eKPe2WWUi2dFiktmibx/vdZoQPwu65W/BEKCk2sYZkOVX/rbUMDuQZP++5V9RIUjYxBo7vur7mNKfMDgr9Nr+LbbkU3FigsqCtOgk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=aLbP/MM9; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=npRodn1v; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=aLbP/MM9; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=npRodn1v; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="aLbP/MM9"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="npRodn1v"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="aLbP/MM9"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="npRodn1v" 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== Authentication-Results: smtp-out1.suse.de; 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-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> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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-Queue-Id: 9038321A78 X-Spam-Score: -3.01 X-Spam-Level: X-Spam-Flag: NO X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_THREE(0.00)[3]; RCPT_COUNT_FIVE(0.00)[5]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; DWL_DNSWL_BLOCKED(0.00)[suse.cz:dkim]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:email,suse.cz:dkim,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; RCVD_TLS_LAST(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.cz:+] X-Rspamd-Action: no action X-Rspamd-Server: rspamd1.dmz-prg2.suse.org 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: 13710831 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5999214A0BD for ; Tue, 25 Jun 2024 10:19:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719310756; cv=none; b=FBUl3l48n6jtTz65qCdbcW9Iarju955IaewMOuSGPimUZ0ZbEWfnQV1K7XrssrmexgQj0Fre4fI3BeWJRWH0VMuEYMHXqRGr4qyXOa14el8GHxGqv7NXNKQZ6vf2NDgTzapDli9PnJQWR+Bg4aGm3USuuJ5zukQ1klDiw8Fc4+I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719310756; c=relaxed/simple; bh=W6XufS+irzkVLcuC4WuSgVtbQbyLhmOcwBflH4kmDVk=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=gZkavu36gdOZufImcc+aOP32QBAAfddgtVW+OP3dJ3Q7/ueAHt/0ZtaF0S8wE2ySCl3kFCkxkoAYOBPnpTpkrmJcxtp9Nnk6nBezKlIHyiavBRVabVc+kKgelJe7EOLLH4/JEdykWPh8+r33udnVeDFZ8TULn2GTdG3N4kd8QiY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=kBPyOTV0; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=xWW1KRCc; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=kBPyOTV0; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=xWW1KRCc; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="kBPyOTV0"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="xWW1KRCc"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="kBPyOTV0"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="xWW1KRCc" 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== Authentication-Results: smtp-out2.suse.de; none 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> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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-Spamd-Result: default: False [-2.44 / 50.00]; BAYES_HAM(-2.64)[98.40%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; TO_DN_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_FIVE(0.00)[5]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.cz:email] X-Spam-Flag: NO X-Spam-Score: -2.44 X-Spam-Level: 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: 13710826 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B01114A0BF for ; Tue, 25 Jun 2024 10:19:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719310754; cv=none; b=FVEGfMkReoVfGgdnhJfORRAbIqOJ83YXK0RDJn4GXz8pGJu85XA6MBN7N/9eub+SBzta/mVJv7eN9HtTmGgIwzYa6HSKSKBCy3AwkrgE0i+ZznjFTGfUoPT5DycpoQh7BU5sDKmf/YpDFjTWw0a+5ebzuIVUp3/Ur03LIl8opTE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719310754; c=relaxed/simple; bh=uNQmjIDmbRqrgOgCnQp9TWHkJn+vXefHwUGc9G4atKs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=DbA/Wh++XXB0pO5ulr+Ip2IiXp5ld72h8xHJEuO9mlx2KKD/h47iyv/epG74lMph9zLj9//WWveHV8Enfpyw4y9gHUCMa0NXTn9L2qg08VVLzrqZjbCSbKsMtAiRKJfOqFaM/xnI9MzTTe1ffRcBH5kVvMnQzWglQJWfZKu8Cn4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=GWFhszbJ; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=mBATL9t0; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=GWFhszbJ; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=mBATL9t0; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="GWFhszbJ"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="mBATL9t0"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="GWFhszbJ"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="mBATL9t0" 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== Authentication-Results: smtp-out2.suse.de; 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-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> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_SOME(0.00)[]; RCVD_TLS_LAST(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_EQ_ENVFROM(0.00)[]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.cz:email,suse.cz:dkim]; RCVD_COUNT_THREE(0.00)[3]; RCPT_COUNT_FIVE(0.00)[5]; DKIM_TRACE(0.00)[suse.cz:+] X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: 97CBD1F84F X-Spam-Flag: NO X-Spam-Score: -3.01 X-Spam-Level: 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: 13710827 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 67B3C14A4C7 for ; Tue, 25 Jun 2024 10:19:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719310754; cv=none; b=bjjcl+Y/aVQTn5gGwL7nY/bQy2jx5Ww7rrVdruH7rPygvVf2Nen2EBJiLC2GVqhcErDOxebOPjQ5w1ujs3CzuV9F916gtI4/DPKYHRrnpdTAEdxMy5dKvHlmfVFruyQgpqF9RYvdJXTXfqHJuU8kctF1KTk78D4VxGKEGEzQ+Z4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719310754; c=relaxed/simple; bh=kzZAggEGB8nxww3IMybdnW/wrXAOWD0Xm8Cb8kJ8pv4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=P0neKwCvxbBGPmi0RhScoL9Xin3LqbVUHy0f0ydKxUdCepM6Ko5aHvK3wZpHugMTbi2Q/fEVy32a/ypE1P0ZqsNyrvwtS5DQZpri4HGBlc18n1cYSTnq0XKWCGV58KqJCOPXPRGLz8hYpR7iGUUq5mXTYYlWKmEAPTtZu6Bsvwg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=g6XL5W2b; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=vdQLeaCI; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=g6XL5W2b; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=vdQLeaCI; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="g6XL5W2b"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="vdQLeaCI"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="g6XL5W2b"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="vdQLeaCI" 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== Authentication-Results: smtp-out2.suse.de; none 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> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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-Spam-Score: -2.80 X-Spam-Level: X-Spam-Flag: NO X-Spamd-Result: default: False [-2.80 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; RCVD_COUNT_THREE(0.00)[3]; TO_DN_SOME(0.00)[]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_FIVE(0.00)[5]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:email,imap1.dmz-prg2.suse.org:helo] 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: 13710828 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5C5A014A4C0 for ; Tue, 25 Jun 2024 10:19:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719310754; cv=none; b=L3Q06CxOYzt9JiQbc4/w/ms3jfab6vXDjUqcbYT1nxij5MGJj9kmKnsWp6Gwv5uuSnDnFgOe4PjzoVcXXEPUv/y20RPve2PmB8e7Pxtr+iyl0F6De4T2/c+ueZs8y0BcJS9Kk9Wy4mQkrBa6mogWnC4Xsgql9HAH8K0R4fu73tA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719310754; c=relaxed/simple; bh=1E7MXXKYPrw3MTlpAhRlnbE6/sd+3vrz3Oi0fWfrESc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lgm6L0lEBs6kOIbUK2zEQPgDlAfEnQxKNc5XCnH05m6vcCGp+PEJBczLgt590pz6m7if0qerjWNJqL2/nrILMTEmUeY2vFrDMBEg3zMIFmWoG0OD/F/yZEdNWMKpQoLl1hnOX1X/BQ3Js8u0O6gkuGe9tNljVo9qSaBwd77s3BM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=JmDEVsny; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=xWktmHdd; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=JmDEVsny; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=xWktmHdd; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="JmDEVsny"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="xWktmHdd"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="JmDEVsny"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="xWktmHdd" 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== Authentication-Results: smtp-out2.suse.de; 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-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> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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-Queue-Id: 9AA5A1F850 X-Spam-Score: -3.01 X-Spam-Level: X-Spam-Flag: NO X-Spamd-Result: default: False [-3.01 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_THREE(0.00)[3]; RCPT_COUNT_FIVE(0.00)[5]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; DWL_DNSWL_BLOCKED(0.00)[suse.cz:dkim]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns,suse.cz:email,suse.cz:dkim]; RCVD_TLS_LAST(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.cz:+] X-Rspamd-Action: no action X-Rspamd-Server: rspamd1.dmz-prg2.suse.org 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: 13710832 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4EC4714B07C for ; Tue, 25 Jun 2024 10:19:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719310756; cv=none; b=RlBwhm0hi5/qmJI1+sA7p59yhRkoEC8TLFsNKSxcF0YgDrFLQ+LoYiF0wX68HUdlnwlsTk5gqOflSIaMljmsNooXb+qVwG9tly+hGbj8cOCwe4xLW7DxVVATfijlHVfOddAFhcBjZ8aoVsu24Mpv70kEbE0jbL7hufseP+csfeA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719310756; c=relaxed/simple; bh=Bu7YUmZoT9vACQSaTZDW2SetomtAJn73UDFWVLSHt8E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QPz0M0yiGN32tiX4frMvlOSm4/pH571o2sNP8SNxMlC+YrPiYCfzMWqIZxwW2aFelmq0SJkQ/FAMUIxBKTndj/OxKPVb04wjnNJkEdcHG9rxNKiHMh9/Lh0/gwP2i/LqjtLYPQUJtQOdfqwTPpnN4VOD2lRdhP3R9WNl+9RC8Uo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=GDIuGNll; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=VDTO+LRc; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=GDIuGNll; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=VDTO+LRc; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="GDIuGNll"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="VDTO+LRc"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="GDIuGNll"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="VDTO+LRc" 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== Authentication-Results: smtp-out1.suse.de; 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-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> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: 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-Spamd-Result: default: False [-2.89 / 50.00]; BAYES_HAM(-2.88)[99.49%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; R_DKIM_ALLOW(-0.20)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:97:from]; TO_DN_SOME(0.00)[]; RCVD_TLS_LAST(0.00)[]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:97:from]; FROM_EQ_ENVFROM(0.00)[]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.cz:email,suse.cz:dkim,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; RCVD_COUNT_THREE(0.00)[3]; RCPT_COUNT_FIVE(0.00)[5]; DKIM_TRACE(0.00)[suse.cz:+] X-Rspamd-Action: no action X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Queue-Id: 9A0FB21A79 X-Spam-Flag: NO X-Spam-Score: -2.89 X-Spam-Level: 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);