From patchwork Wed Mar 29 14:13:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13192522 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 BF394C6FD18 for ; Wed, 29 Mar 2023 14:14:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 460766B0088; Wed, 29 Mar 2023 10:14:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 40FCC6B0089; Wed, 29 Mar 2023 10:14:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 264C76B008A; Wed, 29 Mar 2023 10:14:43 -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 0E74A6B0088 for ; Wed, 29 Mar 2023 10:14:43 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id D3F0B1C61BB for ; Wed, 29 Mar 2023 14:14:42 +0000 (UTC) X-FDA: 80622131604.22.500F009 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf29.hostedemail.com (Postfix) with ESMTP id D6D84120020 for ; Wed, 29 Mar 2023 14:14:40 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fcnlM7wm; spf=pass (imf29.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=1680099280; 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=v6WcNKpTWWgexmydU39qEchX1MtJJl9VMoZGlW6ePEY=; b=0t3SLQGtoHHMj3g++55Z0ktMo2T+FA7DBS2fDaPZYADL/qwO8Sng3qEC7T0GVnqVKWetLP iZDZX5O2zBymYU6plgOOpk13UtsAP+6G84UEzXKjBBtl+LnVhD3B2f1wTBYS/rsl2yPT0+ tBPYG36T02d33YkYITQvuN9hYOpSO5U= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fcnlM7wm; spf=pass (imf29.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=1680099280; a=rsa-sha256; cv=none; b=ppi9LPA2LhRs7XZuFBy/CwPRRApnWex+dMVy6OfD9gxtgvUWEYduXEVZndhu/ku0mfJzLS MNVvUCFxdzNL0yWlPuRL1N78cPrnxX19Ct/pB9Dyl9jUCy08zLZMpkuULjtit4OPYCLMXD uA5t7nBbJ+JdkxQMwBqLLB7P2MPL/DE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680099280; 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=v6WcNKpTWWgexmydU39qEchX1MtJJl9VMoZGlW6ePEY=; b=fcnlM7wmufZdjeVJ1N0qIER77Qvut65Q6/b1CUVkM3f+pzjILKvWhErozoWT7rqdGwWopf SXxfoZ3CAiFJ0J96gVxDQfj660NOqX28Wic0hsFUpGD/vHHvXyn/A5CV77s7clU8qhb6dr N2M1O9qL69lD5xg8umWJRHJ8YIzdEGc= 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-428-r-bTm78zPGe9KMPftn10KA-1; Wed, 29 Mar 2023 10:14:36 -0400 X-MC-Unique: r-bTm78zPGe9KMPftn10KA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D52383C0E441; Wed, 29 Mar 2023 14:14:35 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id C31801121330; Wed, 29 Mar 2023 14:14:33 +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, Boris Pismenny , John Fastabend Subject: [RFC PATCH v2 13/48] tls: Inline do_tcp_sendpages() Date: Wed, 29 Mar 2023 15:13:19 +0100 Message-Id: <20230329141354.516864-14-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.3 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: D6D84120020 X-Stat-Signature: 95k4gz9a5stjx8oocsw7mpc4uk19hdg8 X-Rspam-User: X-HE-Tag: 1680099280-824317 X-HE-Meta: U2FsdGVkX18uTSMgs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ib/cFpGfrlWhFJ5dlVirvzjSeWeB4kufvTA2m5L9fIB0gnCmPufGwBZjzB2NRW0xyp745T7L8ZK0szrCaJVGDg7KHxGr2+yxQAQf9UkRKzmZmxm1W/Qv9TLKLzwVfiG23jYl7cDjeTEDAvh8A9XG8JSO70/6Wi/IzowzI3+oeg3QQloe4jJiGVGa0KrujZgIcxFtQ9tnojJq2sdrF/TLUyHN8EQKRD/akXUpdma0mRIoXtzue3SEsusVvqvzfUo6j/pN1foDMlfcJRAHTriZoEYHsXOjxaKzxXyThyCh/YdH2XYHoaYfAzHSjaNeATJs3rg8IQ0GEPg8tmzono+ZaXR9Fnwz6McARV6rxJg6tW+YRMD853Y3SjRKOLxFJXn3HPArEG7SGaM6hEvgkgb0n3cnRsAQ4WWYPAySMQu8cMhZ9T9Mt5ky23ingnW+ZKMU/Q2YQ== 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 | 25 ++++++++++++++++--------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/include/net/tls.h b/include/net/tls.h index 154949c7b0c8..d31521c36a84 100644 --- a/include/net/tls.h +++ b/include/net/tls.h @@ -256,7 +256,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 3735cb00905d..9a1e77de6a1f 100644 --- a/net/tls/tls_main.c +++ b/net/tls/tls_main.c @@ -124,7 +124,11 @@ 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 = flags | MSG_SENDPAGE_NOTLAST, + .msg_kflags = MSG_SPLICE_PAGES, + }; int ret = 0; struct page *p; size_t size; @@ -133,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) { @@ -154,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; } @@ -168,7 +175,7 @@ int tls_push_sg(struct sock *sk, size = sg->length; } - ctx->in_tcp_sendpages = false; + ctx->splicing_pages = false; return 0; } @@ -246,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; }