Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2721119rwd; Fri, 2 Jun 2023 13:45:09 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7193TV6l3MH/d5CXvVHr4HQZM+2fsPyomnyL9RqLqB3sqkxDHQRxj7pmNSvNrHUHaiMz7j X-Received: by 2002:a17:902:ce8a:b0:1af:f751:1be9 with SMTP id f10-20020a170902ce8a00b001aff7511be9mr1030932plg.32.1685738708887; Fri, 02 Jun 2023 13:45:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685738708; cv=none; d=google.com; s=arc-20160816; b=IvxLXfHLmUvXI1uns4o9lBSPP95s7kUSixvinJClRtfAgbqBwN9vccze6BFKxZEbll xJAWyoIPrWQ5/F2Xeo5ehyggMSQMOTVPdHIF1IjkyipzbJdVFhJU9K7EahdkpZiIDgFH 5s35r9afUNNm1TUKJNZq/FcKG6FFKsnlheoO7vldOFJVASHhYNFEqNhRRAyv3Hr3EE3O wdv6p4aAcv8FlmdhsrVEqY+XasaETV9kPknM1GBQSpLfqpDCTMGh732TXLvCbgKquvhy OoWvByhAzX+t30cEwbBflNhA49jkjBJ3fS/Q0vMjouHprbOZ48SirQuDS0il+odOlpK/ 5QSg== 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-id:mime-version:subject :cc:to:references:in-reply-to:from:organization:dkim-signature; bh=9cFmOTRalrutMLCpPhglIGPnK0Bp8qtiBThh8gpw5mE=; b=l0G45pmit84qPa+2BRPHIt8hTe9wSPLl2kznlsdA8xc6xMYf75JPZ13509LiFTVedy uJvpP4cHwhZRSEOUD8cxRKkoAOm/W82iq68yQWuYh4L4TgT/RXMufWmQtwcaiavhXWgi /ocF932RF/5JvYYxy1Wj4uy6/9Sq2pZVCmJ0p0bES4Vkm5NnjEpVyhlrgjUqAVegikpa 7M8Bpg5s3WsCEGZsQht6IO2/r5s6zL4IOC3Ia3yXFDyPoEk2+0f3dNs9HSAY/mp6PUu8 ON/zd1c//faMP6FeF1klhtxl3NAPIhL2JyqQ7SP+Wbvjhk3bd30rLAvkKb9jYdBuI5Wh /N5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Zxqx5rW1; 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 e12-20020a17090301cc00b001ae82f13a0fsi1331160plh.643.2023.06.02.13.44.55; Fri, 02 Jun 2023 13:45:08 -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=Zxqx5rW1; 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 S235709AbjFBUjd (ORCPT + 99 others); Fri, 2 Jun 2023 16:39:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230341AbjFBUjb (ORCPT ); Fri, 2 Jun 2023 16:39:31 -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 79767E42 for ; Fri, 2 Jun 2023 13:38:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685738327; 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=9cFmOTRalrutMLCpPhglIGPnK0Bp8qtiBThh8gpw5mE=; b=Zxqx5rW1cM1Ut1CTrIc6avc2KtEGrhLfqyRIozmxLDEvAQxY3R41L8GpdrshfnODjvCaZh hu912rpR/BJqwZlUkUuWPZbysZV5hDice7jUptQD6sLKcF0gJLJQGjtMT6GyVZ7g0G6nUm pNVcRUwZra39aT4U/bcGeJPwIwQF9uo= 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-63-wEvFv4c5MtC6Mv9sV1jM2g-1; Fri, 02 Jun 2023 16:38:45 -0400 X-MC-Unique: wEvFv4c5MtC6Mv9sV1jM2g-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 51E093C13511; Fri, 2 Jun 2023 20:38:44 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.182]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2D7E12026D49; Fri, 2 Jun 2023 20:38:41 +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: <20230524153311.3625329-1-dhowells@redhat.com> <20230524153311.3625329-10-dhowells@redhat.com> <20230526180844.73745d78@kernel.org> <499791.1685485603@warthog.procyon.org.uk> <832277.1685630048@warthog.procyon.org.uk> <909595.1685639680@warthog.procyon.org.uk> <20230601212043.720f85c2@kernel.org> <952877.1685694220@warthog.procyon.org.uk> <1227123.1685706296@warthog.procyon.org.uk> <20230602093929.29fd447d@kernel.org> To: Linus Torvalds Cc: dhowells@redhat.com, Jakub Kicinski , netdev@vger.kernel.org, "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, Chuck Lever , Boris Pismenny , John Fastabend , Christoph Hellwig Subject: Re: Bug in short splice to socket? MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1379960.1685738320.1@warthog.procyon.org.uk> Date: Fri, 02 Jun 2023 21:38:40 +0100 Message-ID: <1379961.1685738320@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 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 Linus Torvalds wrote: > So a "splice_eof()" sounds fine to me, and we'd make the semantics be > the current behavior: > > - splice() sets SPLICE_F_MORE if 'len > read_len' > > - splice() _clears_ SPLICE_F_MORE if we have hit 'len' > > - splice always sets SPLICE_F_MORE if it was passed by the user > > BUT with the small new 'splice_eof()' rule that: > > - if the user did *not* set SPLICE_F_MORE *and* we didn't hit that > "use all of len" case that cleared SPLICE_F_MORE, *and* we did a > "->splice_in()" that returned EOF (ie zero), *then* we will also do > that ->splice_eof() call. > > The above sounds like "stable and possibly useful semantics" to me. It > would just have to be documented. > > Is that what people want? That's easier to implement, I think. That's basically what I was trying to achieve by sending a zero-length actor call, but this is a cleaner way of doing it, particularly if it's added as a socket op next to ->sendmsg(). Otherwise I have to build up the input side to try and tell me in advance whether it thinks we hit an EOF/hole/whatever condition. The problem is that, as previously mentioned, it doesn't work for all circumstances - seqfile, pipes, sockets for instance. Take the following scenario for example: I could read from a TCP socket, filling up the pipe-buffer, but not with sufficient data to fulfill the operation. Say I drain the TCP socket, but it's still open, so might produce more data. I then call the actor, which passes all the data to sendmsg() with MSG_SPLICE_PAGES and MSG_MORE and clears the buffer. I then go round again, but in the meantime, the source socket got shut down with no further data available and do_splice_to() returns 0. There's no way to predict this, so having a ->splice_eof() call would handle this situation. David