From mboxrd@z Thu Jan 1 00:00:00 1970 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 03912C761A6 for ; Mon, 3 Apr 2023 09:50:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 621AE6B0075; Mon, 3 Apr 2023 05:50:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 5D2286B0078; Mon, 3 Apr 2023 05:50:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 499646B007B; Mon, 3 Apr 2023 05:50:58 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 381A26B0075 for ; Mon, 3 Apr 2023 05:50:58 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 08D21ABEB5 for ; Mon, 3 Apr 2023 09:50:58 +0000 (UTC) X-FDA: 80639610996.03.F90A0F1 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf29.hostedemail.com (Postfix) with ESMTP id 3C63D120014 for ; Mon, 3 Apr 2023 09:50:56 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=asAatQVZ; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf29.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1680515456; 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-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=fhMzb4M7buCw/z89I96CjAU7IGJVjjKJKkPGs/PZ09w=; b=itl5T/xE9ZgjB12M4AE5UgQyyG6vuSevOAhEs84B5CqVw5R4OWB51zs/1SmA4ZoLxbMiDG PzXgl8jxNEVixF181XKf6mKON4mExSHfOteIbKYCLugEJhsWqij/T6Go7xrmVr4BtJrKCp zoB7mzr3lL5aGy7H30BAyFgY/4kWEEU= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=asAatQVZ; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf29.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1680515456; a=rsa-sha256; cv=none; b=FGxp+4oeV4AN9eeO52yswNJJbTKdl/sVLhp6Q5HC9JmBj6B4HJbuWPJ7JX1fbHyogfnuLI 1kb2kyv2wQ748+7gpR4IF0jRkJHDHeN5NU7ZEQKZFMd7fl/Q6Gro2/0Ue5DL6rlHTxXRr1 9C0hK1cOHqnGyX83VN2VboDiGftPPxY= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680515455; 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: in-reply-to:in-reply-to:references:references; bh=fhMzb4M7buCw/z89I96CjAU7IGJVjjKJKkPGs/PZ09w=; b=asAatQVZs1Jz5uSviPzaA4u/YI00AVoDheIzaVAQtNMw74q/4e4+PK6Ac8Cq2sxYPAUpqW U3csRHebfuIQcW17dDSLJ74GEpjy7A0xWxupPKq6PRu96UvUj14YaWev9fZAQ/MY6fzRQ+ XLqhQesidFrKl6d5xmI5QV8dmdxLO80= 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-39-4-IXX9ZSPZipH8aFkS7Z8Q-1; Mon, 03 Apr 2023 05:50:50 -0400 X-MC-Unique: 4-IXX9ZSPZipH8aFkS7Z8Q-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 416BE1C05147; Mon, 3 Apr 2023 09:50:49 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 52E2BC15BA0; Mon, 3 Apr 2023 09:50:47 +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: <64299af9e8861_2d2a20208e6@willemb.c.googlers.com.notmuch> References: <64299af9e8861_2d2a20208e6@willemb.c.googlers.com.notmuch> <20230331160914.1608208-1-dhowells@redhat.com> <20230331160914.1608208-16-dhowells@redhat.com> To: Willem de Bruijn 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 Subject: Re: [PATCH v3 15/55] ip, udp: Support MSG_SPLICE_PAGES MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1818503.1680515446.1@warthog.procyon.org.uk> Date: Mon, 03 Apr 2023 10:50:46 +0100 Message-ID: <1818504.1680515446@warthog.procyon.org.uk> X-Scan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nlDq+FDJPUUQ47WchPpOeyatRVLLiBKpMLWt3wzqFczdjDxoI92hZAna7LjOdSyG88 AMaX7ZQL z/DOyzQvK2rTaTzC6YesQOKvd2Gi5SpW/q951io1QCa8fP+np0xN79E1jESYlcGqqy1dRqpnkXUKR842d7r63bpZeRsQZwV78ljEzxd/iskCVAGN9srsnbk02zj2Vf5ihJjZZtAPDihEx7hEetF1HKljMlsJzdZJ8XWxc0C/M54POoPrQvuJgalxzpUwE+Cksw/st9j7hZW3f15z++/SJXDtKfawz4CC+0lCCVmFP7KnZPbvECsvwbALNlsZmjstZ5ugD/WI/WYNBYLO4a6m3w3ZKkeFLaQyHDEJ8S/MPuj/pUiwHBK2sSBDj76hCl4t7jT9/ 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: Willem de Bruijn wrote: > > + } else if ((flags & MSG_SPLICE_PAGES) && length) { > > + if (inet->hdrincl) > > + return -EPERM; > > + if (rt->dst.dev->features & NETIF_F_SG) > > + /* We need an empty buffer to attach stuff to */ > > + initial_length = transhdrlen; > > I still don't entirely understand what initial_length means. > > More importantly, transhdrlen can be zero. If not called for UDP > but for RAW. Or if this is a subsequent call to a packet that is > being held with MSG_MORE. > > This works fine for existing use-cases, which go to alloc_new_skb. > Not sure how this case would be different. But the comment alludes > that it does. The problem is that in the non-MSG_ZEROCOPY case, __ip_append_data() assumes that it's going to copy the data it is given and will allocate sufficient space in the skb in advance to hold it - but I don't want to do that because I want to splice in the pages holding the data instead. However, I do need to allocate space to hold the transport header. Maybe I should change 'initial_length' to 'initial_alloc'? It represents the amount I think we should allocate. Or maybe I should have a separate allocation clause for MSG_SPLICE_PAGES? I also wonder if __ip_append_data() really needs two places that call getfrag(). David