Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1157898rwd; Wed, 7 Jun 2023 11:53:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7zZAcEYTEsDTus5O5EvjYVoL1v1CFbxDux9PtI9Dfsy8iY0qyCSK5TXV9gcdnDIwGQJUq4 X-Received: by 2002:a05:6a00:1a0e:b0:651:cd9d:7dd7 with SMTP id g14-20020a056a001a0e00b00651cd9d7dd7mr7430584pfv.15.1686164020134; Wed, 07 Jun 2023 11:53:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686164020; cv=none; d=google.com; s=arc-20160816; b=HccKQM7gnxEvXCcKnr775G/e2KGhPRf/jTAzKOQXvUuonbQ6H2IsEZt3xO+lpseoZs 2HzO+s1DnkWXg+RRzUsDdXznB6+0xwumfaqUJJvdfgdIpo6DFjSZ/s0G6Igminmaxe3r eaPI3eNTRZWx+HEmuA5g+nl9yHAbb8yiWleY99TqtdUqwTjAt+d9KxvnFIab1WKkfHwK H7yHz+R3YRB3zw+4rH/usdqL9z2L2G7M9P0df/x3wfqfPk18DDDmDrfmNyoW0klLUUY4 1ClD0PVtXl5iPoYc7yF5ccg3au7uQEDo9kEnTx9KlonYDzaCVAKUie7vjlIRE1hJ9yiB Gd8A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=4vaOjJ4V8cBQxw4FBR0piHsYWVs4rIzqgZ7rDnK+p44=; b=AQ5PN0tMI5UZ7pKYCuysP1JtR0IWj88bcZNJfWIxBax7eIRhMlO0KR5eSWG7m54V9Q yqDCyfID9n0a5y8LPkFlKDDJpfl1w4L5COiLpslCq20a5xOzcHGKbyaYr0qW5LXXO6It dQkDzpfsDJfzcnq11W1fhEV+QMYwQ5RIMSdaSN1GwJVjTKq8fMvoVNHAkToFjDxS+Odc dcWDVr4eXrZH+66ITPHojjFnUdBfkxNWW5tsZS68AAuOAp+MlGxTQlYK2tcbMZXDwxV/ AFcgQX9zamTBUVzY38ugdVRCnXeoIs2/3KtpvoI4DI9tag/4sg/Ub4NMTkwSK7rUCYwY oAFw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=X9GwB2Fj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t185-20020a6381c2000000b00528c2cf454asi9274190pgd.666.2023.06.07.11.53.24; Wed, 07 Jun 2023 11:53:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=X9GwB2Fj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232233AbjFGSWX (ORCPT + 99 others); Wed, 7 Jun 2023 14:22:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232915AbjFGSVg (ORCPT ); Wed, 7 Jun 2023 14:21:36 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92374210C for ; Wed, 7 Jun 2023 11:20:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686162035; 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=4vaOjJ4V8cBQxw4FBR0piHsYWVs4rIzqgZ7rDnK+p44=; b=X9GwB2FjaXk8Kb7wW3VftwCFebXLDFbS1iAHgGxYgUMd/tiPmtsOnLgg1N89R6okAK2rO9 4zarLww8E4stczYklnxwL39G3G2TNhbdZ8/sjRQ8CDk98G/bf+YA3EoL9n3CnICG6/QP9i CGIYMtQcBq3HvqBnSKExkZAulur6bNU= 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-354-LRCuNYAMOOq4Tm5Pxw5q1A-1; Wed, 07 Jun 2023 14:20:25 -0400 X-MC-Unique: LRCuNYAMOOq4Tm5Pxw5q1A-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 5340480027F; Wed, 7 Jun 2023 18:20:24 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.182]) by smtp.corp.redhat.com (Postfix) with ESMTP id 87D23403367; Wed, 7 Jun 2023 18:20:22 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org, Linus Torvalds Cc: David Howells , Chuck Lever , Boris Pismenny , John Fastabend , Jakub Kicinski , "David S. Miller" , Eric Dumazet , Paolo Abeni , Willem de Bruijn , David Ahern , Matthew Wilcox , Jens Axboe , linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH net-next v6 13/14] tls/device: Support MSG_SPLICE_PAGES Date: Wed, 7 Jun 2023 19:19:19 +0100 Message-ID: <20230607181920.2294972-14-dhowells@redhat.com> In-Reply-To: <20230607181920.2294972-1-dhowells@redhat.com> References: <20230607181920.2294972-1-dhowells@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Make TLS's device sendmsg() support MSG_SPLICE_PAGES. This causes pages to be spliced from the source iterator if possible. This allows ->sendpage() to be replaced by something that can handle multiple multipage folios in a single transaction. Signed-off-by: David Howells Reviewed-by: Jakub Kicinski cc: Chuck Lever cc: Boris Pismenny cc: John Fastabend cc: Eric Dumazet cc: "David S. Miller" cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: netdev@vger.kernel.org --- net/tls/tls_device.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/net/tls/tls_device.c b/net/tls/tls_device.c index 439be833dcf9..bb3bb523544e 100644 --- a/net/tls/tls_device.c +++ b/net/tls/tls_device.c @@ -509,6 +509,29 @@ static int tls_push_data(struct sock *sk, tls_append_frag(record, &zc_pfrag, copy); iter_offset.offset += copy; + } else if (copy && (flags & MSG_SPLICE_PAGES)) { + struct page_frag zc_pfrag; + struct page **pages = &zc_pfrag.page; + size_t off; + + rc = iov_iter_extract_pages(iter_offset.msg_iter, + &pages, copy, 1, 0, &off); + if (rc <= 0) { + if (rc == 0) + rc = -EIO; + goto handle_error; + } + copy = rc; + + if (WARN_ON_ONCE(!sendpage_ok(zc_pfrag.page))) { + iov_iter_revert(iter_offset.msg_iter, copy); + rc = -EIO; + goto handle_error; + } + + zc_pfrag.offset = off; + zc_pfrag.size = copy; + tls_append_frag(record, &zc_pfrag, copy); } else if (copy) { copy = min_t(size_t, copy, pfrag->size - pfrag->offset); @@ -572,6 +595,9 @@ int tls_device_sendmsg(struct sock *sk, struct msghdr *msg, size_t size) union tls_iter_offset iter; int rc; + if (!tls_ctx->zerocopy_sendfile) + msg->msg_flags &= ~MSG_SPLICE_PAGES; + mutex_lock(&tls_ctx->tx_lock); lock_sock(sk);