Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp32366405rwd; Fri, 7 Jul 2023 12:41:47 -0700 (PDT) X-Google-Smtp-Source: APBJJlGn3T/fqs/pC37RX8JQ3UIniX3suWCAawivOaReTSiDg7k17TEXxAqEp4ciA5dQcPupjOf9 X-Received: by 2002:a17:906:212:b0:992:a31f:f584 with SMTP id 18-20020a170906021200b00992a31ff584mr4948133ejd.31.1688758907179; Fri, 07 Jul 2023 12:41:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688758907; cv=none; d=google.com; s=arc-20160816; b=r8iSbPzb1zihss7/EkIGMsU4MKcV3NcZRB8H8q5wWkVNogFyyZPgVDL+m15bv/HDSB nXW+j98XIXw0g2ost4f461PqV+KrcvlnWhtMxHc6Pmn5Xmdhei+oLtIfp7FB06hWE8Vb RVt5xk2cBwt7qA4nnBB4xyQgg2bGTBcm7KODBp+Xeqcb14/eajeCPx6wg6XHqqpdrE+M EMjmBkrapE+ncEvfnmFPfXnTEI9ynkey80aPbl/FbbCMOs5Ml+2Mv3mW4vk6l3wupPK8 8IlRojHj1Bxv2eb1Fh/BNaJ1w7ge3vde/2YkXlr9pqFSsXaQzF+wBkZCz8dX/VOL3fP1 9tDQ== 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=seBiEYyQl/sPQhTfynLvcE2AicprHHoeUGgJSBpaBto=; fh=xSck0SVaesw341p8IQ4w8DBecLsKtjXTEcxFaWXD8+8=; b=WHjki8Plr1qyjGZAPK5OR2U+krm35FZcDU3akGD0BTUZR8LLkSrpkXWLL54ZA3bkWh xXWRb//uvNcRjADspVp4aV3qmHUpkmxTHlOJw8pAzok37ErJZe6CMwxonjclqpNckTNL +3Smp2V6Rzd6Aqai7LHSaZ0BNtC8hMhAew2FU5uAfxRysVZb8CpovdxUfzDTYolQT9eD MHCJxTw5VXo+2OxnWDm93vk6RcLeICYurixpVbDwDB4xUMyXb/xBXmXgrStLhD4DC8gU cixKxx1guS8A+otiiUb0MN3drT3yLzlG7s9utMGgHOoUAYPT26k62ztWB4XzZOgjGGmQ lnLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=google header.b=Cd0KRLvP; 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 t10-20020a1709060c4a00b00992b168204fsi2022812ejf.891.2023.07.07.12.41.23; Fri, 07 Jul 2023 12:41:47 -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=Cd0KRLvP; 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 S232986AbjGGTLA (ORCPT + 99 others); Fri, 7 Jul 2023 15:11:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229611AbjGGTK6 (ORCPT ); Fri, 7 Jul 2023 15:10:58 -0400 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04F2F10C for ; Fri, 7 Jul 2023 12:10:56 -0700 (PDT) Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-992b2249d82so282901266b.1 for ; Fri, 07 Jul 2023 12:10:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; t=1688757054; x=1691349054; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=seBiEYyQl/sPQhTfynLvcE2AicprHHoeUGgJSBpaBto=; b=Cd0KRLvPOJG9xAzy8pcb1wf0vD421dLLavq1yz28mnIxKv5P9YcyNfetfoQsrRsUtt OLrhUjbd1Teach+HMEkGN2UdlPjRq2jweklw2ro1EB34p6zbquYe4+OQpQMDrdnnL4qz SIBkooDG34cKvgZpz+EoJdjECZ3/uh19sWJH4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688757054; x=1691349054; 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=seBiEYyQl/sPQhTfynLvcE2AicprHHoeUGgJSBpaBto=; b=lyhbsO2VKX1W+WxZrnUeteML0ENoD7d1Cv2IadmLMjPXDOtzwCfO22+jsh2eLQPGKk reWtj7BwCOnoSv5t9TYjKbx2u/Y2BA+xlMJ5WLfqbgQCsyYb+s9BoevN6Zcin1A5jORm jPNtzo2XlCzpsLgM7pOkxbVgXnkzr3hKd1i4YXZDmwccEWAgi9x/T/V9AfGS5UoNJ2ai uPMGoqw50b/gQP/QN7RX1kgHDuj9BY4/0phI10roVvitjoablneL97AqIt5LQRpeje4L CxpDtPNm0JMJ83XiknjTPnHDXmBsDGRP0U/MsawjsskFT+xGRar12pvYG5b9m4L28nBx 43ig== X-Gm-Message-State: ABy/qLaV8tTTpr9kqzmGIHzy8H/nLvyS8kBdKFCYFOhWWHvl2+E5pM3/ lyYPY1sAc8l2UPRFKczF3k4Cz0PriLHyj56n0bZFPA== X-Received: by 2002:a17:906:68c9:b0:991:d2a8:658a with SMTP id y9-20020a17090668c900b00991d2a8658amr4554703ejr.34.1688757054255; Fri, 07 Jul 2023 12:10:54 -0700 (PDT) Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com. [209.85.208.54]) by smtp.gmail.com with ESMTPSA id qc15-20020a170906d8af00b00992eabc0ad8sm2502628ejb.42.2023.07.07.12.10.53 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 07 Jul 2023 12:10:53 -0700 (PDT) Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-51bece5d935so3028279a12.1 for ; Fri, 07 Jul 2023 12:10:53 -0700 (PDT) X-Received: by 2002:aa7:cfc3:0:b0:51e:1705:155c with SMTP id r3-20020aa7cfc3000000b0051e1705155cmr4076276edy.35.1688757052998; Fri, 07 Jul 2023 12:10:52 -0700 (PDT) MIME-Version: 1.0 References: <20230626-vorverlegen-setzen-c7f96e10df34@brauner> <4sdy3yn462gdvubecjp4u7wj7hl5aah4kgsxslxlyqfnv67i72@euauz57cr3ex> <20230626-fazit-campen-d54e428aa4d6@brauner> <20230707-konsens-ruckartig-211a4fb24e27@brauner> In-Reply-To: <20230707-konsens-ruckartig-211a4fb24e27@brauner> From: Linus Torvalds Date: Fri, 7 Jul 2023 12:10:36 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Pending splice(file -> FIFO) excludes all other FIFO operations forever (was: ... always blocks read(FIFO), regardless of O_NONBLOCK on read side?) To: Christian Brauner Cc: =?UTF-8?Q?Ahelenia_Ziemia=C5=84ska?= , Jens Axboe , David Howells , Alexander Viro , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: multipart/mixed; boundary="00000000000041bbf005ffea6443" 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 --00000000000041bbf005ffea6443 Content-Type: text/plain; charset="UTF-8" On Fri, 7 Jul 2023 at 10:21, Christian Brauner wrote: > > Forgot to say, fwiw, I've been running this through the LTP splice, > pipe, and ipc tests without issues. A hanging reader can be signaled > away cleanly with this. So that patch still has a couple of "wait for this" cases remaining. In particular, when we do a read, and we do have pipe buffers, both the read() system call and a number of internal splice functions will go "Ahh, I have data", and then do pipe_buf_confirm() and read it. Which then results in pipe_buf_confirm() blocking. It now blocks interruptibly, which is much nicer, but several of these users *could* just do a non-blocking confirmation instead, and wait for pipe readability. HOWEVER, that's slightly less trivial than you'd expect, because the "wait for readability" needs to be done without the pipe lock held - so you can't actually check the pipe buffer state at that point (since you need the pipe lock to look up the buffer). That's true even of "trivial" cases like actual user-space "read() with O_NONBLOCK and poll()" situations. Now, the solution to all this is *fairly* straightforward: (a) don't use "!pipe_empty()" for a readability check. We already have "pipe_readable()", but it's hidden in fs/pipe.c, so all the splice() code ended up writing the "does this pipe have data" using "!pipe_empty()" instead. (b) make "pipe_buf_confirm()" take a "non-blocking" boolean argument, and if it is non-blocking but hits one of those blocked pages, set "pipe->not_ready", and return -EAGAIN. This is ok, because "pipe_buf_confirm()" is always under the pipe lock, and we'll just clear "pipe->not_ready" under the pipe lock after finalizing all those pages (and before waking up readers) (c) make "pipe_wait_readable()" and "poll()" know about this all, so that we wait properly for a pipe that was not ready to become ready This all makes *most* users deal properly with these blocking events. In particular, things like splice_to_socket() can now do the whole proper "wait without holding the pipe lock" sequence, even when the pipe is not empty, just in this blocked state. This *may* also make all the cases Jens had with io_uring and splicing JustWork(tm). NOTE! NOTE! NOTE! Once more, this "feels right to me", and I'd argue that the basic approach is fairly straightfoward. The patch is also not horrendous. It all makes a fair amount of sense. BUT! I haven't tested this, and like the previous patch, I really would want people to think about this a lot. Comments? Jens? Linus --00000000000041bbf005ffea6443 Content-Type: text/x-patch; charset="US-ASCII"; name="patch.diff" Content-Disposition: attachment; filename="patch.diff" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_ljsyc30n0 IGZzL2Z1c2UvZGV2LmMgICAgICAgICAgICAgfCAgNCArLS0KIGZzL3BpcGUuYyAgICAgICAgICAg ICAgICAgfCAyMyArKysrLS0tLS0tLS0tCiBmcy9zcGxpY2UuYyAgICAgICAgICAgICAgIHwgODIg KysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKysrKystLS0tLS0tLS0tLS0KIGluY2x1ZGUv bGludXgvcGlwZV9mc19pLmggfCAyNSArKysrKysrKysrKysrLS0KIDQgZmlsZXMgY2hhbmdlZCwg OTMgaW5zZXJ0aW9ucygrKSwgNDEgZGVsZXRpb25zKC0pCgpkaWZmIC0tZ2l0IGEvZnMvZnVzZS9k ZXYuYyBiL2ZzL2Z1c2UvZGV2LmMKaW5kZXggMWE4ZjgyZjQ3OGNiLi5iODkxNDY4ZGVlMDYgMTAw NjQ0Ci0tLSBhL2ZzL2Z1c2UvZGV2LmMKKysrIGIvZnMvZnVzZS9kZXYuYwpAQCAtNzAwLDcgKzcw MCw3IEBAIHN0YXRpYyBpbnQgZnVzZV9jb3B5X2ZpbGwoc3RydWN0IGZ1c2VfY29weV9zdGF0ZSAq Y3MpCiAJCXN0cnVjdCBwaXBlX2J1ZmZlciAqYnVmID0gY3MtPnBpcGVidWZzOwogCiAJCWlmICgh Y3MtPndyaXRlKSB7Ci0JCQllcnIgPSBwaXBlX2J1Zl9jb25maXJtKGNzLT5waXBlLCBidWYpOwor CQkJZXJyID0gcGlwZV9idWZfY29uZmlybShjcy0+cGlwZSwgYnVmLCBmYWxzZSk7CiAJCQlpZiAo ZXJyKQogCQkJCXJldHVybiBlcnI7CiAKQEAgLTgwMCw3ICs4MDAsNyBAQCBzdGF0aWMgaW50IGZ1 c2VfdHJ5X21vdmVfcGFnZShzdHJ1Y3QgZnVzZV9jb3B5X3N0YXRlICpjcywgc3RydWN0IHBhZ2Ug KipwY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