From patchwork Tue Jul 2 14:50:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13719873 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 C6BBAC3064D for ; Tue, 2 Jul 2024 14:50:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 457406B0088; Tue, 2 Jul 2024 10:50:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4057E6B0089; Tue, 2 Jul 2024 10:50:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2A6536B008A; Tue, 2 Jul 2024 10:50:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 0D5146B0088 for ; Tue, 2 Jul 2024 10:50:24 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 7291CC026F for ; Tue, 2 Jul 2024 14:50:23 +0000 (UTC) X-FDA: 82295098326.16.0A3FFF1 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf07.hostedemail.com (Postfix) with ESMTP id 91B0240003 for ; Tue, 2 Jul 2024 14:50:21 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=DxXBMRAa; spf=pass (imf07.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1719931804; 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-type: content-transfer-encoding:content-transfer-encoding:in-reply-to: references:dkim-signature; bh=uWZifttcEAbyBfObjSbGpm26/PI7fGmjt0k2HweKiRc=; b=jCTxWX3/bhDH5bMMIbd0AfykrM7tkLXf/hx7quD0fyQ1ILavvybbfr+BbMoRZnjOQ6JUMG ynddRMDev5iqV0GOxvq+NuxtzK/bPfc2CtjWihUwZVw0/NxgYddGReVe55n65FNyBt87Nx IS7D/nxbEDouAjKDw2gs2zMaXxY8aF4= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=DxXBMRAa; spf=pass (imf07.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1719931804; a=rsa-sha256; cv=none; b=ewFf3zEWINtDIVcfx+XpyPPOgcynL5WjnQaq/Vy39cSUQS5k5YKKSea96B7IQH0JnqT6pN tXMeQv1CPqf86cSGG0Mc0yaB36LHzgKZ34PN9OWm1s84uUEm4oP6AR1dC5Azs6WdFxvDKV HMaq9ku4kkblC0BalcENpU6gw6L7G6w= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1719931821; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=uWZifttcEAbyBfObjSbGpm26/PI7fGmjt0k2HweKiRc=; b=DxXBMRAalBWmSrdJ2I6mfrjlzzKp/e0V+BOeC6bDyNcOOCAHg015pEdZ3LIFGzzrGrLlmT Z1IBJkDs+O/tMZM7/7wNvuaNOkf+QHFd7rhV5Cm8CpwTeBFefyNOLMIbgBScz//XwV2vux PmwUDityAoH8fSKRdl0Ve5Z3s4TZyhY= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-544-7te1MDSUOmGrLCL5FkfiOg-1; Tue, 02 Jul 2024 10:50:16 -0400 X-MC-Unique: 7te1MDSUOmGrLCL5FkfiOg-1 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0252219560B8; Tue, 2 Jul 2024 14:50:14 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.111]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 640C93000221; Tue, 2 Jul 2024 14:50:10 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells To: Steve French cc: dhowells@redhat.com, Paulo Alcantara , Jeff Layton , Christian Brauner , Matthew Wilcox , linux-cifs@vger.kernel.org, netfs@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH] cifs: Fix read-performance regression by dropping readahead expansion MIME-Version: 1.0 Content-ID: <3042270.1719931809.1@warthog.procyon.org.uk> Date: Tue, 02 Jul 2024 15:50:09 +0100 Message-ID: <3042271.1719931809@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.4.1 on 10.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pIEK3s7jlZ7LAbL8y5JOIYmD/jvgp8g wvYdjX7W TTKpxXGANY0L+m0tGI5w4cipMQ9lwGGa1T3oin67FCipL3C8GW27TGmbk9Nmyau3lEBDgw2rLL2DuiiEMHht4ISU+KahuhtHJm3JkM84eEKO/cmIdyYtYSKXMHkgiDVu+LSWM/C9Gduaf5kNmzCacMqqz54FEcXy8fSD7ZS/jSYH85Qjdg3YCgLPSAtAf3nuKK0hTXVaQCB+mtwJ8xcbcHw4fgV3jhEQg6fIcW4Lm82wcJVl8SnIDuMbEuFWyf+NWxnmAl7rspJyM5YZuYiWxS3RWmEz3uPcll6BxN3NuU9XpzT7lrVh68fhlT4LrbEaU0J34UxZ39/8isSWNIVoz+5eEtD6BPD1YIV+SoVD1OvrwYMuWX248H9pZQxBQs2J/ILIr5xg/alwFV7MGbR7+/BvIdc9t1ODeIIVTmtZSASh3mvgpEnS61u3rj2ZOToxYl64qBmUhzVLs7IpSasvLJlVOvwoSDndoBZP8ArMWaaIAgPA4lxB4NyLuiuLKrpyw9XTOLmtcgb7lMtS5R7bfdCuabJxOK8m3LU0AYPia3r7yob0Fv9/xuB+eEiVnqOLG8IQKPxKB5akhOKR8RgNcXbG6IaQqCpN57FHL 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: cifs_expand_read() is causing a performance regression of around 30% by causing extra pagecache to be allocated for an inode in the readahead path before we begin actually dispatching RPC requests, thereby delaying the actual I/O. The expansion is sized according to the rsize parameter, which seems to be 4MiB on my test system; this is a big step up from the first requests made by the fio test program. Fix this by removing cifs_expand_readahead(). Readahead expansion is mostly useful for when we're using the local cache if the local cache has a block size greater than PAGE_SIZE, so we can dispense with it when not caching. Signed-off-by: David Howells cc: Steve French cc: Paulo Alcantara cc: Jeff Layton cc: Matthew Wilcox cc: linux-cifs@vger.kernel.org cc: netfs@lists.linux.dev cc: linux-fsdevel@vger.kernel.org cc: linux-mm@kvack.org --- fs/smb/client/file.c | 30 ------------------------------ 1 file changed, 30 deletions(-) diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c index f1f2573bb18d..1374635e89fa 100644 --- a/fs/smb/client/file.c +++ b/fs/smb/client/file.c @@ -245,35 +245,6 @@ static int cifs_init_request(struct netfs_io_request *rreq, struct file *file) return 0; } -/* - * Expand the size of a readahead to the size of the rsize, if at least as - * large as a page, allowing for the possibility that rsize is not pow-2 - * aligned. - */ -static void cifs_expand_readahead(struct netfs_io_request *rreq) -{ - unsigned int rsize = rreq->rsize; - loff_t misalignment, i_size = i_size_read(rreq->inode); - - if (rsize < PAGE_SIZE) - return; - - if (rsize < INT_MAX) - rsize = roundup_pow_of_two(rsize); - else - rsize = ((unsigned int)INT_MAX + 1) / 2; - - misalignment = rreq->start & (rsize - 1); - if (misalignment) { - rreq->start -= misalignment; - rreq->len += misalignment; - } - - rreq->len = round_up(rreq->len, rsize); - if (rreq->start < i_size && rreq->len > i_size - rreq->start) - rreq->len = i_size - rreq->start; -} - /* * Completion of a request operation. */ @@ -329,7 +300,6 @@ const struct netfs_request_ops cifs_req_ops = { .init_request = cifs_init_request, .free_request = cifs_free_request, .free_subrequest = cifs_free_subrequest, - .expand_readahead = cifs_expand_readahead, .clamp_length = cifs_clamp_length, .issue_read = cifs_req_issue_read, .done = cifs_rreq_done,