From patchwork Wed Apr 5 16:53:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13202261 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 2FB96C76188 for ; Wed, 5 Apr 2023 16:54:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B681E6B0081; Wed, 5 Apr 2023 12:54:18 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B3E126B0080; Wed, 5 Apr 2023 12:54:18 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 91C266B0082; Wed, 5 Apr 2023 12:54:18 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 7E0C26B0080 for ; Wed, 5 Apr 2023 12:54:18 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 4FB3580316 for ; Wed, 5 Apr 2023 16:54:18 +0000 (UTC) X-FDA: 80647935396.15.B69EE38 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf27.hostedemail.com (Postfix) with ESMTP id 78DEF4000B for ; Wed, 5 Apr 2023 16:54:16 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=DvWA3Yf6; spf=pass (imf27.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=1680713656; 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=LU+EuI1w95foBpvL+MnfTRdJBoeqcZi7esoiDYFHUqg=; b=YtGv3LpM+mMcVaj+P25FFjuc2i/GhNVCmEfApyUQd7wCY4wQ2E81IqcSZtmPnjsd1oE2Jh H+aYuGurcBtGns8PdAkwqKsFIFfoayaK8oHAFM+haOPRgZtLzcH2+dw5QuEePBorIQMQxs fEUhZyYE9tGv1lnIlC5xs7vXtkPvXfg= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=DvWA3Yf6; spf=pass (imf27.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=1680713656; a=rsa-sha256; cv=none; b=GjNGEuf4KJ1xV88nDXofTomsPjzdHIqsnyXAlqXJ2hyuEnBgac8HwqNaTy/rCxKRezWse4 Y75dyYrfD5JsGf+3IIIpgLYUQtz2eChAOsGmTwIGMHXj2Vm/fWW8gmJ5BfczkBocHOMeEN dHJL2YnG17D+R2YOjjUe4mMqzEoQ93s= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680713655; 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=LU+EuI1w95foBpvL+MnfTRdJBoeqcZi7esoiDYFHUqg=; b=DvWA3Yf63Yp2qydqmp4Pru2vSRHQYI0G7TN2VfepNyldnuQOTzzp2jYLi6sXEsBbgztLV1 gimaEqQACGwVQzKeh3pWw2GPTdFMYChMx+Tior+8fTTTulBmx+SdAxXDhu4mwcd77PCkmW whFpP5GcS5U8FFjlt3pb1jh3qxI46Fg= 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-256-Ory9MB64PridaGhduckyKQ-1; Wed, 05 Apr 2023 12:54:12 -0400 X-MC-Unique: Ory9MB64PridaGhduckyKQ-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 95935885620; Wed, 5 Apr 2023 16:54:11 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4A2CDC1602A; Wed, 5 Apr 2023 16:54:09 +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 , 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 v4 09/20] tcp_bpf: Inline do_tcp_sendpages as it's now a wrapper around tcp_sendmsg Date: Wed, 5 Apr 2023 17:53:28 +0100 Message-Id: <20230405165339.3468808-10-dhowells@redhat.com> In-Reply-To: <20230405165339.3468808-1-dhowells@redhat.com> References: <20230405165339.3468808-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Rspamd-Queue-Id: 78DEF4000B X-Stat-Signature: mah9ypciw7ksxako6q3mj875y4rdnncw X-Rspam-User: X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5oeXwJ1TYksUkqxjxoRmA05PKjckvlPgufdXHJyfBKX5BowSbRW+O1reZFEYKnDJ9KN/ohzSiMVRpJUUSSo+LMhwS0kaZ34wlD1ePdV+HpMOHL7RMTfbT/8jI6QtDIhSXDAnMdFKSSHXadc+/3uTvaIwoml7iJrI6q0SbwSfDT/8SzA3X6StPUebHBoYcx1GoZEKmBwOSFk/OudPPKv61pSRmSgfKwD/ug+6XEMS2paa/vI5MWjp7Foiya7xEZe688aMghKvNxwyqgHxLxXwxCPTFMW0pT/M2zFdtBLo2eWZZ/Ul+a8mwy8/Pg+GS3162hqxiLJ52Yw9wl+YwPyVP6HLnoEW1N+J/hUB1KxhvxzZ6nadcsTi/ovTFabMQUBpOnTmmfVpyJMH2zvzEcH4UQNUBVwQj7GnYnWvFVf7V+bQfePZurIbOV0aNPax9g4jKxE8LTUICUTHtQTDyl4vbfCP35voRkRDOcXKS25qg/6qK9zhXlL9EQs3sT8FfJ/TMjjm8GYC1lw== 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 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;