From patchwork Mon May 15 09:33:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13241057 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 42CA2C7EE22 for ; Mon, 15 May 2023 09:34:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CEB49900009; Mon, 15 May 2023 05:34:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C9BB2900002; Mon, 15 May 2023 05:34:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B1510900009; Mon, 15 May 2023 05:34:20 -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 9A77A900002 for ; Mon, 15 May 2023 05:34:20 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 6ABEF16139F for ; Mon, 15 May 2023 09:34:20 +0000 (UTC) X-FDA: 80791978680.08.25EE34A 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 A6ED4100009 for ; Mon, 15 May 2023 09:34:18 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ZUvheB0h; 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=1684143258; 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=2EXLlBUI8HMrlq1LdzuePmnE9vo0jChMg019VHUJEgs=; b=TLukAbXMZ9dNxMuDgmXiCENpOnXWL2IDGRzj88E/rCyMTMZTmV3NmoJzQPMCSHjREvm+L+ 6qcXhRYMMg+p9qeIWMUBwK2zgahAa3UUr9vLw6+8j9JMAINzLPrXXFEFKwOvYT6tDgq+ME 3SwRCHJOJcpYqQ0TjkEt3UrlYRZm+Pw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684143258; a=rsa-sha256; cv=none; b=jiu98ch4oj/b+usDF58qUh2fjb735lGaNafJXF4y2a7oF15QLFimlnSshOVEIYQ+v1odnX Em2dp7L4yRx2Go0KtKdUmzSKcbBwHc2Nwq3wAb6ODbvV1hPytSd2CtB3lKlym3qOV4hVQY S62hw4kmNd/tf52+3FiSfy3sfQTeXSo= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=ZUvheB0h; 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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684143258; 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=2EXLlBUI8HMrlq1LdzuePmnE9vo0jChMg019VHUJEgs=; b=ZUvheB0hn5C4B/pbO7XCsqaNupZ5eLA69FS2Y8QaR7gzmcPKsOUe30eP53P8C8IzB+Bh1A HC4R+DjEBwIDFhJ9xYM2XGmS6+ioBBVnFPe2oxORIh1+BkdoGNrZwz6VZ+6MzXtg8e76bW q4EIy4RAPOU7UnO4fzL2bJ02xp/4+3o= 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-515-ekVa9ADbMTarb4EWYMOq1Q-1; Mon, 15 May 2023 05:34:16 -0400 X-MC-Unique: ekVa9ADbMTarb4EWYMOq1Q-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BF541185A790; Mon, 15 May 2023 09:34:15 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9E68B2026D16; Mon, 15 May 2023 09:34:12 +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 , David Ahern , 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 v7 06/16] tcp_bpf: Inline do_tcp_sendpages as it's now a wrapper around tcp_sendmsg Date: Mon, 15 May 2023 10:33:35 +0100 Message-Id: <20230515093345.396978-7-dhowells@redhat.com> In-Reply-To: <20230515093345.396978-1-dhowells@redhat.com> References: <20230515093345.396978-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Stat-Signature: iir88d89o3qzpxfzp497xs5956jwy4c3 X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: A6ED4100009 X-Rsp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Ey236X1Ml9BZfEEapnCsOgO1zZuuBXUtYKNISUeKG1sfR6yPVoSByJM1FbrktjDePBJmk/lSRY/an3/uOn4CGuCdRLQWfOu2RirSHMjCceZKwIywpcmAsGdR1UUXwyEw4QJPHvR2lEuYngI3dcJgW71lGMRsO5ynT5ITfTXAfetmDalavKq6hlNoXxZEzHls2bHt65RUoL9n+iG94W4U9q87OVsAVwGs49Y71JIUkDnD3MsCQBg5ZT4jwOjjJ2IeiaUR8bQsMuVx/xMNms8mjs15geBan85DsmsuiNDl+jXJJqxx62lxUcyKWZE1OkOSdVWyiLonFt8H4bWDlSi5mSY8zKwOesPRe9CvS8OHXdMman329hMFOEEje6giHi9R9RizC7Rq+JPyqFHJSOBLApkMC7A/FkH7PJJVbdX9JYaUdzbKz1RwwKjpNDhPnyNap2RSOq+8/g6hGMm+paQzxkrrTju4PAy 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 2e9547467edb..0291d15acd19 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;