Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5732468rwl; Tue, 11 Apr 2023 09:13:01 -0700 (PDT) X-Google-Smtp-Source: AKy350YWLdTUN415QztTjqL564mjQmjhDNlWPO3ek9YOlpQFLXlOfr1NjPMpB6EsyN8cVqJlTJ+t X-Received: by 2002:a17:902:d512:b0:1a5:918:df40 with SMTP id b18-20020a170902d51200b001a50918df40mr22379054plg.13.1681229580627; Tue, 11 Apr 2023 09:13:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681229580; cv=none; d=google.com; s=arc-20160816; b=wLReY3t0IkOcLIh1YcYBOQ1JoMNWn5BpTUdNd5JqdRX+Vqh3V75m9I6d7va4BdLLmQ hEh/nawQ3bYiRfo+5jMStB9+uUQrQ+K27qVfsIDqjt41hOEoC3WGWScUeXORqjF6hkas Th7XPa/5y+jA4RA45pDh3RGSCLXZOgOxWZ9R7L2Ghlwn4UioRtG4MZ2hc8QO+WV9AfjI kKYNRK4pYMYa2OSB4UElyK7tKse1QXUNCmUebtr5cUo36bYZGgmw5RDZQXNWmXcf14JK 859mMWD6tAIt2b9MjrRLagwRhZK3MaeiRjQOlWp/J+9iG9uPqScZAt0wskkh+nZfXK44 0nJw== 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=ixYp8U9bxWbRy0uTYM5jwtBZUcxG981BMDx6Mvgz/Cw=; b=wJLyfmAgPqYPNIrpKotsBAX538Q2ECKM5h2cld5bCE6zDW0lkSdfaVS6nT5LjG4Nos 3GKdoCiHofjzEcnhzaqMGncFNV1/rqSXFnJyAemCVa9CM03DA/5C+jQhKW/zbiTl34wk b12QIp17d/lDMoJkarL00ygCnq70d6zTNgGG3EOqbXibpBEMgR8no0+1PtP8PWH8mrpR x17TqSubBfjB6McvhW88rC4h1oorjbGeLkaJ7Aj/FQxyN+6qpOdW3KzexRIL0qXtwtQX TFDbHaYfzo0Yi+uMyPuqZkZ+MKhOUgOXlWTNm6XbYZ/Se+4bv+ar0Pkp+DTnd1aQ4bvp WSxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Js0h0Peg; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o7-20020a1709026b0700b001a288c5d34bsi13420812plk.85.2023.04.11.09.12.49; Tue, 11 Apr 2023 09:13:00 -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=Js0h0Peg; 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 S230247AbjDKQLn (ORCPT + 99 others); Tue, 11 Apr 2023 12:11:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230226AbjDKQLK (ORCPT ); Tue, 11 Apr 2023 12:11:10 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75B0B2D64 for ; Tue, 11 Apr 2023 09:09:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681229397; 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=ixYp8U9bxWbRy0uTYM5jwtBZUcxG981BMDx6Mvgz/Cw=; b=Js0h0PegXi6rozO6RV49/bDxVt86AiFrittQrG/bvozKJ30TF/237YYgJCaa0tJPkdEznr neySYCW0ClH1VBGc3wGRHylw7Fp5IqIyrgm7+lQaaCDI5g5rAbR5FmRpjtblVeqHpao89G 0WVX6owXBybUduQwdQDIoaT5p/cLeDo= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-668-6XnKugzfOdqRWqhI-2hRlw-1; Tue, 11 Apr 2023 12:09:54 -0400 X-MC-Unique: 6XnKugzfOdqRWqhI-2hRlw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0FCA51C05143; Tue, 11 Apr 2023 16:09:53 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id E6A1A2027040; Tue, 11 Apr 2023 16:09:50 +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 v6 14/18] ip, udp: Support MSG_SPLICE_PAGES Date: Tue, 11 Apr 2023 17:08:58 +0100 Message-Id: <20230411160902.4134381-15-dhowells@redhat.com> In-Reply-To: <20230411160902.4134381-1-dhowells@redhat.com> References: <20230411160902.4134381-1-dhowells@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Spam-Status: No, score=-0.2 required=5.0 tests=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 autolearn=unavailable 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: X-Mailing-List: linux-kernel@vger.kernel.org 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 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/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 bd002222cf2d..b594da6d6bc1 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;