Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp800365rwl; Wed, 29 Mar 2023 08:37:35 -0700 (PDT) X-Google-Smtp-Source: AKy350ZE3/TGT1MMS9zAbB4dDrb9+cGF6Xjeq2sXShgngoCJQs38fps6Con6PH+QFsaQURYh62sm X-Received: by 2002:a17:907:1c21:b0:8b1:7ead:7d43 with SMTP id nc33-20020a1709071c2100b008b17ead7d43mr27402224ejc.50.1680104255625; Wed, 29 Mar 2023 08:37:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680104255; cv=none; d=google.com; s=arc-20160816; b=a92Wh+mH1K/VjQ3jSGlzrTd35AHJwDdObJFp9AP1nsViCGqLI1i8P8A70XS/UDmoIL +m+l+yodg5hzNmkS2kS5dLChWCTCMbXCUQiBu6cyFEm3ZZlGrJcGUEkWSAX5xvc37YlH KCGdkoQwC0/FKMiIMkFopCAqepL/ILubirn8YF8AZTETNIH2+TXyHjtRUA9xuD3Vl0Ey q2BH4nyobh08NM/dfIkN2BWf9pMoc1cATieM1H6oly1pYIE/YDDVt54vbZcSUGXy97pS zRodFnhnva4iAItGiA7Hxk+VJvngcpCYTH/ArMFiybBZ985/hHKcehhezy51D7l0YKJU AkMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:content-transfer-encoding :content-id:mime-version:subject:cc:to:references:in-reply-to:from :organization:dkim-signature; bh=NeCkkPoa7tXS33oTjWiTv3O34+xg2iZRZ8XP3QkDkJA=; b=SUwtOYhRyqZ8hAPfaEh/5PNaN1Fxz9WcSHTePi8GM4fg3odErBK+eI+LcPieBvVabq T1JLn7AYDp5ZJly9MaSgyOIixzgPw3ExDTCoiwWE6wGZyhSbHSFLdc4tea5/7nOlKjc1 QkugQa4Oqq8UUshNCZ5cXuICUVd3tazcZnKhfSNcxfH2SfrewGX7vSBTVvx367svxMEC ZIkku07GhutRRen/PBwJFrYPmFy3tR8I0CDlCLfGfQF7QPOUQW9+QLru4Kv7V8oNsJB8 /85aucoTz6DGiMvK6TOKDsDz+KM3xtS8BOS2cUkmygPVyy0/LFDYIDG3Op/ZiO5lbALg u0jA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=clByEt79; 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 m12-20020a056402050c00b004fe9345386esi32694116edv.585.2023.03.29.08.36.41; Wed, 29 Mar 2023 08:37:35 -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=clByEt79; 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 S230152AbjC2Pee (ORCPT + 99 others); Wed, 29 Mar 2023 11:34:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42364 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229834AbjC2PeR (ORCPT ); Wed, 29 Mar 2023 11:34:17 -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 AF7A03C20 for ; Wed, 29 Mar 2023 08:33:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680104005; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=NeCkkPoa7tXS33oTjWiTv3O34+xg2iZRZ8XP3QkDkJA=; b=clByEt798/zYg+AoqcEvCZZHseCF3s3Vo+ygY9LcxITx5PLLksqZaKz0+5SBYqLR5vsWW3 Lr0FqMoA1uCZgmLF9NECrBbpQIYOHiVZC5PWZQXghGV3W7/RNsVRcaMM/2g19Z7o1vgf2U EcNf68uL0h1MJTcH1bEP8rvR3yNcRTA= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-341-EMw0FyvuP6ivsPNFD8FRkA-1; Wed, 29 Mar 2023 11:33:20 -0400 X-MC-Unique: EMw0FyvuP6ivsPNFD8FRkA-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C594438149D4; Wed, 29 Mar 2023 15:32:55 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id AB1F41121330; Wed, 29 Mar 2023 15:32:53 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: References: <20230329141354.516864-1-dhowells@redhat.com> <20230329141354.516864-31-dhowells@redhat.com> To: Bernard Metzler Cc: dhowells@redhat.com, Matthew Wilcox , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Al Viro , Christoph Hellwig , Jens Axboe , Jeff Layton , Christian Brauner , Chuck Lever III , Linus Torvalds , "netdev@vger.kernel.org" , "linux-fsdevel@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" , Tom Talpey , "linux-rdma@vger.kernel.org" Subject: Re: [RFC PATCH v2 30/48] siw: Use sendmsg(MSG_SPLICE_PAGES) rather than sendpage to transmit MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <522641.1680103968.1@warthog.procyon.org.uk> Content-Transfer-Encoding: quoted-printable Date: Wed, 29 Mar 2023 16:32:48 +0100 Message-ID: <522642.1680103968@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE 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 Bernard Metzler wrote: > > When transmitting data, call down into TCP using a single sendmsg with > > MSG_SPLICE_PAGES to indicate that content should be spliced rather tha= n > > performing several sendmsg and sendpage calls to transmit header, data > > pages and trailer. > > = > > To make this work, the data is assembled in a bio_vec array and attach= ed to > > a BVEC-type iterator. The header and trailer (if present) are copied = into > > page fragments that can be freed with put_page(). > = > I like it a lot if it still keeps zero copy sendpage() semantics for > the cases the driver can make use of data transfers w/o copy. = > Is 'msg.msg_flags |=3D MSG_SPLICE_PAGES' doing that magic? Yes. MSG_SPLICE_PAGES indicates that you want the socket to retain your buffer and pass it directly to the device. Note that it's just a hint, however, pages that are unspliceable (eg. they belong to the slab) will ge= t copied into a page fragment instead. Further, if the device cannot suppor= t a vector, then the hint can be ignored and all the data can be copied as nor= mal. > 'splicing' suggest just merging pages to me. 'splicing' as in what the splice system call does. Unfortunately, MSG_ZEROCOPY is already a (different) thing. > It would simplify the transmit code path substantially, also getting > rid of kmap_local_page()/kunmap_local() sequences for multi-fragment > sendmsg()'s. If the ITER_ITERLIST iterator is accepted, then siw would be able to do mi= x KVEC and BVEC iterators, e.g. what I did for sunrpc here: https://lore.kernel.org/linux-fsdevel/20230329141354.516864-42-dhowells@r= edhat.com/T/#u This means that in siw_tx_hdt() where I made it copy data into page fragme= nts using page_frag_memdup() and attach that to a bvec: hdr_len =3D c_tx->ctrl_len - c_tx->ctrl_sent; h =3D page_frag_memdup(NULL, hdr, hdr_len, GFP_NOFS, ULONG_MAX); if (!h) goto done; bvec_set_virt(&bvec[0], h, hdr_len); seg =3D 1; it can just set up a kvec instead. Unfortunately, it's not so easy to get rid of all of the kmap'ing as we ne= ed to do some of it to do the hashing. David