From patchwork Thu Mar 16 15:25:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13177804 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 645DBC6FD19 for ; Thu, 16 Mar 2023 15:26:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 01741900002; Thu, 16 Mar 2023 11:26:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id F3248940007; Thu, 16 Mar 2023 11:26:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id DAC70900007; Thu, 16 Mar 2023 11:26:43 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id C574B900002 for ; Thu, 16 Mar 2023 11:26:43 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 8900E4044E for ; Thu, 16 Mar 2023 15:26:43 +0000 (UTC) X-FDA: 80575138686.16.7F9C09C Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf17.hostedemail.com (Postfix) with ESMTP id D1B5640008 for ; Thu, 16 Mar 2023 15:26:41 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Nf3aoiNh; spf=pass (imf17.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=1678980401; 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=BzKLWGCXQtXNifDkEBjMJKTqvygvxDfZtzwfOTzlK8p65znnmPSOjw1CesXcNJkT8ETrSa RH6yhfoIKMS5DCY7s9Fo9xP/iIBOtFnWiw+npG7TslgEfzYumpcPTwdQwW5S2/AfDrV1U5 f9J5CfgEcj8HOC9zTzFaT+O+iNqDyUU= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Nf3aoiNh; spf=pass (imf17.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=1678980401; a=rsa-sha256; cv=none; b=lxiIFOG1vysGLmh7sMpMTXCtanpLz0o1c4mVfCl5Ix4sWqOMjVzyIeIXKBlwX+ZVtYxNCK rg2PN6jC09FuaLGiCrLJlA+/qRqcvHbfDd4+Y3bbayJPz2lViCRptwBEmcWbkdZQeMlqXy VPRZur1hEA6a4qxUmIV6WoZh7Gj8jMk= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678980400; 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=Nf3aoiNhicefF8RGLcDts9UYB7b6F/T0NFzyTq6NRIWTKZTBx7EyePt+JOkf/0dI7C/Ywg yV6S+Bm51lYWCoBEY37oMPS1izbWlkt0SdfatF5XrDz0rarOcn8xAagIQMXB6Cp7+GyRdM BkuHJNDPt+OW23wJjaiSRGiiDvIAvPE= 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-592-b1SC9PDcPYSYvZwVDt6M2w-1; Thu, 16 Mar 2023 11:26:37 -0400 X-MC-Unique: b1SC9PDcPYSYvZwVDt6M2w-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 31C5638149B9; Thu, 16 Mar 2023 15:26:36 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1CF1E1121315; Thu, 16 Mar 2023 15:26:34 +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 , 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: [RFC PATCH 05/28] tcp_bpf: Inline do_tcp_sendpages as it's now a wrapper around tcp_sendmsg Date: Thu, 16 Mar 2023 15:25:55 +0000 Message-Id: <20230316152618.711970-6-dhowells@redhat.com> In-Reply-To: <20230316152618.711970-1-dhowells@redhat.com> References: <20230316152618.711970-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Rspam-User: X-Rspamd-Server: rspam03 X-Stat-Signature: dewn7rydqdkkwwa78zcypc57bfcihhgg X-Rspamd-Queue-Id: D1B5640008 X-HE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Nakeq6L5Osq9LEoF3BETST8FiKdg0rd9zx0S1hCfJbIi1IyOqF/XEJ8d4Ccn9n8fjgbOKwBh65qvD1uVgWV8dPjAq0fhP+27ZdrdS9yi38rSYCoIzEgFJqAO9NbyCD2FEr0nIbYEcQ1joz9Ktaho7wB/1P0ZisKllHh7bx968RZK1xull9M0LnrFpQ1BWlPE7dUXuIJKKXGrMeDjpDBkq6AhfuCBl2wzPHm7IYGDRw65tPwktTiDDOHf0w//skWm6/ZEY3JDbHYGV606x76wmMsNdO7BvUGErb5V0e0o053a8zIU4MTwTZtHbKgx4IevKW7TrWFlC0mxh8L+sS+ArtLe9BRb/gO0hfOxcrM22OAP//9rRZrAvnb5cRv8n+bQmP5ND4nMjxFdR93uupO32YC4WiFRM4KTqRikRKiAdt4oPMBE980TZpjcn20f5ieScWmpYSYOpFMroFbZqiMTxxn+GYQmtMUFbsnKw== 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;