From patchwork Fri Jun 9 10:02:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13273621 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 C9D41C7EE2E for ; Fri, 9 Jun 2023 10:03:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 639B28E000B; Fri, 9 Jun 2023 06:03:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5C25C8E0001; Fri, 9 Jun 2023 06:03:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4621B8E000B; Fri, 9 Jun 2023 06:03:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 334B88E0001 for ; Fri, 9 Jun 2023 06:03:01 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id EF5E014017C for ; Fri, 9 Jun 2023 10:03:00 +0000 (UTC) X-FDA: 80882770920.10.263A813 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf23.hostedemail.com (Postfix) with ESMTP id 3E4C6140023 for ; Fri, 9 Jun 2023 10:02:58 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fhtorRS2; spf=pass (imf23.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=1686304979; 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=R74bPi2kwyePE/xmRN7KyjHRwIflZ6VoOr6lAl3jXjM=; b=g7STVGsu8+pw/t8KC82+M8aL5bWGRX8bmgAieeD7WurARc+DC1QrdX1kEpjxjVDWPEwwnU j+axm2lqnKmd7C3eitcWEI+yH2ItDhbJqbfClhrkJNNr3Yd9URE21U6mPRR2iHE4+fRRb7 FDAMKCw1mg/IsjtCwLThE9QCTO1dmTY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686304979; a=rsa-sha256; cv=none; b=0iZXIocBoO8Ws2Qa3syr32rPFC3alZ9KCeC9HaL551i3A6rKgBqOq61zOeQhC6uAcj6LS+ iVuegbMvSaeiZK9e40eiBg3UxmpeG7WTlVCaSHTC3WPCwBR7Q1TwQVl6Tfo3332y+AE0Kx uIJEvA/giouilRrKW2XFdx2sr3UlKRc= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=fhtorRS2; spf=pass (imf23.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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686304978; 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=fhtorRS2UnBGgWaU67YcN3Fq4QhH6cyNqYrxDo59fz51UNg06xiNVyG7ZUXoFnerZAj19R 7ztCCuIHK0s4rRkH+K72Qr0D3UaglfgwdZi4dUtZdj/OrINru4IVURLqa8BMB2xEnkLVtB X8ozhmNqC5O94eVff+DIHc7IHyW6rQQ= 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 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Rspamd-Queue-Id: 3E4C6140023 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 6hiwh9ipnp6dea374c59ffjcfkmf7ynb X-HE-Tag: 1686304978-570449 X-HE-Meta: U2FsdGVkX18HaE+145coO7KggC+ywNzaw4zBIm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YPCbCcpPLnWIG9VXom9q4ADACGtR8YbwwV2ofD6f9/+g6aSyTBpsGMTOc8RaKpI5dE3H9/IuAKQIpcEfZB2rZhpmzxSoVdkmP4uAB++JuKyjDDMylOc1i4yyVnsLuyFpF/ZdZxHLh40Ha5Gh0y7C7X9q4jeExupj9OZE0EtIe1XG7eWa3u67bSe0iBUPqdvGhoGIBInRSqH9aPykLmgyK4g5p5Ev9YinDae0OuetJbYF2kwyJXvPjvJ1DjjIzhDGdYyr4YqivvMou0uqAuJoCyDOqomu9LjyVvwCEhzIYz0Enbt0CM4MrDrpa6bSrQqXBDt4ooVlg/D+ep43hX3PkJ/KF67f2yyO9SCuLBpkFTyFrOSBqXaewTH04xfXimDsHhk4qe65FDIdY9UTRMX4pC/pKy89uOYQK8TfN+4AiADSMPghxZ7GN9+Nn+t+NzRvBWwIw0cSb4MSQi9kOoedteq/B+Tia/DE74hsdhj7zZVmDMDw= 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: 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