From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.219.51 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796252774; b=uT+5Ax1o4TsrQ6m0+huLWkvjXL4d/hJs4UhDdxMvzayAait4349fXYYevuApQjfVTOGx DMx/J6zFJRdlLjuwXsLJp9EglJKKtOJonYqVR6cMqDtMT7YrMyBTwNIfuprzJdm73sm8v SfKEpncEAKcbB5wUmoe3ihQ+k8WRhgDONgwaeVnQdC/WQBP2VkEME2Qz6cWPpMkfoL3xN VCGcJz1YUaDtsR0ueiEoSp3TtNuOckOXl1lOzuDgNu3H+9yEAvlUHPA6T4f1YrRMLM8EK 2pwklPzuIgolB2DJ85vNnt6zoX+HBvVPShHuvDJqlBCBA/iga2tiAdJcu0Vt9rSez3g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796252774; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Sender:From:X-Google-Original-From:Date:To:Cc:Subject:Message-ID: References:MIME-Version:Content-Type:Content-Disposition:In-Reply-To; bh=k111TxlRXpJkaBe5sRMhjn6YnqDs29tU5B6BDdKq8SA=; b=4Ezej5DhV0+JSKmxlGTgKZqpYZ8do/Ou6ZvtHKaVuiKN7jATwjiryOkAnP0EDyzL5tsb oHCMAPo3jE3ff2u99s5F502S7TfZ72oA5hcgEIRejyiEdKofxKZJKG2TaE8BQjc7Jl2mF aNwp3UCCy62KJ1FizaDbD5nYS7gFoKyz6PGH4zzJEHmchu/MjvALf5jtV3XOEXQNizgG8 snp3bPoHYVukDUhiKjXlqlS71NFsD4TkGdM8oe6Wgl2i58N3A/JDUxD8mXfbiGiQA40gA 1kn7CjyJyHPBkv8S14j8Zg/HaC9qUWbDephZFyCTtM9l2ofBpEGM68WoxMgM7WznooA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=hammerspace.com; spf=pass smtp.mailfrom=hammerspace.com; dkim=pass header.d=hammerspace.com header.i=@hammerspace.com header.a=rsa-sha256 header.s=google header.b="I17f8h/G"; arc=none smtp.remote-ip=209.85.219.51 Received: from mail-qv1-f51.google.com (mail-qv1-f51.google.com [209.85.219.51]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 569B8606A322 for ; Wed, 2 Dec 2026 23:06:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 569B8606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=hammerspace.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=hammerspace.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=hammerspace.com header.i=@hammerspace.com header.a=rsa-sha256 header.s=google header.b=I17f8h/G Received: by mail-qv1-f51.google.com with SMTP id 6a1803df08f44-91ebf4cd218so119690686d6.3 for ; Wed, 02 Dec 2026 15:06:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hammerspace.com; s=google; t=1796252773; x=1796857573; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:date:from:sender:from:to:cc :subject:date:message-id:reply-to:content-type; bh=k111TxlRXpJkaBe5sRMhjn6YnqDs29tU5B6BDdKq8SA=; b=I17f8h/GlZVj9EAmCiOttdP1U9kg2BdJmIH4ghouo7Ll/bzB7775zS9oYi/mR9X/+C mJa3hC+k7cAJnsAieAQnZ2ghzdlSeEOZbH4omptL1GeY9BKuBAt+kuy+Gln9rzthNXmJ aj5hWZlXSOzt0y7P4McU3deJaUWNd9+x8435Hiuq4A4E/FCtMoK/Lkyk4uZ6nH+xlNGZ HzRRMe+juChj4RCcg0vyqnsd+ZMOdK3nA0NYvRMXSS3eb3Z1E8KDEb7MoKgI6KvUiEmi pV2oZgYOQMOK0smU7ixQWIoMDufklmp7DtHeGOltHecN92hj6hI5QsamvuDRjHFpSYVR bnbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796252773; x=1796857573; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:date:from:sender:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=k111TxlRXpJkaBe5sRMhjn6YnqDs29tU5B6BDdKq8SA=; b=Y8fK463t9LRd+Ea+ABtoOEp+tBQSXo+B1s84VgC+nRSmXSqg8PBuPhx7B/pnfeGIX7 DzaFIAmxzk8NGQ8H2XEpj5JuRiIyj8maJOmDJj+UByQQHkgMJlNqRyNbvUO6tcI96LUh 0b2t7PmAn3x5ioCEDm080pAByaDWVnyIFe7ooTqlQa9Nz3uhS2ZXMQRtvtA6xHgpEhGs j7azuqvf9JpMQVdzrBGqloa5DoaWfl4JxT86PFGkIfSQRSjdroFiLQDKsMmPPD9pDx/i VAcGoMYHogcW2SHcQp/qCDrWmu0Jz4XQg12BefgY7OTPoToIH2d3gK05fpC7SOT3BUTW mZ1w== X-Forwarded-Encrypted: i=1; AL+hErF7go8+ajNFDZiF/XZdnUdszzyAbHpynahTZDSiAuCOC8R472GRa7zxR7HHLAbozwjF41oSjN/96Y307cN3@vger.kernel.org X-Gm-Message-State: APuU4Z/ITIeqpbE/gm5HLNAXv+pVAv9K7KF3WZT5Gv+h1Gpl+6zs6A+R rLG+GUTY3eRV163R5zg+7nrD7lifZ6faf9gVUmJNY2u6BblWLzJ2ibE9AW7CJeXlbWY= X-Gm-Gg: AZFdTZfn5y6cRST03mgohu3QD/fcrDDt0ZY2XACK7lFHfzLhGzVzqYipyfwf4dWr7W8 kTqkY1+Y7kzkcJQ5Ze43MwKJ2q7WfcvxwCiGmROaTKoNfcxkPknzdTPXTJJ615L5cjTe2dIQKpy 9nkhpScgp50ipzIfvVT0I2zrV4suTSaa+UaOEtG7UWSkB1T2ttY2ZxleKIvG9YQazQS5tPnsvoI TUS7cTFtU815iEZTxwRrkXsrft2/z/MgK7ELXhIswP7rif+jv4cHPiwUf8c5rUkGKHDuHzIukQU I5b2cMlNcVHFFU72Oj2bSgV9ogzaTaNqXpZ8ncdua3WR3jRb2Xo7ndMovRaE7dnDz3dDiK/0AaH X671RIhxNnn9ob0hQx0T6r6mm/vs9D0KJlmzn13GiTRIP1KSDYQnAJ4RtronMZEk+pPXhUHpwIR /cb9BtgqPaes/IlT2ibxJbDDN7sXOGpBHSVVf1Wl2pxKfC/n3CV+r5Sqfme+CbYuO2QCcaJhxLG z9Kryh+4iLycpdFm6E2mCiLbXbpwumFUAtBh8Wus4SeIAHG99fohdREpJBYKD1DeCpS3F9nkGXr vk1/Zz2EEqvCcW6qnt7c9qyhTcStmSbD+16UGIJE6myQCJbSyc3b/W53zNFSG7ZN0vTgGmxpy3X 0hZMBen+6wFheWvc67YtFlVTVylBXLBRifeiBSw== X-Received: by 2002:a05:6214:2522:b0:921:156f:7d5a with SMTP id 6a1803df08f44-92134af6b50mr775358416d6.41.1796252772924; Wed, 02 Dec 2026 15:06:12 -0800 (PST) Received: from localhost (pool-68-160-167-46.bstnma.fios.verizon.net. [68.160.167.46]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-9217efd0637sm206315496d6.42.2026.12.02.15.06.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 15:06:12 -0800 (PST) Sender: Mike Snitzer From: Mike Snitzer X-Google-Original-From: Mike Snitzer Date: Wed, 2 Dec 2026 18:06:10 -0500 To: Jan Kara , Matthew Wilcox , Christian Brauner Cc: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Chuck Lever , Jeff Layton , linux-nfs@vger.kernel.org Subject: Re: [PATCH v12 0/7] mm, iomap, NFSD: stop DONTCACHE writes reading back shared pages Message-ID: References: <20261112190911.84702-1-snitzer@kernel.org> X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Hi again! I would appreciate it if you (or others) might revisit this to see if the constrained nature of these changes soften concerns about complexity. On Mon, Nov 16, 2026 at 03:47:49PM -0500, Mike Snitzer wrote: > On Mon, Nov 16, 2026 at 12:02:20PM +0100, Jan Kara wrote: > > Hi! > > > > On Thu 12-11-26 14:09:03, Mike Snitzer wrote: > > > An RWF_DONTCACHE write is buffered IO: its data goes through the page > > > cache, and writeback drops each folio once the folio is written back. > > > A write that starts or ends inside a folio covers that folio only > > > partially. Usually another write covers the rest of the folio. If > > > writeback drops the folio before the other write writes its part, the > > > other write must first read the folio back from disk. 32 threads > > > writing interleaved records to one XFS file, 4 KiB pages, before and > > > after 5/7: > > > > > > record pwritev2() flags 4 KiB device MiB/s > > > bytes reads per write > > > before after before after > > > 47008 RWF_DONTCACHE 0.97 0.0005 831 2281 > > > 47008 RWF_DONTCACHE|RWF_DSYNC 0.99 0.0005 601 1227 > > > 6000 RWF_DONTCACHE 0.97 0.0001 121 488 > > > 6000 RWF_DONTCACHE|RWF_DSYNC 0.99 0.0002 90 206 > > > > > > 47008 bytes is the transfer size of IO500's ior-hard, in which each > > > rank writes interleaved records to one shared file. Any record size > > > that is not a multiple of the page size has the same problem. 6000 > > > bytes is a second example. > > > > OK, I understand the problem but frankly I hate the complexity this > > introduces. Patches 1-3 are good improvements, patch 4 is OK but 5 & 6 look > > too complex for too niche usecase to me. I didn't really pay attention to > > previous revisions of this patch set so I'm sorry if this was discussed but > > can't we just make iomap for unaligned RWF_DONTCACHE write ask for > > minimum-sized folios for the partial edges without FGP_DONTCACHE and > > use FGP_DONTCACHE only for folios fully within write? That will also solve > > the problem with the following write having to read again from the disk and > > it will be much simpler. Sure the edge folios will not be dropped after IO > > completion which may have smaller or larger effect (depending on the > > overall write size) but I'd say that's the cost of userspace making life > > hard for the kernel :-p > > Thanks for looking, Jan. > > On complexity: 5/7 and 6/7 add almost nothing to the fast path. The > new code runs only at a partial edge. Aligned IO, and IO that is not > RWF_DONTCACHE, pays for it with a few flag tests: > > - IO that is not RWF_DONTCACHE (buffered, direct, reads): every new > branch is behind IOMAP_DONTCACHE or FGP_DONTCACHE. The cost is one > flag test in the found-folio path of __filemap_get_folio(), one when > a folio is created, and one per write call in > iomap_file_buffered_write(). > - An aligned RWF_DONTCACHE write: iomap_get_folio() tests whether the > folio is partially covered, which is a mask and two compares per > folio. The test is false, so FGP_DONTCACHE_EDGE is not set, and the > folio is created and marked dropbehind as before. These ^ are the tests that minimally impact common code. These are no impact: > - No new locks, atomics, allocations, page flags or per-file state. > The state of an edge is the uptodate state that the folio already > has. Writeback and reads do not change. > - folio_dontcache_edge_written() and the two 6/7 helpers run only at a > partial edge, or for a caller that asks for IOCB_DONTCACHE_DEFER > (NFSD). Merely documented these ^ to show they don't impact common code. > So the complexity is all in the misaligned case, which needs it. I'd > argue that if the kernel (MM) can handle userspace making life hard it > should, within reason. I think my patchset nicely isolates the > complexity to userspace that makes life difficult. > > The first part of what you describe is what 5/7 already does. iomap > asks for a minimum-sized folio at each partial edge, and a new edge > folio is not marked dropbehind. 5/7 adds one more step: the write that > completes an edge marks it, so the writeback that cleans it drops it. > > Without that step, every edge stays cached until reclaim. For this > workload, that is a large part of what the writes put in the page > cache: > > - With 4 KiB pages, each record leaves about one page cached. Through > LOCALIO with cached edges, 8.6% of the data stayed resident with > 47008-byte records, and 66% with 6000-byte records. When the write > that completes an edge drops it, 0% stayed resident. > - With 64 KiB pages, a 47008-byte record never covers a whole folio. > So no folio is ever marked, and RWF_DONTCACHE caches as much as a > normal buffered write. > - Jon Flynn measured cached edges through NFSD on four pNFS data servers > with ior-hard. The page cache grew by 622 GiB in a 318 s write phase. > With this series it grew by 2.9 GiB. > > So for this misaligned workload, cached edges keep from 9% to all of the > written data in the page cache, depending on the record size and the > page size. The reads stop, but the page cache fills until reclaim runs. > > 6/7 does not change what is cached. A caller that syncs its own write > (NFSD, for a FILE_SYNC WRITE) uses it to mark the shared folios after > its sync. Without it, each segment wakes the DONTCACHE writeback kick > for pages that the sync then writes. Thanks, Mike