Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp1881251rwd; Fri, 9 Jun 2023 03:42:25 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6of0D5L95n4h6QuKr3vgCr6TbnrbPJKwcp37osANBhkraFHWOHk0BBmiYVfPGuxQZltTLe X-Received: by 2002:a17:903:489:b0:1a9:b0a3:f03a with SMTP id jj9-20020a170903048900b001a9b0a3f03amr941452plb.9.1686307344922; Fri, 09 Jun 2023 03:42:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686307344; cv=none; d=google.com; s=arc-20160816; b=bVrhANX7yqccZTLwDZpbitxgmbqJNfiwHnSeCvWocmQH7zrdePH2SqdCgS6SCdlqd3 EgsnaCaPlIZZIIlHwZWXslDSsi4wef8pGUeYq40IkLj4QfvellzmMiXI7gCEt7V0ks8/ gC7P9Nswevs6qwSjM1Uy3kwJMpGCp8bVWxPIJysnSchzEYQeVWBD/lnGtrtikQGmuvzX jLa1sVkl2cqmlhm5ni8j3avgXgnGq3yXZ6cECapHgTJ1JiekKnBpuOf/9CzK1+cjiC47 q43lWkbCBb+nkkZoApkQSTG4aT7/KMCcLLXBicxBCtv80Bex/sspAZ3OW+3qP1U0rSex ZL1g== 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=R74bPi2kwyePE/xmRN7KyjHRwIflZ6VoOr6lAl3jXjM=; b=LfcT8J/5YKEYQnInG8QXDJ1xjpVbb4BVU3m3QDKQfxadasdJYU2/4fFjZeMqDBu5AV kGbaJgTkTcAfIbz+OJ628IZfhetov2Qgmmv8ItZxBsEfoLXOVzd+CYbEitp6ZxMakf59 TysDAArISRwYfCwgmdQzZNt8UMAajISODCs1+Ej3WIdpeXLCrv8SFmEEbeRjEEKX2yGw uvXpBQ2PJ+b7VDMRpBvviaMRQGGg6sMrRE2zPyomI8DSdtqPdbeDw5oUA2j/HnQBVHGw SVya2C7B/lFLGND6wgqMoUqCVTKMaTSM90nGh7MM6h3NTK17MquKad1Sh5Nuq12pPFy7 4qyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=X4sPd8sB; 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 c17-20020a170903235100b001b22c8d0dc5si2635058plh.437.2023.06.09.03.42.10; Fri, 09 Jun 2023 03:42:24 -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=X4sPd8sB; 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 S238266AbjFIKPq (ORCPT + 99 others); Fri, 9 Jun 2023 06:15:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240924AbjFIKOJ (ORCPT ); Fri, 9 Jun 2023 06:14:09 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B950C4231 for ; Fri, 9 Jun 2023 03:02:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686304973; 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=R74bPi2kwyePE/xmRN7KyjHRwIflZ6VoOr6lAl3jXjM=; b=X4sPd8sBzYwU+K110FCl7zOTDbjBCuSbkvFdMncuyzY1NkR5jxeq3k7bP0HCbA53y5dt5S zspkP2Iwq04M9M2B0k/OgV+COogPXe4hNYd55D0zq0rrmulPPt1pUQXfXlm34BYrFZbico RIA+15GxEpURf1kSgRp0U/KhSTpAqm4= 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-631-Y2G43H3wN2OR5zQ7GU9neg-1; Fri, 09 Jun 2023 06:02:42 -0400 X-MC-Unique: Y2G43H3wN2OR5zQ7GU9neg-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 6545785A5BA; Fri, 9 Jun 2023 10:02:41 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.51]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8EEBF492B0A; Fri, 9 Jun 2023 10:02:39 +0000 (UTC) From: David Howells To: netdev@vger.kernel.org Cc: David Howells , 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, Tom Herbert , Tom Herbert Subject: [PATCH net-next 5/6] kcm: Use sendmsg(MSG_SPLICE_PAGES) rather then sendpage Date: Fri, 9 Jun 2023 11:02:20 +0100 Message-ID: <20230609100221.2620633-6-dhowells@redhat.com> In-Reply-To: <20230609100221.2620633-1-dhowells@redhat.com> References: <20230609100221.2620633-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=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 When transmitting data, call down into the transport socket using sendmsg with MSG_SPLICE_PAGES to indicate that content should be spliced rather than using sendpage. Signed-off-by: David Howells cc: Tom Herbert cc: Tom Herbert cc: "David S. Miller" cc: Eric Dumazet cc: Jakub Kicinski cc: Paolo Abeni cc: Jens Axboe cc: Matthew Wilcox cc: netdev@vger.kernel.org --- net/kcm/kcmsock.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/net/kcm/kcmsock.c b/net/kcm/kcmsock.c index 7dee74430b59..3bcac1453f10 100644 --- a/net/kcm/kcmsock.c +++ b/net/kcm/kcmsock.c @@ -641,6 +641,10 @@ static int kcm_write_msgs(struct kcm_sock *kcm) for (fragidx = 0; fragidx < skb_shinfo(skb)->nr_frags; fragidx++) { + struct bio_vec bvec; + struct msghdr msg = { + .msg_flags = MSG_DONTWAIT | MSG_SPLICE_PAGES, + }; skb_frag_t *frag; frag_offset = 0; @@ -651,11 +655,13 @@ static int kcm_write_msgs(struct kcm_sock *kcm) goto out; } - ret = kernel_sendpage(psock->sk->sk_socket, - skb_frag_page(frag), - skb_frag_off(frag) + frag_offset, - skb_frag_size(frag) - frag_offset, - MSG_DONTWAIT); + bvec_set_page(&bvec, + skb_frag_page(frag), + skb_frag_size(frag) - frag_offset, + skb_frag_off(frag) + frag_offset); + iov_iter_bvec(&msg.msg_iter, ITER_SOURCE, &bvec, 1, + bvec.bv_len); + ret = sock_sendmsg(psock->sk->sk_socket, &msg); if (ret <= 0) { if (ret == -EAGAIN) { /* Save state to try again when there's