From patchwork Wed Dec 4 18:10:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13894162 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 C00D3E7716D for ; Wed, 4 Dec 2024 18:10:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 243C06B0083; Wed, 4 Dec 2024 13:10:34 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1EC816B0089; Wed, 4 Dec 2024 13:10:34 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E42DC6B0085; Wed, 4 Dec 2024 13:10:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id AFA376B0082 for ; Wed, 4 Dec 2024 13:10:33 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 668DE14116D for ; Wed, 4 Dec 2024 18:10:33 +0000 (UTC) X-FDA: 82858066074.27.8F919C9 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf07.hostedemail.com (Postfix) with ESMTP id ACFB440016 for ; Wed, 4 Dec 2024 18:10:15 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=tLgNrw2S; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=AJF4o5Wr; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=tLgNrw2S; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=AJF4o5Wr; spf=pass (imf07.hostedemail.com: domain of jack@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733335815; 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=YRRVp8GDv5ciFU8Vi3NK539eFxAC9ZKJdJnKCRgH7L8=; b=uxBrxotpI4dQyD1OBalPgoOqH6F/LuzrciwUq9V1sIEoUtwSb96nPWgyLfLFrJVAeg+9ul lz+xbWmrtfSG4rS9vVvctjjTL2xknJ2Dgepod5pEZuQkwzIDX7p2Hc60SwlQcxt/RvOAoa J2thduCND7YsJ/Xp1EFIL5V60cP7cF4= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=tLgNrw2S; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=AJF4o5Wr; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=tLgNrw2S; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=AJF4o5Wr; spf=pass (imf07.hostedemail.com: domain of jack@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733335815; a=rsa-sha256; cv=none; b=kshrXMzyOvxJi1f6fdP4JHDNuOEQf/kePWvUE5qodQIV6DKn7x7DNhThWuDHzfFjjh77ua qwmqRwGNIbYCJcw9kkYQQU3N3rm8gdbFHTRgrCO4PK9dOkZFI4/PxRYiEgyUzamHgiFXLz j9I7B49CMb5N3DcNezaPlAdjEN2h2js= 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 280101F391; Wed, 4 Dec 2024 18:10:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1733335829; 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=YRRVp8GDv5ciFU8Vi3NK539eFxAC9ZKJdJnKCRgH7L8=; b=tLgNrw2SSinViQkbbJRU+fhzUy6L+N8bkRvx9sxjHg8WLiumifZKfiTexcaRAUTOv0wa0w 3Y82DQ9MALJYn0FQ2KdiRp6xqwDLXLiONu1eSiADkCD38w84ZMC+rkWg6Q+HDrEHM8uieO Gja0WfdIGNwDkgJ/GOgVFNRLebD+q9Q= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1733335829; 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=YRRVp8GDv5ciFU8Vi3NK539eFxAC9ZKJdJnKCRgH7L8=; b=AJF4o5WryyXhlaKQNsx1NmW9touxveeG+Yh4OrVREWMDrbRGJ7ZvPALcKaB67tcsRBLMqr 0CRHuYF+bT6grGBw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1733335829; 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=YRRVp8GDv5ciFU8Vi3NK539eFxAC9ZKJdJnKCRgH7L8=; b=tLgNrw2SSinViQkbbJRU+fhzUy6L+N8bkRvx9sxjHg8WLiumifZKfiTexcaRAUTOv0wa0w 3Y82DQ9MALJYn0FQ2KdiRp6xqwDLXLiONu1eSiADkCD38w84ZMC+rkWg6Q+HDrEHM8uieO Gja0WfdIGNwDkgJ/GOgVFNRLebD+q9Q= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1733335829; 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=YRRVp8GDv5ciFU8Vi3NK539eFxAC9ZKJdJnKCRgH7L8=; b=AJF4o5WryyXhlaKQNsx1NmW9touxveeG+Yh4OrVREWMDrbRGJ7ZvPALcKaB67tcsRBLMqr 0CRHuYF+bT6grGBw== 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 1507E13A41; Wed, 4 Dec 2024 18:10:29 +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 L4jbBBWbUGcfJAAAD6G6ig (envelope-from ); Wed, 04 Dec 2024 18:10:29 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 9B992A089B; Wed, 4 Dec 2024 19:10:20 +0100 (CET) From: Jan Kara To: Andrew Morton Cc: , Matthew Wilcox , , Jan Kara Subject: [PATCH 1/2] readahead: Don't shorted readahead window in read_pages() Date: Wed, 4 Dec 2024 19:10:15 +0100 Message-Id: <20241204181016.15273-2-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20241204181016.15273-1-jack@suse.cz> References: <20241204181016.15273-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1372; i=jack@suse.cz; h=from:subject; bh=A4tsTegl357UhkwXDmfPLpj1g2fDGSUagcySv02HY9k=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBnUJsGMzu51Nl5sO9cmnme2WMMG2Vp67WUyVvFoI6H PEQeuvuJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCZ1CbBgAKCRCcnaoHP2RA2VbNB/ 9e6QWAakdEIqj7QtPm5A6RZs+LXzV1dLegNIC+NW7PamHW+WaiXxQ3DnnvfWndYND4lSLtLVaYNeZz ViLXV9/vlwd9Iff2j+IZjf81DBfh7o7/r6BewIYlgtIjWhRY/JAPo7wxA0+fORtN9l+hE8OgmMqPFE 6RMyMbPL5pog0Ig3LTotHkm/UfS7qjjdHn9FzEmtLqOCg8SNF+7ZpEWviVwiXLIXOJtRxsQEZiqbYN 8iCY/p144rKTwteAmADMPbQHaEkWwrjdAm0J4Q6ZhUARVqj+CPC4H1pcom+lr31JX9zO/u1ZTOoPjg Jt0hQ3QbrNaMvwTpBXkIaUCjxPSrpB X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C X-Rspamd-Action: no action X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: ACFB440016 X-Rspam-User: X-Stat-Signature: 3mczh79jsffas3ap9hfyie84sgaya6im X-HE-Tag: 1733335815-419125 X-HE-Meta: U2FsdGVkX18lzwPIBo50D90b984vXxXfCaD36p2qKt2TNg76Un4QOJrRGXXFoYDVpi3YMoE/S/7gSM9TNMdLw/nNXPNusmc06EiSpsNJJq56qcAVJ227UVQBVqNqBDkaosOBftK0pi8tZl4vlqSbFDkcVIMzmY+HjZMU6LPOBrAgVR8wdqOCur9UGq8Ayma1Jv4wQnMugHbkmZanhZ+Y7F+fEw5qNSV0tXd4hmviBV88pC6ygTofqJ6bRhpYpG5S/zyw4yzbBUG03W5gjHC/6g9BhjeyzRL+Zk5ywhHaXbU6bW7YcgX5qCIh/qohpJhI9vDZTVpb5REpWewww0nnV2uqFckle79zph+w0d/dmtnVU4U8EtnUlkX8oz2swZMr4olwU4aQtSTIaHFiXaXlNah+s995az3HhlR4K+H+we2dqRqsUTGM27NaqWmW2rN5xqTs1bYSFSKUERJICsR6CXTUjdFt7+Ww0YiyuevqW+r0RTClTy3COoR7xHovv1dXwCdrpTnBomLL4E2aZyDK36zdjiTGxPPJtb2zCQT6Jh0I6GBEpUAHR+QOD8SH97lO9QhnWVQ7ff5YbQZ9NfF/EzfTcqLw3X/oc3EsNFAhA69gYCaASNNtCONYlMmThmHM7HqxTDc86rh5wYnPljOTDnhD2usuFcHgtxgtKEUXxea+ZL+wqRSzqrYwb/G6AZEJEuwznR7e0jOUXIUtWlfBXK31BdID1M3qoS5CgV422FU7h/J+Lxb1XRfiuhXAqA3hkP1xnX3062iQBH6ppgjoy4orMFsUpyZSiY1kyXBuBtSW4kE49QbDvOLrsAoXddoYCOQxh+qg3B/pnF01CQKTC5Eda+6JITkOIfg119afboVbKRVFzcALuN8erD+40DlI3huE9O07IUchr5fenaqw9pbEQs5LySbklC+HlVJxfoGnHhjjyp7aKzeXaOOVu+5pcjF4UEYs9XzKWMoY8FL UtUWWwie mC2l6FyCRokoShw6fVQx5C5nDqrNjQonR+2Kmbzu1Vdq0BBEi2aNFH+GWihOXwNy6//g1e0FV0ynv9oRT34GTTQkQbuTGi+GxSkRhoNWG05TuwUcTmzmrAPXPXhr/SXmsER8utpx3UjpMdg9Aq5JSXvrQD2pLl8Eqjugf6eKT5WcAtqRqpxhjTsVVPUpW1E7Jk0C4aBWd0TszDkSGTcZlX/nr/50YKDtF+O8hROknn/AAXS3zvYTPQW3hoiQid/CM1XniD1OJcK5d4d84B/TRBlFuhM56Dg0yKgm1 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 ->readahead callback doesn't read all requested pages, read_pages() shortens the readahead window (ra->size). However we don't know why pages were not read and what appropriate window size is. So don't try to secondguess the filesystem. If it needs different readahead window, it should set it manually similary as during expansion the filesystem can use readahead_expand(). Signed-off-by: Jan Kara --- mm/readahead.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/mm/readahead.c b/mm/readahead.c index ea650b8b02fb..78d7f4db9966 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -158,20 +158,10 @@ static void read_pages(struct readahead_control *rac) if (aops->readahead) { aops->readahead(rac); - /* - * Clean up the remaining folios. The sizes in ->ra - * may be used to size the next readahead, so make sure - * they accurately reflect what happened. - */ + /* Clean up the remaining folios. */ while ((folio = readahead_folio(rac)) != NULL) { - unsigned long nr = folio_nr_pages(folio); - folio_get(folio); - rac->ra->size -= nr; - if (rac->ra->async_size >= nr) { - rac->ra->async_size -= nr; - filemap_remove_folio(folio); - } + filemap_remove_folio(folio); folio_unlock(folio); folio_put(folio); } From patchwork Wed Dec 4 18:10:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13894161 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 854B2E77171 for ; Wed, 4 Dec 2024 18:10:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F05C66B0082; Wed, 4 Dec 2024 13:10:33 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DF2D06B0088; Wed, 4 Dec 2024 13:10:33 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BFA496B0083; Wed, 4 Dec 2024 13:10:33 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 9D2026B0085 for ; Wed, 4 Dec 2024 13:10:33 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 287381611E7 for ; Wed, 4 Dec 2024 18:10:33 +0000 (UTC) X-FDA: 82858066578.02.C741B65 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf15.hostedemail.com (Postfix) with ESMTP id 93C7CA0022 for ; Wed, 4 Dec 2024 18:10:15 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=XBrWVSAC; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=bpxBZKaS; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=XBrWVSAC; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=bpxBZKaS; spf=pass (imf15.hostedemail.com: domain of jack@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1733335816; 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=pLbh/B5ZrBYqXSiuvC61pHk/xApVQ10fXBkwkHhdWqA=; b=IA1+8MKTxaPXb8r0pgWkYP1QJb9y9wgWkivaECSC3LPeQG/FaKuoqAq9JBq1n540q3+L26 UmqchBSdgmfF9pyn/a8AAEdU3dlK7/vuyFEfUAeT0+hwM5six4scPOeQPF+B1ycQQzOZwZ w31G04NFXBP/BEK8hIYC9Q5EUfeEpHI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1733335816; a=rsa-sha256; cv=none; b=il+WY4FdYJ2P6atnNJy8VlrA5DSAjH5aI9SIKJIbEyFokzV3Abb58evfaWMncwwZ+XP+NE zMA8yhsRyAMxAhbgxEQCKKbZzYjZpvofjn0ju1vHRyICBOo7Vi1YvpVv/zj2JfMn7KUU4P qIQa+lFBDMyAD2FfyLma2MS87/FzMew= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=XBrWVSAC; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=bpxBZKaS; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=XBrWVSAC; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=bpxBZKaS; spf=pass (imf15.hostedemail.com: domain of jack@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 1B71A1F38E; Wed, 4 Dec 2024 18:10:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1733335829; 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=pLbh/B5ZrBYqXSiuvC61pHk/xApVQ10fXBkwkHhdWqA=; b=XBrWVSACVFrKgx1ofqQI6yh93jwJcXtFJDta42EJOJevhVfSeb0B/SzTS4+tQvUliHsoRF BP4pflN0eFlxhdQyoACD5FTIQzeOTXSfLy+VcmK2/d9th/iHGlIZcboHd8k/YrtXkAXIWt YVY4G3K2GcJNav7jtJ96eVR7nhqMM6Y= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1733335829; 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=pLbh/B5ZrBYqXSiuvC61pHk/xApVQ10fXBkwkHhdWqA=; b=bpxBZKaS5MO4tvC1Ek2DxE6w/snx/QXgCZHmCCJ8SPFPPIg6cTGHs+V6kHXY8KfurHNNFm 92cZ4lLc3H7neECg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1733335829; 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=pLbh/B5ZrBYqXSiuvC61pHk/xApVQ10fXBkwkHhdWqA=; b=XBrWVSACVFrKgx1ofqQI6yh93jwJcXtFJDta42EJOJevhVfSeb0B/SzTS4+tQvUliHsoRF BP4pflN0eFlxhdQyoACD5FTIQzeOTXSfLy+VcmK2/d9th/iHGlIZcboHd8k/YrtXkAXIWt YVY4G3K2GcJNav7jtJ96eVR7nhqMM6Y= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1733335829; 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=pLbh/B5ZrBYqXSiuvC61pHk/xApVQ10fXBkwkHhdWqA=; b=bpxBZKaS5MO4tvC1Ek2DxE6w/snx/QXgCZHmCCJ8SPFPPIg6cTGHs+V6kHXY8KfurHNNFm 92cZ4lLc3H7neECg== 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 0B09713647; Wed, 4 Dec 2024 18:10:29 +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 c0GsAhWbUGccJAAAD6G6ig (envelope-from ); Wed, 04 Dec 2024 18:10:29 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id A37B3A0918; Wed, 4 Dec 2024 19:10:20 +0100 (CET) From: Jan Kara To: Andrew Morton Cc: , Matthew Wilcox , , Jan Kara Subject: [PATCH 2/2] readahead: properly shorten readahead when falling back to do_page_cache_ra() Date: Wed, 4 Dec 2024 19:10:16 +0100 Message-Id: <20241204181016.15273-3-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20241204181016.15273-1-jack@suse.cz> References: <20241204181016.15273-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2079; i=jack@suse.cz; h=from:subject; bh=sfDjWR9l2q0I6e9RtVsVOtQ/QIvJpETYv/xLjFoCRTA=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBnUJsHX0VYtNJp25g9VSejTibuHWKcLphPJJDG+Lge 5Qgi77aJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCZ1CbBwAKCRCcnaoHP2RA2d0KB/ 9F0Jsz5AdXt/pdHYspx0h2y6MWRluBhnTRKPDu6DFXFceCRqCaEJ4b0r0GyuNFyzmhk/Rb6JtuEevw +eOOoAxMKRhIjsOWlal8W9b70g0Gbi7kQzNY9Bc2IBDUXJfJzKaidSXHoo21fdxQ1o/x0JbjKg7ESL ZiWn2zpPFRhLeL8pCWLR99O1ofTs8+MeiGzXql2g4UFNqdWxZ/v89U1Y2JJ/RCppzTUET8T8+sW8vc 6TBryHEkZg7HWWSNJSmpZZghGhrInkjP1So1qQqWSDrkxH8SI4JBPgqk/vuBYnEnNzM5Rhw2sRuUzJ uBzH+Q1CGG6TPriOgSdB1f7WEmvnLq X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C X-Rspamd-Queue-Id: 93C7CA0022 X-Rspam-User: X-Rspamd-Server: rspam07 X-Stat-Signature: pu7o8j733enms9uara7rgn7k7zeqgyiu X-HE-Tag: 1733335815-141190 X-HE-Meta: U2FsdGVkX1+yjTmlvZJOGMTbcDqTeCVhS7nlKvh4Ym9E8Gjrj1pPF6etYm47mdqTFT6zoa+3KTtZQN7iPak8gQL+SI8sxRwxvnHmxlau2HJuq5WCI11+1ZAr4p6jxiLeOeL1Lgkl1GnqMA+H2sOtFHxZyYKBaRS2NQPjLHmt1bv+H1vPjbIVOCxwuisF27xTL6iRvXqENYnYPKdwhTGTv8nxiMlMFE/uDJXAyE1SFnNG4nS++hVAOT5qX7z4Bj06KPzVhdHkjdg2wygX2SRNvtNpkk2f2kPGtLvJY7oXcYfNpO6/LMKEEHVRrmbBOWpKY+L5+RPaI0AoJf3apQdupVm2LokNITFJCgDGF9ITsc/dIHaXilipsl6U2qsD21lPaOSO6YwKGzYX8zoIQ+tAh6VDx0vIUW/kCKk/AtgbUDVrhUq1vVotX+MmnZL8qYwm9/Vyg2WphKBMaUFSjgnXbGyQzz4hi+u0+dqLA55YTx7uJ/lcJAT+fj/YFH/p1eNw6HEqBSoOAsq13UFIl649Lh6Gi27aUvHo4LYEp0YMxSpMzoRZviAqTlsp2/kN5pn9OuCJdlPySbPd/YTKyXMe9Ia/qETN//sEWzVadW07nIwxpNiSXBQQCvAxgLFnKOFME/KDAJswqmJ158uAvmcLxxubPNBjaUnG9MW4BxQR6Qlw7NO0uCTbJPCOHBpzqQG6/LKss9Yoc2oFLcWnPn5n/ETFugSDQmsTjAkw2UMY4N1DhFzeDpULE5s8Q/6Wb4yMn8omGiFwwu+SB7R7QgjgrtSyWi9B40ftenESBxx5zPJNJfhfPDwbMs1wEz0SahtW0B0QzuLzRE5L0L7VcBL4mCbI05jv+jl3S2Sn55MP1CSZmvsK68/2v7YuK8G2Hq7aCb3192QmFwZ2hapbVnRedA/e1pn0xOZa/RucZDd0PJfBIxCeD1dK9+HjypewREPVd9DLDohjSrxtCdndw5Q LZ7O5pL5 /8lv8VyHs8Tp1nFFSaHlV8kBEGRO9YkfGga6v5+hlmtfVq5cEHweeOdwaqemNqVZxdR+urSrhaqnFXfbHMvzzcjbqH9Zl7JjwzRjjt43wd69W/NzZqOlTFtEJvrQp7hUivGQaB0HnXyMWh14tS0BP4I8+v5nqhED5OG+/FxMX8303tSIrSR/hRx+WEQbDE7k1R/1VlMWS9HxDWAzUZPOTvOQwaaUmyhh4GTHfV09q3TGIj7BqgKGaaTvKmNEqIeAGXZ/SIDcGKejqe/F8ge0YymeHJwYlui28MNeZ 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. Unlike previous attempt at this fix (commit 7c877586da31) which had to be reverted, we are now careful to check there is indeed something to read so that we don't submit negative-sized readahead. Signed-off-by: Jan Kara --- mm/readahead.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/mm/readahead.c b/mm/readahead.c index 78d7f4db9966..006954c76652 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -448,7 +448,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; unsigned int min_order = mapping_min_folio_order(mapping); pgoff_t limit = (i_size_read(mapping->host) - 1) >> PAGE_SHIFT; pgoff_t mark = index + ra->size - ra->async_size; @@ -506,12 +507,18 @@ void page_cache_ra_order(struct readahead_control *ractl, /* * If there were already pages in the page cache, then we may have * left some gaps. Let the regular readahead code take care of this - * situation. + * situation below. */ if (!err) return; fallback: - do_page_cache_ra(ractl, ra->size, ra->async_size); + /* + * ->readahead() may have updated readahead window size so we have to + * check there's still something to read. + */ + if (ra->size > index - start) + do_page_cache_ra(ractl, ra->size - (index - start), + ra->async_size); } static unsigned long ractl_max_pages(struct readahead_control *ractl,