Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5732728rwl; Tue, 11 Apr 2023 09:13:12 -0700 (PDT) X-Google-Smtp-Source: AKy350bDk3/x+eRPDjUavgqGhLMcyJ8oNUq/8xxtlgAKyxP2CZPnvYwKBpOc1XYL0y4/0NYioAag X-Received: by 2002:a17:903:2ce:b0:1a1:9666:7a30 with SMTP id s14-20020a17090302ce00b001a196667a30mr19160747plk.54.1681229592072; Tue, 11 Apr 2023 09:13:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681229592; cv=none; d=google.com; s=arc-20160816; b=zqS/VPGsq4P4bjhnWi3CoB3mjYz6kDM+FbUuVPSQjRHKLLdoV1pxqYVkxoYdHX1ecA aQhCJ+WDv7equY02gm5Xm8wjkhb/dP7HZKPPGegvy/sw50v14tkBxsCR9cbmRsDk81MZ rDjYaOtoYWc1+WLG9lPoNqPWvjGw12BM/UpskIRtU94xkuuvuUzfBLQRfhVnREVXjLjT E9xHVmXjQ9H9H6T8mhi+Jrp2aefJOrB2bLV3amblcKgH3NALveRn2bw8gQn/730q2IM3 9lTOdV/lgD4PXY+sBm7O9sJ8wBdCNDOKgzAQ5onhmxIyvY9zWLdhehg43J1Bwk1HrsW2 cNtA== 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=rjJlYTxOmtT7wdKdf7S5Ju9QN7AtCPTA0VxjqyvYpeA=; b=pg53BVBga9juITvfAdTTFmmAL2wJFgQhwPXv3IMNNV9f7dlAVFHRSI3NM+Nk3EgsoX vUzB/QGckQxVXvZP64ZL2TSkUNwB+46TXj8sHMowDowWh2W58udbCrt2vL3jjwwqo2UO qiv+Iyrv+D+vWT7nOqPLV2DZDiKXFKOF2TlszzuUfns4FKsvGVE7aXzd1KL2VExmqCA2 UFYH31GuKbL648Ez+0kRDSNktCDvDWVqikrSmoZDB5AS9auvQeg+BnKVc/JO1EOji1tc 9rTHNPF7Cc1cP4fIGAQgTN/1aoZBnaetGDsomTGGFUIKcNkq5w1gqzJuJljGmW/xolvt niSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="F7I7K/Ph"; 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 b12-20020a170902d50c00b001a5d5b97c74si7693531plg.259.2023.04.11.09.12.54; Tue, 11 Apr 2023 09:13:12 -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="F7I7K/Ph"; 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 S231218AbjDKQLh (ORCPT + 99 others); Tue, 11 Apr 2023 12:11:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230212AbjDKQLJ (ORCPT ); Tue, 11 Apr 2023 12:11:09 -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 403B54EDA for ; Tue, 11 Apr 2023 09:09:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681229382; 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=rjJlYTxOmtT7wdKdf7S5Ju9QN7AtCPTA0VxjqyvYpeA=; b=F7I7K/PhBye+yTjJhV8A7UC83T7LrJKnBBSg/eJIwkw8GwP0DYiWxunOTP1zmqov/Vh0JH LQfT3qOQtkS0JbNI0Vpg/8W9NsbVd8B4EbEQQENuEizCbQWuUH9lzGH4slAFqGawChxcyY MHm74AL1mY1Y7Zy1TLRicDj5C7ZEXH0= 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-548-cmT0nmxaN_-wKHRfTU4xrw-1; Tue, 11 Apr 2023 12:09:39 -0400 X-MC-Unique: cmT0nmxaN_-wKHRfTU4xrw-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id ABF7538149AF; Tue, 11 Apr 2023 16:09:37 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 47A44C15BBA; Tue, 11 Apr 2023 16:09:35 +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 v6 09/18] tcp_bpf: Inline do_tcp_sendpages as it's now a wrapper around tcp_sendmsg Date: Tue, 11 Apr 2023 17:08:53 +0100 Message-Id: <20230411160902.4134381-10-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.8 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 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 ebf917511937..24bfb885777e 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;