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 8168EC7EE23 for ; Wed, 31 May 2023 00:32:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C4FA1280002; Tue, 30 May 2023 20:32:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BFFC8280001; Tue, 30 May 2023 20:32:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AC7BB280002; Tue, 30 May 2023 20:32:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 9DA88280001 for ; Tue, 30 May 2023 20:32:17 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 7461D8036B for ; Wed, 31 May 2023 00:32:17 +0000 (UTC) X-FDA: 80848673514.30.E6F212C Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf08.hostedemail.com (Postfix) with ESMTP id B608F160010 for ; Wed, 31 May 2023 00:32:15 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=OUzgd5vh; spf=pass (imf08.hostedemail.com: domain of kuba@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=kuba@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1685493135; 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:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=fBOx4IYfVgf6x0cG+ScwlUNVX++rzTlmhMaBkt6d0YY=; b=6cYhZuZIRTLSN6cpKW9DilOECQfjaxCmNI+iYJzXU1j2hHB+SKYfIjwWnS9FCPAuvAbnW/ 5zcgqhCwwldPaP1QASFrSVUDbLgV2ao9Bx+jfqFTRCzNaGKAyEv3CCh2dpPkSKNuexAt11 4NUiwre2R2B/wO6CDdy/C+XPIXrhfMw= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1685493135; a=rsa-sha256; cv=none; b=U7WAepqkhGhhEh6AeYiaMrySYbRThNXFpaAZpVmtA0N5RJ9nEGINBGgs9696q1MiBnRV/S JNLRqmTX3G8q0rolb4BpITKGYE2LlVFyKmL20wJy3Bqy09SRYhB38Aw4UoneauhkIL1uPq EuxUNcAYAeS7MvlstVwYk2zgge27K9Q= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=OUzgd5vh; spf=pass (imf08.hostedemail.com: domain of kuba@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=kuba@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 8C83163519; Wed, 31 May 2023 00:32:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4D875C433D2; Wed, 31 May 2023 00:32:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685493134; bh=R71oU/0C7O8aZ1Fo65yDpnqy1TpGhfrRouAYxvAjdW8=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=OUzgd5vhGClmDKAEtoIbqwLsQS0UPyIv9zBCQ5Ph80pA8CbxCAJoXLCUZjfxEsmj7 PgTvwepq7y4uuHCcIpViRQhnOV+J8SuU5K1zrY+2j54yrHw/X8REBwzUBj8eqGRrM6 pEHx97BTFBdADQPYE82kZ5igqX4LDL7AzYZELUfpd5lNNlBZtEgaatqMi9I5EZYHC1 tDUVfAVWLMfSBDb9LfdAr9FmihzxuO+r5Kwl7Pnsd1ZWBjjh98avBnsP7Lqm43iFTS bjvK9giC87TxwLMoTpme192nFucxCXdbfUIxehZ0GyPv7hkeqtIfftVQFWK5Do8Izr oz0lrJhs7RgQw== Date: Tue, 30 May 2023 17:32:12 -0700 From: Jakub Kicinski To: David Howells Cc: 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 , Linus Torvalds Subject: Re: Bug in short splice to socket? Message-ID: <20230530173212.5fec9fc3@kernel.org> In-Reply-To: <499791.1685485603@warthog.procyon.org.uk> References: <20230526180844.73745d78@kernel.org> <20230524153311.3625329-1-dhowells@redhat.com> <20230524153311.3625329-10-dhowells@redhat.com> <499791.1685485603@warthog.procyon.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: B608F160010 X-Rspam-User: X-Stat-Signature: tmefxcrpy9brg7wxu4wmfxtxoj7panaj X-Rspamd-Server: rspam03 X-HE-Tag: 1685493135-90889 X-HE-Meta: U2FsdGVkX19fxW7BQ/c8o2mx04MAmnLffVGdtuwStzsLTYGSNyVUaY+qxEdNUHRsxs2VGQPKZYyvMf4QpBLMKjY/qsAjaRbs6sbUo1mxasARxUHYd1n983RutF9vZWmE37boLvxT8NfNx5wy8VDmkazNWdYvqwHARdRED40nQScjzBBW1MqfcPBqu79fPDBLfDJJLFLUuDpBSFq/ApzM+cu+uOY5vMKQJG5afYqLHEkQ0LVcn5T8OgQz9v9dUMLNLfV1q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WahcCDKY7+EHOjAfR7P1O9ywoaP8nrycozsrI4fuCzcd0Pu6zfaOY4u16VkosjAa1yWecRLqz9EfdjGGjsLdrlK3aTVz39zcJocF8u6F8JJXxBsL2vAxCp6z+62WZFCs77meip6+DsfZC5ujwtquWQllyx/nGHAiQr+dSKMqz8mv3w= 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: On Tue, 30 May 2023 23:26:43 +0100 David Howells wrote: > Interesting. Now that you've pointed me at it, I've tried running it. Mostly > it passes, but I'm having some problems with the multi_chunk_sendfile tests > that time out. I think that splice_direct_to_actor() has a bug. The problem > is this bit of code: > > /* > * If more data is pending, set SPLICE_F_MORE > * If this is the last data and SPLICE_F_MORE was not set > * initially, clears it. > */ > if (read_len < len) > sd->flags |= SPLICE_F_MORE; > else if (!more) > sd->flags &= ~SPLICE_F_MORE; > > When used with sendfile(), it sets SPLICE_F_MORE (which causes MSG_MORE to be > passed to the network protocol) if we haven't yet read everything that the > user requested and clears it if we fulfilled what the user requested. > > This has the weird effect that MSG_MORE gets kind of inverted. It's never > seen by the actor if we can read the entire request into the pipe - except if > we hit the EOF first. If we hit the EOF before we fulfil the entire request, > we get a short read and SPLICE_F_MORE and thus MSG_MORE *is* set. The > upstream TLS code ignores it - but I'm changing this with my patches as > sendmsg() then uses it to mark the EOR. > > I think we probably need to fix this in some way to check the size of source > file - which may not be a regular file:-/ With the attached change, all tests > pass; without it, a bunch of tests fail with timeouts. Yeah.. it's one of those 'known warts' which we worked around in TLS because I don't know enough about VFS to confidently fix it in fs/. Proper fix would be pretty nice to have. The original-original report of the problem is here, FWIW: https://lore.kernel.org/netdev/1591392508-14592-1-git-send-email-pooja.trivedi@stackpath.com/ And my somewhat hacky fix was d452d48b9f8.