From patchwork Fri Mar 31 16:08:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13196171 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 11976C761A6 for ; Fri, 31 Mar 2023 16:09:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A837D6B0082; Fri, 31 Mar 2023 12:09:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A33FD6B0083; Fri, 31 Mar 2023 12:09:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8FBB56B0085; Fri, 31 Mar 2023 12:09:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 7DB196B0082 for ; Fri, 31 Mar 2023 12:09:58 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 3398D411A6 for ; Fri, 31 Mar 2023 16:09:58 +0000 (UTC) X-FDA: 80629679676.05.08D08F1 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf06.hostedemail.com (Postfix) with ESMTP id 2F3C2180008 for ; Fri, 31 Mar 2023 16:09:55 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=II2y+WEu; spf=pass (imf06.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1680278996; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=V4A9+ThbnxeOTamldoFRxBPwB7/WQbFmJXJUgDasL0c=; b=3vBhfePFmWWwXZCEZFAvn7MEpFz9in3dQUYrtNXGnEfeBBO/kUDJR6hh1XaObvgXMi0Kyo eR6uxZqq++F540iIRhw9+rjX8kKBWrtGaXAhweJSA/spyVyMBOhHuMPhryyZW7Dg0whudQ z6hIfkaPvqpgv8azyJ1NpRLJFolPOsI= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=II2y+WEu; spf=pass (imf06.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680278996; a=rsa-sha256; cv=none; b=CRuAet671UjzTNJzW5Q68ra+AlHQ3l4X6cgj4e6xWzgGqV5o/upB3R7cMWYhAW07+LWqci H9oYcjPfQNhdcKhMutwnuoLPEae+Kd39YKRvWiFiQpy/4MFYXd/WOM1tY96Y1UNN8yrA5u xm8fhsL5yDAHUYvaUfwn5RoOKa8O9fE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680278995; 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=V4A9+ThbnxeOTamldoFRxBPwB7/WQbFmJXJUgDasL0c=; b=II2y+WEuRpmyNF09XU0RvehiVZB4qlJYjAIux3AixgyEV4COdtMQ8gnLSp85dTgF+iQz6w tmGA+/b5gLVfl3cobtlaCMY2KEOSVI8GBqd3r8fG34vafdCXwlf9Kot0haOLzJ45jJuJs+ BPcAFCLs7VxII4oStIHQcMuYvNeCAic= 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-316-ldaH4sxnN8OIiGvOqC_Jew-1; Fri, 31 Mar 2023 12:09:51 -0400 X-MC-Unique: ldaH4sxnN8OIiGvOqC_Jew-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1C5C6101A550; Fri, 31 Mar 2023 16:09:50 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id DFCB151FF; Fri, 31 Mar 2023 16:09:47 +0000 (UTC) From: David Howells To: Matthew Wilcox , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Cc: David Howells , Al Viro , Christoph Hellwig , Jens Axboe , Jeff Layton , Christian Brauner , Chuck Lever III , Linus Torvalds , netdev@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, John Fastabend , Jakub Sitnicki , bpf@vger.kernel.org Subject: [PATCH v3 10/55] tcp_bpf: Inline do_tcp_sendpages as it's now a wrapper around tcp_sendmsg Date: Fri, 31 Mar 2023 17:08:29 +0100 Message-Id: <20230331160914.1608208-11-dhowells@redhat.com> In-Reply-To: <20230331160914.1608208-1-dhowells@redhat.com> References: <20230331160914.1608208-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Rspamd-Queue-Id: 2F3C2180008 X-Stat-Signature: 7wcrqiiagwy3cs7agb4cw5r6uosqunjg X-Rspam-User: X-Rspamd-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iJ5/USBTOr6M5bfa9JG9qryIE6FtJWV0w1V5wXyh85hhPueEgYGJTwd02AO4oTVkTFM6TzdK3KtVXVXRPJG3FwLyisfcO/8xmUSXOP71PdlJPF6tc4s84F+/uKu4m3ujDySRqdchOIZahXGWlUTe7IfKsa+Wr3+QU9ef1YX/VIRLhSSyoXJpKZs743E5Uy2/iNhAi7XgnaK31qmbWZ45aDthhMam2K/8Ypc1h1lFCk5SqDepXZbdc8ILgaRFGmDSyguAbaBAfA3Vmlw9f1Q4tM61fRuV9z2YD+n1sjsxkx/7Cum54O3TXfR22hYlM+E48Svkahb6wKwn+aOAD7N+XMjKOVVLLkSPe6qJV1Ozb8lLrSFdUz8qVHuQvVHNxn9HID4Awj6xiUA9FaJUfmfqdjBMwOXFQ/gPbLVydQdKeN3kHXQBbqG0YrVCfCRDQUkt7QtTKLKdZ4lk4cnjqcWrxCu3hJTsGvP0lKymdl6q00+AxcgMwLG2hJa5TXdBCDCGCg6vd6Pg== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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: 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 cf26d65ca389..7f17134637eb 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; @@ -398,7 +402,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;