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]) by smtp.lore.kernel.org (Postfix) with ESMTP id A86ADC77B7F for ; Mon, 23 Jun 2025 14:17:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4A22F6B00A0; Mon, 23 Jun 2025 10:17:14 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 403B06B00A5; Mon, 23 Jun 2025 10:17:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2F3FB6B00A6; Mon, 23 Jun 2025 10:17:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 16B366B00A0 for ; Mon, 23 Jun 2025 10:17:14 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id C502D1212AA for ; Mon, 23 Jun 2025 14:17:13 +0000 (UTC) X-FDA: 83586867546.23.F395D1B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf11.hostedemail.com (Postfix) with ESMTP id 04D694001D for ; Mon, 23 Jun 2025 14:17:11 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=PlmE8uPl; spf=pass (imf11.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=quarantine) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1750688232; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=DENPfef9k5KPGfxCMnb/tEj2yf0fmCOohO51w/ehSyg=; b=Hfo8movR2GUAAXDsF/ktIGMnUjMFzabI/VubZK5DiruSRXx2EGgJBrPJvsVVOhJuhVur/B 4+Jj3pNe1gfDyek77CsKn3WE5nwhwPvEkWYGed8V0J72uCn0dhmYHQJg6/hpKjrLGMHVkU z4a1HlaYaPbwoBcPzoEVWIns57l67js= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1750688232; a=rsa-sha256; cv=none; b=TRk8MZhtATr963Kou/CNYTvr/FKfAStn43QbSmRUqQOe/nqrwrf41vh9ettl1B2PnSFPhn a2SxgIm4wkb8h4z+DIKZuGolMBXDhJEzY8YTFmVxnpHdlZ1TujkF/TWs3sOBJlbJlfUfh9 oMYQSh3CF4ZLhK90v9TUhSzAnwMCxps= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=PlmE8uPl; spf=pass (imf11.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=quarantine) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750688231; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=DENPfef9k5KPGfxCMnb/tEj2yf0fmCOohO51w/ehSyg=; b=PlmE8uPly3FZbk1cMHFHxY4NGwvHUsMgCnRKNhH56szTBeIBM3LIq+OESpNE6FN/nL2cSe nMjXtpCsIDxE5yrBNu69LYGgwHBzufqNjdO4OQHrTM7WR5rtBh+VpknNH9g9SPzQ0PemvA 9anLKm1587K+oHga4ia2fltaaE1gptA= Received: from mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-19-rkV28ZGCPsW3UDW4tgao9A-1; Mon, 23 Jun 2025 10:17:08 -0400 X-MC-Unique: rkV28ZGCPsW3UDW4tgao9A-1 X-Mimecast-MFC-AGG-ID: rkV28ZGCPsW3UDW4tgao9A_1750688226 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8303418011FB; Mon, 23 Jun 2025 14:17:05 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.81]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0A2CB1800284; Mon, 23 Jun 2025 14:16:59 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: References: <1069540.1746202908@warthog.procyon.org.uk> <165f5d5b-34f2-40de-b0ec-8c1ca36babe8@lunn.ch> <0aa1b4a2-47b2-40a4-ae14-ce2dd457a1f7@lunn.ch> <1015189.1746187621@warthog.procyon.org.uk> <1021352.1746193306@warthog.procyon.org.uk> <2135907.1747061490@warthog.procyon.org.uk> To: Christoph Hellwig Cc: dhowells@redhat.com, Andrew Lunn , Eric Dumazet , "David S. Miller" , Jakub Kicinski , David Hildenbrand , John Hubbard , willy@infradead.org, Christian Brauner , Al Viro , Miklos Szeredi , torvalds@linux-foundation.org, netdev@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: AF_UNIX/zerocopy/pipe/vmsplice/splice vs FOLL_PIN MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1111402.1750688218.1@warthog.procyon.org.uk> Date: Mon, 23 Jun 2025 15:16:58 +0100 Message-ID: <1111403.1750688218@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 04D694001D X-Stat-Signature: 6bpokk41h7ray4w454o8n9zzbek4zccu X-Rspam-User: X-HE-Tag: 1750688231-766812 X-HE-Meta: U2FsdGVkX1+MiNSX+Uh8ITbvHTpXqH0olmJ4hVVbmkzmjgi6iX2nNGL7zmi6ajEarssz90Ala1JR4XelNe9lessHfxjYRoyEftWAILtrkir2JakUQXFunIkb01VKLg/iFe1/QnOcT4BIUDDkBtD2X1WICRvg63pc29Y+eVr8c2pjwTQ5g6+FGlj5/VBX83NHkHH5iDttKOakwo+Px6zzvI0h4z9DGHH5ily4+kT7wP6ayR/Y0KixigaK0BRCCGzqOh7ccFBUrNN16clnVRXEYQFeb5+DXrNnO400T0G23eVUN3QVkuHHE4rCkrRsCken/Wytnc0NucPuwU+EC15hc10ikYL7kvzSRInJDxtunQ5uW9mOGOywthrCINhNS8jcl5rCFAJq//+q5F9aKC+fESLBXUCZ2j/ZIg+8IZX2H+/2DW/RNjJiMzFWV/nGuJgLoO0KyxRjleKx6o0cV2dM54Y7nKyTg1NTPlvCLjk4ihcDOGG+Ri03ieBf5tzPuDN0sdprPvTTot9IsJkgBqPdo0Tm0vV67e3UufI+RGRQiFp3P15xjZExCV42aXRMeiU314MgwS+WvArIg6tNtKU7JNrGaXMvUxm8P6KHh0iM8AMBXMhPSL4lSs/+5iH0hw2pLg8iAf5t6zOY6F8VH9MJuH8w1wPkw+N18rGKiXKBQz3GRY5RnMjqcVw0vL3AneAa4+KOyIywAqKOAu1OxDkg/2jju1Jeg4dAxNMOjqQInqchB01/aGc7WsNXpFVOC57auNBmhhTXmZK6Ae1KGLFku6ysdsDYdThvEGVncXx+SZSA1df0Mi3U+igYkspzonAza1L22jQ1RgIsscqV4y2O6eJM10rFeyj0goIe8pIV01pke4p36a/lO88fyIxMqkNcc598e1YQ4uD4E1wl20uT7F4FtlP3+zVnX9INerdebVUSrqSC+Z3fh3dLcavUr9wIU4jKgKfh7mqdh7ujxjr 6iSND1YW 3/6GdF1psHXw+aGkVZuh6pAmx2Q== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Christoph Hellwig wrote: > > The question is what should happen here to a memory span for which the > > network layer or pipe driver is not allowed to take reference, but rather > > must call a destructor? Particularly if, say, it's just a small part of a > > larger span. > > What is a "span" in this context? In the first case, I was thinking along the lines of a bio_vec that says {physaddr,len} defining a "span" of memory. Basically just a contiguous range of physical addresses, if you prefer. However, someone can, for example, vmsplice a span of memory into a pipe - say they add a whole page, all nicely aligned, but then they splice it out a byte at a time into 4096 other pipes. Each of those other pipes now has a small part of a larger span and needs to share the cleanup information. Now, imagine that a network filesystem writes a message into a TCP socket, where that message corresponds to an RPC call request and includes a number of kernel buffers that the network layer isn't permitted to look at the refcounts on, but rather a destructor must be called. The request message may transit through the loopback driver and get placed on the Rx queue of another TCP socket - from whence it may be spliced off into a pipe. Alternatively, if virtual I/O is involved, this message may get passed down to a layer outside of the system (though I don't think this is, in principle, any different from DMA being done by a NIC). And then there's relayfs and fuse, which seem to do weird stuff. For the splicing of a loop-backed kernel message out of a TCP socket, it might make sense just to copy the message at that point. The problem is that the kernel doesn't know what's going to happen next to it. > In general splice unlike direct I/O relies on page reference counts inside > the splice machinery. But that is configurable through the > pipe_buf_operations. So if you want something to be handled by splice that > does not use simple page refcounts you need special pipe_buf_operations for > it. And you'd better have a really good use case for this to be worthwhile. Yes. vmsplice, is the equivalent of direct I/O and should really do the same pinning thing that, say, write() to an O_DIRECT file does. David