From patchwork Thu Apr 6 09:42:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13203055 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 1D58FC77B6C for ; Thu, 6 Apr 2023 09:43:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B37FE6B0085; Thu, 6 Apr 2023 05:43:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B0E196B0087; Thu, 6 Apr 2023 05:43:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9AEC56B0088; Thu, 6 Apr 2023 05:43:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 8C8436B0085 for ; Thu, 6 Apr 2023 05:43:25 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 666B6A0EBA for ; Thu, 6 Apr 2023 09:43:25 +0000 (UTC) X-FDA: 80650478370.04.74146F6 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf14.hostedemail.com (Postfix) with ESMTP id 95D10100002 for ; Thu, 6 Apr 2023 09:43:23 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AFGlLihX; spf=pass (imf14.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.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=1680774203; 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=rjJlYTxOmtT7wdKdf7S5Ju9QN7AtCPTA0VxjqyvYpeA=; b=LcNxKdocrBtDx2UAaMmNIeKjKf0T2Oa7I8HVLtUdNt0MqqQlofLos/3f8vtIhv7qThgVD0 MqE3wkE30Zraj5x4d0Z666oDSTKLOuEDfTbQ3arzDw022mbOWmBBo5FxoiBUhLvDUq4Xer jl6XqfZMYRSdMNehNPERaw38jkyXOrA= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AFGlLihX; spf=pass (imf14.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.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=1680774203; a=rsa-sha256; cv=none; b=uJtf92AeGFJ8TZPmJLva0sl3mwH2Cfcf7Rw51qm7UQo5iMk6VOx0np7UNTdqZqBWUk8m8Y 4Vr42SAx4hFJQDmpipBCTeuStxfMAGBCkd378E/tvH9gzBu+NMF2vcuM8tNOwFoHjRmJO9 YdwAnpDm3YIDA2HXPnOQS7krg1M5ItY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680774202; 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=AFGlLihX6O6GlDdSb+De7CjBMf9pvdmQZMzSiO1X4SGuZZTdUmXm/VoewXURCI6HLOR9/g 0+snB++L0ew+Xbw1d+KevFsbngYSPxMfjLCs0eKlcMP3cuEF5ZxKMhkDryUjiCN3hEDHaR EEusINXflIBBpyY34jVWbFjslZx2cfE= 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-3-tBtsn0JjNXKzzGvLcjsJcg-1; Thu, 06 Apr 2023 05:43:17 -0400 X-MC-Unique: tBtsn0JjNXKzzGvLcjsJcg-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 9072B2800486; Thu, 6 Apr 2023 09:43:16 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 33CEEC12901; Thu, 6 Apr 2023 09:43:14 +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 , David Ahern , bpf@vger.kernel.org Subject: [PATCH net-next v5 08/19] tcp_bpf: Inline do_tcp_sendpages as it's now a wrapper around tcp_sendmsg Date: Thu, 6 Apr 2023 10:42:34 +0100 Message-Id: <20230406094245.3633290-9-dhowells@redhat.com> In-Reply-To: <20230406094245.3633290-1-dhowells@redhat.com> References: <20230406094245.3633290-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 95D10100002 X-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q5+05Za1N1w1Ir3hPcCBRIsO/wxpIoAaSVqBhAfYPx63u0A7lleOcpPahcvcPvJ4TK1nQzavfpe3sjAYJW2oyu0+K2I5ywE26wpI5RRzPHDTaohT7eGkIf25PEB4lCJnrjPB/QPB1os0aRnoAG/ta1hCYbHGI/4dUDn3y5H1qGf+bToQ0vzdbNxMcCVdQbjuDRYiUX/zVvr/iLf7FaNDacqsX7m+LUsafDns4kXfLjo86t9+Ktw5SvNDuAuP9POjaEQCWJP/u2MrrrAwP6yAsbwFGxliMgNkhZu4y3+e4IS/EJjXr5+MD6y92Bnmz2z9D1I60eYi5ujRmkjVxvoQR1il9bUsAi15HlqBEXjU8qds2lxnXWAo5ED8DbMyJ8mczV8C3d7aOyM/QsDayHuLifnLGWJuUwQDLqrxpc4/ih0ybPTN4wSNGlBfI/A4mOwr+OzAAh4EwMgIeIeZ2Gf9H+2f+xp3TiFDWXA/gGUvyieKLDRbkrzPHEE6GO9o9ocTK8aVNrvGECPLtteHcc6w08Hbw== 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: 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;