From nobody Wed Nov 12 11:53:28 2025 X-Original-To: freebsd-hackers@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4d61ys2YSQz6Gsg2 for ; Wed, 12 Nov 2025 11:54:13 +0000 (UTC) (envelope-from lionelcons1972@gmail.com) Received: from mail-ej1-x631.google.com (mail-ej1-x631.google.com [IPv6:2a00:1450:4864:20::631]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "WR4" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4d61yr56MBz3Z7v for ; Wed, 12 Nov 2025 11:54:12 +0000 (UTC) (envelope-from lionelcons1972@gmail.com) Authentication-Results: mx1.freebsd.org; dkim=pass header.d=gmail.com header.s=20230601 header.b=kmRXDtdk; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (mx1.freebsd.org: domain of lionelcons1972@gmail.com designates 2a00:1450:4864:20::631 as permitted sender) smtp.mailfrom=lionelcons1972@gmail.com Received: by mail-ej1-x631.google.com with SMTP id a640c23a62f3a-b73161849e1so134772066b.2 for ; Wed, 12 Nov 2025 03:54:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1762948445; x=1763553245; darn=freebsd.org; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=nzGFTVeoK0suaHrxLMLtFHCVOUxG3ADnh2TDJb9IrHY=; b=kmRXDtdkk4rfFKvqbklO81Q3FhDB9918PlZb7XmsOEHRAK3UHpJcq7z4XAID7RSfvM wDwGGknhrCMDNMyMhHnoo01dVo5wJhRsljQMQ1/UPiKy6PWp3AuMY45yXSBvyherelLi VvgtBFDjVvgledSi38ya+tQBokKegV395e/4ZIRW8h5FFx4PmP0HeY2xuxfpYHuIrOtE 1hpjsQ5tnrmgAYEBpJd6m4OWpo/VSk/rbUqlxO4fvXwvw2Wgt8vgrnW3Pee/RjYNti1H iCAGd+qAEvWT3wEydpkrxWkPVMpSQz0otkOMX4pbij5K+PFQsx1aPbX4ZvIJLwPRIOtR N7Xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762948445; x=1763553245; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=nzGFTVeoK0suaHrxLMLtFHCVOUxG3ADnh2TDJb9IrHY=; b=VpdISLWx7OU3ZU9BhdodFS1/jxUjgAfcheWmQMIgwrF/+oNfQBNN4reSEsMj6dxh0d euai94vexd9cKMTkQ8MBr/b4P4sGbsGdjM/zzspd1jEJUKZqwWTG+f5Pvm+vo9duDiBs uzcTf1ngtNVS198xDDkmtTeyWBbCNKAK8PeoBuv1DLwvVBAGXqNhjPsUjgQ8zPPgjQwI Co8tbLYavDd+PXhfbmFN6acyUZ/RSLs8FL+r5JEhzKR1aGDbmiUqGk4wKLyAh0cPhcXf EfR8qEfBOLqR5yBD6OmVljazA/G+sB8RHf+aS9xMVZB6OUbl7iH3zoLNldNOlyD6dDBq XAfA== X-Gm-Message-State: AOJu0YyUd+MifhS3nz5o56WpPWArWQJwxwvnKMbw5EdP9LVcMXsohtgy BDJLDEgo0JFndPP3JeXBJ4VsXb7m49jG+PNkxycTsngeanlrUXrDlPD3FX92R4Bp+iCpEE3/BNA HB0a8lXNeyhkop0NqCsLo7sbSAnnyhTFeRA== X-Gm-Gg: ASbGncv3n6MELp+AXRwwRiXwU/lzE2Z8KxuEnAOuVck78V5uk6HDpXQKQtKKrJfsTwA +JvmX01j9bj4If7o7p9AId4F0oVXMgIcd9jxtwPQ5h8ib7l0h3czPpZS229w9CaIX3ebJVoMVUJ ltwCxV64UVvtqSqF4rg95SAPEmb5eVKD/2bkfT+WhA1+BxmvZ5zFbIoJGN1FM9iaGeJTSgy/pgm nVEXjoMIDJqHNwlPPXFas6IsaeO6GMg1ZKzqnBlFzPyNqC8542t+yUVSKAiHoQgVZfWIw== X-Google-Smtp-Source: AGHT+IGpr/jblSa8Ckz/R94yL3yZiG0Xuqr2P1fa2hLErstbOhF3YWTHloC7iwXReDN2q3MHvoVPrgSqxxaXsXkZJ2s= X-Received: by 2002:a17:906:c14b:b0:b73:2836:4039 with SMTP id a640c23a62f3a-b7331a9b60fmr263199166b.51.1762948444816; Wed, 12 Nov 2025 03:54:04 -0800 (PST) List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@FreeBSD.org MIME-Version: 1.0 References: In-Reply-To: From: Lionel Cons Date: Wed, 12 Nov 2025 12:53:28 +0100 X-Gm-Features: AWmQ_bnUXX7cRYUnPDUeJmOIr9DIIFaAcV-bGsVzVxPIffQlgEh_hQHPB2odHKE Message-ID: Subject: Re: Implementing VOP_READPLUS() in FreeBSD 15? To: freebsd-hackers@freebsd.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spamd-Bar: -- X-Spamd-Result: default: False [-3.00 / 15.00]; SUBJECT_ENDS_QUESTION(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-0.999]; DMARC_POLICY_ALLOW(-0.50)[gmail.com,none]; R_SPF_ALLOW(-0.20)[+ip6:2a00:1450:4000::/36]; R_DKIM_ALLOW(-0.20)[gmail.com:s=20230601]; MIME_GOOD(-0.10)[text/plain]; RCVD_TLS_LAST(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; DWL_DNSWL_NONE(0.00)[gmail.com:dkim]; FREEMAIL_FROM(0.00)[gmail.com]; DKIM_TRACE(0.00)[gmail.com:+]; FROM_HAS_DN(0.00)[]; FREEMAIL_ENVFROM(0.00)[gmail.com]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; TO_DN_NONE(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; MISSING_XM_UA(0.00)[]; MLMMJ_DEST(0.00)[freebsd-hackers@freebsd.org]; ASN(0.00)[asn:15169, ipnet:2a00:1450::/32, country:US]; MID_RHS_MATCH_FROMTLD(0.00)[]; RCVD_COUNT_ONE(0.00)[1]; RCVD_IN_DNSWL_NONE(0.00)[2a00:1450:4864:20::631:from] X-Rspamd-Queue-Id: 4d61yr56MBz3Z7v On Fri, 7 Nov 2025 at 03:02, Rick Macklem wrote: > > On Thu, Nov 6, 2025 at 11:40=E2=80=AFAM Aur=C3=A9lien Couderc > wrote: > > > > This is a followup to a discussion with the nfs-ganesha developers. > > > > Could FreeBSD implement a VOP_READPLUS() in FreeBSD 15, please? > > > > Citing Lionel Cons/CERN: > > > But the point is to optimise the read(). First, you have less traffic= over the wire (which is a > > > thing if your reads are in the gigabyte range for large VMs), and it = tells the VM host that it > > > can just map all those MMU pages representing the hole to the "defaul= t zero page", which > > > in turn saves lots of space in the L3 and L2 caches ----> THIS DOES W= ONDERS to VM > > > performance. > > > > > > Example: > > > The performance benefit here comes from the fast that instead of mapp= ing a 1TB hole > > > (1099511627776 bytes) to individual 524288 2M pages (x86 2M hugepage = size), and then > > > potentially reading from them, you just have ONE 2M page in the cache= , and all reads come > > > from that. > > > > > > READ_PLUS is THE game changer for that kind of application, especiall= y in our case (HPC > > > simulations). > Why doesn't the application use lseek(SEEK_DATA/SEEK_HOLE) and only read(= 2) the > data segments? Because these are extra syscalls with extra latency, and this is not applicable to Infiniband/RDMA. But let's move back in history first: The filesystem op READ_PLUS (and WRITE_PLUS) comes from Sun Microsystems. Originally conceived by Eric Blake and Roland Mainz as part of the "new VM system", and was slated to be integrated in Solaris 12. But when ORACLE bought SUN, Solaris 12 was canceled - but at least the new VM system was backported to Solaris 11.3 and 11.4. About the fate of the new IO system, I do not know. How would the new IO system look like: 1. READ_PLUS, to issue a read, instead of getting a straight buffer filled it returned a set of ranges+data. Each range is one of DATA, HOLE, ADB (application data block). 2. WRITE_PLUS is READ_PLUS in reverse, you pass a set of either DATA; HOLE or ADB to the driver, plus flags which sets can be concurrently written. For backwards compatibility there is a method to query which IO calls are supported by a filesystem, and if no bits of READ_PLUS or WRITE_PLUS are set, then it will be emulated. > > This is implemented now in FreeBSD and in several other POSIX-like OSs > and avoids > problems like filling the buffer cache with blocks of all zeros or > returning a lot of blocks > with all zeros to the application via read(2). Yeah, but touching each page you read just to scan for zeros is inefficient, especially if you have 2M large pages and RDMA. This kills performance. > > Right now, I not aware of any read_plus(2) syscall (please correct me > if I am wrong on this), > so applications that read(2) sparse files without bothering to do > lseek(SEEK_DATA/SEEK_HOLE) will get a lot of 0s to process. > > To do VOP_READPLUS() is a lot of work. Once the VOP_READPLUS() is defined= , > there needs to be implementations in the various local fs (ZFS, UFS, > ..). That requires > work by people who know these areas. I am only minimally conversant with = either > ZFS or UFS and would not want to attempt to do a good VOP_READPLUS() > implementation for either of them. (Without fs specific > implementations, there isn't > much point in doing it, imho.) Both UFS and ZFS can run via emulation, until there is a native implementat= ion. Lionel