From patchwork Thu May 18 13:07:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13246764 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 3A81FC77B7A for ; Thu, 18 May 2023 13:09:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CB5DE900010; Thu, 18 May 2023 09:09:37 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id C199D900003; Thu, 18 May 2023 09:09:37 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AB8EA900010; Thu, 18 May 2023 09:09:37 -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 94906900003 for ; Thu, 18 May 2023 09:09:37 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 658CF40848 for ; Thu, 18 May 2023 13:09:37 +0000 (UTC) X-FDA: 80803407594.22.D368405 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf23.hostedemail.com (Postfix) with ESMTP id 371EE14018E for ; Thu, 18 May 2023 13:07:58 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=EkC7VsvO; spf=pass (imf23.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=1684415279; 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=ouJcqTk/sxBVLvtkvRj9aJ/qE1dB3wHYtJeurIuARHOU35FmrIPz8BTyw5jzy/ndrkCaba 4b7ZqLorLLcjdXgiCayacTFbUgC6tcfR/hmuZxK5S7JHYoDbT/+P0ZYzvdcOk1qy+6GsO6 SkNzsPlde3jB2bv3LwaVhNimy70rZ4g= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684415279; a=rsa-sha256; cv=none; b=H3gDIE7e4+XUT1Eldv6xPoLkAWaRBrv7Ad7EicDswiIpDIL8F8LFlgEtjzMfq37w+57d/O fezVeZbgeCTAsB0pRWbATfGNuKnaQP4yU2aiH3C6vSEUvrDfURuQHFoEibf3GUqD96AUSO bjeW6tXYFoYoyK9nSwQC0a5vqVrVHt4= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=EkC7VsvO; spf=pass (imf23.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=1684415278; 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=EkC7VsvOGxY/5VzhnL5xHTuZWV1Yjk5RIv5FqtbIFQtBncdSf41MgsMBNaIGyCZf842Rbf Gd0chgxEBOQhXDC3e9WjL1gKVYQgs6GUqUCzXAZf0vvgGKHUfrb2QLRjZnrNGSKEVEXOtA KqqMkRBZL1spgHaE3QwUTe4ZQe01Ja8= 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-209-s4xticGiMR-62gp7XbuBGA-1; Thu, 18 May 2023 09:07:52 -0400 X-MC-Unique: s4xticGiMR-62gp7XbuBGA-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 38B6985C07A; Thu, 18 May 2023 13:07:48 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 155802026D25; Thu, 18 May 2023 13:07:43 +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 v9 06/16] tcp_bpf: Inline do_tcp_sendpages as it's now a wrapper around tcp_sendmsg Date: Thu, 18 May 2023 14:07:03 +0100 Message-Id: <20230518130713.1515729-7-dhowells@redhat.com> In-Reply-To: <20230518130713.1515729-1-dhowells@redhat.com> References: <20230518130713.1515729-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Stat-Signature: re7rij8ojs3pre5ezdxufjciaxot167m X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 371EE14018E X-Rspam-User: X-HE-Tag: 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86/WTpkZcvVg/NhPmZvm9MtHNseP28A4Fv0lVokrYi9IauT33mU/zEOKavM+9Yu1IbBBc+KVrB6XoyAU0VJRvPwguOTdZ5NQ7T7L0wEdfmE0rlBusLfi55Vpydtxv+5zqUNjGkzl4/xO5bkmCdyZX/jexBhsl4W4osyMXdwovPlx8fme3e6HvHqXIni/gG6r6EES9OeXNv040XGZjghDWGrTd03qxE3Ka1aFUH1SpRQqSbZvXvo0kJYkjCsyl2FAfXFyy3qxL164zyTvhbru+iNcICJTAty8MwgPWjnhJx7agaq+fBRf173QCUeXnL5clhCiARX8w/3GOQkWmkyoTSWnNWeWcRIji47RSky40IqJWHJEursi0SuQxQkBPkrHFhpo1wOydRVZ6tvZ2m2PenK66RfsYM67NKIyyatFZWTvSnTk5SVZKxeouEAcdojzKQCkVbfrfV7KoJgCY4de2TgQe6/Un/NgtbDRnTH/As7 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;