Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp750739rwd; Thu, 1 Jun 2023 06:12:19 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6S9m+1UbJKnidFaFQKvp8k0h4UYqRhv4JDOBfswUvu4vENqMVc5yO0ozH+jkllBrZ49X5o X-Received: by 2002:a05:6a00:2352:b0:64d:2ea4:9377 with SMTP id j18-20020a056a00235200b0064d2ea49377mr7075017pfj.14.1685625138436; Thu, 01 Jun 2023 06:12:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685625138; cv=none; d=google.com; s=arc-20160816; b=fJ84ZeT3GNxAvR3KkTxBJJK9OslKmKdZZwYxrJnwui8OMFeSEib03am4OutzrpNsZP Y/0cFrwqmYe7WY1+P7sIxd5IgwTV44bRALMuDJ6v1mS+HJm50zEwBESA9GmJq+cFWIh0 RHGBvAiK13DqiW4zPPX0UCPukO6EFTscrHluEV6oPFklVL1Z74FEdx8PIir310D4LqZ3 +1X9ff7EbK/TTQ4JO4MwxPJncNW/qMXqZrzwQ/SCyMfBgxWS3h97lqVCW0nSYNdOvwts xd9kBdwaPJ1XxdXVbBEBcgc09P7MMYSlLGiocVDS8K6VTUsY25BmJjxn7hs9zkKxg2yb kMIw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=bGLeNL4xyVWCzs5LFhZzIMiXdkid2+oUWl2Rt0i8z+U=; b=hKBbMYtfsAldIr5rKkd9+R8+2bkST4217pwVcJbH1B6B57TYPPB+Pej9tPDZ8lEylc OLHPyeCYwk1NJW9mSoQW50mY9n8eFlN+hCF8/UB1BqGHCXjaxgsC9jzb2ODEcofAV2MC RJJqITEIyFZ0chm2GxP3zBI6pYqP1DYTcmMY57BK1WO5xwVuI6zoPjS1TMNcoWozZ+r+ By27EWyrzK1q7Ja8bTrjL/FjTxt/RnhMXYb1OKYY7IW4jsj8tAZaR3HqwsheCGlM1Yqw IxVRAUjeqbpAdGqQzl+qJZaj2TIca87Rncv/G/RkfM1HOitAXPraPpk6l83gq1kRjpn4 FHoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=KM71FxQk; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d192-20020a621dc9000000b0063b1739532esi3596958pfd.139.2023.06.01.06.12.04; Thu, 01 Jun 2023 06:12:18 -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=@linux-foundation.org header.s=google header.b=KM71FxQk; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233421AbjFANJi (ORCPT + 99 others); Thu, 1 Jun 2023 09:09:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232291AbjFANJh (ORCPT ); Thu, 1 Jun 2023 09:09:37 -0400 Received: from mail-ed1-x536.google.com (mail-ed1-x536.google.com [IPv6:2a00:1450:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BD7FE7 for ; Thu, 1 Jun 2023 06:09:36 -0700 (PDT) Received: by mail-ed1-x536.google.com with SMTP id 4fb4d7f45d1cf-51493ec65d8so1303168a12.2 for ; Thu, 01 Jun 2023 06:09:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1685624974; x=1688216974; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=bGLeNL4xyVWCzs5LFhZzIMiXdkid2+oUWl2Rt0i8z+U=; b=KM71FxQkhuCtTMGGWiWYBAzAbtxhLH88ZlN+MyRy2N8QngJe39QtlpcVLxM1ho6S6b XNuqd3EwfJyffpJtz1Pnu78Lc+opffulOzPdP86t3TK8meFA+nKCurJ9cEmmFY4vWvTe asM1KsDs+fBxS1q0X8slyE8vfNQcJPyGVM4nY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685624974; x=1688216974; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bGLeNL4xyVWCzs5LFhZzIMiXdkid2+oUWl2Rt0i8z+U=; b=bFmSGVv8Z47Gd27sUbJzQgV6g98jZsJtAS+rB4GWIkewVdVToRpt0LRCSaDvgzmBA1 Yll7Lj/dCeUWPw05qHwfowQu0X+1e8jCUknz92oz0f85aY0lthJphpBY5VJe0oyXMqny ewZqS0Asx66BAog8d3UXn+85mpWOqjpbEIh/vzV7Q/0l67tbBTkvfO5a8lyYOuZ+MWSN cVTS4HWMtRdohh1xEUr/ta5UAn7y+cKPUHie1YgxNG2NZ2c0t1R/9ek6Yak3iVxy9vZv AWubdF/RuTKFEb8iLVVWwa/n6g09DNekXZcPcP1fEWYonbAinFPNgFRCmoRK37zwPt/8 Txhw== X-Gm-Message-State: AC+VfDz+oR3V1bHJPnk8MlA9ig4bBgtCGoL1g9nlUMHpR8cBrX1LvmYa vV9Ck7H8aGvhr8o9ChsF2vdn8Nc41A+7DjBtpKITmsWI X-Received: by 2002:aa7:d9da:0:b0:510:f6e9:6d92 with SMTP id v26-20020aa7d9da000000b00510f6e96d92mr6228428eds.0.1685624974501; Thu, 01 Jun 2023 06:09:34 -0700 (PDT) Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com. [209.85.218.53]) by smtp.gmail.com with ESMTPSA id v5-20020aa7d805000000b005149134ccfbsm6657750edq.52.2023.06.01.06.09.33 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 01 Jun 2023 06:09:33 -0700 (PDT) Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-96f50e26b8bso118294466b.2 for ; Thu, 01 Jun 2023 06:09:33 -0700 (PDT) X-Received: by 2002:a17:907:9722:b0:95e:d448:477 with SMTP id jg34-20020a170907972200b0095ed4480477mr8993487ejc.33.1685624973235; Thu, 01 Jun 2023 06:09:33 -0700 (PDT) MIME-Version: 1.0 References: <20230524153311.3625329-1-dhowells@redhat.com> <20230524153311.3625329-10-dhowells@redhat.com> <20230526180844.73745d78@kernel.org> <499791.1685485603@warthog.procyon.org.uk> In-Reply-To: <499791.1685485603@warthog.procyon.org.uk> From: Linus Torvalds Date: Thu, 1 Jun 2023 09:09:16 -0400 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Bug in short splice to socket? To: David Howells Cc: 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 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=no 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 On Tue, May 30, 2023 at 6:26=E2=80=AFPM David Howells = wrote: > > When used with sendfile(), it sets SPLICE_F_MORE (which causes MSG_MORE t= o be > passed to the network protocol) if we haven't yet read everything that th= e > user requested and clears it if we fulfilled what the user requested. > > This has the weird effect that MSG_MORE gets kind of inverted. [...] I hate this patch. The old code is unquestionably garbage, but this just ends up resulting in more of the same. The reason the old code is garbage is that it sets SPLICE_F_MORE entirely in the wrong place. It sets it *after* it has done the splice(). That's just crazy. And that craziness is the direct cause of the bug. You try to fix the bug by just extending on the craziness. No. The crazy should be removed, not extended upon. The "flag" setting should be done *before* the send, if we know that more data is pending even after the "do_splice_to()". Not after. And the networking code should do its own "oh, splice gave me X bytes, but I only used Y, so I know more data is pending, so I'll set MSG_MORE on the *current* packet". But that's entirely inside of whatever networking code that does th esplice. So no. I absolutely refuse to entertain this patch because it's completely broken. The fact that the old code was also completely broken is *not* an excuse to make for more nonsensical breakage that may or may just hide the crazy. Linus