From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 799041A6825 for ; Wed, 3 Jun 2026 05:30:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780464640; cv=none; b=BsD1Y9Dmx4ebAXTT34DHAok3qu0ySRJWqkT1Lmn5GPE+XyelUN46cyPvgKldp6gGOgeVd9rRqhHPpBSsQ1QAykYeUgiXjU/GQXJeU7TjsKCebo174QriMMnUQuqUsjG87RX9W1YbzHoGlrPcbIefS185furLxKzt+5IBKi/vMzU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780464640; c=relaxed/simple; bh=Q0D8jDrRcRHDJM37OlpFYuTE9Um5+/MQvZUeKQkrNhs=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=YcwSkhzropbsm8c831sFLMQeNGkPjGwHC26hWYjP9724yy4i8z5bbTGSViJSz7xgRaInLXZ9Mnz5HJhpJml+SAL3l3c1K8Ku4fHHpNr8aqmo5pa4+R4nJGFfYrXw8EVcizAvsroX1KXyrYEowUWVXFlMo1GZDYwhkW1t2MCAfYc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--praan.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=K7n8LFwI; arc=none smtp.client-ip=209.85.216.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--praan.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="K7n8LFwI" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-36bc380fbf9so5063974a91.3 for ; Tue, 02 Jun 2026 22:30:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1780464637; x=1781069437; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=zvYVhLCrvwQ19orwR9RfHUVycxN5Xiji++Ju2gKa2bM=; b=K7n8LFwIxfvk8fhqCaP/7BmJa9y03iO7hKyv5JLnF9HmSKg3lH1MvYdGj5A8aUdk6E kOmVZPEEPDFP2EEwH8mfGW8xqJ3CjwR4qwL0bkWbEMnNYL6jiXTx4eDoj4/QrIRLwjRt avGX7I/0yVNOxwUNTo38cGgsqXiyLfVCwX+kXg2iEf03wDTrYMJxaWGECeAo0SL2vr5o Oe2tSY4MZ3rZ+2YFV+KP1wyPPwgoL9AlhDamuGw6oqHqYXZY7Li1aDJxfqodgWn+A46l HSQfUk1y2djCGVtcApsK19xs0RR4JdlFRREAHkna5j9Qt5ASXeQzLq8+5URX0mhbKNWa kNSw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1780464637; x=1781069437; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=zvYVhLCrvwQ19orwR9RfHUVycxN5Xiji++Ju2gKa2bM=; b=CyXwqLk69ku67kCKfZjjimGsEl8Ng+4K5mr2C+MbxIjaQXV8x1ulop3FDbFaMi6JGf d5d/VrYM3XgMbnoSseGVA8NnWMW8udn/Nsq7Lg015pUGX7vBXVjlrNOOR8/gemgi8/VJ spgNHj4s+zTE7owBBzaPml9cf5Btg1k0L+yrSdThFi9emAS7eqnolsIzEsxAGVLegJK5 eo/0W+Ha9R4XEnLA3dN8RT3oWdjPulcTlPqru0QyzUpdMT3v6DErdde9jQThWu+1N1SF wju5l1O6nwtfezO4AEyN9i12V2U0ngCWDG3kaoqNe2XxK335E8gsbOmoQAmqblA5D3+i Mc/w== X-Forwarded-Encrypted: i=1; AFNElJ9ic0jNGLwZjxMp55UkghEY4X+bODsTwscrNBx/cwBschwli+OUO2EReY5HtmwqKtQstR5H/GvQ+lDPL94=@vger.kernel.org X-Gm-Message-State: AOJu0YwX95nT9wtBxhWG57OPlDb60Jc29I3AdvYLGVLSyHBfxaIzyIhC oAvepGooFTwIiQlOIiYpLJx1KAIxchvnne4hgz3tsW774kdk/SNlyD7tZLbeSmx1ClNbRvIqPKQ dvA== X-Received: from pjbgc16.prod.google.com ([2002:a17:90b:3110:b0:367:f83b:97d]) (user=praan job=prod-delivery.src-stubby-dispatcher) by 2002:a17:90a:c2c5:b0:35c:cba:3453 with SMTP id 98e67ed59e1d1-36e33105750mr2104272a91.22.1780464636449; Tue, 02 Jun 2026 22:30:36 -0700 (PDT) Date: Wed, 3 Jun 2026 05:30:26 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.54.0.1013.g208068f2d8-goog Message-ID: <20260603053033.3300318-1-praan@google.com> Subject: [PATCH v1 0/7] nfs: Modernize Direct I/O path From: Pranjal Shrivastava To: linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Trond Myklebust , Anna Schumaker , Christoph Hellwig , Christoph Hellwig , Shivaji Kant , Pranjal Shrivastava Content-Type: text/plain; charset="UTF-8" Modernize the NFS Direct I/O path as a preparatory step to enable PCI Peer-to-Peer DMA (P2PDMA) support. Following feedback on the initial RFC [1], the modernization and architectural changes are split into this standalone series. Currently, NFS O_DIRECT relies on the legacy iov_iter_get_pages_alloc2() API which does not support the pinning requirements for P2P memory. The implementation moves NFS to the modern iov_iter_extract_pages() API and migrates NFS direct I/O away from pages to use folios. Design ====== 1. Pin-Awareness Standard NFS requests use get_page() and put_page() for memory management. However, memory extracted via iov_iter_extract_pages() requires explicit pinning. Introduce a PG_PINNED flag and a wb_nr_pinned count to struct nfs_page. This allows the request lifecycle to track ownership of physical pins and ensure that unpinning is performed only when the I/O is complete. 2. API Migration Migrate the Direct I/O path to the modern iov_iter_extract_pages() API. This aligns NFS with the modern extraction model and serves as the foundation for passing ITER_ALLOW_P2PDMA in a follow-up series. 3. Extraction Helper and Folio Support Introduce a new extraction helper in direct.c to group contiguous pages from the same folio into a single struct nfs_page. This effectively migrates the Direct I/O path from being page-based to being folio-based. Note: zone_device_pages_have_same_pgmap() checks are intentionally omitted in the extraction helper since P2PDMA enablement will be introduced in a follow-up series. Bisectability ============= The series attempts to remain bisectable. [Patches 1-2] Introduce pin-aware infrastructure and accounting. [Patch 3] Adds a centralized request release helper. [Patch 4] Migrates the Direct I/O path to iov_iter_extract_pages(). [Patches 5-6] Implement the extraction helper and folio-based grouping. [Patch 7] Removes orphaned page-based helpers. Testing ======= The series lightly tested using fio (bs=1M, size=1G) on a small (non-server) machine running Linux 7.1-rc6. Some test logs from a run: nfs-test: (g=0): rw=read, bs=(R) 1024KiB-1024KiB, (W) 1024KiB-1024KiB, (T) 1024KiB-1024KiB, ioengine=libaio, iodepth=1 fio-3.42-37-g5b47 Starting 1 process nfs-test: (groupid=0, jobs=1): err= 0: pid=33264: Tue Jun 2 23:50:15 2026 read: IOPS=5145, BW=5146MiB/s (5396MB/s)(1024MiB/199msec) slat (usec): min=8, max=168, avg=11.12, stdev= 5.16 clat (usec): min=153, max=628, avg=182.20, stdev=24.15 lat (usec): min=165, max=796, avg=193.33, stdev=27.64 clat percentiles (usec): | 1.00th=[ 159], 5.00th=[ 163], 10.00th=[ 165], 20.00th=[ 169], | 30.00th=[ 172], 40.00th=[ 176], 50.00th=[ 178], 60.00th=[ 182], | 70.00th=[ 186], 80.00th=[ 194], 90.00th=[ 202], 95.00th=[ 215], | 99.00th=[ 229], 99.50th=[ 334], 99.90th=[ 408], 99.95th=[ 627], | 99.99th=[ 627] lat (usec) : 250=99.32%, 500=0.59%, 750=0.10% cpu : usr=1.01%, sys=5.56%, ctx=1025, majf=0, minf=265 IO depths : 1=100.0%, 2=0.0%, 4=0.0%, 8=0.0%, 16=0.0%, 32=0.0%, >=64=0.0% submit : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0% complete : 0=0.0%, 4=100.0%, 8=0.0%, 16=0.0%, 32=0.0%, 64=0.0%, >=64=0.0% issued rwts: total=1024,0,0,0 short=0,0,0,0 dropped=0,0,0,0 latency : target=0.00ns, window=0.00ns, percentile=100.00%, depth=1 Run status group 0 (all jobs): READ: bw=5146MiB/s (5396MB/s), 5146MiB/s-5146MiB/s (5396MB/s-5396MB/s), io=1024MiB (1074MB), run=199-199msec Pranjal Shrivastava (7): nfs: make nfs_page pin-aware nfs: Track number of pinned pages in nfs_page nfs: Introduce nfs_release_request_list helper nfs: migrate direct I/O to iov_iter_extract_pages nfs: introduce nfs_direct_extract_pages helper nfs: Optimize direct I/O to use folios for requests nfs: Cleanup the nfs_page_create_from_page helper fs/nfs/direct.c | 160 ++++++++++++++++++++++----------------- fs/nfs/pagelist.c | 86 +++++++++++---------- fs/nfs/read.c | 2 +- fs/nfs/write.c | 2 +- include/linux/nfs_page.h | 12 ++- 5 files changed, 144 insertions(+), 118 deletions(-) base-commit: 2c9eb6f2c18bff4cf3ddeab96db5137cc2b2572b -- 2.54.0.1013.g208068f2d8-goog