From mboxrd@z Thu Jan 1 00:00:00 1970 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 A4F89C02183 for ; Tue, 14 Jan 2025 14:13:10 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F0A296B007B; Tue, 14 Jan 2025 09:13:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EBA6C6B0083; Tue, 14 Jan 2025 09:13:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D81826B0085; Tue, 14 Jan 2025 09:13:09 -0500 (EST) 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 B63136B007B for ; Tue, 14 Jan 2025 09:13:09 -0500 (EST) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 4257280929 for ; Tue, 14 Jan 2025 14:13:09 +0000 (UTC) X-FDA: 83006249298.21.FC603D0 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf19.hostedemail.com (Postfix) with ESMTP id 2D6BE1A0021 for ; Tue, 14 Jan 2025 14:13:07 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hZxA7bkb; spf=pass (imf19.hostedemail.com: domain of bcodding@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bcodding@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1736863987; a=rsa-sha256; cv=none; b=pP9vfM7Y5gEH5T47UoThVYZFlnpXZTRmeVANQ0QSinKK7pMuGRXvHNjETjoxjxGhkcyLE4 47JVhSR70qeNsjazu80A27VtNMzwlPDOw2xn9IOF94Z08qn4F9M/1BeZ3WR3SgyYhlSnEB FO74kIvQyVpjx+Pkh1d4qbtKRPYR0wU= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hZxA7bkb; spf=pass (imf19.hostedemail.com: domain of bcodding@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=bcodding@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=1736863987; 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:in-reply-to:references:references:dkim-signature; bh=B04i/gZ8lgb0zv2argciPqONFDUYHmh8OQrj2OyE9uo=; b=5JBLF+Z2vAQDhJ0DsMaXBMkeg8Bx6LyqXlQflsQ9eLE/xT71A7Dv67aFoi03JghIp7M+W2 S5dZ+NEnLf6zWfQzJOZD3cerYZZPsXqX+/ncpBzXvKvax8gJPHHY0c/HjPNgkjWaQknxq+ fE0q+v5+XSQOPZ/2w+OU0sfaPmgRCFs= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1736863986; 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: in-reply-to:in-reply-to:references:references; bh=B04i/gZ8lgb0zv2argciPqONFDUYHmh8OQrj2OyE9uo=; b=hZxA7bkbaTNlJjmbVNEdx1Ay7sHBbL0AEdi1udlPbskPEWelgOCUHYDznEGzl3LTdaeqWF p2i5dOdkl/ow5aJf/6FAJJ67DyxoVGeAoSvDUeRKGXtWhEovQEbPVYg6XvrvFlEUTjKhtY jyo+h2s1qWt0oKNP4CcBE8wYvy8BpDs= Received: from mx-prod-mc-05.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-324-GmAEdh9ENC6QwlqhKjVq9w-1; Tue, 14 Jan 2025 09:13:04 -0500 X-MC-Unique: GmAEdh9ENC6QwlqhKjVq9w-1 X-Mimecast-MFC-AGG-ID: GmAEdh9ENC6QwlqhKjVq9w Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 648AA1955DC0; Tue, 14 Jan 2025 14:13:02 +0000 (UTC) Received: from [192.168.37.1] (unknown [10.22.76.4]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 1476219560A3; Tue, 14 Jan 2025 14:12:58 +0000 (UTC) From: Benjamin Coddington To: Amir Goldstein Cc: Shyam Prasad N , lsf-pc@lists.linux-foundation.org, linux-fsdevel , linux-mm@kvack.org, brauner@kernel.org, Matthew Wilcox , David Howells , Jeff Layton , Steve French , trondmy@kernel.org, Shyam Prasad N Subject: Re: [LSF/MM/BPF TOPIC] Predictive readahead of dentries Date: Tue, 14 Jan 2025 09:12:57 -0500 Message-ID: <460E352E-DDFA-4259-A017-CAE51C78EDFC@redhat.com> In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Rspamd-Queue-Id: 2D6BE1A0021 X-Stat-Signature: nacu6kd6ghs536bjshqf3ao1x6uwxwkm X-Rspam-User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vFiY7iIKn+VWNYVf0lyDjpd0yLLIZ7XdgFBYjYlK8wC93IRTkYwpeUXXKnRCKEnjJJeE1ciVpEF8jcJ1+ajU9jyrjTPn7MZKETp5o81e4FMecjsTls0004pNof1D9k+ccxLq67YACLNPONLL7Ajta8lof0MuyDeHVmuD9cq6FEBOHBBc+cUYwFcHyjSP/MBz5K8jptc3aDTfW7T9gsgkAM1XLnDtlwztPFdNxQKYDmnQY/euH3C70T1iZg5chKiztm1gji+UlB3mmH5NQN8cxXpbXjvdckdm/L2mz2hj7wZy7xN4lSQzMh/zAVxjQ= 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: On 14 Jan 2025, at 8:24, Amir Goldstein wrote: > On Tue, Jan 14, 2025 at 4:38 AM Shyam Prasad N wrote: >> >> The Linux kernel does buffered reads and writes using the page cache >> layer, where the filesystem reads and writes are offloaded to the >> VM/MM layer. The VM layer does a predictive readahead of data by >> optionally asking the filesystem to read more data asynchronously than >> what was requested. >> >> The VFS layer maintains a dentry cache which gets populated during >> access of dentries (either during readdir/getdents or during lookup). >> This dentries within a directory actually forms the address space for >> the directory, which is read sequentially during getdents. For network >> filesystems, the dentries are also looked up during revalidate. >> >> During sequential getdents, it makes sense to perform a readahead >> similar to file reads. Even for revalidations and dentry lookups, >> there can be some heuristics that can be maintained to know if the >> lookups within the directory are sequential in nature. With this, the >> dentry cache can be pre-populated for a directory, even before the >> dentries are accessed, thereby boosting the performance. This could >> give even more benefits for network filesystems by avoiding costly >> round trips to the server. >> > > I believe you are referring to READDIRPLUS, which is quite common > for network protocols and also supported by FUSE. > > Unlike network protocols, FUSE decides by server configuration and > heuristics whether to "fuse_use_readdirplus" - specifically in readdirplus_auto > mode, FUSE starts with readdirplus, but if nothing calls lookup on the > directory inode by the time the next getdents call, it stops with readdirplus. > > I personally ran into the problem that I would like to control from the > application, which knows if it is doing "ls" or "ls -l" whether a specific > getdents() will use FUSE readdirplus or not, because in some situations > where "ls -l" is not needed that can avoid a lot of unneeded IO. Indeed, we often have folks wanting dramatically different behavior from getdents() in NFS, and every time we've tried to improve our heuristics someone else shouts "regression"! We can tune the NFS heuristic per-mount, but it often makes the wrong choice.. As you say letting the application make the call would be ideal. POSIX_FADV_ ? Ben