Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5816039rwl; Tue, 11 Apr 2023 10:17:33 -0700 (PDT) X-Google-Smtp-Source: AKy350bBBOAEov4WsZE5cBl3JEfARSzG8n8PUCaR5HTmSYI6XcIQIOu9M8RW18dVrEhwBZNU+02t X-Received: by 2002:a17:906:facf:b0:92f:ccf3:f0ce with SMTP id lu15-20020a170906facf00b0092fccf3f0cemr15369064ejb.45.1681233453192; Tue, 11 Apr 2023 10:17:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681233453; cv=none; d=google.com; s=arc-20160816; b=FmR8kIzeHGAKpQFFBSstD3XsXwe3TFmKyCzANwYaDjQJ4xrxfSf6VlcoeSTxSW2OJO 1DGM0qresXMQt5AWJxQazkB1kxRQHOcKav2U1gh4HhW3s/TrQWgBADyyO824GMlEWNDA 8gEQaKHN89TXRXf1xODF6Yk2iqBhN4j36MGLkfyVyN8NlDZF0oMSrWk/2qmX4usLzqyC njMjcyfPKKF4UPVX3FtrcyfiOwCcwlJ7dND9ewx2OXEnvNUfnvbgerL3U7VHo+F3R80Y lRxNNqKXZtvN0usNrq985wy2HGgroZd0iFovc9Kf487QNlVV4aFjc2A5ETPWE1StX6Qs xCkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=Gm7xePjxYk7+XJPNyNCPc3m+W8vE886GdLa6QN77x1c=; b=CkI6n9OzpVUvBSUv0LjRgIg5aQufmz/sYdODW9AZr+UvaPUa85CPUZ1aBPEzd27Y85 hXm+qD9f3nw8/awRXJX4cxb5MLXi7/oo2/XwZKM2MnLiqVccwluEeuvr0QmkHZqsF1yH QHUTDgL93RTC/U9MzfkipGYp2t2D2GJHyBKfcoKka7JwMBjQxMrff7EQrCtfea0FI40s Z29gjJ1YaWKEKa8wV6I7dH3knPmgJCxE8VnA3BYcDhN9STFuIr/Or+Vsk3LPXLv/lg4W Q7r6yS/AAgWq5i6/ZjNyqknWQ0xLg15kxWY5TYHNNJ+dR8JNuZVoBgNjtqcR2ixIJ7p4 bLgw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20221208 header.b="Dt/fnq5R"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ay1-20020a170906d28100b00949f92e5595si1190948ejb.266.2023.04.11.10.17.05; Tue, 11 Apr 2023 10:17:33 -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=@google.com header.s=20221208 header.b="Dt/fnq5R"; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229852AbjDKRJO (ORCPT + 99 others); Tue, 11 Apr 2023 13:09:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229666AbjDKRJN (ORCPT ); Tue, 11 Apr 2023 13:09:13 -0400 Received: from mail-yb1-xb2f.google.com (mail-yb1-xb2f.google.com [IPv6:2607:f8b0:4864:20::b2f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8FFA3AB3 for ; Tue, 11 Apr 2023 10:09:12 -0700 (PDT) Received: by mail-yb1-xb2f.google.com with SMTP id u13so9066063ybu.5 for ; Tue, 11 Apr 2023 10:09:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20221208; t=1681232952; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Gm7xePjxYk7+XJPNyNCPc3m+W8vE886GdLa6QN77x1c=; b=Dt/fnq5Rohg8OvlruMfiPphHzl880reg7mPfS4YNa5TmiKezMqJU7c5N642pzetXf2 6NbxlvK5ktk5iVQVml81CM9HQp85vFnzaieIFuuBqYSPu6WYL5u9tdlk4I6vgkBMqUvC w6wRpn8CV3RHhSbKqat6mlHmMYEYrkecxwv76tB8yR+Z9cCcwUm2we4/xm2upTtQATqH K4dsin1oFx+mWY14ixXb3oYb59cL4azDcD+rWQMZleC8KPvs8F+48Wq+ejwmTxLhkXPf IQbCu9aPtXBDaBDRLeDoRMpbwBZMZsK7uZVTPVozcyVwBpKD7OpdbHbV6DcndD7Ixvtu 1lzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681232952; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Gm7xePjxYk7+XJPNyNCPc3m+W8vE886GdLa6QN77x1c=; b=K4z28zR4akjGeW2uaZ8ie2dal5s235RGC8Ssfd6QYLsZoKvGYOT2tpRo7A1CPv3z50 0ZAJHm21iPrf/Sfcdyi3ME4fAzHZeI/LWgjoIf7rgLhcuZzE7b4dxFxcUT0CPbzRGVWp FD9RsYIHAhVKQ43W6ETgY4iYisOQEppOP0sKcvHmRy/nnBijQwXqBWmNvG6ABXQIk3q1 E69MADVVNYWKt3kCkspc6nU1FeU44N0ebGN+P39rNXDvg3LCvigqw9g/yjGve8HcQEHF /RqmHg82q9n60h89474cdVkVIblx04CJSDZG1vUsx2uAkOzJfuTDX2qqXJuEGwO7MoNA EPKA== X-Gm-Message-State: AAQBX9ceV1AZrlE1d7V/0OQgZGgop7gE+lcyMveh9oEOyTr6hQS88NLA 8LhUmA8zU+P6GaRBN/2IVxhurhEtpZg0X06brVAG7Q== X-Received: by 2002:a25:7347:0:b0:b8f:892:3967 with SMTP id o68-20020a257347000000b00b8f08923967mr2861731ybc.4.1681232951657; Tue, 11 Apr 2023 10:09:11 -0700 (PDT) MIME-Version: 1.0 References: <20230411160902.4134381-1-dhowells@redhat.com> <20230411160902.4134381-8-dhowells@redhat.com> In-Reply-To: <20230411160902.4134381-8-dhowells@redhat.com> From: Eric Dumazet Date: Tue, 11 Apr 2023 19:09:00 +0200 Message-ID: Subject: Re: [PATCH net-next v6 07/18] tcp: Support MSG_SPLICE_PAGES To: David Howells Cc: netdev@vger.kernel.org, "David S. Miller" , 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-15.7 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,ENV_AND_HDR_SPF_MATCH, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL, USER_IN_DEF_SPF_WL 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 On Tue, Apr 11, 2023 at 6:09=E2=80=AFPM David Howells = wrote: > > Make TCP's sendmsg() support MSG_SPLICE_PAGES. This causes pages to be > spliced or copied (if it cannot 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: Eric Dumazet > cc: "David S. Miller" > cc: David Ahern > 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/tcp.c | 43 ++++++++++++++++++++++++++++++++++++------- > 1 file changed, 36 insertions(+), 7 deletions(-) > > diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c > index fd68d49490f2..0b2213da5aaf 100644 > --- a/net/ipv4/tcp.c > +++ b/net/ipv4/tcp.c > @@ -1221,7 +1221,7 @@ int tcp_sendmsg_locked(struct sock *sk, struct msgh= dr *msg, size_t size) > int flags, err, copied =3D 0; > int mss_now =3D 0, size_goal, copied_syn =3D 0; > int process_backlog =3D 0; > - bool zc =3D false; > + int zc =3D 0; > long timeo; > > flags =3D msg->msg_flags; > @@ -1232,17 +1232,22 @@ int tcp_sendmsg_locked(struct sock *sk, struct ms= ghdr *msg, size_t size) > if (msg->msg_ubuf) { > uarg =3D msg->msg_ubuf; > net_zcopy_get(uarg); > - zc =3D sk->sk_route_caps & NETIF_F_SG; > + if (sk->sk_route_caps & NETIF_F_SG) > + zc =3D 1; zc is set to 0, 1, MSG_ZEROCOPY , MSG_SPLICE_PAGES I find this a bit confusing. Maybe use a private enum ? > } else if (sock_flag(sk, SOCK_ZEROCOPY)) { > uarg =3D msg_zerocopy_realloc(sk, size, skb_zcopy= (skb)); > if (!uarg) { > err =3D -ENOBUFS; > goto out_err; > } > - zc =3D sk->sk_route_caps & NETIF_F_SG; > - if (!zc) > + if (sk->sk_route_caps & NETIF_F_SG) > + zc =3D MSG_ZEROCOPY; > + else > uarg_to_msgzc(uarg)->zerocopy =3D 0; > } > + } else if (unlikely(msg->msg_flags & MSG_SPLICE_PAGES) && size) { > + if (sk->sk_route_caps & NETIF_F_SG) > + zc =3D MSG_SPLICE_PAGES;