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 90064C021A4 for ; Mon, 24 Feb 2025 12:56:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 12F066B007B; Mon, 24 Feb 2025 07:56:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0B87E6B0083; Mon, 24 Feb 2025 07:56:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E9AE36B0085; Mon, 24 Feb 2025 07:56:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id CBB506B007B for ; Mon, 24 Feb 2025 07:56:51 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id CF3E21CA259 for ; Mon, 24 Feb 2025 12:56:44 +0000 (UTC) X-FDA: 83154837528.10.E67AF4C Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf01.hostedemail.com (Postfix) with ESMTP id B481640009 for ; Mon, 24 Feb 2025 12:56:34 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=GVq+obXY; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=LEKZcQHr; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=GVq+obXY; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=LEKZcQHr; spf=pass (imf01.hostedemail.com: domain of dsterba@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=dsterba@suse.cz; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1740401795; h=from:from:sender:reply-to: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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=ABRZsikHdvHqgE/zdj7fxNHzmZtBSGT51GLjtRuTsHE=; b=u9wEueFUhtCZRzpX1g4L0SITNM+fR/NSCAQDCQ8ISL66sJ0Z+tXW5cx9S0hUTKyHEtd6NC faLpxW4GoNo7zqK2UtIBrVHYyEZGDkGNLVzLdvL+TQ4UfdPWHSfmruvMOcSmnC2GcGrKdL K1VjZy4q186vWuKhnHRTuhnUmOCpPRg= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=GVq+obXY; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=LEKZcQHr; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=GVq+obXY; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=LEKZcQHr; spf=pass (imf01.hostedemail.com: domain of dsterba@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=dsterba@suse.cz; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1740401795; a=rsa-sha256; cv=none; b=cTi0KnQ8eTwB+oZOFzZTdUn2lhP1FeIVElwlP3gfh6szmJpV0C0M9l/0fJOGkegrU7EFNk VLhr5ZVrOehF2855r2TLMuksL7TVn9tvvw4JKK24ss95UfDNw0ji35Bc3DgVtLEumrO1vs zdF+HrxN1LSROhJoE7KT0I5/HYH9j1A= 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 032DE21160; Mon, 24 Feb 2025 12:56:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1740401793; h=from:from:reply-to:reply-to:date:date:message-id:message-id:to:to: cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ABRZsikHdvHqgE/zdj7fxNHzmZtBSGT51GLjtRuTsHE=; b=GVq+obXYC2PEKWxQrTR6ckn0Kos0taQ6X+8d579oZwSxoROr9t1lkTh48lG72ZRRh+4XFl gpisgfvfrx/KnkNe7dP8ko524hFyXyY/QCoXYwQHtVblW4RUycI0AWjzGTEq5AgJ0wvkrI ffBJYSSx2A7G3JdL4KPdF3Ilm56Rshk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1740401793; h=from:from:reply-to:reply-to:date:date:message-id:message-id:to:to: cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ABRZsikHdvHqgE/zdj7fxNHzmZtBSGT51GLjtRuTsHE=; b=LEKZcQHrvukA4tbFLWJnBVXwryF3YCkPyG+iPqFnwmgTiiF1DlndoshV/Q+0mVnNtTvKnb xYYyuAngjStAH7AQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1740401793; h=from:from:reply-to:reply-to:date:date:message-id:message-id:to:to: cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ABRZsikHdvHqgE/zdj7fxNHzmZtBSGT51GLjtRuTsHE=; b=GVq+obXYC2PEKWxQrTR6ckn0Kos0taQ6X+8d579oZwSxoROr9t1lkTh48lG72ZRRh+4XFl gpisgfvfrx/KnkNe7dP8ko524hFyXyY/QCoXYwQHtVblW4RUycI0AWjzGTEq5AgJ0wvkrI ffBJYSSx2A7G3JdL4KPdF3Ilm56Rshk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1740401793; h=from:from:reply-to:reply-to:date:date:message-id:message-id:to:to: cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=ABRZsikHdvHqgE/zdj7fxNHzmZtBSGT51GLjtRuTsHE=; b=LEKZcQHrvukA4tbFLWJnBVXwryF3YCkPyG+iPqFnwmgTiiF1DlndoshV/Q+0mVnNtTvKnb xYYyuAngjStAH7AQ== 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 D59BB13332; Mon, 24 Feb 2025 12:56:32 +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 mR/wM4BsvGeoJwAAD6G6ig (envelope-from ); Mon, 24 Feb 2025 12:56:32 +0000 Date: Mon, 24 Feb 2025 13:56:27 +0100 From: David Sterba To: Ritesh Harjani Cc: Kalesh Singh , lsf-pc@lists.linux-foundation.org, "open list:MEMORY MANAGEMENT" , linux-fsdevel , Suren Baghdasaryan , David Hildenbrand , Lorenzo Stoakes , "Liam R. Howlett" , Juan Yescas , android-mm , Matthew Wilcox , Vlastimil Babka , Michal Hocko Subject: Re: [LSF/MM/BPF TOPIC] Optimizing Page Cache Readahead Behavior Message-ID: <20250224125627.GL5777@twin.jikos.cz> Reply-To: dsterba@suse.cz References: <87wmdhgr5x.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87wmdhgr5x.fsf@gmail.com> User-Agent: Mutt/1.5.23.1-rc1 (2014-03-12) X-Rspamd-Action: no action X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: B481640009 X-Stat-Signature: 3mgc1dzseok51mczta8g7rnhosybnwri X-Rspam-User: X-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E9Lz8+a2F+nN2jZNnVi84P6LYmGYXG8v+yiBHCRaR0TWwN6MrtGc244V6Z7veYXkyFYv2H1V+feumR8NOb/gwV2I2pqmAvX32qRSrVZ9UeCZjrdbA91k4S3J6MS3iFWeWHWvoE8XgOGQHBwSZTFBcru8xJuzxOquQZbX0k1cf5Y96fCptXuoNv5bc1I+9lP/OxmkS3Tg7tejq3Xdss+xRI5uGtEIy8WDqSjXHB5WqlUmcFqDrPXi9/iRQZ7ECNWOZaPXTwWOdONOSLx99TO9bJE1gnPdUUcZaQ9+kY6gfmg6FNORwT0jugdPclAkjKt8BQB9cf2LMQIte8HOwEJX7w7qXQ+UOPNdcYNMyEw2JnhZtmZyUO2/RTDDiQDZZNkF+Dr+ZexWKQKE X-Bogosity: Ham, tests=bogofilter, spamicity=0.000028, 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 Sun, Feb 23, 2025 at 11:04:50AM +0530, Ritesh Harjani wrote: > Kalesh Singh writes: > > > Hi organizers of LSF/MM, > > > > I realize this is a late submission, but I was hoping there might > > still be a chance to have this topic considered for discussion. > > > > Problem Statement > > =============== > > > > Readahead can result in unnecessary page cache pollution for mapped > > regions that are never accessed. Current mechanisms to disable > > readahead lack granularity and rather operate at the file or VMA > > >From what I understand the readahead setting is done at the per-bdi > level (default set to 128K). That means we don't get to control the > amount of readahead pages needed on a per file basis. If say we can > control the amount of readahead pages on a per open fd, will that solve > the problem you are facing? That also means we don't need to change the > setting for the entire system, but we can control this knob on a per fd > basis? > > I just quickly hacked fcntl to allow setting no. of ra_pages in > inode->i_ra_pages. Readahead algorithm then takes this setting whenever > it initializes the readahead control in "file_ra_state_init()" > So after one opens the file, we can set the fcntl F_SET_FILE_READAHEAD > to the preferred value on the open fd. > > > Note: I am not saying the implementation could be 100% correct. But it's > just a quick working PoC to discuss whether this is the right approach > to the given problem. > @@ -678,6 +678,8 @@ struct inode { > unsigned short i_bytes; > u8 i_blkbits; > enum rw_hint i_write_hint; > + /* Per inode setting for max readahead in page_size units */ > + unsigned long i_ra_pages; > blkcnt_t i_blocks; If your final patch needs to store data in struct inode, please try to optimize it so that the size does not change. There are at least 2 4 byte holes so if you're fine with a page size unit for readahead then this should be sufficient.