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]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 16792CCA462 for ; Fri, 16 Oct 2026 11:18:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 137266B0088; Fri, 16 Oct 2026 07:18:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 0E71B6B008A; Fri, 16 Oct 2026 07:18:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F09346B008C; Fri, 16 Oct 2026 07:18:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id C56D86B0088 for ; Fri, 16 Oct 2026 07:18:20 -0400 (EDT) Received: from smtpin25.hostedemail.com (lb01a-stub [10.200.18.249]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 57A908037D for ; Fri, 16 Oct 2026 11:18:20 +0000 (UTC) X-FDA: 85328240760.25.6C0E26A Received: from tor.source.kernel.org (tor.source.kernel.org [172.105.4.254]) by imf04.hostedemail.com (Postfix) with ESMTP id AD19540004 for ; Fri, 16 Oct 2026 11:18:18 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=lGun4XNF; spf=pass (imf04.hostedemail.com: domain of jlayton@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1792149498; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=aQmVzZIVo4Cy0sgPzXllYD8IK37O7VSIcN/u0dlrwMg=; b=zPU1piqBaHnBLYuVaSiM5b2Ob+XA/uxwxFeP48aAs0pwWDSGtrh66ZxfRfEhByr+ernnIi HW1JOPMFOYLrlGTI5sEuvkaOrIWXvNIdkuqpZvcI9Jb87kzGoTxOr9ZiIo3Qn8VJ3+Jj+H ByNKsc7zjDWq79z43/G+eckU6P+Y5Q8= ARC-Seal: i=1; a=rsa-sha256; d=hostedemail.com; s=arc-20220608; cv=none; t=1792149498; b=QJiMU+Udmcc/PP54zpmROqUJisnGZrZFudby9pooDiKrMsT6p7sjU4bJlx6TZ/yG3PqCz9 pEQsyMj/3zi7IDrss0NSjy3SCnIYHRhsSX3mDmYOcMTejImaREEd6sAvsjL56ILrwDQBAZ HfZ0+9+oD3IUicQCy/kVMprsWTRH45w= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20260515 header.b=lGun4XNF; spf=pass (imf04.hostedemail.com: domain of jlayton@kernel.org designates 172.105.4.254 as permitted sender) smtp.mailfrom=jlayton@kernel.org; dmarc=pass (policy=quarantine) header.from=kernel.org Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by tor.source.kernel.org (Postfix) with ESMTP id B1ECF60008; Fri, 16 Oct 2026 11:18:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 887B51F000C4; Fri, 16 Oct 2026 11:18:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1792149497; bh=aQmVzZIVo4Cy0sgPzXllYD8IK37O7VSIcN/u0dlrwMg=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=lGun4XNFnUSytMvv4V3VHsZlLlnPY2nQJPm8i8Ukvi4yKZwFX3EwZI7U8jBNJ6yaT iyKM3XA3nbK99GFd1bBFLjIwP6y8jeOmUWDDVp+r7bxUJaULB1yBO+Ol8wY8Lp6HeX /wTdfC0UB5PXhh+QW5olgD1O6+1Zq9VCQIlGfH3QJQMZYepjq1RZdbHHEhdo4B3K/R ZkPUmZ0890ZZEP2owXaIUnbOa73MtWTq4F/ZmgG+98PWGNR123oc481BrHWHDbMHk1 pVoRVjvUSWXsJEzl3CR+7D2EwI8b5U6D2N3Pz7yzcOmdm7mozYfxva/T4jtr0DFGYl HaSFoqXrNnTWA== Message-ID: <224b94f6797ab29cde44f37b4145778829bc41c8.camel@kernel.org> Subject: Re: [PATCH v4 00/10] NFSD: keep direct-mode I/O out of the page cache From: Jeff Layton To: Mike Snitzer , Chuck Lever Cc: linux-nfs@vger.kernel.org, NeilBrown , Olga Kornievskaia , Dai Ngo , Tom Talpey , Christoph Hellwig , Jens Axboe , Matthew Wilcox , linux-mm@kvack.org Date: Fri, 16 Oct 2026 07:18:13 -0400 In-Reply-To: <20261015233309.42999-1-snitzer@kernel.org> References: <20261015233309.42999-1-snitzer@kernel.org> Autocrypt: addr=jlayton@kernel.org; prefer-encrypt=mutual; keydata=mQINBE6V0TwBEADXhJg7s8wFDwBMEvn0qyhAnzFLTOCHooMZyx7XO7dAiIhDSi7G1NPxw n8jdFUQMCR/GlpozMFlSFiZXiObE7sef9rTtM68ukUyZM4pJ9l0KjQNgDJ6Fr342Htkjxu/kFV1Wv egyjnSsFt7EGoDjdKqr1TS9syJYFjagYtvWk/UfHlW09X+jOh4vYtfX7iYSx/NfqV3W1D7EDi0PqV T2h6v8i8YqsATFPwO4nuiTmL6I40ZofxVd+9wdRI4Db8yUNA4ZSP2nqLcLtFjClYRBoJvRWvsv4lm 0OX6MYPtv76hka8lW4mnRmZqqx3UtfHX/hF/zH24Gj7A6sYKYLCU3YrI2Ogiu7/ksKcl7goQjpvtV YrOOI5VGLHge0awt7bhMCTM9KAfPc+xL/ZxAMVWd3NCk5SamL2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cB+bwDJFgvvDYaZ5bI3ln4V3EyW5i2NfXazz/GA/I/ZtbsigCFc 8ftCBKZWZmIExheXRvbiA8amxheXRvbkBrZXJuZWwub3JnPokCOAQTAQIAIgUCWe8u6AIbAwYLCQg HAwIGFQgCCQoLBBYCAwECHgECF4AACgkQAA5oQRlWghUuCg/+Lb/xGxZD2Q1oJVAE37uW308UpVSD 2tAMJUvFTdDbfe3zKlPDTuVsyNsALBGclPLagJ5ZTP+Vp2irAN9uwBuacBOTtmOdz4ZN2tdvNgozz uxp4CHBDVzAslUi2idy+xpsp47DWPxYFIRP3M8QG/aNW052LaPc0cedYxp8+9eiVUNpxF4SiU4i9J DfX/sn9XcfoVZIxMpCRE750zvJvcCUz9HojsrMQ1NFc7MFT1z3MOW2/RlzPcog7xvR5ENPH19ojRD CHqumUHRry+RF0lH00clzX/W8OrQJZtoBPXv9ahka/Vp7kEulcBJr1cH5Wz/WprhsIM7U9pse1f1g Yy9YbXtWctUz8uvDR7shsQxAhX3qO7DilMtuGo1v97I/Kx4gXQ52syh/w6EBny71CZrOgD6kJwPVV AaM1LRC28muq91WCFhs/nzHozpbzcheyGtMUI2Ao4K6mnY+3zIuXPygZMFr9KXE6fF7HzKxKuZMJO aEZCiDOq0anx6FmOzs5E6Jqdpo/mtI8beK+BE7Va6ni7YrQlnT0i3vaTVMTiCThbqsB20VrbMjlhp f8lfK1XVNbRq/R7GZ9zHESlsa35ha60yd/j3pu5hT2xyy8krV8vGhHvnJ1XRMJBAB/UYb6FyC7S+m QZIQXVeAA+smfTT0tDrisj1U5x6ZB9b3nBg65kc= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.60.2 (3.60.2-2.fc44) MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: AD19540004 X-Stat-Signature: 4e5oifgmb4qy9ptnt97qsshhq4e1434p X-HE-Tag: 1792149498-233559 X-HE-Meta: U2FsdGVkX18raNTTc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VbQGMnKXpbFpY3UxyaBYjJ07nX/J0hIxNPKPjyJCwaUbmjIyvYRhORikOjj4kD8iKAomoS+NTmv78VRj7iqOKPjkdfS6RiynT0frMcXCa0uifV4ioUL3D9UxD8q2MNwX3L0VwdRiB+PokH/xFMrrstaQto7lWBSLJk5NEBcH+ZzHshgmZNJlWurfiwkcdVYk+4rXGUXp/Awzo627zmk+p Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Thu, 2026-10-15 at 19:32 -0400, Mike Snitzer wrote: > Hi, >=20 > This series refines the heuristics NFSD_IO_DIRECT already uses, mostly > on the WRITE path and in one corner of the READ path: the io_cache_write > and io_cache_read modes where an aligned request goes to the filesystem > as O_DIRECT, with DONTCACHE for the parts a misaligned WRITE cannot issue > directly. >=20 > It does not knowingly undercut anything the existing upstream code is > built on. An aligned WRITE is still one O_DIRECT write and an aligned > READ is still one O_DIRECT read. A misaligned WRITE is still split into > a direct middle and buffered ends, and by default those ends are still > DONTCACHE where the filesystem supports it. io_cache_read and > io_cache_write mean what they did, and nothing new is asked of the > filesystem. What changes is where the split is cut and when it is worth > making, which READs are worth expanding, how often a synchronous WRITE > is persisted, and what happens to the page two misaligned WRITEs share. >=20 > 1/10 is a stable fix. A misaligned WRITE is split into a direct middle > and buffered ends, and the middle was cut at the filesystem's DIO offset > alignment. Where the page is larger than that alignment (16 and 64 KiB > pages over 4096-byte blocks, or 4 KiB pages over 512-byte blocks) the > middle then starts or stops inside the page a buffered end writes, its > invalidation drops that page, and whichever of the two neighbouring > WRITEs comes second reads it back from the device. A misaligned end is > now cut at a multiple of the larger of the alignment and the page size. > An end that is already DIO-aligned gets no buffered segment and stays > where it is, so a DIO-aligned WRITE is still issued direct on every page > size. Such an end can share its page with a buffered neighbour, but > NFSD's direct WRITEs are synchronous and XFS holds its IOLOCK across > iomap_dio_rw(), the page cache invalidation after the write included, > so the neighbour cannot dirty that page in between and make the > invalidation fail. >=20 > 2/10 also marks the direct middle IOCB_DONTCACHE, for when XFS > re-issues it as buffered I/O (-ENOTBLK) because something else has > dirtied page cache in its range, such as a local process writing the > exported file through mmap, which XFS's IOLOCK does not keep out. >=20 > 3/10 splits a misaligned WRITE only for a direct middle of at least > direct_misaligned_min_bytes (debugfs, default 8192), and moves the > segment flag decisions into nfsd_write_dio_iters_init(), both from > Christoph's suggested diff. The threshold counts bytes: with 1/10 a > split WRITE's middle is whole pages, and a threshold of two pages would > demand a 32 KiB middle on 16 KiB pages and 128 KiB on 64 KiB pages. >=20 > 4/10 (Jonathan) adds direct_misaligned_dontcache (default Y), which > selects whether the parts that are not O_DIRECT are DONTCACHE or > cached. >=20 > 5/10 stops expanding a READ smaller than its alignment into one or two > whole aligned device reads. The check sits in nfsd_direct_read_ok(), > beside the last-operation-in-COMPOUND check now in nfsd-testing. >=20 > 6/10 persists a FILE_SYNC or DATA_SYNC WRITE that is split, or issued > buffered, once after all of its segments, instead of once per segment: > one fsync where there were up to three. A WRITE issued whole as > O_DIRECT keeps IOCB_DSYNC, so iomap can still complete a DATA_SYNC > overwrite with FUA writes. >=20 > 7/10 is an mm patch: folio_mark_dropbehind() marks an existing folio > dropbehind and keeps WB_DONTCACHE_DIRTY balanced when the folio is > already dirty, as folio_mark_dirty() does for PG_dirty where > folio_set_dirty() only sets the flag. Marking an already dirty folio > with folio_set_dropbehind() instead drives the counter negative, and > the DONTCACHE writeback kick then stops writing anything back for every > writer on that bdi_writeback. >=20 > 8/10 is also mm: it reports WB_DONTCACHE_DIRTY in the bdi debugfs stats, > as BdiDontcacheDirty and per bdi_writeback as WbDontcacheDirty, summed > over the per-cpu batches since the flusher targets the summed value. > The counter drives the DONTCACHE writeback kick but was not reported > anywhere; this is how the balance 7/10 keeps was observed. It carries > Fixes: for the commit that added the counter. >=20 > 7/10 and 8/10 are Cc'd to linux-mm and need an mm ack. >=20 > 9/10 calls folio_mark_dropbehind() to keep the page two misaligned > WRITEs share until both have written it, with no state in NFSD: 704 > device reads for 42895 WRITEs where there were 45144 for 45664 > (47008-byte records, 32 interleaved writers, 4 KiB pages), and on a > four-server pNFS flexfiles rig 0.003 device reads per record instead of > 0.014-0.015, about 2.9 GiB of page-cache growth instead of 11 GiB, and > 2.4% to 4.9% more write throughput. >=20 > 10/10 adds tracepoints for how each direct-mode READ and WRITE was > serviced, and why a WRITE was not issued direct. >=20 > The series applies to cel/nfsd-testing (78c334bc5ae6) and each patch > builds with W=3D1 with no warnings. >=20 > Changes since v3: > - Dropped "NFSD: Enable return of an updated stable_how to NFS > clients" and "NFSD: add direct-mode WRITE settings that persist each > WRITE" (v3 8/9 and 9/9). The rest of the series does not depend on > them. > - New 1/10, NFSD: cut a misaligned direct-mode WRITE at page > boundaries (Cc: stable). v3 cut the direct middle where the DIO > offset alignment falls, which is a page boundary only when that > alignment is the page size. > - Rebased onto the current cel/nfsd-testing. 5/10's size check moved > into nfsd_direct_read_ok(). > - Descriptions, comments and nfsd-io-modes.rst corrected throughout, > among them: 2/10 says what can still make XFS re-issue the middle > buffered once 1/10 keeps it off the pages the buffered ends share; > 3/10 says why a WRITE misaligned in memory is not split; 4/10 no > longer misstates what the split threshold decides. > - 3/10: the threshold is direct_misaligned_min_bytes (default 8192) > instead of direct_misaligned_num_pages (default 2). On 4 KiB pages > the default is unchanged. The debugfs file is renamed with its unit, > so a value written to the old name is not read as bytes. > - 6/10: a WRITE issued whole as O_DIRECT keeps IOCB_DSYNC; v3 turned a > DATA_SYNC overwrite into a plain write plus an fsync. > - New 7/10, mm: add folio_mark_dropbehind(). v3 marked an already > dirty folio dropbehind directly; the clean that follows subtracts it > from WB_DONTCACHE_DIRTY, which never counted it, so the counter > drifted negative and stopped the DONTCACHE writeback kick for the > whole bdi_writeback. > - New 8/10, mm: expose WB_DONTCACHE_DIRTY in bdi debugfs stats. Reports > the counter 7/10 keeps balanced; Fixes: Jeff's commit that added it. > - 9/10: claims a page only where a buffered segment covers it partly, at > either end of any segment, so a multi-page start or end segment and a > sub-page WRITE are handled; claims for a split WRITE at any DIO offset > alignment, since 1/10 keeps the direct middle out of the claimed > pages; does not claim when the mapping's minimum folio is larger than > a page; allocates with __GFP_WRITE; does not mark a page a short > write did not reach; a FILE_SYNC or DATA_SYNC WRITE marks its shared > pages after its own fsync, when they are clean, so they are not > counted as DONTCACHE dirty and do not wake the writeback kick. The > description no longer says marking must not be accounted or that the > kick targets marked folios. > - 10/10: the DONTCACHE state is its own tracepoint argument instead of a > bit ORed into the disposition (nsegs is dropped; it follows from the > segment sizes); the redundant #include "vfs.h" is gone; > NFSD_WRITE_DIO_NO_ALIGN is renamed NFSD_WRITE_DIO_NO_ALIGNMENT to > match its string; mem_offset is 0 for a WRITE with no payload. >=20 > v3: https://lore.kernel.org/linux-nfs/20261001045502.48381-1-snitzer@kern= el.org/ > v2: https://lore.kernel.org/linux-nfs/20260929231329.22018-1-snitzer@kern= el.org/ > v1: https://lore.kernel.org/linux-nfs/20260929173423.16149-1-snitzer@kern= el.org/ >=20 > Thanks, > Mike >=20 > Jonathan Flynn (1): > NFSD: add direct_misaligned_dontcache debugfs knob >=20 > Mike Snitzer (9): > NFSD: cut a misaligned direct-mode WRITE at page boundaries > NFSD: mark the direct middle of a split WRITE IOCB_DONTCACHE as well > NFSD: only split a direct-mode WRITE for a worthwhile direct middle > NFSD: do not use direct I/O for a READ smaller than its alignment > NFSD: persist a synchronous direct-mode WRITE once, after all of its se= gments > mm: add folio_mark_dropbehind() to mark a folio dropbehind and account = it > mm: expose WB_DONTCACHE_DIRTY in bdi debugfs stats > NFSD: keep boundary page of a split direct-mode WRITE until both writer= s complete > NFSD: add tracing for how direct-mode READ and WRITE are serviced >=20 > .../filesystems/nfs/nfsd-io-modes.rst | 93 +++++- > fs/nfsd/debugfs.c | 25 ++ > fs/nfsd/nfsd.h | 2 + > fs/nfsd/trace.h | 77 +++++ > fs/nfsd/vfs.c | 265 +++++++++++++++--- > fs/nfsd/vfs.h | 9 + > include/linux/pagemap.h | 1 + > mm/backing-dev.c | 11 + > mm/filemap.c | 31 ++ > 9 files changed, 473 insertions(+), 41 deletions(-) >=20 >=20 > base-commit: 78c334bc5ae61d23ca1cc2e43079c620f1d40866 I think this all looks good and should be good optimizations. I take back what I said earlier about splitting the mm: patches out -- you do need the new helper for the later patches in the series. It's fairly self-contained though so maybe it's not a big deal to carry #7 in the nfsd tree. Note that sashiko has some comments about a potential race there too. #8 seems like it should go via mm tree though. The other thing we should consider is whether to make the new controls you're adding to debugfs into netlink controls instead. I see no reason not to do that and it'll save us from having to convert them later. --=20 Jeff Layton