Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp835277rwd; Thu, 18 May 2023 04:48:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ43whh0Bm8qS8CX15mbkTsQjCWVf1pLd2VdtumqrPXhtjKKh2FOdskwfyhiVjZ4EV0+ixTj X-Received: by 2002:a05:6a20:160a:b0:103:81cc:dd3f with SMTP id l10-20020a056a20160a00b0010381ccdd3fmr2321633pzj.48.1684410493386; Thu, 18 May 2023 04:48:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684410493; cv=none; d=google.com; s=arc-20160816; b=vYntMv3xxfK0AtBLOQ7zHj+uwpijn26ZD9V/X8IBdJ2lp6TuZVDzPelj8iCPNNzXiA 5O+EWrnUMhbsbPUFKYT3vDaPwYN3Vn08KrUrsUBSfmajEEt+P5CnoCYQBcYxmUVBebHB S2jvRQcnjcUeg0Khvl23WiUYNaBw2o+zINBtVGNt+GDqaitTSwjgWOmnkSNbTuSpnmWJ VhGgOcPSXxEOUhKF1NQZaMdjOV4gSF6VtNN3pQ/cCK80ZmTlZnjQaw1l3GIJx/fUnFp+ EX0THSTxjaHHZ3xTjMFn5iU+jRNiAwpBaUeKHNlUae4JtERAnYzZgf0a1+CdYCmHzX26 9rqw== 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=2EXLlBUI8HMrlq1LdzuePmnE9vo0jChMg019VHUJEgs=; b=lwzQ1mhpnrS3tODnzOL7IaOWgxwvZBbI5CDFK6BU6M3tNiqVcyDEngV8ogRFUrGtYB TvxjGQGoOYYX5x0G6S06afhxo73oC9DjP80c8e6TveIgIP4I0AX/KfepWgww8tSIXw8M IKfpld2UDmrQD2R6/nwJpCNeBMF8KGV0gMzUsS81KX241plzXcHes9q0W8hhSbWB+9FV SLoO7mozYGcEUivONg31ckZ6fm4Cwg/Fd2pIrg7aDT51ummY9px579at7jOYTenFpOGd NRCFCu5sP/6L7aUcHts760QFs8kxUZT+p3Oqhv8YFsAf/3/SVNAu66vx96ZC71Cw1ZHk baRw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=QwPdJ3Pq; 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 y24-20020a17090aa41800b0024de687d6e3si1574091pjp.111.2023.05.18.04.47.57; Thu, 18 May 2023 04:48:13 -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=QwPdJ3Pq; 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 S231435AbjERLgo (ORCPT + 99 others); Thu, 18 May 2023 07:36:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231340AbjERLgY (ORCPT ); Thu, 18 May 2023 07:36:24 -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 936C5100 for ; Thu, 18 May 2023 04:35:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684409733; 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=2EXLlBUI8HMrlq1LdzuePmnE9vo0jChMg019VHUJEgs=; b=QwPdJ3PqCF66n1nSTJtH3dnojHaceQppcgdF438zTiJnVGPlLrj5bS+2zEd1PFzV+djhMt qfYoLWtmI7dSkKzNQLCbA24qlwQ9OJ2+atiPyDjO5jORgCmAtEuho3wiHMLPb/i7d8H+hE 5bzOsyOqVaweQdUfnvgMiMDkg7+U45Q= 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-84-Mvf0PKrvOkyxjyMevBqNLQ-1; Thu, 18 May 2023 07:35:29 -0400 X-MC-Unique: Mvf0PKrvOkyxjyMevBqNLQ-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C1BF83C10221; Thu, 18 May 2023 11:35:28 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 27987492B01; Thu, 18 May 2023 11:35:26 +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, John Fastabend , Jakub Sitnicki , bpf@vger.kernel.org Subject: [PATCH net-next v8 06/16] tcp_bpf: Inline do_tcp_sendpages as it's now a wrapper around tcp_sendmsg Date: Thu, 18 May 2023 12:34:43 +0100 Message-Id: <20230518113453.1350757-7-dhowells@redhat.com> In-Reply-To: <20230518113453.1350757-1-dhowells@redhat.com> References: <20230518113453.1350757-1-dhowells@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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=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 do_tcp_sendpages() is now just a small wrapper around tcp_sendmsg_locked(), so inline it. This is part of replacing ->sendpage() with a call to sendmsg() with MSG_SPLICE_PAGES set. Signed-off-by: David Howells cc: John Fastabend cc: Jakub Sitnicki cc: "David S. Miller" cc: Eric Dumazet cc: David Ahern cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: netdev@vger.kernel.org cc: bpf@vger.kernel.org --- net/ipv4/tcp_bpf.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/net/ipv4/tcp_bpf.c b/net/ipv4/tcp_bpf.c index 2e9547467edb..0291d15acd19 100644 --- a/net/ipv4/tcp_bpf.c +++ b/net/ipv4/tcp_bpf.c @@ -72,11 +72,13 @@ static int tcp_bpf_push(struct sock *sk, struct sk_msg *msg, u32 apply_bytes, { bool apply = apply_bytes; struct scatterlist *sge; + struct msghdr msghdr = { .msg_flags = flags | MSG_SPLICE_PAGES, }; struct page *page; int size, ret = 0; u32 off; while (1) { + struct bio_vec bvec; bool has_tx_ulp; sge = sk_msg_elem(msg, msg->sg.start); @@ -88,16 +90,18 @@ static int tcp_bpf_push(struct sock *sk, struct sk_msg *msg, u32 apply_bytes, tcp_rate_check_app_limited(sk); retry: has_tx_ulp = tls_sw_has_ctx_tx(sk); - if (has_tx_ulp) { - flags |= MSG_SENDPAGE_NOPOLICY; - ret = kernel_sendpage_locked(sk, - page, off, size, flags); - } else { - ret = do_tcp_sendpages(sk, page, off, size, flags); - } + if (has_tx_ulp) + msghdr.msg_flags |= MSG_SENDPAGE_NOPOLICY; + if (flags & MSG_SENDPAGE_NOTLAST) + msghdr.msg_flags |= MSG_MORE; + + bvec_set_page(&bvec, page, size, off); + iov_iter_bvec(&msghdr.msg_iter, ITER_SOURCE, &bvec, 1, size); + ret = tcp_sendmsg_locked(sk, &msghdr, size); if (ret <= 0) return ret; + if (apply) apply_bytes -= ret; msg->sg.size -= ret; @@ -404,7 +408,7 @@ static int tcp_bpf_sendmsg(struct sock *sk, struct msghdr *msg, size_t size) long timeo; int flags; - /* Don't let internal do_tcp_sendpages() flags through */ + /* Don't let internal sendpage flags through */ flags = (msg->msg_flags & ~MSG_SENDPAGE_DECRYPTED); flags |= MSG_NO_SHARED_FRAGS;