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 2B732C3ABBF for ; Tue, 6 May 2025 13:56:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6F5F76B00A5; Tue, 6 May 2025 09:56:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 67C816B00A6; Tue, 6 May 2025 09:56:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 569526B00A7; Tue, 6 May 2025 09:56:26 -0400 (EDT) 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 368C36B00A5 for ; Tue, 6 May 2025 09:56:26 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 2CB931A0296 for ; Tue, 6 May 2025 13:56:27 +0000 (UTC) X-FDA: 83412632814.28.043D165 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) by imf17.hostedemail.com (Postfix) with ESMTP id EF0264000C for ; Tue, 6 May 2025 13:56:23 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=d4+QEZ9G; spf=none (imf17.hostedemail.com: domain of BATV+7bc025a671db8664be8f+7926+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+7bc025a671db8664be8f+7926+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1746539785; 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=sDSa7bE8NOJXLelvEMpU/rC6sYcMXis7kEsdOk5BpI0=; b=bBHpkzRxhDvuLcVc5iNWvv0JG+H6f4QzVquMxfuBvxQ6213FYYpdp/Y7JdJIgsbvoQhzhz 9lgG9sNar3sFF7GpUeL6bgbOP8PDWNYbRO6vpL9x1c3E6hi2Zu3T0iilv7j7qVEml/tY6X oLt37cVy6C4+Fz2rgfjy4ac3g4IDk5c= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=infradead.org header.s=bombadil.20210309 header.b=d4+QEZ9G; spf=none (imf17.hostedemail.com: domain of BATV+7bc025a671db8664be8f+7926+infradead.org+hch@bombadil.srs.infradead.org has no SPF policy when checking 198.137.202.133) smtp.mailfrom=BATV+7bc025a671db8664be8f+7926+infradead.org+hch@bombadil.srs.infradead.org; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1746539785; a=rsa-sha256; cv=none; b=QoyiYX7QoiBy/QaqQVJQ/56Lc3rWAboCBp8KPnKr0NPVS5EOrvU7Vgio50AXe9CNS6CC3v Pja/daj+kIGT2mL+QEylbp862cII8vFa46b7TKMvPD285hAVhdDTV/sRxlcQ1D3J3ooTfj E5NbrVZPdm0eLB5fdwPPq8hgvGYdA8E= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=sDSa7bE8NOJXLelvEMpU/rC6sYcMXis7kEsdOk5BpI0=; b=d4+QEZ9GFyHLyMVwJ48TKE6Ihn S1FaSH9ltOcNp8C2wL3927zufKs6vPAHstgRsiUbOBT/avqnIvnJLb7XBsytAf6hUbBRr4DgcLD5E QxXqrbiDvqWJCSj2su4ZAgm5Q24jQsVEwnveMOLWQOD3Acy7oJfqgeOursDLY7diLPcQGrKbhQfz1 2MtbfQJI/M5z/exkUBLhgl5GT5inYAirRFLHgqvcAauiRhQlDigbzHxDM9FPDkScK6uy9NW0KpzHo s+JcggW/WUYOWoHuOaWCNLI3mFZnAJNRXSqKNpYdStdAjwQHF0vy1LmTYJlZviuRWeeFgcQVT4zGa YJ2py6yA==; Received: from hch by bombadil.infradead.org with local (Exim 4.98.2 #2 (Red Hat Linux)) id 1uCImP-0000000CDgT-3Equ; Tue, 06 May 2025 13:56:17 +0000 Date: Tue, 6 May 2025 06:56:17 -0700 From: Christoph Hellwig To: David Howells Cc: Jakub Kicinski , Andrew Lunn , Eric Dumazet , "David S. Miller" , David Hildenbrand , John Hubbard , Christoph Hellwig , willy@infradead.org, netdev@vger.kernel.org, linux-mm@kvack.org, Willem de Bruijn Subject: Re: Reorganising how the networking layer handles memory Message-ID: References: <20250505131446.7448e9bf@kernel.org> <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> <1069540.1746202908@warthog.procyon.org.uk> <1216273.1746539449@warthog.procyon.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1216273.1746539449@warthog.procyon.org.uk> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html X-Rspam-User: X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: EF0264000C X-Stat-Signature: o7odjuuooc34mfyrm7x8u6pa437aab9d X-HE-Tag: 1746539783-956990 X-HE-Meta: U2FsdGVkX19/NmNoWRcAYQNPOpeLHFZ2rroTj3cV4ATSi94Kwn10oLPAeMgac6cjrIfN8qIz8OfzDvNwWrS3mh7TvQgdaeO14WKIwx2eT7iTcdKqYxzCQX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ilter, 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: On Tue, May 06, 2025 at 02:50:49PM +0100, David Howells wrote: > > > (2) sendmsg(MSG_ZEROCOPY) suffers from the O_DIRECT vs fork() bug because > > > it doesn't use page pinning. It needs to use the GUP routines. > > > > We end up calling iov_iter_get_pages2(). Is it not setting > > FOLL_PIN is a conscious choice, or nobody cared until now? > > iov_iter_get_pages*() predates GUP, I think. It predates pin_user_pages, but get_user_pages is much older. > There's now an > iov_iter_extract_pages() that does the pinning stuff, but you have to do a > different cleanup, which is why I created a new API call. But yes, iov_iter_get_pages* needs to go away in favour of iov_iter_extract_pages, and I'm still annoyed that despite multiple pings no one has done any work on that outside of block / block based direct I/O and netfs. > > > (3) sendmsg(MSG_SPLICE_PAGES) isn't entirely satisfactory because it can't be > > > used with certain memory types (e.g. slab). It takes a ref on whatever > > > it is given - which is wrong if it should pin this instead. > > > > s/takes a ref/requires a ref/ ? I mean - the caller implicitly grants > > a ref to the stack, right? But yes, the networking stack will try to > > release it. > > I mean 'takes' as in skb_append_pagefrags() calls get_page() - something that > needs to be changed. > > Christoph Hellwig would like to make it such that the extractor gets > {phyaddr,len} rather than {page,off,len} - so all you, the network layer, see > is that you've got a span of memory to use as your buffer. How that span of > memory is managed is the responsibility of whoever called sendmsg() - and they > need a callback to be able to handle that. Not sure what the extractor is, but we plan to change the bio_vec to be physical address instead of page+offset based. Where we is a lot more people than just me. > Once advantage of delegating it to the caller, though, and having the caller > keep track of which bits in still needs to hold on to by transmission > completion position is that we don't need to manage refs/pins across sk_buff > duplication - let alone what we should do with stuff that's kmalloc'd. And the callers already do that for all other kinds of I/O anyway.