Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp13147704rwd; Fri, 23 Jun 2023 16:53:58 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6hAYZ2nTyDD7uo58tUv1hPN2Jgl+sDpK1Y9qtVs7IZqB6wohNh3OlLH6YMx+79uXqKWx0n X-Received: by 2002:a17:902:ab95:b0:1b0:378e:2768 with SMTP id f21-20020a170902ab9500b001b0378e2768mr627595plr.7.1687564438396; Fri, 23 Jun 2023 16:53:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687564438; cv=none; d=google.com; s=arc-20160816; b=0KEJk4z6EIwduKz41aNbBKsuH2p2FXyrDgIbXpKi/6mFm4qAYHEFoveVQsB2Uox/jQ 9KxXjAKUqqNmZI93Ou1ZigebwiaUnZflbVq2K9yRHTJNaR2tBV7YUFxNRWV5oNBa723B wFw3QrZxikFMLJHxqizSiXSTlmkrSFJmPlHJREe5micRE8NbtVtFhRtt/eb+EW3zYDNQ 91zE6F0NTUcarxQhMwPHzvHOgstR63EFOmaBscCtji+/H6rabo650iU3cq3FxR2i4sWz g13J21oA9b0GpGtrfNnyfKCRwt7T5FJsmickr+4Wku+k7LqYoLo5SQ2ypkIE+qtkOGeo jzug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=Apfq7AhNdXkzjdfdSdVi+dqQ3I5tsUXwD6FmqXc0zjI=; fh=mPGpBhgapmP7dY8KfO0k8iJH0pLHG8do6haQEdCyVLo=; b=rqVKHRQFeoUF5cO3DFOfljVacJQjyNSyUx1qr3ivwJh00fO5eea1ise/gyUQ/PZbVW RDvWnmyy0fTpzyoojoKBuY8+XMzRPaAIOz0rLzU409tjiMdGK7nzC4PxNqqsbv/dVxF9 lYGkvE2W5/Pz7tAVwfJNG/eifnfTsLETxgnbUhj9s7AmqYuIkiD5bmonnG8PvVyoDW4i OatrtjOlxPAHvhLBZu1q8UVvue5sI5thfNXUl1XgXFMVAvdYVVAOBcWY6oYflBVS4oGf fArKKi8o5nTtl1MsMv3r3bmDxJiADPfJWd0c3hus4SZ3RKq2VuUXdZdm4xcHRce3E5Mp tyHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=GhxuHOMt; 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 jd22-20020a170903261600b001b11168bde3si233515plb.521.2023.06.23.16.53.47; Fri, 23 Jun 2023 16:53:58 -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=GhxuHOMt; 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 S230478AbjFWXcZ (ORCPT + 99 others); Fri, 23 Jun 2023 19:32:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53604 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230088AbjFWXcY (ORCPT ); Fri, 23 Jun 2023 19:32:24 -0400 Received: from mail-lj1-x231.google.com (mail-lj1-x231.google.com [IPv6:2a00:1450:4864:20::231]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A91EE2696 for ; Fri, 23 Jun 2023 16:32:23 -0700 (PDT) Received: by mail-lj1-x231.google.com with SMTP id 38308e7fff4ca-2b4636bb22eso19729111fa.2 for ; Fri, 23 Jun 2023 16:32:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1687563142; x=1690155142; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Apfq7AhNdXkzjdfdSdVi+dqQ3I5tsUXwD6FmqXc0zjI=; b=GhxuHOMtbdUcSShbDvNYafl9pfOfd6C8va282O3ywbZvR+t/p39SBpkbaPQBjAxbR3 ECY1FdMZKen56LNaIkVkSoUdZbup6/JW+3+b2jAohLrBxRhHDuGmhXCEETCdDAigSwGb Q9k48RVeA5YcZnEYsMV42MaqtCmnXtKLebNsI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687563142; x=1690155142; h=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=Apfq7AhNdXkzjdfdSdVi+dqQ3I5tsUXwD6FmqXc0zjI=; b=XP3KOmGHdaZyUtjK7nNiSChg1OABaCHYrRrJmYQYNxW2MEPOiXWtY8MIunKRTKEC9R WyRVMg5QiwKMV2amaXg54/Fy14jaNp2Vibq3h1lClh2ohKMA7KNkZBwRkWqMth2Qwl33 ffrn07u8H1PnhMtn7D3vwwJy9N7P6eysRsmbnZNtBUOnUtM3D5SUgDMd69wh21UJW//v 210dk0pbvvIXlYjpi5AkHj0q7hX24whQ8Bc5A3jl9kb4grBZRgVxMmOO1j5WLfzmWKyp HYh6l3+CVAfrkJdgn1btRGffzjpRvwekHw8hsSAauCZ2Ny66kw3Bt7DyRH1aOteLOU9e DDxw== X-Gm-Message-State: AC+VfDzhpgjaUQL4kwOL+4t8ti63aPXYR99cf/9yc6253hLu5hiBvGGZ HjrDEnAtHcyMH3cc9MWWM+zrBtKwp53ExgwklqpC7jsa X-Received: by 2002:a2e:904f:0:b0:2b4:94ec:e8 with SMTP id n15-20020a2e904f000000b002b494ec00e8mr8808879ljg.39.1687563141683; Fri, 23 Jun 2023 16:32:21 -0700 (PDT) Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com. [209.85.208.52]) by smtp.gmail.com with ESMTPSA id re3-20020a170906d8c300b00977ca5de275sm213158ejb.13.2023.06.23.16.32.20 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 23 Jun 2023 16:32:21 -0700 (PDT) Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-51bdf83a513so1220711a12.2 for ; Fri, 23 Jun 2023 16:32:20 -0700 (PDT) X-Received: by 2002:a05:6402:1344:b0:51b:e5d7:98eb with SMTP id y4-20020a056402134400b0051be5d798ebmr4390582edw.41.1687563140463; Fri, 23 Jun 2023 16:32:20 -0700 (PDT) MIME-Version: 1.0 References: <2730511.1687559668@warthog.procyon.org.uk> In-Reply-To: From: Linus Torvalds Date: Fri, 23 Jun 2023 16:32:03 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] pipe: Make a partially-satisfied blocking read wait for more To: David Howells Cc: Franck Grosjean , Phil Auld , Alexander Viro , Christian Brauner , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" 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, URIBL_BLOCKED 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 Fri, 23 Jun 2023 at 16:08, Linus Torvalds wrote: > > In fact, I'd expect that patch to fail immediately on a perfectly > normal program that passes a token around by doing a small write to a > pipe, and have the "token reader" do a bigger write. Bigger _read_, of course. This might be hidden by such programs typically doing a single byte write and a single byte read, but I could easily imagine situations where people actually depend on the POSIX atomicity guarantees, ie you write a "token packet" that might be variable-sized, and the reader then just does a maximally sized read, knowing that it will get a full packet or nothing. So a read() of a pipe absolutely has to return when it has gotten *any* data. Except if it can know that there is a writer that is still busy and still in the process of writing more data. Which was that old 'pipe->waiting_writers' logic - it basically counted "there are active writers that still have more data to write, but the buffer filled up". That logic went back to ancient times, when our pipe buffer was just a single page - so it helped throughput immensely if we had writers that did big writes, and readers would continue to read even when the small buffer was completely used up (rather than return data just one page at a time for each read() system call). Linus