From patchwork Thu May 18 11:34:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13246569 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 1FDD9C7EE23 for ; Thu, 18 May 2023 11:35:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B0463280005; Thu, 18 May 2023 07:35:47 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AB18E900003; Thu, 18 May 2023 07:35:47 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 92A63280005; Thu, 18 May 2023 07:35:47 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 843C2900003 for ; Thu, 18 May 2023 07:35:47 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 5A8E114025B for ; Thu, 18 May 2023 11:35:47 +0000 (UTC) X-FDA: 80803171134.12.4BAEC3E 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 7E8C7140009 for ; Thu, 18 May 2023 11:35:45 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=d1ZQgZ5e; 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=1684409745; 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=thP0XJD2q9xHSVtGqf3E5rqOdlI8XpP1DJztrWscRwfQbMzI7EUEjfGfwEw0Z1gqwxZNh8 eCkcytKfhBNRac6d/3U24uZVSutkB1sv6fW3KUEVPY+FxQ7XwInzDaSC8H7fglWeJltXw9 HLLgyP3Qbq6dZpIYniebNwFBIzES0Z0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1684409745; a=rsa-sha256; cv=none; b=oRL44CS8eAzpoBlkPTlz20+KmduZuEWSURdbiu9TQ3zanicXxoTPWrkmRgZH0eIU4ALhDS 5frjaW/ZivbmNk1YwFkqIBKJMBSfy4xUqn3Iv+wUTvkutx4rJjlJ93Z9mzgL2YIc/bN5GN 3DeoAixlKEfoG/md7J2g8ZQoq/lHWO8= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=d1ZQgZ5e; 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=1684409744; 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=d1ZQgZ5ePQPrrfY8jedIgC/v5ofo2qI9kXjBNTPZklkTSs+FadSWII13LBI4p9R8d/sKOA 7Iqslyo3zmjhBsn95XSAkq0KSx+sgb7pNLBZINMOCP7bQa/ztUtLGLdexVhLE4EmXsWCO0 G3XxEeL7HHkQlGQBeVP16pJAvX2KeUU= 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-575-Of9dg0BOOn66lre7Opvf8A-1; Thu, 18 May 2023 07:35:39 -0400 X-MC-Unique: Of9dg0BOOn66lre7Opvf8A-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5D25829DD980; Thu, 18 May 2023 11:35:38 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.221]) by smtp.corp.redhat.com (Postfix) with ESMTP id D496C2166B31; Thu, 18 May 2023 11:35:35 +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 v8 08/16] tls: Inline do_tcp_sendpages() Date: Thu, 18 May 2023 12:34:45 +0100 Message-Id: <20230518113453.1350757-9-dhowells@redhat.com> In-Reply-To: <20230518113453.1350757-1-dhowells@redhat.com> References: <20230518113453.1350757-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Rspamd-Queue-Id: 7E8C7140009 X-Rspam-User: X-Rspamd-Server: rspam06 X-Stat-Signature: fkkqr6b38mygyi6fxgb4x84no7q17uow X-HE-Tag: 1684409745-210711 X-HE-Meta: U2F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DRt7U2UJgnDQ0qsDuhmX1PZNhDnHI9XNsGeCshKyGN99Ohsexyxlk2okl3r5t0Yfjc+eY+oTmrhT7JR4hwy/x3eiS59drvTzqxbT2priN+Mn36ixJDkCWinjDsK5XfI0ij9x4pKpEJFzkAA/zRCLDSuZJA0RsvuiJFyJfAAtWG+TzibnYuuYRPgxUdM3TtPIlxKvRWWPY6DgnHI1zrHZ8k0313qBcmjPerJY3pOzHX+LXuRgkX/BbzyHLYoWeaFSU1ne5Hwuehnzorqeo1bstEUh1jEC3Hy8ObWkAsETsEPnsMxk17BEoow27yqFWoEaBhF7sVtud2ewKGWFbsQqTBDY0lZDd00o2NTJU/tDRIqXI8tb2S6UMOEkYk/NxeoK8w3y95LMLD3R8gqVEkDARRlq18lgCKqIQXdHMNwL2fW0lqkOXtAr/myT5eUn2Hf+ONyg 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; }