From patchwork Thu Apr 6 09:42:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13203057 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 A905BC77B6C for ; Thu, 6 Apr 2023 09:43:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 40A586B0088; Thu, 6 Apr 2023 05:43:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3BB3C6B0089; Thu, 6 Apr 2023 05:43:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 236436B008A; Thu, 6 Apr 2023 05:43:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 0A89F6B0088 for ; Thu, 6 Apr 2023 05:43:29 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id D67D31C698E for ; Thu, 6 Apr 2023 09:43:28 +0000 (UTC) X-FDA: 80650478496.04.712AE7B Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf10.hostedemail.com (Postfix) with ESMTP id 31B78C000A for ; Thu, 6 Apr 2023 09:43:27 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=cQgpHBma; spf=pass (imf10.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=1680774207; 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=3FA5Yjp/rAglxaSde3E7QeP89aqCLnwKrUfyvWNxLew=; b=5k2G1UjfrKpXFoo/OP4ky1Hc4TzxQWpUvhnRYYBINH0kbnjObYk4+vmu/sNS+UFvycfExu rF+G8rJMO/OUVMLtsl4fIkt5hODRJQ1WION7krmKZ+Eva7oo1ybNi0JTAJ9i9Usi2FEMJ2 R1XIz/Ge6BRNFfIj+HfINCcFxuzpl6k= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=cQgpHBma; spf=pass (imf10.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680774207; a=rsa-sha256; cv=none; b=KLY6i3vU++l17cSrpmXAQZQbKhs+wqdwMJCZrCQXtNNTvw2ywHcMwaBM75+EJfykFmiqSg c5YCxi5IWG1DES5j7R/12dOSqdCBuz3GwAl7AzOVsFhqChND7ZLHJokzxeXoD18JbIwSVV Otd6JOv2sEaONFBO/QfBeg0aPIiShnE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680774206; 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=3FA5Yjp/rAglxaSde3E7QeP89aqCLnwKrUfyvWNxLew=; b=cQgpHBma29RwI8QeQq5o/TmfCpwGcEqz2z/GzlYEFkLHeARI05F+pfIsdj0BhKvmf00Kg/ CpmlrIaFT4Qi50IMR65SFDGybKz+AVWZZnI1ZAi0ym4+XcSFKs0pbi1VJk8X6WyCSn+7nc 0taDkLyJamUrp3sqjGtP79lRmOUJ3wI= 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-635-Db4pioF3PMmf8aN9sn6_TA-1; Thu, 06 Apr 2023 05:43:23 -0400 X-MC-Unique: Db4pioF3PMmf8aN9sn6_TA-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 633491C041BB; Thu, 6 Apr 2023 09:43:22 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3BBE92166B29; Thu, 6 Apr 2023 09:43: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 , 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 v5 10/19] tls: Inline do_tcp_sendpages() Date: Thu, 6 Apr 2023 10:42:36 +0100 Message-Id: <20230406094245.3633290-11-dhowells@redhat.com> In-Reply-To: <20230406094245.3633290-1-dhowells@redhat.com> References: <20230406094245.3633290-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 31B78C000A X-Stat-Signature: kkdibqdem3qqxsd6giyap73x43q5upnt X-Rspam-User: X-HE-Tag: 1680774207-957315 X-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oqsu/nmwlOqQ8UrPjDawntL5dusj5IHiAkbn5RkhrgH8tyntWGPIOXJciXbaVC97wAFWaFS14rKroZAOQ2/ovuRzXN6iWryYiRpNM89SAyg7vHtWGdzW7bHzcXBat/aa9zm9nGW/e5jYolq9OAsSEo9GMK+st0AsxeIbaTtdMOYERjWkbK41WlvY1lWXgTn0m0MVIUaJ/7PzAvYv/EXTPe5d868UIgr8usf0vbOuO3JAyAh4xe/IaxYWhjV1c/l8PrG6/vOOXPgYlYXEixrC+Cf4zoRu1F/dmrwmd5m+E5f9KZ2o29petbvFTAJhKri8RX+jjpl5Wd8jIuH15iJU4I6Njb3+yMvTD776zO3b4GQXkmweOzG/auq5OK/n+QzD+a7uiRPy7kUa5jtmE0cyK/WWvOY/AVfLFSMJkEaTwYzbvrotVdSvuURGR+Vo7RbCoB8l/nRxBufz0GXXOnnW8k4ViRuYi8KXJwmSLUPQJH4lfwA== 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 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 b32c112984dd..1d0e318d7977 100644 --- a/net/tls/tls_main.c +++ b/net/tls/tls_main.c @@ -124,7 +124,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; @@ -133,16 +136,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 +160,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 +174,7 @@ int tls_push_sg(struct sock *sk, size = sg->length; } - ctx->in_tcp_sendpages = false; + ctx->splicing_pages = false; return 0; } @@ -246,11 +252,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; }