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 X-Spam-Level: X-Spam-Status: No, score=-8.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DC70EC433B4 for ; Fri, 14 May 2021 17:49:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 4FA5461451 for ; Fri, 14 May 2021 17:49:06 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4FA5461451 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=infradead.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id CDCF26B006C; Fri, 14 May 2021 13:49:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CB2956B006E; Fri, 14 May 2021 13:49:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BA1116B0071; Fri, 14 May 2021 13:49:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0091.hostedemail.com [216.40.44.91]) by kanga.kvack.org (Postfix) with ESMTP id 87E366B006C for ; Fri, 14 May 2021 13:49:05 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 2F47E8249980 for ; Fri, 14 May 2021 17:49:05 +0000 (UTC) X-FDA: 78140572650.12.F6B8C1C Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf17.hostedemail.com (Postfix) with ESMTP id 30FE340002CA for ; Fri, 14 May 2021 17:49:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:To:From:Date:Sender:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description; bh=2pAe91SWzc/6riCJTnq7kqxW30iWZ5ZzX7m8q/+xTL0=; b=pxBgiq2xmX4brOJjhFnslcv0it MmKEA6uhuUypxWEc3UG6F1Wp650xb/5yQzn09Tqc9aJ4pnsXBpgk2zl5T/eiWto8mOykLDJ1lbnf1 6ZyM7o7qGX3h6fHDf5e2mcVTXr2BCpli8AJsT2vKKgaWdmw6EAZbo4LtKmdz5VmuJAeyJ/kdfOuj7 4b9SOEQPkp96VlcfvuqnozuLOQ3koM0kxl6BiARLyqvR/gq2ISejZm3FjS6N027kuaqQdSfAQSV72 y2x/473TwS/oB+ykEC+G0nCJblIVfUMF9LU+lz/5Gn+n9u0pXX+cUIhlqb5WhazNmPjaYln0v3z4b eyqkiIBA==; Received: from willy by casper.infradead.org with local (Exim 4.94 #2 (Red Hat Linux)) id 1lhbvG-00AaXL-9i; Fri, 14 May 2021 17:48:31 +0000 Date: Fri, 14 May 2021 18:48:26 +0100 From: Matthew Wilcox To: lsf-pc@lists.linux-foundation.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-block@vger.kernel.org, linux-ide@vger.kernel.org, linux-scsi@vger.kernel.org, linux-nvme@lists.infradead.org Subject: Re: [LSF/MM/BPF TOPIC] Memory folios Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=pxBgiq2x; spf=none (imf17.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 30FE340002CA X-Stat-Signature: etxbmi36woon8w651tqufnrf7yzrmx1a X-HE-Tag: 1621014542-210809 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: On Mon, May 10, 2021 at 06:56:17PM +0100, Matthew Wilcox wrote: > I don't know exactly how much will be left to discuss about supporting > larger memory allocation units in the page cache by December. In my > ideal world, all the patches I've submitted so far are accepted, I > persuade every filesystem maintainer to convert their own filesystem > and struct page is nothing but a bad memory by December. In reality, > I'm just not that persuasive. > > So, probably some kind of discussion will be worthwhile about > converting the remaining filesystems to use folios, when it's worth > having filesystems opt-in to multi-page folios, what we can do about > buffer-head based filesystems, and so on. > > Hopefully we aren't still discussing whether folios are a good idea > or not by then. I got an email from Hannes today asking about memory folios as they pertain to the block layer, and I thought this would be a good chance to talk about them. If you're not familiar with the term "folio", https://lore.kernel.org/lkml/20210505150628.111735-10-willy@infradead.org/ is not a bad introduction. Thanks to the work done by Ming Lei in 2017, the block layer already supports multipage bvecs, so to a first order of approximation, I don't need anything from the block layer on down through the various storage layers. Which is why I haven't been talking to anyone in storage! It might change (slightly) the contents of bios. For example, bvec[n]->bv_offset might now be larger than PAGE_SIZE. Drivers should handle this OK, but probably haven't been audited to make sure they do. Mostly, it's simply that drivers will now see fewer, larger, segments in their bios. Once a filesystem supports multipage folios, we will allocate order-N pages as part of readahead (and sufficiently large writes). Dirtiness is tracked on a per-folio basis (not per page), so folios take trips around the LRU as a single unit and finally make it to being written back as a single unit. Drivers still need to cope with sub-folio-sized reads and writes. O_DIRECT still exists and (eg) doing a sub-page, block-aligned write will not necessarily cause readaround to happen. Filesystems may read and write their own metadata at whatever granularity and alignment they see fit. But the vast majority of pagecache I/O will be folio-sized and folio-aligned. I do have two small patches which make it easier for the one filesystem that I've converted so far (iomap/xfs) to add folios to bios and get folios back out of bios: https://lore.kernel.org/lkml/20210505150628.111735-72-willy@infradead.org/ https://lore.kernel.org/lkml/20210505150628.111735-73-willy@infradead.org/ as well as a third patch that estimates how large a bio to allocate, given the current folio that it's working on: https://git.infradead.org/users/willy/pagecache.git/commitdiff/89541b126a59dc7319ad618767e2d880fcadd6c2 It would be possible to make other changes in future. For example, if we decide it'd be better, we could change bvecs from being (page, offset, length) to (folio, offset, length). I don't know that it's worth doing; it would need to be evaluated on its merits. Personally, I'd rather see us move to a (phys_addr, length) pair, but I'm a little busy at the moment. Hannes has some fun ideas about using the folio work to support larger sector sizes, and I think they're doable.