From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0403B606A322 for ; Wed, 2 Dec 2026 23:06:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=hammerspace.com header.i=@hammerspace.com header.a=rsa-sha256 header.s=google header.b=TBpZnoil Received: by kanga.kvack.org (Postfix) id F2A436B05B2; Wed, 2 Dec 2026 18:06:16 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F01FB6B05B3; Wed, 2 Dec 2026 18:06:16 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DF0B16B05B4; Wed, 2 Dec 2026 18:06:16 -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 BB4246B05B2 for ; Wed, 2 Dec 2026 18:06:16 -0500 (EST) Received: from smtpin04.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 4456B404E9 for ; Wed, 2 Dec 2026 23:06:16 +0000 (UTC) X-FDA: 85500578352.04.2608F5E Received: from mail-qv1-f42.google.com (mail-qv1-f42.google.com [209.85.219.42]) by imf05.hostedemail.com (Postfix) with ESMTP id 3615B100008 for ; Wed, 2 Dec 2026 23:06:14 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=hammerspace.com header.s=google header.b=TBpZnoil; dmarc=pass (policy=quarantine) header.from=hammerspace.com; spf=pass (imf05.hostedemail.com: domain of mike.snitzer@hammerspace.com designates 209.85.219.42 as permitted sender) smtp.mailfrom=mike.snitzer@hammerspace.com ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1796252774; b=Wc4Nv/kpgSspY84mZNdH8YmwETIcNk6NtOZ8xfpvdBaW/1SzXLXn4sjpCFsF3VZYpy0sil bWQkd8SY760upSVFOPbjEyMVT5vDRaLSfmBPmFfj0ohPb6UPxMyUavBe5GHnmrY9fTZ0DP 9XbgWpclQMgKH8xknJRSEMiG1e+EuOM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1796252774; h=from:from:sender: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=k111TxlRXpJkaBe5sRMhjn6YnqDs29tU5B6BDdKq8SA=; b=4emb4j0xU9krFNxYyy3vQhsXbedkXikGEphGEEU2q4mF9DOPlexUTkz5Ef5UvewrGxcnIm oISfPRYOYjVusMFlm/bhJoS9fHI4x75G6+m16gd19r1CxgkmESyZvcrACeJEgREuwXuAAX /LyKvCB/tVu/jpQBcx6q+Dsp2luTTAk= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=hammerspace.com header.s=google header.b=TBpZnoil; dmarc=pass (policy=quarantine) header.from=hammerspace.com; spf=pass (imf05.hostedemail.com: domain of mike.snitzer@hammerspace.com designates 209.85.219.42 as permitted sender) smtp.mailfrom=mike.snitzer@hammerspace.com Received: by mail-qv1-f42.google.com with SMTP id 6a1803df08f44-91ebf4cd218so119690676d6.3 for ; Wed, 02 Dec 2026 15:06:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hammerspace.com; s=google; t=1796252773; x=1796857573; darn=kvack.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=TBpZnoilV78elGQplimGHN4EHUe6SGFxdcvAwJEfb5IxLQxYrVaw0+Rp3F8RaltXwc s0lp6oYh4NA80+qh/XzQTKNc/QrlTpaUK9R2md2F4usz3zfBSMveI/pRp+uWy9THDGKn LE1c7rUXcBOgVuzFxYjWachxnqpA+qwGJMz48qtGG5xv1E4ZB6kSMtZ1FxzaIAnNqe28 1DdXTDb/QhJrx8bLCTAyxaztZxa8DwHNDYbqPB9z7wjJB0XoTvFINawVrSp2vyJP6Nog KloNjzCZhpvp6z7EZaOCy9IbF1YX3rpWT+11SEFMwC5uLQwtV4bhx8wk6JLrz9VRJuth mHYQ== 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=U1KBeWm7UZm1AmuWfH7Yl+cvetxyUTAMjdLsX/dO9BhZwjTZZNt/YCsMwyVJKIKjZf m5E4X3jFvSH1QEYGZ2eTAIBqRwho+mIAT+f3hWpktEMP5DDfOAvuaRD5q9Fh5tp9m5SI F6O2Be4XInVzTSOAHnmujOW0t9hJ0Tz/BPZqA/IhSs7SPy6JC+L3mV7mhnb8lP7tr5Fs 6Nc/H0Zh1oJUm6aTMRRPcHra1gJ/wQiwjfr0B8WxgrZToSr25ssetRoZ5TAXzFYRqIrR GYeWrJscZbT8a3KH6dyW/4Uq0JUY2lR+5RwsIW9jX6Sznwtw5RuC2sASnYXizEg+j6Vr lnCw== X-Gm-Message-State: APuU4Z/d4JZ1rvS3uKY75a+SirnuKUsKhjSCC6fcEvnBrGWbSRWVqcwN XSZrc1RTTKQrNM52Ri8X+nZb0ZCJXnGmMf9UKfiJLZMOvqYaf8EZTARtEdaNqnh3Fbc= X-Gm-Gg: AZFdTZdnSpQltskgAs6BPFvNgu/4pXUXxdc4HD6BjI3GGKaq6NuT3ACS7iiesjTEvFm U/0eWrlX168Mmtwe67uhdfEv2M8Y+snSMPuaT1qZbihbWB07IcQacExH1/vBzRH46Vt4QcwyhgV bdE/5dPgUjRMi3fRICwT7O3kOTAcmqUlytMPeDKWMB45qgegQSvr9qa2EO4R0H1XDXN97gJsAME /s9/94u6c/7y5Dg6ouYjtyBvZAAIuhXHbpjA3/e5C+qikC0NG8YKG8DDictsvvyFLqaohvecNPM Jcq8CZLUYFftqSmt3Ovdl6IOsJKsg4/YgPcfbW5Pljg9SHyglJiiIe/TWQg2dm5eleGMW9GJNTs wQm33LRN9/oQsxOtITcbYuzPrsAILzNitf/1X+sbb8CtoIQOkPzY2TwJAt8jWjC4zRVzwVvhtFb KikepRhGJIY+sq58rTOQAZsyeZgxAPDmbCBvYnSKMU9YZLXLH4NDgc0U6ooYHkYIPRWqs7ATd09 YWMUSCTttBZzxGzwKTDhtna0tkhLgpWpMAO4ufh7piPqOjj1F5wthSV/Ezy/aTau8OCKMzNi2GO iKcJxVzjjAetoUzncTAUrlX+zqEUbzMFOKxYz9MmHEO2cp7R1UbW7g6Yy+rE0DO+6paVMDOWBs4 TKyo2NncfvXCT7KL5Olno4briIK3vi9AMH/5Lyw== 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) 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-Archived-By: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Stat-Signature: 591nonhjjr6zzra478c1xen3dgg4z5rn X-Rspamd-Queue-Id: 3615B100008 X-Rspamd-Server: rspam05 X-Rspam-User: X-Spam-Status: No, score=-3.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-HE-Tag: 1796252774-60841 X-HE-Meta: U2FsdGVkX1/QX5doAznESn4RZej5kUXdhhXbDbjRPcOBTHaOWpycPA2Z3DYFx4WSzC6STQkFfHfiQxxuVPkc9zLkA5+LlMioWlh3swFoBVT2Dz80IIfKdzc7Afg/eu3oo0w5MW0MY4OWF0WrVHZjxfxc2fU3VeZcUMBcbAvzXb+hrj9KWepYbaE3hDC0w7QhyQrHhZYDunV5wyNIHyDUKdq+97QeLZisuTbbqZI/0yLUSakrWQyEE5RFI9+KqWTKjrySDdijEJjV318XF+ADFhsuXgr0c5HKpDvVZDMxB445/tVwHd8QO+Y7C56f9s5UG9798qDnxn+kAF+Zp5vD5UuHpnzxzJHFOvzCoXZgeB+yc+7wPAKBiB2LGyzfdifSDByQvGTJaoFOcjAVs3uPK+yuyi82uYCUnyd+Q+CnfgldXaaI8LCenwfV2uoUjOVT6dtfyrM/gAc+hTtENH3T+tdsmJqCvY8+MwAEKHkMVJ9nNrUsuTAfCql6yXJT/QCddIBvP4hIw2jhy4xZhV0l3m5eyjKi/BkKEJy0qrNZmiQbfSUh3IGjfoNGcVE6aMQB7MJEk5BIAZL45XzOeUcqrJyLMd1leVyay7LmWv65WH+oy9UsTOOb7aT7pF7XjvvRrQYrFJw9QWEHaW1UIpA5+y/7T3UdC7kg5zE7f/QIXs+5HUHmsk1keZ5XBl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cYeTcZJ1A== Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 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