From patchwork Mon May 22 12:11:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13250304 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 05C2FC7EE2D for ; Mon, 22 May 2023 12:12:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9392B90000D; Mon, 22 May 2023 08:12:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8C0B0900003; Mon, 22 May 2023 08:12:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7618990000D; Mon, 22 May 2023 08:12:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 631AB900003 for ; Mon, 22 May 2023 08:12:22 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 20C8C1404EF for ; Mon, 22 May 2023 12:12:22 +0000 (UTC) X-FDA: 80817778524.16.6A99AB3 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf16.hostedemail.com (Postfix) with ESMTP id 6AB09180014 for ; Mon, 22 May 2023 12:12:20 +0000 (UTC) Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=H8WSKRZD; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf16.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684757540; a=rsa-sha256; cv=none; b=8OfOhVip02rr0rftm02nDtAAnP3475jXpnxrBP0IZ1/MHOlIwhkKeQLes7TR566zLxPzEc D9j+YOscf9LS6PplIQXEXipn+Jc9GPZHkF3EFhNZwBB1jswDvpffcYzb24XkHLRlWK8yIK YmIGzMbNPiKwP4IKmQPcC1zKqEryjnk= ARC-Authentication-Results: i=1; imf16.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=H8WSKRZD; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf16.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1684757540; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=5dEuCyEYbAeTLbptDWG+lpG3TePaGyDY6iKA6gIr8Gk=; b=ipSWE+ERowiG11oXxhJWZAvMuWtNg0pj52DOoIQBz3MA4om+CRBAnn5w7fI+9UPpKqZQYW 1Q4UKtZis8mEy/trHAeIv8br6BEvmV3ss2y4qqFNIqK8lKgFtexFGgWRdeYQWXUXO0obtd lwMKWwtX6HVKOGA8OVIL7qSv1xDXLzE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684757539; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5dEuCyEYbAeTLbptDWG+lpG3TePaGyDY6iKA6gIr8Gk=; b=H8WSKRZDo82RCXfVpZOrezmdo6ULq+BPkyKRJr3f6E+EJGWjlFpTpMlDIJyr4lK53+TIrr 322XEIJNl0x2xRhQm8K062wUUeqMCUoJWwmGpt55WpBeoUieGL1FLssDXQz7X9WkvZM23u wwxJklM0ldYvrMn1bO7kjn/heUrm3ak= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-569-bsmo5ELVM-2TXNBTHt6zHg-1; Mon, 22 May 2023 08:12:14 -0400 X-MC-Unique: bsmo5ELVM-2TXNBTHt6zHg-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8B87B85A5A8; Mon, 22 May 2023 12:12:13 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0EFBB1121314; Mon, 22 May 2023 12:12:10 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Al Viro , Christoph Hellwig , Jens Axboe , Jeff Layton , Christian Brauner , Chuck Lever III , Linus Torvalds , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH net-next v10 12/16] ip6, udp6: Support MSG_SPLICE_PAGES Date: Mon, 22 May 2023 13:11:21 +0100 Message-Id: <20230522121125.2595254-13-dhowells@redhat.com> In-Reply-To: <20230522121125.2595254-1-dhowells@redhat.com> References: <20230522121125.2595254-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 6AB09180014 X-Stat-Signature: q4o6qfydpxgdyxbcdyrtwzudt7gq7pi9 X-HE-Tag: 1684757540-10925 X-HE-Meta: U2FsdGVkX1/oSH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oYbd/TGmiiCgPusySgTGSRggoxlMo/jAzBHaF8hGzce+tam8vJcoudChSURAQUqXfTzQKt5VZeYcaAjeRYeMyVDuqk+yJNEQ2kDOSBvm9DqMAJR2oCgtXcoL7ECUiKwhreqPwyCh+NsRHCWxOrYbqJma5Flj5pzacY00ryaafdgLniPkyicgFbqI7HPeBicmk/UiHLBT80DF3SWWCF/3/OIUAR3i0RqzlKUX23aLNWz0noGFby/gwX/w/hzvKGQ0j4q4qpl0bjdwKoXVGqmRThR4u3ZDd60T4oOmNAJo8viYs2FMbOJ4k88ROXPjN0UyYzQGFzb8TobdTdD0CbAt2DWGEmIAOCiDL5SpMbiTfuloUoP8k7WozNJbuuUbk887fWd53HGBL3CymPndP3FJV/SXfFnv0vbTBDvHgNNMJk= 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: Make IP6/UDP6 sendmsg() support MSG_SPLICE_PAGES. This causes pages to be spliced from the source iterator if possible, copying the data if not. This allows ->sendpage() to be replaced by something that can handle multiple multipage folios in a single transaction. Signed-off-by: David Howells cc: Willem de Bruijn cc: David Ahern cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: netdev@vger.kernel.org --- Notes: ver #6) - Use common helper. net/ipv6/ip6_output.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/net/ipv6/ip6_output.c b/net/ipv6/ip6_output.c index 9554cf46ed88..c722cb881b2d 100644 --- a/net/ipv6/ip6_output.c +++ b/net/ipv6/ip6_output.c @@ -1589,6 +1589,14 @@ static int __ip6_append_data(struct sock *sk, skb_zcopy_set(skb, uarg, &extra_uref); } } + } else if ((flags & MSG_SPLICE_PAGES) && length) { + if (inet_sk(sk)->hdrincl) + return -EPERM; + if (rt->dst.dev->features & NETIF_F_SG) + /* We need an empty buffer to attach stuff to */ + paged = true; + else + flags &= ~MSG_SPLICE_PAGES; } /* @@ -1778,6 +1786,15 @@ static int __ip6_append_data(struct sock *sk, err = -EFAULT; goto error; } + } else if (flags & MSG_SPLICE_PAGES) { + struct msghdr *msg = from; + + err = skb_splice_from_iter(skb, &msg->msg_iter, copy, + sk->sk_allocation); + if (err < 0) + goto error; + copy = err; + wmem_alloc_delta += copy; } else if (!zc) { int i = skb_shinfo(skb)->nr_frags;