From patchwork Mon May 15 09:33:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13241088 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 AB192C77B75 for ; Mon, 15 May 2023 09:34:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 488EF90000B; Mon, 15 May 2023 05:34:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 45E39900002; Mon, 15 May 2023 05:34:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2FF5A90000B; Mon, 15 May 2023 05:34:35 -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 1CDEF900002 for ; Mon, 15 May 2023 05:34:35 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id E9A6BA13DF for ; Mon, 15 May 2023 09:34:34 +0000 (UTC) X-FDA: 80791979268.06.723DFC5 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf26.hostedemail.com (Postfix) with ESMTP id 4AAC1140006 for ; Mon, 15 May 2023 09:34:33 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JoV9Foex; spf=pass (imf26.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=1684143273; 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=JUrQ0rsOJEKe2VauAy4RSjWfQDMPveXienxXCaL8A+w=; b=peDVltt0T6YxdDzohhlTuV82evEnJxRzMMWq0qGEGxd9yaZM/na6zbCOS50tbvFu2ntvuY eTNc4nYtAs3FD8FZmNJzbWdD3SLv009hz0Cvekg5IRgMHGK8GxpOE3TD/lIooOeckdC5rb +v/nvHywLNxbYJUPA2pQvn7YnnL0aaw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684143273; a=rsa-sha256; cv=none; b=3pIgOxB5e6yXSZcR4Ari9+Beq6mFLskxNzF9EMCoAdBoWxW+mHfV3lft/S4Qz/cfP2tBwQ TS9G+DAaXd13dMY8/+BvmyVUMOpcXekiTm3ETzWHGZqLwUXGJHAbGKoW+2SfxsL/l4gypw YWkxdd4cxMDsD7IbUARAKyVq1E1FP64= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=JoV9Foex; spf=pass (imf26.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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1684143272; 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=JUrQ0rsOJEKe2VauAy4RSjWfQDMPveXienxXCaL8A+w=; b=JoV9FoexsZz6pUK7tuSYzHWj9E0T/iq0dZqEESvTWfA59SYNimuDwy3FqRY/qgk5T2y8V1 ZOFXFz78DR7RSRSSmseBrfNk3lAnwZywVsenr+M3yTzs7F9/Ynw7sl3DgpEvUzcyNIL678 X9AFwi9rcj3SW1OaQ4YWQ6IzOjt1mMU= 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-654-_VdNKKjjMc2ew_BgJPdgKA-1; Mon, 15 May 2023 05:34:25 -0400 X-MC-Unique: _VdNKKjjMc2ew_BgJPdgKA-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 781491C0950C; Mon, 15 May 2023 09:34:24 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id E5861C15BA0; Mon, 15 May 2023 09:34:20 +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, Boris Pismenny , John Fastabend Subject: [PATCH net-next v7 08/16] tls: Inline do_tcp_sendpages() Date: Mon, 15 May 2023 10:33:37 +0100 Message-Id: <20230515093345.396978-9-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.8 X-Stat-Signature: ycugqp9jz6hieddjxbs4j4ptti5czte6 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: 4AAC1140006 X-HE-Tag: 1684143273-264810 X-HE-Meta: U2FsdGVkX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PB6qx8J8fEOJZTtxb7tR25AfVQOxK4oL4M3pcrUGv3j5+dk1S/GRn4VRZIfHcyeaZSDsTAMGqAqRFjtls5vBofrn+MokopanwMKSElxuscjdfX0EpnWgHpCjJJUoi3x4CmsjEyskS/YJsMy4sNmZlO0NBBxOFwS39AggmGofyXropCBTtdJ02t6kMO6qfxN2OVmDfK9fY4mLcgEUzLQttqcIBDsUliF3B/ZUSrZqYQOW7Iy0QjKvzJHnAIs2t2MKJLWD5udl19EwsSNdiODkmqjbbyPzR41sJUnC7rKcm4iUNGlNe+fz32YkqIs3fPoIyuOfHIT44Oz/W7ViAuAaw2O5sWrEMqrxb0HY0jCbyd+wfz657lKGieMcw6HJmBe/SuKxtgsQGOhgXn8svl8vYHX9Nm26bBzqramg2vfIlNsiUwQfa/I4ym 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, allowing do_tcp_sendpages() to be removed. This is part of replacing ->sendpage() with a call to sendmsg() with MSG_SPLICE_PAGES set. Signed-off-by: David Howells cc: Boris Pismenny cc: John Fastabend cc: Jakub Kicinski cc: "David S. Miller" cc: Eric Dumazet cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: netdev@vger.kernel.org --- include/net/tls.h | 2 +- net/tls/tls_main.c | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/include/net/tls.h b/include/net/tls.h index 6056ce5a2aa5..5791ca7a189c 100644 --- a/include/net/tls.h +++ b/include/net/tls.h @@ -258,7 +258,7 @@ struct tls_context { struct scatterlist *partially_sent_record; u16 partially_sent_offset; - bool in_tcp_sendpages; + bool splicing_pages; bool pending_open_record_frags; struct mutex tx_lock; /* protects partially_sent_* fields and diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c index f2e7302a4d96..3d45fdb5c4e9 100644 --- a/net/tls/tls_main.c +++ b/net/tls/tls_main.c @@ -125,7 +125,10 @@ int tls_push_sg(struct sock *sk, u16 first_offset, int flags) { - int sendpage_flags = flags | MSG_SENDPAGE_NOTLAST; + struct bio_vec bvec; + struct msghdr msg = { + .msg_flags = MSG_SENDPAGE_NOTLAST | MSG_SPLICE_PAGES | flags, + }; int ret = 0; struct page *p; size_t size; @@ -134,16 +137,19 @@ int tls_push_sg(struct sock *sk, size = sg->length - offset; offset += sg->offset; - ctx->in_tcp_sendpages = true; + ctx->splicing_pages = true; while (1) { if (sg_is_last(sg)) - sendpage_flags = flags; + msg.msg_flags = flags; /* is sending application-limited? */ tcp_rate_check_app_limited(sk); p = sg_page(sg); retry: - ret = do_tcp_sendpages(sk, p, offset, size, sendpage_flags); + bvec_set_page(&bvec, p, size, offset); + iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1, size); + + ret = tcp_sendmsg_locked(sk, &msg, size); if (ret != size) { if (ret > 0) { @@ -155,7 +161,7 @@ int tls_push_sg(struct sock *sk, offset -= sg->offset; ctx->partially_sent_offset = offset; ctx->partially_sent_record = (void *)sg; - ctx->in_tcp_sendpages = false; + ctx->splicing_pages = false; return ret; } @@ -169,7 +175,7 @@ int tls_push_sg(struct sock *sk, size = sg->length; } - ctx->in_tcp_sendpages = false; + ctx->splicing_pages = false; return 0; } @@ -247,11 +253,11 @@ static void tls_write_space(struct sock *sk) { struct tls_context *ctx = tls_get_ctx(sk); - /* If in_tcp_sendpages call lower protocol write space handler + /* If splicing_pages call lower protocol write space handler * to ensure we wake up any waiting operations there. For example - * if do_tcp_sendpages where to call sk_wait_event. + * if splicing pages where to call sk_wait_event. */ - if (ctx->in_tcp_sendpages) { + if (ctx->splicing_pages) { ctx->sk_write_space(sk); return; }