From patchwork Wed Apr 5 16:53:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13202263 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 28B6EC7619A for ; Wed, 5 Apr 2023 16:54:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B40916B0078; Wed, 5 Apr 2023 12:54:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AF0D36B0080; Wed, 5 Apr 2023 12:54:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9B8F96B0083; Wed, 5 Apr 2023 12:54:23 -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 8DD916B0078 for ; Wed, 5 Apr 2023 12:54:23 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 6CC88ABFDF for ; Wed, 5 Apr 2023 16:54:23 +0000 (UTC) X-FDA: 80647935606.26.B844CAF Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf07.hostedemail.com (Postfix) with ESMTP id A3B8140010 for ; Wed, 5 Apr 2023 16:54:21 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=iF7LZ0fI; spf=pass (imf07.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=1680713661; 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=wxh2/dj0o7MVHO1aUN3dYnUzfVbWpzyG5IaP8zSar8OtLCQez5X94buo7ZlrMqHzpmrfi9 B+eEG84LeVh7Do8IDkTQEmWF7utefUcj05SQgikX60ft+647o1Us2F56UP5t9QjfCkeIe4 KpyQ6jFCZtaC4BYCgSKbTLIj2YSSTK0= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=iF7LZ0fI; spf=pass (imf07.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=1680713661; a=rsa-sha256; cv=none; b=SW6hHRnPuZ8n02QnBXBhtvMm/7RCCS4IaLc5ouBSHZxS+eHI5nPtGZCrvqLXXNZxX5XfYR qMvQUXgo66awITCmC/FtC3w8ibUROpGqFxFyl/3puvvf2fcIv519ENLafxESOIsVqAYL8a ZdBuPQjzJkSr5yxACaAnc42PVqBgSW0= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680713661; 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=iF7LZ0fIlmdktmckJW8p9EWwJP3TLyy2mlRWqd0i4TcicrfhvvWSa/ZB4vibSq3N+XxwfC XkinYHW0OMmbpnmOWHOnLYmVAeLuOptdEBfO5USXsDHLAy3AAV+CcQCZrN0+rS8b00PdLL b0yepgdujJavksgwpO9x6z1A/jci1yI= 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-452-U_gW8eScNw2-IFPm1Urp3A-1; Wed, 05 Apr 2023 12:54:18 -0400 X-MC-Unique: U_gW8eScNw2-IFPm1Urp3A-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6D39D2807D69; Wed, 5 Apr 2023 16:54:17 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3A90D40C6EC4; Wed, 5 Apr 2023 16:54:15 +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 v4 11/20] tls: Inline do_tcp_sendpages() Date: Wed, 5 Apr 2023 17:53:30 +0100 Message-Id: <20230405165339.3468808-12-dhowells@redhat.com> In-Reply-To: <20230405165339.3468808-1-dhowells@redhat.com> References: <20230405165339.3468808-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Stat-Signature: garm8xo3izcuuhyizspntaxpoaim6kje X-Rspam-User: X-Rspamd-Queue-Id: A3B8140010 X-Rspamd-Server: rspam06 X-HE-Tag: 1680713661-77225 X-HE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WjFyhBJxa1thLyYL09ww2KppigCTVcA6Tc1LG5PUhhrEjNefCUWTVB5MZ6a6wCjGCyL/JRZetkouumxw3nf0j1isKVPs/LpDQ7TopUC08tTesVROAYPyWnS8LCRwVX1bBKCEUEd4hmXc+KczIkXPfNiD/MWC8D5cuq4T4VsozJAgWwpk1osqFiBm5GYKjRFYisNPPNE+71bmHP8TdhqliGpK4jHPkPHDwzueUpgyTrSJGozICVnpr0Nk3AiTvXeOgixJOuT1ehgKWJvMyej8LA/vY4yz/SMaIcURd5m+GYLY1FjHHzTw9kzVfx3TS08r1QIn6j0aOAQaaVpcyTxGdc/LaTJFXbZO8s1n5xV940SUDMfsafnIkDI/sow8/yomuyiczR5JAL4KIAcc8H9j5UW1vulkLf+xihnwORIb93dHIEnEAvIqgqjhGG+zWJIv7Oa03oJHW6A92/M6SSZC+QjmwAA== 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; }