Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp981691rwd; Thu, 18 May 2023 06:34:09 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5ZW81sFefhGUd4s6kYgomCQRmPmFnBywt5YVrGOczDzl/9tg7MlqDUWv/J06IcgyTNm9P+ X-Received: by 2002:a05:6a20:6f03:b0:100:7ac0:b32d with SMTP id gt3-20020a056a206f0300b001007ac0b32dmr1778046pzb.44.1684416849524; Thu, 18 May 2023 06:34:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684416849; cv=none; d=google.com; s=arc-20160816; b=c9J5JR52miokI7LSGDRG34dRXk8FBoP2v1Yd1VlXp+/kEtzaW/VqqGxywmh68oYH4+ m9LB/OMHgEgUmuoaf/hyXO+ryeqEsF57dlw+fxBXowPufq7Z3aZlAj4havgdquSGtIwH WIKQZWmY0k4dz03SNS5rUEwX0+T/9xjsl3jTUq4MDHseNhpZIQaZm7dT36kxZb+uEkSA +XUvIi53CqQMgDcwCYjn3yTZOlY34HYSXIYh3Lz7fW7Q7bAaCGUCNHXGH3J4hxxVdcr8 RrcUxb6wZ5r91YQkx/N143u9l1SSHYsfhVx0jL21OrlZhctQG769qHdmey+kgKaGnguX rxYw== 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=s0HLYuUB2jLzLV5RsMAvU4xOq5QsowkLC8sg0290GoDxuJ2hPW1YuelOPfdSSMt31z Y5EeGqxxcJ/4WxoavJrWGd0rXFTjVJDCL+jbNpE7/u/c4i9p2dsSGP/AWz9i4utTLQ2R N6ZLk0LwlhWuJKSeMIOGpdlfD8o9BJJ23dQF23ki/mXWKUQeFfYmFPVpJxcjZfcDlt7t gYaas4kjng+0vFCi3ebNvPSjN5Co36tZ+k8yJ/dS3UZijqZn7IWkqF19+dmwWkKU5mpM X7PVIDH/q0HwHWMY3hj7UE/AOvgWsOGzioZE2sVmsDRz9v5VtcyvKNxQvl18pNK/tVSM qUWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EkC7VsvO; 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 iz20-20020a170902ef9400b001ab2337ecf5si1199912plb.467.2023.05.18.06.33.28; Thu, 18 May 2023 06:34:09 -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=EkC7VsvO; 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 S231159AbjERNJI (ORCPT + 99 others); Thu, 18 May 2023 09:09:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41278 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230268AbjERNI5 (ORCPT ); Thu, 18 May 2023 09:08:57 -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 231D41733 for ; Thu, 18 May 2023 06:07:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684415278; 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=EkC7VsvOGxY/5VzhnL5xHTuZWV1Yjk5RIv5FqtbIFQtBncdSf41MgsMBNaIGyCZf842Rbf Gd0chgxEBOQhXDC3e9WjL1gKVYQgs6GUqUCzXAZf0vvgGKHUfrb2QLRjZnrNGSKEVEXOtA KqqMkRBZL1spgHaE3QwUTe4ZQe01Ja8= 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-209-s4xticGiMR-62gp7XbuBGA-1; Thu, 18 May 2023 09:07:52 -0400 X-MC-Unique: s4xticGiMR-62gp7XbuBGA-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 38B6985C07A; Thu, 18 May 2023 13:07:48 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 155802026D25; Thu, 18 May 2023 13:07:43 +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 v9 06/16] tcp_bpf: Inline do_tcp_sendpages as it's now a wrapper around tcp_sendmsg Date: Thu, 18 May 2023 14:07:03 +0100 Message-Id: <20230518130713.1515729-7-dhowells@redhat.com> In-Reply-To: <20230518130713.1515729-1-dhowells@redhat.com> References: <20230518130713.1515729-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=-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, 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;