Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp802486rwd; Wed, 31 May 2023 05:49:20 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7IylaSFQ6i3MwcZxgMofOCueERTDI7HJ5nO0AOH/s8mdqDAlzcHG+7Pq4aGS1p7iQXuux4 X-Received: by 2002:a05:6a20:5494:b0:112:cf5:d5fb with SMTP id i20-20020a056a20549400b001120cf5d5fbmr4855565pzk.50.1685537359741; Wed, 31 May 2023 05:49:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685537359; cv=none; d=google.com; s=arc-20160816; b=EpVREg+rHbkcaqqJmCFGtRmex0iBqdl8Eg/quDeXxLVuwCaQaVwciTkKxP1VVNl6hq g3Z7U0uTfSMytvwhjfRwOpL5RfFd4NtH0a0pVwsTsTJEpXmZIKLoig9xuT5rV8+ucpWr +ENpoAQR5lsSNRh6YCGA1r/KohH1Fyq7P/VQT1M+LPqRHl5/776zHBPOKJu4A62xTjvm atseOOd4PiKJgqHkih+HR2poc41Nx3jxC3x3smC1HB/zkGYoa4y/vH0tNnJ4fJODDR3k 7XrZkRGn6fpOksaSiaZlSwNodeppI6JNsmAfzkgtbRYMSVUe9eIzj76lX92LUGYeAn5U bvKQ== 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=uuYRuRqPrqYrWBy2myOfoGGw2Qio81ibrygQkKyKemI=; b=v2xuFxHX01v+cxbkYM1SQcWID1d95zyH78bJEuNwx+N/GZW/6VFnWOjpfQIjGehkDo bjVam8el4VI5osv/x3SHdBGg+HFU7M6HBjyrqO5W6N+qYmuspOI3xTYLKvXbv6lV4357 StubTBxyDeAa7pOUPNTuhXRbR/9tdbjspOLBCTPOPQBXxa41hB+zfOoKWfwPzjCTMmqt 4CJ6HotIX0N5bZ/9d0DDlYmEfaLsmoVsK7X7kInDgDntmHLLLpYSqMMWkjgy5TYicrD7 Z8vTdkQpDd9nAJHObo+BFgzhb+IKSWVci/64zCCxiJgfM+azV4wMdm68ILzBBP3zw3RD +5Kg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=G09xyAbt; 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 jb18-20020a170903259200b001b02ce8470dsi767412plb.543.2023.05.31.05.49.07; Wed, 31 May 2023 05:49:19 -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=G09xyAbt; 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 S235925AbjEaMrJ (ORCPT + 99 others); Wed, 31 May 2023 08:47:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233059AbjEaMrI (ORCPT ); Wed, 31 May 2023 08:47:08 -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 10EF812E for ; Wed, 31 May 2023 05:45:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685537154; 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=uuYRuRqPrqYrWBy2myOfoGGw2Qio81ibrygQkKyKemI=; b=G09xyAbtaLd0YusgR+cF8uHNuSVjQQSuw1TsOzPj7hQdntCUi0JadTv4rYgXGARJSuDioR Fr5gGLzY1KcR0F9XnZMXtw9/gsFVvV8/zECc+g1yiEKURxPLYzvKPOR/yQCO+5YZp3S0Sw gbuUMpzuiIX8dPNmfV9Fuomq/deQrh0= 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-54-R6gsZvE5P7aGqYDd_4hZXw-1; Wed, 31 May 2023 08:45:51 -0400 X-MC-Unique: R6gsZvE5P7aGqYDd_4hZXw-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 650F3811E7F; Wed, 31 May 2023 12:45:50 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.182]) by smtp.corp.redhat.com (Postfix) with ESMTP id 994162166B25; Wed, 31 May 2023 12:45:48 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org 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 v2 5/6] tls/device: Support MSG_SPLICE_PAGES Date: Wed, 31 May 2023 13:45:27 +0100 Message-ID: <20230531124528.699123-6-dhowells@redhat.com> In-Reply-To: <20230531124528.699123-1-dhowells@redhat.com> References: <20230531124528.699123-1-dhowells@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Spam-Status: No, score=-2.3 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=ham 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 cc: Chuck Lever cc: Boris Pismenny cc: John Fastabend cc: Jakub Kicinski 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 a959572a816f..221fb30cba51 100644 --- a/net/tls/tls_device.c +++ b/net/tls/tls_device.c @@ -508,6 +508,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); @@ -571,6 +594,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);