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 22E49C19F32 for ; Fri, 28 Feb 2025 01:12:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 76FEB6B0082; Thu, 27 Feb 2025 20:12:38 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 71F7C6B0083; Thu, 27 Feb 2025 20:12:38 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5EA3A6B0085; Thu, 27 Feb 2025 20:12:38 -0500 (EST) 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 3FEC66B0082 for ; Thu, 27 Feb 2025 20:12:38 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id A2E6081F93 for ; Fri, 28 Feb 2025 01:12:37 +0000 (UTC) X-FDA: 83167578354.03.608729F Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by imf01.hostedemail.com (Postfix) with ESMTP id 9F6AB40007 for ; Fri, 28 Feb 2025 01:12:35 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=fromorbit-com.20230601.gappssmtp.com header.s=20230601 header.b=vYlcuCGg; dmarc=pass (policy=quarantine) header.from=fromorbit.com; spf=pass (imf01.hostedemail.com: domain of david@fromorbit.com designates 209.85.214.170 as permitted sender) smtp.mailfrom=david@fromorbit.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1740705155; a=rsa-sha256; cv=none; b=wnGT3y0X5yUgxsNPUUiJxpTG11zmj003O++mi5VbQFNsCuBcBx/WCNmCFlIwBWSs80s6+2 vRzPShjqO3J/whKs9o252bjGh8qq41BhME+WDfwcbJ/JX8L/37+jv7bGTPBa8fYazMBUSJ UqpjGPrVJeJa44x58FEUlSYJmNDXWpk= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=fromorbit-com.20230601.gappssmtp.com header.s=20230601 header.b=vYlcuCGg; dmarc=pass (policy=quarantine) header.from=fromorbit.com; spf=pass (imf01.hostedemail.com: domain of david@fromorbit.com designates 209.85.214.170 as permitted sender) smtp.mailfrom=david@fromorbit.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1740705155; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=+LGRA7VPphS9Jn5iBE0/oDb80AP+NSCSCumMI2FV4Lw=; b=LfYGoSWkG3rfKw3tMh2t8celmkuO2+Thmr7KKdoTqVR03QxdwfUuGSaJwOvpKCs/4UaAUf zeVFPaInoR0SUyOZh6ZBeD5FjTh0LQwY6yMpFs1VKd7joNM2n50f/ET6YvaftS8mT18fMW NpvTrXLfEbiB8nCCMAHgNeBPRZcWHw8= Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-22334203781so40007615ad.0 for ; Thu, 27 Feb 2025 17:12:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fromorbit-com.20230601.gappssmtp.com; s=20230601; t=1740705154; x=1741309954; darn=kvack.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=+LGRA7VPphS9Jn5iBE0/oDb80AP+NSCSCumMI2FV4Lw=; b=vYlcuCGgVIKpqeX6fnjYetyBSCqCEE0s4DLUyLsv3ntMGfLFZL5Z/UlxDLvmoYpX12 PNko6tGEoYLFcAe9or2+O1SKNfGfQiMQI66I5wITF3sEHdSov9jxTHnnefGjUqFolTIf njZxqspZbizj9TlD+jJf7KocvexcELKt9ycywCnzkWLAAXOwU3aTopA76UN0fPZjBxJg 65akZJY8OfYSq5tOepn66DfkGLr2e99OFCm+YQWB8P1S+J6t8WGIpGxVtLpYnt1KUlgJ NTM0CXflu6DMnesIiKHsbXNkHA8zLmvDDXvviZ0hPKJ3rgihij81hp6LWYORmyLQBFR2 uI5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1740705154; x=1741309954; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=+LGRA7VPphS9Jn5iBE0/oDb80AP+NSCSCumMI2FV4Lw=; b=CdTdtW2VJjOxllT402hWoD19o3pqLtVstyx4T4WR0s5iM5Bc/tVHpb7y+O/41zXGa3 DwjWgCCq+uMkJPHj/qKRs4VwCFDj19CKo1NPSbpAP4o1PFcKg+geuedq7Xx9J+3oDQ0I rfGihkuIJdJrUTOszWkmwbfauv57mbQUhylDSebIN8jjImGAKklG6TML/hWumJwFwVAR qLh9laYU/15TDV8Uvx1KvCrp6UD4boHJ9cSVBNLRIIsGoJFeuSYk0TsI/djfe2/9i1PR E2lAhJyd/t4dP4ked0cUUNYdUKdLzcVFqHIPA4OiZwyexCGCmpvKjJT0oN5iI2/r3OGn ZKMQ== X-Forwarded-Encrypted: i=1; AJvYcCXlekJSBmMtvUrsqrgQd8lUywG76Hh6jg7+piQB0psXyqXPlRh28NZ2j+zoTL5e/OmEat5g7rMLhQ==@kvack.org X-Gm-Message-State: AOJu0YwK6cgAJSx1ZIDI2+kE8OkaSKDiaWA5+nYbrXmMIKOCyRAx4YiD mmW+ZLIzZqc+e+1l1yiRQtz1idp2wnee2hhJZiS9rm7Iequ2PnmO7DHsw5yIZwo= X-Gm-Gg: ASbGncs/6e2USgTcOHMVRPzz+k9HRgs4++h4secRl4/Oll++1MTfwU/vIaS65SK5jI8 CFVSDLnXS/AZ+3Nth9/U1/j3OT1TnnHkDaZtktHbmdZtSB3DrY34F6RUpbrF42Uzkl5cQmM0v9u PtaEMF478kqoAW40kigBTLk7cGZb8PWkD0JHXFjkEevgR9EBE3TZ5hLX6NaEXuScAjGGkv1peS+ 4rFavWnWb4LHPlEGgRztz9bVDLDXy3HUjuy6H2H9luMG2T9TeaDwVFsoq/KV5s6MVpVX9PC7ly+ Yc2hAV40MPIJxl2cbiCxdJBNQSYdw6ihHKrMB1lIePfkfXfXQSj95ppoVFzj6eAp71743Dj1CNk baA== X-Google-Smtp-Source: AGHT+IFkHEs/ILrzaG2+YI5r0gyFAxGNwuLrYNWmrNl90A1PrcGeF3HOx3TrMc59W5bFoVzhFUbWdg== X-Received: by 2002:a62:ea12:0:b0:732:5875:eb95 with SMTP id d2e1a72fcca58-7349d1e3e32mr8929672b3a.4.1740705154401; Thu, 27 Feb 2025 17:12:34 -0800 (PST) Received: from dread.disaster.area (pa49-186-89-135.pa.vic.optusnet.com.au. [49.186.89.135]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7349fe48873sm2437620b3a.49.2025.02.27.17.12.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Feb 2025 17:12:33 -0800 (PST) Received: from dave by dread.disaster.area with local (Exim 4.98) (envelope-from ) id 1tnovW-00000006qMq-2oW8; Fri, 28 Feb 2025 12:12:30 +1100 Date: Fri, 28 Feb 2025 12:12:30 +1100 From: Dave Chinner To: Matthew Wilcox Cc: Kalesh Singh , Lorenzo Stoakes , Jan Kara , lsf-pc@lists.linux-foundation.org, "open list:MEMORY MANAGEMENT" , linux-fsdevel , Suren Baghdasaryan , David Hildenbrand , "Liam R. Howlett" , Juan Yescas , android-mm , Vlastimil Babka , Michal Hocko , "Cc: Android Kernel" Subject: Re: [Lsf-pc] [LSF/MM/BPF TOPIC] Optimizing Page Cache Readahead Behavior Message-ID: References: <3bd275ed-7951-4a55-9331-560981770d30@lucifer.local> <82fbe53b-98c4-4e55-9eeb-5a013596c4c6@lucifer.local> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Rspam-User: X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 9F6AB40007 X-Stat-Signature: f4bj66bz7srgmt5q3nqjstmfbzxn9pdr X-HE-Tag: 1740705155-471707 X-HE-Meta: U2FsdGVkX183DjA0QQ90W3FhMTsZ01WktPvi2qhuf6Hp2u8pC0QNes7wiyNcmIrRqfHKn1nYHucWBbOIqqJexSNQnYHQHc3HSMACLkkpCTFRu2vGc7S/dw3Z2fySbiQPBpwMG755sEGXYV6C1LdzrTg/uGalMxaIce7LhMHPR8TXqZUx2WSn2H2mNVA7mJvlhS+8kIcUhFFzNxHNoUPnNbE+8hn5y948p8sbsYZBoNhWA0HZo2hkFGt64VWQm72FvWGj9FUVawI9UGAGDPZK1YEyzdJ8zq8/1+gUhYaxDcv+M+Oi7rOmosg05gCk067S8pZeMh4Pm6zvD3p7AZTBu75GL3A7e1oM0n9VxL+QOfWxpjObaRpAiwq5tJbUHoGSla0cdRl3MQmje0D48ZTokcNtEKZSymJZ0McRs+cq/eK+lPGhFKh9GLafEpkZaO9Zv4YSmMlPX7fBoSbfaBGKzsZ7BLpywmzEbOA9nCrPJirFLD8SyalMUnyhh+3Vbn5zLpEPYyYA0kplqVWgqBW2THhpekRcB8grJnZKGFQ+3JSsBZc0WBtWpOZSsSSmENqnaKqd4ub/zIpCziIIF8L+eGcdDT2QE4vOJTvDs3rc7yI2oVzG+MEenqYUD0icc24iCJhIUpNityk7kffQZ03g0nfbezQoGMLYJvGQ60R2Tlsp5PjnfOzCYatPZmm2v8c1yaOSb6VlGjRWV+94jm5erBB8c0z0pTaizeZHp9pTUgLNLJc9Ixw6aADXUELz6j/xq1YlExtzgbOMClWAD9WNhGuaFW3cKAPp6X6mTGOg9+ziTFj081NoFAdLeiBn6cz7L8im79knA+RhW4e9grx2Y7peDx+SvDSIdEoC0coj5hWtlhK3IU6U/66NshUQknOWzwZF0A0XQe6PNBwepXhSegeV5JI+Kb4B7YddaiMHBECECXM3gTm8gqdQH81VoQ1xqQwsezvo96JaR8CykEy s1aQo/Ao 4DZJWHzpKc79XQfUy5+CaM/KD9tSfWWXudXnG2BvFUYc4nThDguaHWfOrk3aicDiEDp72/S9Ug+Nso0H0kB79Tj2jtMirSS7ui2XbBgWZhqlAVoGNxjB/APMC/xuQliopbq7Nm1/6ZoQvMnPMRU45Jbr9PBmAMrywQ24z3+n0DmWQl0tguzV/rS65SL85mxhL8G11h4ByjD3k7tsVucFh4Sov3AQUpkPbbU91wEUkMFJghzGvvq2D3cmnLuJTWIYL8AssUbyQjogSPF89IHWs0waz+2cz2H6j5SvsG7eGfANvqXsDWr7AnHLlcsib9pBSZzIETjsYxcT5P3pIjpa+utIpS9h4CTQYPu8V9m7J9JX5cW1NO+3OHYk4DCVlC5xoMn3HkKlyekLUea9BvcO4fJ+6NZmjCVLqDWDE9JIjBgqiX5NAOJatlv/rutcW5RY8BSC6a/9vM4eEPBh71dd8sgkjniOYNBG6dKo5g/ZV4IlqhkzA/AthKwj5iQ== X-Bogosity: Ham, tests=bogofilter, spamicity=0.071671, 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 Thu, Feb 27, 2025 at 10:12:50PM +0000, Matthew Wilcox wrote: > On Tue, Feb 25, 2025 at 10:56:21AM +1100, Dave Chinner wrote: > > > From the previous discussions that Matthew shared [7], it seems like > > > Dave proposed an alternative to moving the extents to the VFS layer to > > > invert the IO read path operations [8]. Maybe this is a move > > > approachable solution since there is precedence for the same in the > > > write path? > > > > > > [7] https://lore.kernel.org/linux-fsdevel/Zs97qHI-wA1a53Mm@casper.infradead.org/ > > > [8] https://lore.kernel.org/linux-fsdevel/ZtAPsMcc3IC1VaAF@dread.disaster.area/ > > > > Yes, if we are going to optimise away redundant zeros being stored > > in the page cache over holes, we need to know where the holes in the > > file are before the page cache is populated. > > Well, you shot that down when I started trying to flesh it out: > https://lore.kernel.org/linux-fsdevel/Zs+2u3%2FUsoaUHuid@dread.disaster.area/ No, I shot down the idea of having the page cache maintain a generic cache of file offset to LBA address mappings outside the filesystem. Having the filesystem insert a special 'this is a hole' entry into the mapping tree insert of allocating and inserting a page full of zeroes is not an extent cache - it's just a different way of representing a data range that is known to always contain zeroes. > > As for efficient hole tracking in the mapping tree, I suspect that > > we should be looking at using exceptional entries in the mapping > > tree for holes, not inserting mulitple references to the zero folio. > > i.e. the important information for data storage optimisation is that > > the region covers a hole, not that it contains zeros. > > The xarray is very much optimised for storing power-of-two sized & > aligned objects. It makes no sense to try to track extents using the > mapping tree. Certainly. I'm not suggesting that we do this at all, and .... > Now, if we abandon the radix tree for the maple tree, we > could talk about storing zero extents in the same data structure. > But that's a big change with potentially significant downsides. > It's something I want to play with, but I'm a little busy right now. .... I still do not want the page cache to try to maintain a block mapping/extent cache in addition to the what the filesystem must already maintain for the reasons I have previously given. > > For buffered reads, all that is required when such an exceptional > > entry is returned is a memset of the user buffer. For buffered > > writes, we simply treat it like a normal folio allocating write and > > replace the exceptional entry with the allocated (and zeroed) folio. > > ... and unmap the zero page from any mappings. Sure. That's just a call to unmap_mapping_range(), yes? > > For read page faults, the zero page gets mapped (and maybe > > accounted) via the vma rather than the mapping tree entry. For write > > faults, a folio gets allocated and the exception entry replaced > > before we call into ->page_mkwrite(). > > > > Invalidation simply removes the exceptional entries. > > ... and unmap the zero page from any mappings. Invalidation already calls unmap_mapping_range(), so this should already be handled, right? -Dave. -- Dave Chinner david@fromorbit.com