From patchwork Tue Jun 25 10:18:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13710833 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id A0B9BC2BBCA for ; Tue, 25 Jun 2024 10:19:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E64136B02F5; Tue, 25 Jun 2024 06:19:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E145A6B02ED; Tue, 25 Jun 2024 06:19:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B2DE66B02F5; Tue, 25 Jun 2024 06:19:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 80F976B02ED for ; Tue, 25 Jun 2024 06:19:14 -0400 (EDT) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 301361417C6 for ; Tue, 25 Jun 2024 10:19:14 +0000 (UTC) X-FDA: 82269013428.02.19BE244 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) by imf06.hostedemail.com (Postfix) with ESMTP id DB13E180003 for ; Tue, 25 Jun 2024 10:19:11 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=GWFhszbJ; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=mBATL9t0; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=GWFhszbJ; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=mBATL9t0; dmarc=none; spf=pass (imf06.hostedemail.com: domain of jack@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=jack@suse.cz ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719310735; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=XehjZz8U5jmUp0KBCATwed+k3plztjsxZR6NK0NE8js=; b=wGBYuzdge6LA9Nn+Bdt1h40hrZBdqFxQUA3Fun6xH776ByWRShpoIEVUbpXOdEcJpUHdoq umOmkMw2nkhiUYhw5xvRfIUcTv2gPeg6To6bw/dIO5SsElaXq7r5bWtsYOv0O36v0SVEA1 czgSJWqDyRrxhR9QfzfZyCpPWprzueo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719310735; a=rsa-sha256; cv=none; b=07ATDUB1tUJK7xyNwSVoAZ7gljvqXX41cFRLyuRKKxJMvwQl0+NsmwqOE1TcGTJmSuCw7L 22/N6RacBbvIQNn33Kpm3EnsTBxxTzHlleM0hop2pzvUErAlTnRpyhwv6p5IgE0/AIWMPL CNQCPwQYWQEdCOuonUHkphC39V+Oqkk= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=GWFhszbJ; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=mBATL9t0; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=GWFhszbJ; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=mBATL9t0; dmarc=none; spf=pass (imf06.hostedemail.com: domain of jack@suse.cz designates 195.135.223.131 as permitted sender) smtp.mailfrom=jack@suse.cz Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 97CBD1F84F; Tue, 25 Jun 2024 10:19:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1719310750; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XehjZz8U5jmUp0KBCATwed+k3plztjsxZR6NK0NE8js=; b=GWFhszbJE7ATIih77tzjMT/oHF5iOzCCWki1h+d2WN7Z5nHgdpByImeREWmVCUhBYu6YqV 3l0MniMu2E2lA8iM6tQenHrCmSdMuIXbADrmzFDtd/HJfAqrBMLzpcrvnB7O+hT2EVa2Gy CFWfzW+KttaXZPkyrfFm2i09XF845Go= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1719310750; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XehjZz8U5jmUp0KBCATwed+k3plztjsxZR6NK0NE8js=; b=mBATL9t0EsnLa8nZMeqNI+5nPYPaDCLOzd1YBjwgIReTH8881d+1BTu5g3kuP1PAHPRVQS RTOatnacmb9vgXDQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1719310750; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XehjZz8U5jmUp0KBCATwed+k3plztjsxZR6NK0NE8js=; b=GWFhszbJE7ATIih77tzjMT/oHF5iOzCCWki1h+d2WN7Z5nHgdpByImeREWmVCUhBYu6YqV 3l0MniMu2E2lA8iM6tQenHrCmSdMuIXbADrmzFDtd/HJfAqrBMLzpcrvnB7O+hT2EVa2Gy CFWfzW+KttaXZPkyrfFm2i09XF845Go= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1719310750; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XehjZz8U5jmUp0KBCATwed+k3plztjsxZR6NK0NE8js=; b=mBATL9t0EsnLa8nZMeqNI+5nPYPaDCLOzd1YBjwgIReTH8881d+1BTu5g3kuP1PAHPRVQS RTOatnacmb9vgXDQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 8260513A9A; Tue, 25 Jun 2024 10:19:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id PR/XH56ZemZ+WQAAD6G6ig (envelope-from ); Tue, 25 Jun 2024 10:19:10 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 02190A0957; Tue, 25 Jun 2024 12:19:09 +0200 (CEST) From: Jan Kara To: Cc: Andrew Morton , Matthew Wilcox , , Jan Kara Subject: [PATCH 07/10] readahead: Drop dead code in ondemand_readahead() Date: Tue, 25 Jun 2024 12:18:57 +0200 Message-Id: <20240625101909.12234-7-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240625100859.15507-1-jack@suse.cz> References: <20240625100859.15507-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=2287; i=jack@suse.cz; h=from:subject; bh=uNQmjIDmbRqrgOgCnQp9TWHkJn+vXefHwUGc9G4atKs=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBmepmRD/ONRVBSq6jWi4Q/RKRyrz0CpCU34YA1tRUH XgUO4hyJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCZnqZkQAKCRCcnaoHP2RA2V5YCA CN7YjL+MmOOxmPo3WZp3x2ysmGA0VqwFNClS05kep1YLzxJZU1vur+K//frnsYZSNUsL5HwowaPz7E M8GLbyorUMoMLhl2uzW9Lt2yvwNeYJFI0A9Qm5omNEEicRYpodPu9BvNmubrJbxLFzg0SbjRdbQB7I jNP24eTOwdpa355UmJdxUbvypVjim8cgWvU/sGvePm7BbGgLmjGIuhFjB4D4pkOykjCdUaS4y64mvE u95uO41TEJdNTNpLrdFpz4uDB3qmC1iLOmgCvOqRH28W9o5el+AUeWT8s/wT6qn6vIPb3QrnxqQjrL M9534nEPUBagU+LyKPB/KkUOHeYZzx X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C X-Rspamd-Action: no action X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: DB13E180003 X-Stat-Signature: iy1rifmnqjrjzjxp1bzi8cn9n3wyqp5p X-Rspam-User: X-HE-Tag: 1719310751-864996 X-HE-Meta: U2FsdGVkX1+SYpVr+iyzuHAvYZTFNIa8b6LNKjFMigXJ80dMa3+PdtoUbKmTqDoIK9uxP7YVUDm/HKyLqbg/BxldGUhsj4ZtrC6ZQl9VnScjqUCmVKTgiHPKMg3aLLDBN2uOw2BPu3qIpSuVIsLICv3WURSFbH8EK2dQEflxCqyIw6KvM7RlTAUfq4kazGWVWbt5Jvhk1HgSHdPXFFon4xfiAx7GZ98tKHeeRHL/M7cdcwk3AwQ5uAyESdmWG5u0TgF0Sf9YGIY5AwgFR1rthN5xVQ8HR3hbkwrE1M9568G+GUp87aTNwRw5gDbGa4GKmydKAv+pOlQ9zCcycwCkmerZuZP3vp9hLrY6/wjZK9Dcg6wOE/ZZUbPeprRStpSVZQFGHxK22+BIYGHjOX1b0lZvj+npunQnYNXnHSpbUojiYmKIWuBpwBFsdxpyQSZbyegOD+TfMe57qW7n5kiwWtW9WDXsQan69HVPAXVoa6FoMtlw6sd0e+t6O95Q0kxG2XB8EbinNFqdGjLOhcY5zQwRHKRfY7SFL9nOu+NPGgkm2IxRftH/hXhlg1YDd169yrdVVUWZwvmbHzP9lHdDqsKsEajlM29eer5+UsIKXvIcleLWFa4dkJWWpg6Ug9rJijVxU+hcgH4PyOnOEi0Tfo1iwlPjh+CX8AePUqTeUozsq+WbTIdNTqxyh3rxgCGSNbrAevsLZYoCkR1PDhxmB7fLm78sfb4hsckAcmM/rUPZBlfpRnh4E6p7cOLOy3wLKfGl6XjSHrDibJ28P+S4djLDj5egTKr7fQwIVLq9v+g2BYM/j53PhENAsyZKUpvHiN1qI/Z+DgUwaUb7phaeDU17TbHuO8GChJEND0OTQWcOwceaGmkg2wLqVoJfx2bGDauWFXkJrolnCZmg1dcSsUzBBpj7yNrCCJSCZuOVYEqq5wY96lUx0GF3T8koEQd0xi2rAiQkMIIzwS3ZWTH +a04f1HW Fjt3MVBdzFJanZwnRwvUUdrrOdjkOwzXcP1aF1HM74ehHataBO88fiT0xpu9gS/uij+JhBwRyRL04DUq8HVPn3Wb5Sj4P8ls5Z8HC97hkl5eJBgKoXng7Xj2r4DRDJlWU0I86nHZJANbn8tjKMqTmb0SV8LHfqghRaaQ2ROYSEvEfuTuSgfsMydpEf6/lvbia8IJfOyN5R0TrWA6cKxJdYiQvKDlxY1eXEIm+VJYV4cus+aqGB4LEZsxMgmTAHyt4aT8E X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: ondemand_readahead() scales up the readahead window if the current read would hit the readahead mark placed by itself. However the condition is mostly dead code because: a) In case of async readahead we always increase ra->start so ra->start == index is never true. b) In case of sync readahead we either go through try_context_readahead() in which case ra->async_size == 1 < ra->size or we go through initial_readahead where ra->async_size == ra->size iff ra->size == max_pages. So the only practical effect is reducing async_size for large initial reads. Make the code more obvious. Signed-off-by: Jan Kara --- mm/readahead.c | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/mm/readahead.c b/mm/readahead.c index 9ea5125a0dce..d92a5e8d89c4 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -549,7 +549,6 @@ static void ondemand_readahead(struct readahead_control *ractl, struct backing_dev_info *bdi = inode_to_bdi(ractl->mapping->host); struct file_ra_state *ra = ractl->ra; unsigned long max_pages = ra->ra_pages; - unsigned long add_pages; pgoff_t index = readahead_index(ractl); pgoff_t expected, prev_index; unsigned int order = folio ? folio_order(folio) : 0; @@ -638,26 +637,10 @@ static void ondemand_readahead(struct readahead_control *ractl, initial_readahead: ra->start = index; ra->size = get_init_ra_size(req_size, max_pages); - ra->async_size = ra->size > req_size ? ra->size - req_size : ra->size; + ra->async_size = ra->size > req_size ? ra->size - req_size : + ra->size >> 1; readit: - /* - * Will this read hit the readahead marker made by itself? - * If so, trigger the readahead marker hit now, and merge - * the resulted next readahead window into the current one. - * Take care of maximum IO pages as above. - */ - if (index == ra->start && ra->size == ra->async_size) { - add_pages = get_next_ra_size(ra, max_pages); - if (ra->size + add_pages <= max_pages) { - ra->async_size = add_pages; - ra->size += add_pages; - } else { - ra->size = max_pages; - ra->async_size = max_pages >> 1; - } - } - ractl->_index = ra->start; page_cache_ra_order(ractl, ra, order); }