From patchwork Thu May 18 13:07:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13246759 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 2067CC77B7D for ; Thu, 18 May 2023 13:09:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A938090000C; Thu, 18 May 2023 09:09:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A1C4B900003; Thu, 18 May 2023 09:09:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 897A890000C; Thu, 18 May 2023 09:09:01 -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 75AA5900003 for ; Thu, 18 May 2023 09:09:01 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 2D78E80817 for ; Thu, 18 May 2023 13:09:01 +0000 (UTC) X-FDA: 80803406082.22.10E8EFF Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf17.hostedemail.com (Postfix) with ESMTP id CFC9240027 for ; Thu, 18 May 2023 13:08:01 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=MeAO6wyl; spf=pass (imf17.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=1684415281; 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=uCOM95ckOBCstRnBs/chpDx6VXyv0aI3qfIf/0rsryO634RqZgKDvcZc+kpihwxxoFcSxp fw59/S1otCZmn9ISzXHjfJJ2IIbLqh5l6+sQcD2H3nnJE1SbCfLNCnuc8svtdMxEsBPTUX lINnf2kY6ExmQDu4IvhARS1uUxlwk6Q= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684415281; a=rsa-sha256; cv=none; b=sOkAxnHNUu5uONG7V3CKnXNCOoFhFXFWTj2pNddiuTriuUsj7/9a1R9K+obIKSZX/0JNXD EAwz1vLogdl5780MccCzLntvdU4CNEahrV8eisYHBXcMWdWYonm7SZr+T+7uUWa/2wRSHt agHRtVp9yxP0irfwtB8l2jojp/a4GPY= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=MeAO6wyl; spf=pass (imf17.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=1684415281; 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=MeAO6wylu7gjkgqeuDQf0g9Q8UMSi4t5Ua/3qfJizKKEYYZj0w+sEoUUZ5xNBFvS1zBgIq CNHWQcvgv3riAIuRewAPZOprF8QsdDLwPoHHh2hP3qydK+3H2889Ns2D5jtSdnrRObIkm8 8uEWFN0hpWRkCahg/MVyD7eYmT9qx5k= 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-551-cLgcPFrJO0us3MfDI4Owqw-1; Thu, 18 May 2023 09:07:57 -0400 X-MC-Unique: cLgcPFrJO0us3MfDI4Owqw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 540B585C075; Thu, 18 May 2023 13:07:56 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id 36E3E40C2072; Thu, 18 May 2023 13:07:53 +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 v9 08/16] tls: Inline do_tcp_sendpages() Date: Thu, 18 May 2023 14:07:05 +0100 Message-Id: <20230518130713.1515729-9-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.1 X-Stat-Signature: bs7srw4oomqfjs8nxgacjifehtcxcdh7 X-Rspamd-Server: rspam03 X-Rspam-User: X-Rspamd-Queue-Id: CFC9240027 X-HE-Tag: 1684415281-576679 X-HE-Meta: U2FsdGVkX194R31esHPzwzuizxkE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LTVix/obvrYboSsB4w04nOVapOXGW0dBQtOJ7yfhoFfyYmzCUmvfyYS0b0+o6SwhyjXx0wYQXp7jVOHAtqgSOyINYUud9gUua3K6b0Li4i8GmwJIcKwWW8FVD/G5hkbuemsqHnRVjMX33BR6jyQ1wejry6iOQYbStWMQpQFFwl3X1yN14aXsTBiqEP8sMOhYWGwtA/mIFC7LaYqvy8kKmyVgRYry5fk4D69gqR3g1+UguSU3AwTvwznuhn6yhoDEN+BYDBKloBg9kNO8Zy7aazsuYfKr9wFzpdGFYm9v3c6bIyZRY8qYO0uhkwzPFIE9dbi19C9FAcjvLf0LCRtvDrSIGnRrAXLq5duMH7yXMMZs3Fm8ZwRjx74fuNhOhtr/Lhq3N/JQVune2uqs3bz2DVEwEi4 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; }