Message ID | 20230522121125.2595254-12-dhowells@redhat.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1402582vqo; Mon, 22 May 2023 05:16:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4owxiPs6RJiDGqWu21NWr1iIIoqfS9O9esK/kcuZHkdVuSJG+9IFMrlJ/507jJGlG8sfhx X-Received: by 2002:a05:6a00:134c:b0:64d:2b06:5949 with SMTP id k12-20020a056a00134c00b0064d2b065949mr14368781pfu.8.1684757807726; Mon, 22 May 2023 05:16:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684757807; cv=none; d=google.com; s=arc-20160816; b=e21mPfFqtRzfR850ngjoor4HqG1V57Jwwb3KqYX0aI69tYD9EhDG5VN3n9OTs09JK2 B1kkp0osD2Wa1HiNMbGv/6+auC/epm3lfvdyzDFs49J4J1xgJ0LCRfYvk26ukuE5RdNP YbW1WzTuKxgUvA3RH1FEYVd01QwCJOgpkP9C5tUb9G8OaMFteyQikDrtZ25XuOkYIOlm 2v5/ev1dxnFBX8TL8cXa7vtr+76ynxuPUne2tj5cq28JiTU78CrPFEvBcw+5Iu4B7KJ3 fPVqUER/bpdoGMJCvAKjPZ4EQSKrlgtl/Nn64nt1/phxZ75GzuYEDoRfVSCPnsGBeFLo 0rgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Di14zlocOEDECmKOzgXOEyS4sjRLATonTy1WJdIXAUU=; b=tm2vob2yQnzin+UeyctfqRVHlkuCXLee0BNjD0qObrSeZRWC37piF4lvZHCBW16Gr3 mSDWu831Iubx35FRdY2WhdXMxCML71+qebTv49AH59JfgdWcLVtZgP/zpzJfv2vx7To7 vrJHwLuJPjbRjYjQk501rOgmz/pbgcQ1kZR2WNL3KQLmCOpfDm3eBaUDI3H/jaVZ7nrY fLJsSLd6gM0/swJHzqwOXGN5zTx2Iznn+vD2zv2zGvhQWOMwrVadFuUnWn5dQiOBYr+r fLSeW9ecQ4sw4qQZhx7mIfsyxMmkA7zX2K3x4gnoPPtAahEC8l2TzQWqb5AIAZrqbu61 KBtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cul1hH2Z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g3-20020aa79f03000000b00625c6092a12si4702548pfr.215.2023.05.22.05.16.32; Mon, 22 May 2023 05:16:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=cul1hH2Z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233733AbjEVMN6 (ORCPT <rfc822;cscallsign@gmail.com> + 99 others); Mon, 22 May 2023 08:13:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233346AbjEVMNS (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 22 May 2023 08:13:18 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1786FA3 for <linux-kernel@vger.kernel.org>; Mon, 22 May 2023 05:12:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684757538; 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=Di14zlocOEDECmKOzgXOEyS4sjRLATonTy1WJdIXAUU=; b=cul1hH2ZjcACPvgRvbC7yUyba812B7cG0nlVmVZxlpIWux6lQdyw1drqQXvTRCrNx8qBKI VWtv1Q5ELX1Oo5k6013eHW/2PwmW9oIlK21QVZHjdHNgF6zRrQ39P7VPMsSaLcpch2xaPr 0Vv+/6Q6EGDHvvameWjEzSZ/XJ5mUhU= 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-389-i0ekLMi1P3uITGz1Ox_XFQ-1; Mon, 22 May 2023 08:12:11 -0400 X-MC-Unique: i0ekLMi1P3uITGz1Ox_XFQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2602780349B; Mon, 22 May 2023 12:12:10 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.192.68]) by smtp.corp.redhat.com (Postfix) with ESMTP id 856907B7C; Mon, 22 May 2023 12:12:07 +0000 (UTC) From: David Howells <dhowells@redhat.com> To: netdev@vger.kernel.org Cc: David Howells <dhowells@redhat.com>, "David S. Miller" <davem@davemloft.net>, Eric Dumazet <edumazet@google.com>, Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>, Willem de Bruijn <willemdebruijn.kernel@gmail.com>, David Ahern <dsahern@kernel.org>, Matthew Wilcox <willy@infradead.org>, Al Viro <viro@zeniv.linux.org.uk>, Christoph Hellwig <hch@infradead.org>, Jens Axboe <axboe@kernel.dk>, Jeff Layton <jlayton@kernel.org>, Christian Brauner <brauner@kernel.org>, Chuck Lever III <chuck.lever@oracle.com>, Linus Torvalds <torvalds@linux-foundation.org>, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [PATCH net-next v10 11/16] ip, udp: Support MSG_SPLICE_PAGES Date: Mon, 22 May 2023 13:11:20 +0100 Message-Id: <20230522121125.2595254-12-dhowells@redhat.com> In-Reply-To: <20230522121125.2595254-1-dhowells@redhat.com> References: <20230522121125.2595254-1-dhowells@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766596603134894669?= X-GMAIL-MSGID: =?utf-8?q?1766596603134894669?= |
Series |
splice, net: Replace sendpage with sendmsg(MSG_SPLICE_PAGES), part 1
|
|
Commit Message
David Howells
May 22, 2023, 12:11 p.m. UTC
Make IP/UDP sendmsg() support MSG_SPLICE_PAGES. This causes pages to be
spliced from the source iterator.
This allows ->sendpage() to be replaced by something that can handle
multiple multipage folios in a single transaction.
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
cc: David Ahern <dsahern@kernel.org>
cc: "David S. Miller" <davem@davemloft.net>
cc: Eric Dumazet <edumazet@google.com>
cc: Jakub Kicinski <kuba@kernel.org>
cc: Paolo Abeni <pabeni@redhat.com>
cc: Jens Axboe <axboe@kernel.dk>
cc: Matthew Wilcox <willy@infradead.org>
cc: netdev@vger.kernel.org
---
Notes:
ver #6)
- Use common helper.
net/ipv4/ip_output.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/net/ipv4/ip_output.c b/net/ipv4/ip_output.c index 52fc840898d8..c7db973b5d29 100644 --- a/net/ipv4/ip_output.c +++ b/net/ipv4/ip_output.c @@ -1048,6 +1048,14 @@ static int __ip_append_data(struct sock *sk, skb_zcopy_set(skb, uarg, &extra_uref); } } + } else if ((flags & MSG_SPLICE_PAGES) && length) { + if (inet->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; } cork->length += length; @@ -1207,6 +1215,15 @@ static int __ip_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;