From patchwork Tue Jun 25 10:18:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13710841 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E071C30653 for ; Tue, 25 Jun 2024 10:19:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 875386B01F5; Tue, 25 Jun 2024 06:19:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 70F1B6B01F8; Tue, 25 Jun 2024 06:19:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 16B4D6B01F5; Tue, 25 Jun 2024 06:19:15 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id CC0716B02EE for ; Tue, 25 Jun 2024 06:19:14 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 8E5C1417EB for ; Tue, 25 Jun 2024 10:19:14 +0000 (UTC) X-FDA: 82269013428.23.91F8959 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf18.hostedemail.com (Postfix) with ESMTP id 3AD3B1C0005 for ; Tue, 25 Jun 2024 10:19:11 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=X1oBWrVg; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=ddLvbEk0; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=X1oBWrVg; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=ddLvbEk0; spf=pass (imf18.hostedemail.com: domain of jack@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719310744; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=4GtSP3ENf+Nn0Zjpw67fKdoioBHD9GQRHkIbgNMfAUs=; b=XkbRCAy0QnbZqtAvd5/p9IJzNxcY7NRW2kl4qqg1HI2HJ3wH7HkIvA35EUM3hDJL/1yIbs hpqmaTqbPxJV2wUr9zgXqKSzJ1tnlkWQMIDi/IQRaVp87BfxxLU5Ipys5ylUMAia0tPxsB wjMPeUHcnL6rbF0o9CYCZPhQeUpax38= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=X1oBWrVg; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=ddLvbEk0; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=X1oBWrVg; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=ddLvbEk0; spf=pass (imf18.hostedemail.com: domain of jack@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719310744; a=rsa-sha256; cv=none; b=QThp5OdZ0HJePdn8peL4maWHbR6pF86ju64RTqYvZPZPr3QMuAyMBVwzFlMG2ve8ZUa7JQ 9wQIecSlY8zR7MyIF1sb0zZWWxGN+klVNS7bk4N5HencF6sfVfUuLebiyiefQWezs/LEMd XziqEosgANi4hi6I8enE+PvHgmYYkZw= Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 4314121A74; Tue, 25 Jun 2024 10:19:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1719310750; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4GtSP3ENf+Nn0Zjpw67fKdoioBHD9GQRHkIbgNMfAUs=; b=X1oBWrVg4xsMpqF+iw4/qzQawWAC3E53h61k9OlLG8EiWFmGMGYqx5rpsH2yKP9EnsNZ/W p86Al6f+AiXkDugDZvXYh/RCkFEQiVALRyyoKNMhGwQSmMkib0xFO8BxOsIHTJcPOo/STO p/TsyNeT9EaVqNEsCZrkQhiCgiB9NmU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1719310750; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4GtSP3ENf+Nn0Zjpw67fKdoioBHD9GQRHkIbgNMfAUs=; b=ddLvbEk0+zG6pO4x/CX5agTYzeBTfPG+6B/1j9SY6mbfWqNIhzw00lxmbnGW9W8TSucVtd hjyjeT+uvehZJLCw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1719310750; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4GtSP3ENf+Nn0Zjpw67fKdoioBHD9GQRHkIbgNMfAUs=; b=X1oBWrVg4xsMpqF+iw4/qzQawWAC3E53h61k9OlLG8EiWFmGMGYqx5rpsH2yKP9EnsNZ/W p86Al6f+AiXkDugDZvXYh/RCkFEQiVALRyyoKNMhGwQSmMkib0xFO8BxOsIHTJcPOo/STO p/TsyNeT9EaVqNEsCZrkQhiCgiB9NmU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1719310750; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4GtSP3ENf+Nn0Zjpw67fKdoioBHD9GQRHkIbgNMfAUs=; b=ddLvbEk0+zG6pO4x/CX5agTYzeBTfPG+6B/1j9SY6mbfWqNIhzw00lxmbnGW9W8TSucVtd hjyjeT+uvehZJLCw== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 3313213AD8; Tue, 25 Jun 2024 10:19:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id eOd3DJ6ZemZvWQAAD6G6ig (envelope-from ); Tue, 25 Jun 2024 10:19:10 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id D6C2DA091C; Tue, 25 Jun 2024 12:19:09 +0200 (CEST) From: Jan Kara To: Cc: Andrew Morton , Matthew Wilcox , , Jan Kara Subject: [PATCH 03/10] readahead: Properly shorten readahead when falling back to do_page_cache_ra() Date: Tue, 25 Jun 2024 12:18:53 +0200 Message-Id: <20240625101909.12234-3-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240625100859.15507-1-jack@suse.cz> References: <20240625100859.15507-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1393; i=jack@suse.cz; h=from:subject; bh=m/qJzAdNjRqtXAPnSZNOsBtxQm5ctHdoj1WYBPZKGcs=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBmepmNHpSB+XQ/EstcGHqo9zXZBB1e8CwiTXng+TGe fDYhmz6JATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCZnqZjQAKCRCcnaoHP2RA2XGOB/ 41/mS6sUw9L8KFEVMh/gHypoJtCWairiuHE5F2T0SgsKRL+5OTdU8t6rS8Rt0+rM6uHzX90ZGiWa5p 00FN8wTLlDa6vutwd/Sc1Xod1ESJWmLqqiulQ6TvdeAQAkabVbF9tfImx27PE1f+ul5/PGT1eGGGne e9o51jy0+23alb31k15nv0degSjvhPuf+TN/xut37QIU3LJFdV3GMlvPgOaRhgz2qHRbEDZQT5ClXW XW3eVo5umb82WlNwYlD7Ok5rb02xZKGhPkjvtCqyNfKKKNkhttTcer/cK2JR20pXAAtbzXQUSo0szT 14wwSa4lcdVqcVtcRYTgg4aCpA3xOE X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C X-Rspamd-Action: no action X-Rspamd-Server: rspam11 X-Rspamd-Queue-Id: 3AD3B1C0005 X-Stat-Signature: dmg6buim1n3ma6hzjuczurcwpnth6axj X-Rspam-User: X-HE-Tag: 1719310751-34680 X-HE-Meta: U2FsdGVkX18jgX0gEAISkLhMN02pvapUS0CoUJ37m+HyBYkO09R1aDA2RU3YZXzoZ4XkYYVIsM5fTSfXkz3imsMFUFasiA+AJO4+4zzJIFbj9rTdTZdf2v5F5xNKP2A/pmu26QVri1L8ToUy4Pky+MhvrmVayc73oMt/gIGiy2FgajAwfikPFW1Cyl4/RZNiaSPJWYbSmRjihcKhye9wSjMJxjV4IeYNioVXa0qyPCa7paZEetzZ38vm4KALyosWH6COsbziPB4QKZnNkJwJnfNDBrWonw76EpkSIlF79v+Kg9RWYcjPFN2MiImZ/Cj3Knc2Lmz9u3Laxbf35a7oFkB7o4FAX/Vfa8R2RmbsQ64QX/qJtkKc3H5uCvxnF6GvOo6euZxHJHXZLAEOCMm+qh7/PxaDdiPgUNF5lcaan175Yd6vE05nokDCZGGbYN7D/lRwuUr0KS5Hw4FGpLgQXI4nC4vVjMX1jexIG7pZTsFqzMJII8Rrf2XMRBrMeMW0phm8ucMLAn6bgbb2wuBI9nsBf6Kx+6VIddbRPzx2XpRY8fzcKB8EuP/7PlyGXCC1uJ6vjVGAdUzRuyaGZaMtMLwAtsLWDIyA/Fck4p2wXwV2unaCBPFzb0k3/Qfgbz64NBKjDm6AStDDws84RC+tf0ssY4dcfues7+FzKR/TsdflNTJErmGQrpzh0YY9aEUNwQQz5nRW3t8PaG5Myx3Qmvp2F3yNyjh5aKWw5doEIJ8RgCv4MRYorOC/3TaVNsNXhHMW8d6X1R+XME+rsobpT5kJlsBUoZ6LzqrE7aifKr1ERvUH6jScwUPH9xW8c1WmUOdOOubD6uYI2e9exETsMwjSOJEyKwtHmXg2gmOD5rP0dGZ6Pgs3pNUeTLno1j98S/DW/jnAys3o/I7fxlCu3bEuTxHfFvmW6FJLXUl5qaYZ2LMES8fJy43TL6K670eUuixp70DsYVm0fLRjfBq k4HenyDJ uvrxAg+8imMaqoOXagqtTgGJUZVbodha1XhMjYg/n/Bzcn+n2rw1kHuIin74HfsK0F1067S7T9MSaVxet9d1In0pOtrMcv63T+HD64ZTHahCfmxB5XQP0uK7hFwYJ8wz3K010e6QqFWghfwor6lUPxpEP5Ojiyq+BsKBWwHv8jQ7ecE5sCl8u7fEoqxMovll/IfFkNDG5zSsaVYngqP9UqCJSio2kDIgsUOv3jv+YzCl6jjQitruzd0r/HBIUtuBprLVr X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: When we succeed in creating some folios in page_cache_ra_order() but then need to fallback to single page folios, we don't shorten the amount to read passed to do_page_cache_ra() by the amount we've already read. This then results in reading more and also in placing another readahead mark in the middle of the readahead window which confuses readahead code. Fix the problem by properly reducing number of pages to read. Signed-off-by: Jan Kara --- mm/readahead.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/readahead.c b/mm/readahead.c index af0fbd302a38..1c58e0463be1 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -491,7 +491,8 @@ void page_cache_ra_order(struct readahead_control *ractl, struct file_ra_state *ra, unsigned int new_order) { struct address_space *mapping = ractl->mapping; - pgoff_t index = readahead_index(ractl); + pgoff_t start = readahead_index(ractl); + pgoff_t index = start; pgoff_t limit = (i_size_read(mapping->host) - 1) >> PAGE_SHIFT; pgoff_t mark = index + ra->size - ra->async_size; unsigned int nofs; @@ -544,7 +545,7 @@ void page_cache_ra_order(struct readahead_control *ractl, if (!err) return; fallback: - do_page_cache_ra(ractl, ra->size, ra->async_size); + do_page_cache_ra(ractl, ra->size - (index - start), ra->async_size); } /*