From patchwork Wed Mar 29 14:13:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13192520 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 46810C6FD18 for ; Wed, 29 Mar 2023 14:14:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 216296B0085; Wed, 29 Mar 2023 10:14:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1C6C66B0087; Wed, 29 Mar 2023 10:14:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 090186B0088; Wed, 29 Mar 2023 10:14:37 -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 E14996B0085 for ; Wed, 29 Mar 2023 10:14:36 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id B8075AC262 for ; Wed, 29 Mar 2023 14:14:36 +0000 (UTC) X-FDA: 80622131352.29.4D402E2 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf19.hostedemail.com (Postfix) with ESMTP id 0B1EF1A0029 for ; Wed, 29 Mar 2023 14:14:34 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=O3xNpvbS; spf=pass (imf19.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=1680099275; 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=IPPCq0ZNbfka5IkWtM4RvnmTVXGKvKX41N3In/k9mAn5rTxtkS/Sq4b1h26rBLjuU4WFed aMM8ygVy+guFEjyDQWWZvymBV/KAHUyO+LFgS81E2wMxB2xBbqomSz8wFaVzLm5wGqQu1a q1GNDv5z8gBnSpyx8BP4PrIBa6Yo4Xc= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=O3xNpvbS; spf=pass (imf19.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=1680099275; a=rsa-sha256; cv=none; b=BFeUyvQBHYI3dt1PanDf6kcSftfv3zQNJtMXw1riM7XRl/BAuDnsu1ac15wVq5P61wUWC/ v894NNMraXX2N5q+lSNUXuNWVT7YbJVoVOmEBio13L102FJZEtGW65TBA9jWx+U7hGhpH1 s0eDiaYfU+T7Ets8SaX5a3RThDSTWRw= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680099274; 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=O3xNpvbSt9lAcVr5qTCr/dsNw8z6LGMAVe9SkWoEGnQDh0tYTFxEPdy8e3S8eWUfxnMndE 0wKx8Co/0o5PWOhdSKWJEaHkEeWjBTW22lr2nngf2AiucmyUqGQDvtGV4qLesWOXvpBlpG dxm/tjpo3iiets6oh6NEeLMZ6drBWgw= 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-16-Xdfj3glLMsiVuDad3Y8AFA-1; Wed, 29 Mar 2023 10:14:32 -0400 X-MC-Unique: Xdfj3glLMsiVuDad3Y8AFA-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4CBFB3C0E451; Wed, 29 Mar 2023 14:14:30 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 243C9492B03; Wed, 29 Mar 2023 14:14:28 +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: [RFC PATCH v2 11/48] tcp_bpf: Inline do_tcp_sendpages as it's now a wrapper around tcp_sendmsg Date: Wed, 29 Mar 2023 15:13:17 +0100 Message-Id: <20230329141354.516864-12-dhowells@redhat.com> In-Reply-To: <20230329141354.516864-1-dhowells@redhat.com> References: <20230329141354.516864-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 0B1EF1A0029 X-Stat-Signature: 1suukhxbfgicins9bj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ohBFNLMWlWv0HBz1BMGNRX0JMhDnr0HLEVgA8fvspRCEFMSZcbPQQYtQDvY6RFJisrVRnAHzvYyH64jcS1a0g9KbQV0COVtnf6/pUl9csAc7/wgs9D8yWAcC6XfN/V9insl0HQz5isU8+lWZl0adCKSvsMZZgesWL+VlHfXBzpQwZVOfgZ0zznUeql8qbpW01A4s9P4EXWgaZVguH314qNvJKBOYnp+jLyvw6sPM4VIYiYsRcLVFzYthpTYCq7gzVBrINV4mjkaI4xtzC+HBPHnQ53PRdxFEixLnJW6OOLtmmU1EPdPbBWOi6kQQX/HKfbMYVBxOhyQ75bL6TMC2Pww8hYdhXoPpJFTWH5Esm1SuiGatMBXPjovDiS5+hNA77iuCXRuUjWd0tshU+O9R7GFjCVbiKsZBzNwVD9m5WbQE+3oV3C+essPN6hZyLS+a3OC5QXwmgedTEJ2/Oo+u0x/bSyp0rpaP0QmXzku7AX7fWZV3YHYKfC/Mw8MFbeUHF0gcn3Oa6Xn/kOUhCQ== 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;