From patchwork Tue Apr 11 16:08:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13207817 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 32D38C77B70 for ; Tue, 11 Apr 2023 16:09:53 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C0B37900007; Tue, 11 Apr 2023 12:09:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B92C1900002; Tue, 11 Apr 2023 12:09:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A3429900007; Tue, 11 Apr 2023 12:09:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 8CB47900002 for ; Tue, 11 Apr 2023 12:09:52 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 5DC97C0E7B for ; Tue, 11 Apr 2023 16:09:52 +0000 (UTC) X-FDA: 80669596224.23.E36BD10 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf18.hostedemail.com (Postfix) with ESMTP id 107721C0020 for ; Tue, 11 Apr 2023 16:09:48 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=GmR5nHIA; spf=pass (imf18.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=1681229389; 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=lXtfXzIiTVZdRlTKdwIgWoyImr4cQmkM3QVYm6sq4pwvDRH43K2sfHisnv/8KjA44i2Ht6 foTKH5Yt2xzgC4j6A581Np3BHGu88j8fMFjEghwAc5md20q/Ff1troS2BnBfdjCRYWsbfC JKEhZpig6J+iZnF7Kz+ObM13kLC4pqA= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=GmR5nHIA; spf=pass (imf18.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=1681229389; a=rsa-sha256; cv=none; b=kpaT+EpPsUKlg1JjJhwSQLMEkwf0V7tFFxCn2aIobenhN74Lyr+Gc7tGF8pO20K3Yyyr2L /JlhYeHukrTi5+Dba4AFKNGEF/zHiKC/ycUivab0jwXePKyrJdXNCQaINjtKgsYp1s8M0Q 1iKyY494iXy6p+YsgCO4iRgQAtVocKc= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1681229388; 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=GmR5nHIAH4Z6dPxqltjuLWqI1H+Zy4qCw0ViFLsO0Rp+nvZfo5k2eQ8aW/wu+odw0j1cGH 7vQYc4KSVNVJ3BIe2iBYTwEj0qrKxEYWO+7SLXhQlS5Lis4cE/g0GIDh3Uxz7CFnwU41se /D44SCOg7FavjeKaBUO7s470+wj9IsY= 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-256-hC-bCB2tOPuewyxBc3G-bQ-1; Tue, 11 Apr 2023 12:09:45 -0400 X-MC-Unique: hC-bCB2tOPuewyxBc3G-bQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 028F638149AF; Tue, 11 Apr 2023 16:09:44 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id A8ED8492B01; Tue, 11 Apr 2023 16:09:41 +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 v6 11/18] tls: Inline do_tcp_sendpages() Date: Tue, 11 Apr 2023 17:08:55 +0100 Message-Id: <20230411160902.4134381-12-dhowells@redhat.com> In-Reply-To: <20230411160902.4134381-1-dhowells@redhat.com> References: <20230411160902.4134381-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Stat-Signature: ehzrxcq8xfzikg8q8h6d3yuagyyow1wp X-Rspam-User: X-Rspamd-Queue-Id: 107721C0020 X-Rspamd-Server: rspam06 X-HE-Tag: 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gjJMwWldyrtqEpWjEveBMZBHyAoQW3XxGt0912IXOHHKLOw6z7XRZEU3sl81SiAsHm0lKzGynw45lPh0YQNYRpTzGVwBKuZjuoXxOZ+pMbLDcGwY0LDcE6Qcub9ErFDq1VAvJn5lv7wAM+GJbuwwdCJYvkMg9DH0I8uzi8sLNGpFwS31kH8y3roqB5wOM+v16dPIRo+a2EA5p9auNInO01a+WxHV5epUOoD0kOM/ivJhxoEQkHKlHU3M1MZnRG8NitavCrs3yR+fcNwMNNi1bZHEeo9X+NG7Fa6KW6ypKBsQiP6W+ZZGF7LNGlrgH+3yvyy/9qRyKmhapF1NOeFKmRjrwSBNqe3bcr2yjZEKj0c1kpLSyKzgVgXOu6itRWZUVMWUEnp7pSBPp4wUMgDfrVD/qowLmXJGEWYS+ky+WFlyGdRyPiDryhoC7iWUD4Tv28tD8WriyFoje7FhJTzfmqeXMYMBKvpRlqrDdhAVmLQ5nGzg== 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; }