From patchwork Wed May 31 11:00:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13261944 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 63A69C77B7A for ; Wed, 31 May 2023 11:00:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CEA118E0002; Wed, 31 May 2023 07:00:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CCA9D8E0001; Wed, 31 May 2023 07:00:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BB0D98E0002; Wed, 31 May 2023 07:00:32 -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 AC4108E0001 for ; Wed, 31 May 2023 07:00:32 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 7DC3214036E for ; Wed, 31 May 2023 11:00:32 +0000 (UTC) X-FDA: 80850256704.26.F6DB0CB Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf28.hostedemail.com (Postfix) with ESMTP id 84F2EC0003 for ; Wed, 31 May 2023 11:00:28 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=MYCEmZpl; spf=pass (imf28.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=1685530828; 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=97CTgaKk+HjxMsHB1NZqYRmtg/935y1khOuMG78saNk=; b=Zn5t1+kdRH9xF01p0EJ1GfzyLodNFgaghbQqIEcr0J7R0S3c59ssmYO6Gu4ANyilidu91t 05Tjb9xt2puMQ0WHNr+nvV73xvCO0pbN/ZyV2YzRiJEn+srty+l5P97+LqAkF7/snWDbAW Opmm1kXKVPBiRc2tFzaBbB9cIqnpuRU= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=MYCEmZpl; spf=pass (imf28.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=1685530828; a=rsa-sha256; cv=none; b=FX7QiCja/aHwhNMXvUZzL4PY36vLAJszkvqI3d6mJXqp9vzEX2GeR8x31DlFyZDTlbQNpK 5wazXW9Jh+DsljwS5ErUvhtKd5AeapAP8kuOwMwzfZVHCNJIM0Abk5qNmBx/piFJDy5Mjd mDRvhgInei3ihp+j9QX1tc91rNpIN64= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685530827; 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=97CTgaKk+HjxMsHB1NZqYRmtg/935y1khOuMG78saNk=; b=MYCEmZplyZkTpDhH0b5lZtPIWa2nW+xa3zhd+YFwINowjFWw1mpQu7vCBxneQbj9IQZK2b QvirN5ttp/FkT+SR9xA9xaJ+UR5uQkcmrEeQEDZqsiN9Vugoz8fne6aSYrxKaO0/WP64KC 9Voajwis2cR8m4u41UVDfzJHvoXzueE= 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-513-3tfZ-SxcM6qaXos3TuNsaQ-1; Wed, 31 May 2023 07:00:21 -0400 X-MC-Unique: 3tfZ-SxcM6qaXos3TuNsaQ-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 BA646101AA42; Wed, 31 May 2023 11:00:20 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.182]) by smtp.corp.redhat.com (Postfix) with ESMTP id E15D72166B25; Wed, 31 May 2023 11:00:18 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Ayush Sawal , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , Simon Horman , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 1/2] chelsio: Support MSG_SPLICE_PAGES Date: Wed, 31 May 2023 12:00:07 +0100 Message-ID: <20230531110008.642903-2-dhowells@redhat.com> In-Reply-To: <20230531110008.642903-1-dhowells@redhat.com> References: <20230531110008.642903-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Rspamd-Queue-Id: 84F2EC0003 X-Rspam-User: X-Stat-Signature: u7o79o1t9xthhmwotyg54pookwioqfdb X-Rspamd-Server: rspam01 X-HE-Tag: 1685530828-30904 X-HE-Meta: U2FsdGVkX18k98BIp6vjleIv8O+W+1LaMZOjacihYj5oGgXmIvti6Wz7VVsUXeREFEwUGhjAqwErPI5hFIUBut5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ccyVI+Gl24Vyp8v8r8wTnKEOcsL4ePqsW7/ESzuJM4kC/m4PriYCdpZbV3qyiHS/4p91dK/xR/ZDnyCoE5hSDu5P3fFr8AHovvZc9lKbgVdP+vdy0ieEMJpei7vJky0EdB2X7DKQ8uAjj9CxC5cEPsUDCYpkxGhh+1lgptS0mecJ1q3ldkbCT2Ztgi5vcCt/WfzUtTakQcE96oHq/QmNdnC6eIsVRdwSdB6cE8vACb2BPZ+nWJx3s+u7vzc7DzgQlJAk81bHqtrr9zBPZZQPXAaJbvwNMsl5v6ANAyy/AfUFdrANr5+tpAQX1jafjv1K1OFMmqe9FNdmpsU4qiuAOuC4XMzBWEQLKDD8ZQKhKEwssKm1A1aC9m8BsmdXEzqwa0iBCcSmsUDVi+/1k= 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: Make Chelsio's TLS offload sendmsg() support MSG_SPLICE_PAGES, splicing in pages from the source iterator if possible and copying the data in otherwise. This allows ->sendpage() to be replaced by something that can handle multiple multipage folios in a single transaction. Signed-off-by: David Howells cc: Ayush Sawal cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: netdev@vger.kernel.org --- .../ethernet/chelsio/inline_crypto/chtls/chtls_io.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_io.c b/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_io.c index ae6b17b96bf1..1d08386ac916 100644 --- a/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_io.c +++ b/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_io.c @@ -1092,7 +1092,17 @@ int chtls_sendmsg(struct sock *sk, struct msghdr *msg, size_t size) if (copy > size) copy = size; - if (skb_tailroom(skb) > 0) { + if (msg->msg_flags & MSG_SPLICE_PAGES) { + err = skb_splice_from_iter(skb, &msg->msg_iter, copy, + sk->sk_allocation); + if (err < 0) { + if (err == -EMSGSIZE) + goto new_buf; + goto do_fault; + } + copy = err; + sk_wmem_queued_add(sk, copy); + } else if (skb_tailroom(skb) > 0) { copy = min(copy, skb_tailroom(skb)); if (is_tls_tx(csk)) copy = min_t(int, copy, csk->tlshws.txleft); From patchwork Wed May 31 11:00:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13261945 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 13297C77B73 for ; Wed, 31 May 2023 11:00:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A2C5E8E0003; Wed, 31 May 2023 07:00:35 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9DAC78E0001; Wed, 31 May 2023 07:00:35 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8A3248E0003; Wed, 31 May 2023 07:00:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 785C58E0001 for ; Wed, 31 May 2023 07:00:35 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 2089A1C731A for ; Wed, 31 May 2023 11:00:35 +0000 (UTC) X-FDA: 80850256830.08.4A9F253 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf20.hostedemail.com (Postfix) with ESMTP id 061901C0032 for ; Wed, 31 May 2023 11:00:32 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hLinTmM6; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf20.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1685530833; 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=nBkFTCC6CO9wuSqa6TDRZsc4R0OnF4ofoS5g5iSEfa8=; b=wnPvnpMbWkB1uG1qY26xvcdAekFWZACDF70CI+Mh1ec+yLmfXhx5UCrs3E78jnBFuzVbGy FdRMq/H1XlRMZSVfmsSxP2fizkzyAUp4zXILoUDodGfI1G4apZ4C7MzNWXGJKijKAMmzl6 hpwQ6ulcDsAR6s/MpnAR3Oa65Izw1nk= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hLinTmM6; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf20.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685530833; a=rsa-sha256; cv=none; b=4W/XRoek0f6fYZfDY2cB3GAHJoibawak9+H/T651GRpmUi1BEaR9Ci2DuXcJNVWfeDBprY 9f4LOfDLQ94UIGhPfTHo3FnehEjbOgYeqk7a35on9f+rzUStrIBbWqj4D03letplnV7pXq kDVn3cSbRLoPswLsQZ4cNfApv1WB63E= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685530832; 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=nBkFTCC6CO9wuSqa6TDRZsc4R0OnF4ofoS5g5iSEfa8=; b=hLinTmM62W25qPSe0PCsNFnbleAnz3W4qgJL6NzJKeK+OT65qvIBRgbrJ8BMPr79Pmz+02 jRxawCNC42qhbKTQd99Sb/XYtF2vEWbzhH1SFfPgFAasyx7S36M7Mj3lrSXjBS7gEv71aT sFMJUhgIX0BFLY2i7ycaZGAlki94Txw= 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-26-W82jFm1ZNtOC3nNUdxtyIw-1; Wed, 31 May 2023 07:00:27 -0400 X-MC-Unique: W82jFm1ZNtOC3nNUdxtyIw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 90765811E78; Wed, 31 May 2023 11:00:24 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.182]) by smtp.corp.redhat.com (Postfix) with ESMTP id 86FBF421C3; Wed, 31 May 2023 11:00:21 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , Ayush Sawal , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , Simon Horman , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v2 2/2] chelsio: Convert chtls_sendpage() to use MSG_SPLICE_PAGES Date: Wed, 31 May 2023 12:00:08 +0100 Message-ID: <20230531110008.642903-3-dhowells@redhat.com> In-Reply-To: <20230531110008.642903-1-dhowells@redhat.com> References: <20230531110008.642903-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-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X4IRDRuBx8SxayLHHzM2xc7WoogCaoicB5h6lAkrrg9A3JP00vnvS1VcWxH 3DipPWiy 8KKRQK+a9Buc33BxuxJ6rdVLNfd4uLlEMo+qz+rxaAalvg/PjeKcf7ijJL0towdQRq4U8YmK6umO7eHxRFZhtWuTdl/r5PAameqz8mJslVP6H4Xr3wI+1OdET29p43lVQ0WXZzOcnhmW9HYfu3h8GD44SjaFT+0iS9f+D2Ea6bcdbM4YlH4P6APzN/k5kmXZ+BSwwTDZptikSXjHUxmeqTZJW7GbLJIkqsGWGyqepMykd/1saJgymRa6VnnYtxh7Mqou+FoFC88ZOn6/Fv/D0IajBswb2YO6oqK1jdCEDx888cTM18uIRWog/JXbeROxXiT0hS8DNYX2/yGRcOPUd/0TUcDTOiI/V+WhJLjh5OI/yLGn6Biwe8CFsa8J01weRK2GUZDstzkrhA2hgLKVlgpSCWq6v/zoAp+OmFQbUXZHKTQpmN9C+mxhYtI1CFq8f1ySFeKSLV2VtHkbALcunrJjwSuQQdkCnNgAPcsqhHIxnxE4952BKW6dOrDioomXVpYNOaDvqPpqtpDT7y1LE3+3SlVabHVMk4b784daqIfOz/PI= 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: Convert chtls_sendpage() to use sendmsg() with MSG_SPLICE_PAGES rather than directly splicing in the pages itself. This allows ->sendpage() to be replaced by something that can handle multiple multipage folios in a single transaction. Signed-off-by: David Howells cc: Ayush Sawal cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: netdev@vger.kernel.org --- Notes: ver #2) - Do reverse-xmas tree variables. .../chelsio/inline_crypto/chtls/chtls_io.c | 109 ++---------------- 1 file changed, 7 insertions(+), 102 deletions(-) diff --git a/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_io.c b/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_io.c index 1d08386ac916..5724bbbb6ee0 100644 --- a/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_io.c +++ b/drivers/net/ethernet/chelsio/inline_crypto/chtls/chtls_io.c @@ -1240,110 +1240,15 @@ int chtls_sendmsg(struct sock *sk, struct msghdr *msg, size_t size) int chtls_sendpage(struct sock *sk, struct page *page, int offset, size_t size, int flags) { - struct chtls_sock *csk; - struct chtls_dev *cdev; - int mss, err, copied; - struct tcp_sock *tp; - long timeo; - - tp = tcp_sk(sk); - copied = 0; - csk = rcu_dereference_sk_user_data(sk); - cdev = csk->cdev; - lock_sock(sk); - timeo = sock_sndtimeo(sk, flags & MSG_DONTWAIT); + struct msghdr msg = { .msg_flags = flags | MSG_SPLICE_PAGES, }; + struct bio_vec bvec; - err = sk_stream_wait_connect(sk, &timeo); - if (!sk_in_state(sk, TCPF_ESTABLISHED | TCPF_CLOSE_WAIT) && - err != 0) - goto out_err; - - mss = csk->mss; - csk_set_flag(csk, CSK_TX_MORE_DATA); - - while (size > 0) { - struct sk_buff *skb = skb_peek_tail(&csk->txq); - int copy, i; - - if (!skb || (ULP_SKB_CB(skb)->flags & ULPCB_FLAG_NO_APPEND) || - (copy = mss - skb->len) <= 0) { -new_buf: - if (!csk_mem_free(cdev, sk)) - goto wait_for_sndbuf; + if (flags & MSG_SENDPAGE_NOTLAST) + msg.msg_flags |= MSG_MORE; - if (is_tls_tx(csk)) { - skb = get_record_skb(sk, - select_size(sk, size, - flags, - TX_TLSHDR_LEN), - true); - } else { - skb = get_tx_skb(sk, 0); - } - if (!skb) - goto wait_for_memory; - copy = mss; - } - if (copy > size) - copy = size; - - i = skb_shinfo(skb)->nr_frags; - if (skb_can_coalesce(skb, i, page, offset)) { - skb_frag_size_add(&skb_shinfo(skb)->frags[i - 1], copy); - } else if (i < MAX_SKB_FRAGS) { - get_page(page); - skb_fill_page_desc(skb, i, page, offset, copy); - } else { - tx_skb_finalize(skb); - push_frames_if_head(sk); - goto new_buf; - } - - skb->len += copy; - if (skb->len == mss) - tx_skb_finalize(skb); - skb->data_len += copy; - skb->truesize += copy; - sk->sk_wmem_queued += copy; - tp->write_seq += copy; - copied += copy; - offset += copy; - size -= copy; - - if (corked(tp, flags) && - (sk_stream_wspace(sk) < sk_stream_min_wspace(sk))) - ULP_SKB_CB(skb)->flags |= ULPCB_FLAG_NO_APPEND; - - if (!size) - break; - - if (unlikely(ULP_SKB_CB(skb)->flags & ULPCB_FLAG_NO_APPEND)) - push_frames_if_head(sk); - continue; -wait_for_sndbuf: - set_bit(SOCK_NOSPACE, &sk->sk_socket->flags); -wait_for_memory: - err = csk_wait_memory(cdev, sk, &timeo); - if (err) - goto do_error; - } -out: - csk_reset_flag(csk, CSK_TX_MORE_DATA); - if (copied) - chtls_tcp_push(sk, flags); -done: - release_sock(sk); - return copied; - -do_error: - if (copied) - goto out; - -out_err: - if (csk_conn_inline(csk)) - csk_reset_flag(csk, CSK_TX_MORE_DATA); - copied = sk_stream_error(sk, flags, err); - goto done; + bvec_set_page(&bvec, page, size, offset); + iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1, size); + return chtls_sendmsg(sk, &msg, size); } static void chtls_select_window(struct sock *sk)