From patchwork Tue Jun 25 10:19:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Kara X-Patchwork-Id: 13710843 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 82ADEC2BBCA for ; Tue, 25 Jun 2024 10:19:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 256546B02F6; Tue, 25 Jun 2024 06:19:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1E0AC6B02FC; Tue, 25 Jun 2024 06:19:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E895B6B02F6; Tue, 25 Jun 2024 06:19:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id BDBA56B02F2 for ; Tue, 25 Jun 2024 06:19:17 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 7DA251C33AE for ; Tue, 25 Jun 2024 10:19:17 +0000 (UTC) X-FDA: 82269013554.06.2AD33C9 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf20.hostedemail.com (Postfix) with ESMTP id 426C91C0016 for ; Tue, 25 Jun 2024 10:19:14 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=GDIuGNll; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=VDTO+LRc; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=GDIuGNll; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=VDTO+LRc; spf=pass (imf20.hostedemail.com: domain of jack@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719310736; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=vyxwvvsZ7JcW5Bl3ExPGCArwxKk1bgXwcn4XRHBgVco=; b=weTbVZK5Y0bAbD6XQPkiA9e9SYnjqaiaH5abAs1b+HFCbtVlqQCmwnLBq/W44fQMfcW2PD YfvQslKmVfgAYwYCB2bTJk7hBP2yLdxUNzQOidpAy+Dc2v64vH1nU1aQSn6Z5Ds8YIPvb3 LmGaABa0pwvONmu0VOYDSCA36H/qYS8= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=GDIuGNll; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=VDTO+LRc; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=GDIuGNll; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=VDTO+LRc; spf=pass (imf20.hostedemail.com: domain of jack@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=jack@suse.cz; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719310736; a=rsa-sha256; cv=none; b=sh9f06l+rWsxl3NMrvytX3+v0b68xXJYbzfvQFks6NdjCRbhk+MSrbxY7WR4X6zdleFmrS dTB/KNCDcZSKYVCj44vJ/ZRXoZ3zAtcGzq6/q6HOELXn7YOpWabvroeBWHyX3AMLzs2cHG 1iGjDsDpFC/+2xXmYetRdUQqEd6rthY= Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 9A0FB21A79; Tue, 25 Jun 2024 10:19:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1719310750; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vyxwvvsZ7JcW5Bl3ExPGCArwxKk1bgXwcn4XRHBgVco=; b=GDIuGNll6Qe2PeuRVsfKphDYbItj3AF5g43txEQCUQJAggZ6VXUKHHY9bZ+gjMr0yY+GbI 84qjRTOGYMW7tJYx9O8On/Hr4C6H5HGwZNYJh8AeeCGpo6BSXa6XpwI3TC56DJ9C30Yhau 7dz3o12FaNDLe8XcftJwZ+VT9nQNvb0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1719310750; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vyxwvvsZ7JcW5Bl3ExPGCArwxKk1bgXwcn4XRHBgVco=; b=VDTO+LRc94g0SdBAa/BekynpkCYovk3M7Lh9FdpVcOjuso/mEHBO7mhbuyV1D8UlapQz14 poFwR1XOAms4beAQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1719310750; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vyxwvvsZ7JcW5Bl3ExPGCArwxKk1bgXwcn4XRHBgVco=; b=GDIuGNll6Qe2PeuRVsfKphDYbItj3AF5g43txEQCUQJAggZ6VXUKHHY9bZ+gjMr0yY+GbI 84qjRTOGYMW7tJYx9O8On/Hr4C6H5HGwZNYJh8AeeCGpo6BSXa6XpwI3TC56DJ9C30Yhau 7dz3o12FaNDLe8XcftJwZ+VT9nQNvb0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1719310750; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=vyxwvvsZ7JcW5Bl3ExPGCArwxKk1bgXwcn4XRHBgVco=; b=VDTO+LRc94g0SdBAa/BekynpkCYovk3M7Lh9FdpVcOjuso/mEHBO7mhbuyV1D8UlapQz14 poFwR1XOAms4beAQ== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 8E8CE13ADA; Tue, 25 Jun 2024 10:19:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id 1ZjMIp6ZemaFWQAAD6G6ig (envelope-from ); Tue, 25 Jun 2024 10:19:10 +0000 Received: by quack3.suse.cz (Postfix, from userid 1000) id 19B82A095B; Tue, 25 Jun 2024 12:19:10 +0200 (CEST) From: Jan Kara To: Cc: Andrew Morton , Matthew Wilcox , , Jan Kara Subject: [PATCH 10/10] readahead: Simplify gotos in page_cache_sync_ra() Date: Tue, 25 Jun 2024 12:19:00 +0200 Message-Id: <20240625101909.12234-10-jack@suse.cz> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20240625100859.15507-1-jack@suse.cz> References: <20240625100859.15507-1-jack@suse.cz> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1867; i=jack@suse.cz; h=from:subject; bh=Bu7YUmZoT9vACQSaTZDW2SetomtAJn73UDFWVLSHt8E=; b=owEBbQGS/pANAwAIAZydqgc/ZEDZAcsmYgBmepmUjRLlwaM3NNckyBBmL/c1D6Ha48fvdYE17Sg7 YsrS5YCJATMEAAEIAB0WIQSrWdEr1p4yirVVKBycnaoHP2RA2QUCZnqZlAAKCRCcnaoHP2RA2djbCA DfC3XEexGDrUgHi3trjPNNDxHxAd2Pva0wrWmypURWj66YlO7SJWQpMNasQ2bKT9dqrU14g+aQdOtM ywVLaQ89uqqhzMyYqN2QD7GWOJhPsAnmjiDF0HoGOb4kjYN1xw8cDvsXeRHBrvTZk33sducrLHSQ3d uPmmSNSQt7JMFIerXvN0yyWyTJIIJmkdgio0e/Y5bR0C+ftUFk5bI7hZaBu74XjehHu6ZkCCzLv1Fn xfdbJ6zFIi1KAjYcd82rXzJdRbit6boVBpqlf8W4tMlaG2m9qhkM8nWwC3QvkSEODq4U6f2nwlkQm2 Lhs8n/XI7CFY64o2ljZ6XcCcF7PvIo X-Developer-Key: i=jack@suse.cz; a=openpgp; fpr=93C6099A142276A28BBE35D815BC833443038D8C X-Rspamd-Action: no action X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 426C91C0016 X-Stat-Signature: oinsb4oof8mk3sk4homupfxuwszw9r9d X-Rspam-User: X-HE-Tag: 1719310754-850451 X-HE-Meta: U2FsdGVkX1/c8aVlRv+aFCU2UGgq8cIQehEphb/IXjmkYzGCPM+l340JSkUNjXj92TliVQNyN4doKYbKwGxw0JVd721IJq8FYKeM8Zdhmw5kMu1EfI1T3xQjX6cMW+fOszd1Nfz5/a1Ldz3VwlqqjMlQR709E/H2qDv6VyBxQwUG5JIUXhaMJe+VuZCfied80T8nLR2EgMVQ6FPaNTj8cqcUEfz3YkEawUdE7J91kSXdzNw3PwGyAqchExlzH1FYA3tNUJf6TYAPnb7TyGXs+TJarjgNCHlrPBSmm5vjXFjAPBz5TYv4pCvErH4qgTNlXMdF/zjEpSejFzXSC8fEa88JULJE6c1UDKfm7n+InR8je9UQn9IrvsBD78WejAH9ztL9gIO9LVkMkZClBJbPC1mwJhLA16SYKLyEXT8/4jVpskoxMyk/RMOb1cit2JMmt/5b37cgcdiPiSri/EKLSJ3Ho6jSQx0MfdGccXNuwipwe4cbmEdPTWIWWiUgDPWHQAIDS+ewsgyOZBP6dreJv8JfF+Vtq4qlZI/YURWXxGwEDg7Dr72DT072EK3iUTrFSPMijANAiQCCTTTRnf1yFIU/MJ1MfMmQ117iRBxX0CvIrBeAEi6ZbVd9pS3H4mXOMWEJ0i3wOwNJG9SKM3wpD0lg4qTim1xOLBiCAWNYD+rlMBRnpr03XBFh9zy4bglxVKDvXbOvADl+QEIRKALDOMr8SR3EwuoNIXmQIkY/PuS4RQXeweMyQLcaOQV47oAo2BvjT4CtJ1nJTN4gOwSbdleSjrqdy259IfS45jqDc9RMfzm5+ej1BQxSqyyQ6vUKMOkoNoQdkod/9JKxIV16jtec5JWzcHPQOoVmkgbXQGRjXLnMCB5L86AzshcA1ocOSGzZpiTZeeTxERAi+r+/dknhQW9TpNyD9yU5zBH8s1VzoaaCFUiwqtzr6NUVONKFTmYarL+j0hco+HHaJcQ H7zaU3hg NX4VQmbrGQYp5wRsgifyrN1yNM0fyT8Hw58roEEsgNKjtT69HhVq8MOE8tjnDCnqmWHLG+Q1ECgX+g9FhbC0Rltc6NjybpZNGLVi8WYiau5mT24TJyUg9GdnYS+/VlcSo369VHMBKlgvB0hfMvEStm4seJMjechBGxfqYYEnbGnxbK6nN8MTGoX+QPt794lMtV2xDbpMkHtVsjhqjuCxRPhPE3X2JcCwe8Jdo1wDY35V4TtEvHDdmMTfzCEopos3UxxZJ X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Unify all conditions for initial readahead to simplify goto logic in page_cache_sync_ra(). No functional changes. Signed-off-by: Jan Kara --- mm/readahead.c | 26 +++++++++----------------- 1 file changed, 9 insertions(+), 17 deletions(-) diff --git a/mm/readahead.c b/mm/readahead.c index 12c0d2215329..d68d5ce657a7 100644 --- a/mm/readahead.c +++ b/mm/readahead.c @@ -532,20 +532,19 @@ void page_cache_sync_ra(struct readahead_control *ractl, } max_pages = ractl_max_pages(ractl, req_count); + prev_index = (unsigned long long)ra->prev_pos >> PAGE_SHIFT; /* - * start of file or oversized read - */ - if (!index || req_count > max_pages) - goto initial_readahead; - - /* - * sequential cache miss + * A start of file, oversized read, or sequential cache miss: * trivial case: (index - prev_index) == 1 * unaligned reads: (index - prev_index) == 0 */ - prev_index = (unsigned long long)ra->prev_pos >> PAGE_SHIFT; - if (index - prev_index <= 1UL) - goto initial_readahead; + if (!index || req_count > max_pages || index - prev_index <= 1UL) { + ra->start = index; + ra->size = get_init_ra_size(req_count, max_pages); + ra->async_size = ra->size > req_count ? ra->size - req_count : + ra->size >> 1; + goto readit; + } /* * Query the page cache and look for the traces(cached history pages) @@ -572,13 +571,6 @@ void page_cache_sync_ra(struct readahead_control *ractl, ra->start = index; ra->size = min(contig_count + req_count, max_pages); ra->async_size = 1; - goto readit; - -initial_readahead: - ra->start = index; - ra->size = get_init_ra_size(req_count, max_pages); - ra->async_size = ra->size > req_count ? ra->size - req_count : - ra->size >> 1; readit: ractl->_index = ra->start; page_cache_ra_order(ractl, ra, 0);